his_api_controller.go 1.6MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/controllers"
  10. "gdyb/enums"
  11. "gdyb/models"
  12. "gdyb/service"
  13. "gdyb/utils"
  14. "github.com/astaxie/beego"
  15. "github.com/axgle/mahonia"
  16. "github.com/go-ole/go-ole/oleutil"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. )
  35. type HisApiController struct {
  36. controllers.BaseAuthAPIController
  37. }
  38. func HisManagerApiRegistRouters() {
  39. //挂号
  40. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  41. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  42. //上传就诊信息-上传明细-结算
  43. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  44. //查询
  45. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  46. //对总账
  47. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  48. //对明细
  49. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  50. //退费,退明细
  51. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  52. //退号
  53. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  54. //退明细
  55. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  56. //上传就诊信息-上传明细-预结算
  57. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  58. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  59. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  60. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  61. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  62. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  63. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  64. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  65. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  66. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  67. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  68. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  69. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  70. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  71. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  72. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  73. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  74. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  75. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  76. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  77. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  78. beego.Router("/api/check", &HisApiController{}, "get:Check")
  79. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  80. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  81. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  82. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  83. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  84. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  85. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  86. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  87. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  88. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  89. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  90. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  91. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  92. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  93. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  94. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  95. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  96. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  97. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  98. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  99. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  100. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  101. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  102. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  103. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  106. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  107. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  108. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  109. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  110. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  111. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  112. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  113. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  114. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  115. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  116. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  117. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  118. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  119. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  120. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  121. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  122. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  123. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  124. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  125. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  126. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  127. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  128. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  129. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  130. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  131. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  132. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  133. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  134. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  135. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  136. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  137. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  138. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  139. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  140. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  141. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  142. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  143. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  144. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  145. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  146. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  147. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  148. //库盘和变更
  149. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  150. //删除库盘和变更
  151. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  152. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  153. //药品变更
  154. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  155. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  156. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  157. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  158. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  159. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  160. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  161. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  162. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  163. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  164. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  165. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  166. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  167. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  168. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  169. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  170. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  171. }
  172. func (c *HisApiController) Get3201() {
  173. adminUser := c.GetAdminUserInfo()
  174. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  175. result, _ := service.AHyb3201(932, 0, 571536.19, 543283.9, "2024-10-01", "2024-10-31", "340699", "11", "390", miConfig.OrgName, "王幸子", miConfig.Code, "340399", "340399", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey, miConfig.Cainfo)
  176. var response Response
  177. if err := json.Unmarshal([]byte(result), &response); err != nil {
  178. fmt.Println("Error decoding JSON:", err)
  179. return
  180. }
  181. }
  182. func (c *HisApiController) TestNet() {
  183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  184. return
  185. //c.ServeSuccessJSON(map[string]interface{}{
  186. // "msg": "成功",
  187. //})
  188. }
  189. func (c *HisApiController) Get3508() {
  190. admin_user_id, _ := c.GetInt64("admin_user_id")
  191. drug_id, _ := c.GetInt64("id")
  192. start_time := c.GetString("start_time")
  193. end_time := c.GetString("end_time")
  194. adminUser := c.GetAdminUserInfo()
  195. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  196. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  197. drug, _ := service.GetDrugByID(drug_id)
  198. var struct3508 models.Struct3508
  199. struct3508.OrgName = miConfig.OrgName
  200. struct3508.FixmedinsCode = miConfig.Code
  201. struct3508.AccessKey = miConfig.AccessKey
  202. struct3508.Opter = curRoles.UserName
  203. struct3508.RequestUrl = miConfig.Url
  204. struct3508.Url = miConfig.Url
  205. struct3508.AppId = miConfig.Cainfo
  206. struct3508.AppSecret = miConfig.AppSecret
  207. struct3508.Enckey = miConfig.EncKey
  208. struct3508.SignKey = miConfig.SignKey
  209. struct3508.SecretKey = miConfig.SecretKey
  210. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  211. struct3508.Begndate = start_time
  212. struct3508.Enddate = end_time
  213. result1, result2, _ := service.FJyb3508(struct3508)
  214. saveLog(result1, result2, "3508", "3508")
  215. var res models.Result3508
  216. var respJSON2 map[string]interface{}
  217. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  220. return
  221. }
  222. userJSONBytes2, _ := json.Marshal(respJSON2)
  223. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  224. utils.ErrorLog("解析失败:%v", err)
  225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  226. return
  227. }
  228. if res.Infcode == -1 {
  229. c.ServeSuccessJSON(map[string]interface{}{
  230. "failed_code": -10,
  231. "msg": res.ErrMsg,
  232. })
  233. } else {
  234. c.ServeSuccessJSON(map[string]interface{}{
  235. "info": res.Output,
  236. })
  237. }
  238. }
  239. func (c *HisApiController) Get3509() {
  240. admin_user_id, _ := c.GetInt64("admin_user_id")
  241. drug_id, _ := c.GetInt64("id")
  242. start_time := c.GetString("start_time")
  243. end_time := c.GetString("end_time")
  244. adminUser := c.GetAdminUserInfo()
  245. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  246. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  247. drug, _ := service.GetDrugByID(drug_id)
  248. var struct3508 models.Struct3509
  249. struct3508.OrgName = miConfig.OrgName
  250. struct3508.FixmedinsCode = miConfig.Code
  251. struct3508.AccessKey = miConfig.AccessKey
  252. struct3508.Opter = curRoles.UserName
  253. struct3508.RequestUrl = miConfig.Url
  254. struct3508.Url = miConfig.Url
  255. struct3508.AppId = miConfig.Cainfo
  256. struct3508.AppSecret = miConfig.AppSecret
  257. struct3508.Enckey = miConfig.EncKey
  258. struct3508.SignKey = miConfig.SignKey
  259. struct3508.SecretKey = miConfig.SecretKey
  260. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  261. struct3508.Begndate = start_time
  262. struct3508.Enddate = end_time
  263. result1, result2, _ := service.FJyb3509(struct3508)
  264. saveLog(result1, result2, "3509", "3509")
  265. var res models.Result3509
  266. var respJSON2 map[string]interface{}
  267. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  270. return
  271. }
  272. userJSONBytes2, _ := json.Marshal(respJSON2)
  273. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  274. utils.ErrorLog("解析失败:%v", err)
  275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  276. return
  277. }
  278. if res.Infcode == -1 {
  279. c.ServeSuccessJSON(map[string]interface{}{
  280. "failed_code": -10,
  281. "msg": res.ErrMsg,
  282. })
  283. } else {
  284. c.ServeSuccessJSON(map[string]interface{}{
  285. "info": res.Output,
  286. })
  287. }
  288. }
  289. func (c *HisApiController) Get3510() {
  290. admin_user_id, _ := c.GetInt64("admin_user_id")
  291. drug_id, _ := c.GetInt64("id")
  292. start_time := c.GetString("start_time")
  293. end_time := c.GetString("end_time")
  294. adminUser := c.GetAdminUserInfo()
  295. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  296. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  297. drug, _ := service.GetDrugByID(drug_id)
  298. var struct3508 models.Struct3510
  299. struct3508.FixmedinsCode = miConfig.Code
  300. struct3508.OrgName = miConfig.OrgName
  301. struct3508.AccessKey = miConfig.AccessKey
  302. struct3508.Opter = curRoles.UserName
  303. struct3508.RequestUrl = miConfig.Url
  304. struct3508.Url = miConfig.Url
  305. struct3508.AppId = miConfig.Cainfo
  306. struct3508.AppSecret = miConfig.AppSecret
  307. struct3508.Enckey = miConfig.EncKey
  308. struct3508.SignKey = miConfig.SignKey
  309. struct3508.SecretKey = miConfig.SecretKey
  310. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  311. struct3508.Begndate = start_time
  312. struct3508.Enddate = end_time
  313. result1, result2, _ := service.FJyb3510(struct3508)
  314. saveLog(result1, result2, "3510", "3510")
  315. var res models.Result3510
  316. var respJSON2 map[string]interface{}
  317. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  320. return
  321. }
  322. userJSONBytes2, _ := json.Marshal(respJSON2)
  323. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  324. utils.ErrorLog("解析失败:%v", err)
  325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  326. return
  327. }
  328. if res.Infcode == -1 {
  329. c.ServeSuccessJSON(map[string]interface{}{
  330. "failed_code": -10,
  331. "msg": res.ErrMsg,
  332. })
  333. } else {
  334. c.ServeSuccessJSON(map[string]interface{}{
  335. "info": res.Output,
  336. })
  337. }
  338. }
  339. func (c *HisApiController) Get3511() {
  340. admin_user_id, _ := c.GetInt64("admin_user_id")
  341. drug_id, _ := c.GetInt64("id")
  342. start_time := c.GetString("start_time")
  343. end_time := c.GetString("end_time")
  344. adminUser := c.GetAdminUserInfo()
  345. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  346. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  347. drug, _ := service.GetDrugByID(drug_id)
  348. var struct3508 models.Struct3511
  349. struct3508.FixmedinsCode = miConfig.Code
  350. struct3508.OrgName = miConfig.OrgName
  351. struct3508.AccessKey = miConfig.AccessKey
  352. struct3508.Opter = curRoles.UserName
  353. struct3508.RequestUrl = miConfig.Url
  354. struct3508.Url = miConfig.Url
  355. struct3508.AppId = miConfig.Cainfo
  356. struct3508.AppSecret = miConfig.AppSecret
  357. struct3508.Enckey = miConfig.EncKey
  358. struct3508.SignKey = miConfig.SignKey
  359. struct3508.SecretKey = miConfig.SecretKey
  360. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  361. struct3508.Begndate = start_time
  362. struct3508.Enddate = end_time
  363. result1, result2, _ := service.FJyb3511(struct3508)
  364. saveLog(result1, result2, "3511", "3511")
  365. var res models.Result3511
  366. var respJSON2 map[string]interface{}
  367. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  370. return
  371. }
  372. userJSONBytes2, _ := json.Marshal(respJSON2)
  373. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  374. utils.ErrorLog("解析失败:%v", err)
  375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  376. return
  377. }
  378. if res.Infcode == -1 {
  379. c.ServeSuccessJSON(map[string]interface{}{
  380. "failed_code": -10,
  381. "msg": res.ErrMsg,
  382. })
  383. } else {
  384. c.ServeSuccessJSON(map[string]interface{}{
  385. "info": res.Output,
  386. })
  387. }
  388. }
  389. func (c *HisApiController) Get3512() {
  390. admin_user_id, _ := c.GetInt64("admin_user_id")
  391. drug_id, _ := c.GetInt64("id")
  392. start_time := c.GetString("start_time")
  393. end_time := c.GetString("end_time")
  394. adminUser := c.GetAdminUserInfo()
  395. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  396. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  397. drug, _ := service.GetDrugByID(drug_id)
  398. var struct3508 models.Struct3512
  399. struct3508.FixmedinsCode = miConfig.Code
  400. struct3508.OrgName = miConfig.OrgName
  401. struct3508.AccessKey = miConfig.AccessKey
  402. struct3508.Opter = curRoles.UserName
  403. struct3508.RequestUrl = miConfig.Url
  404. struct3508.Url = miConfig.Url
  405. struct3508.AppId = miConfig.Cainfo
  406. struct3508.AppSecret = miConfig.AppSecret
  407. struct3508.Enckey = miConfig.EncKey
  408. struct3508.SignKey = miConfig.SignKey
  409. struct3508.SecretKey = miConfig.SecretKey
  410. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  411. struct3508.Begndate = start_time
  412. struct3508.Enddate = end_time
  413. result1, result2, _ := service.FJyb3512(struct3508)
  414. saveLog(result1, result2, "3512", "3512")
  415. var res models.Result3512
  416. var respJSON2 map[string]interface{}
  417. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  420. return
  421. }
  422. userJSONBytes2, _ := json.Marshal(respJSON2)
  423. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  424. utils.ErrorLog("解析失败:%v", err)
  425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  426. return
  427. }
  428. if res.Infcode == -1 {
  429. c.ServeSuccessJSON(map[string]interface{}{
  430. "failed_code": -10,
  431. "msg": res.ErrMsg,
  432. })
  433. } else {
  434. c.ServeSuccessJSON(map[string]interface{}{
  435. "info": res.Output,
  436. })
  437. }
  438. }
  439. func (c *HisApiController) Get3513() {
  440. admin_user_id, _ := c.GetInt64("admin_user_id")
  441. drug_id, _ := c.GetInt64("id")
  442. start_time := c.GetString("start_time")
  443. end_time := c.GetString("end_time")
  444. adminUser := c.GetAdminUserInfo()
  445. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  446. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  447. drug, _ := service.GetDrugByID(drug_id)
  448. var struct3508 models.Struct3513
  449. struct3508.FixmedinsCode = miConfig.Code
  450. struct3508.OrgName = miConfig.OrgName
  451. struct3508.AccessKey = miConfig.AccessKey
  452. struct3508.Opter = curRoles.UserName
  453. struct3508.RequestUrl = miConfig.Url
  454. struct3508.Url = miConfig.Url
  455. struct3508.AppId = miConfig.Cainfo
  456. struct3508.AppSecret = miConfig.AppSecret
  457. struct3508.Enckey = miConfig.EncKey
  458. struct3508.SignKey = miConfig.SignKey
  459. struct3508.SecretKey = miConfig.SecretKey
  460. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  461. struct3508.Begndate = start_time
  462. struct3508.Enddate = end_time
  463. result1, result2, _ := service.FJyb3513(struct3508)
  464. saveLog(result1, result2, "3513", "3513")
  465. var res models.Result3513
  466. var respJSON2 map[string]interface{}
  467. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  470. return
  471. }
  472. userJSONBytes2, _ := json.Marshal(respJSON2)
  473. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  474. utils.ErrorLog("解析失败:%v", err)
  475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  476. return
  477. }
  478. if res.Infcode == -1 {
  479. c.ServeSuccessJSON(map[string]interface{}{
  480. "failed_code": -10,
  481. "msg": res.ErrMsg,
  482. })
  483. } else {
  484. c.ServeSuccessJSON(map[string]interface{}{
  485. "info": res.Output,
  486. })
  487. }
  488. }
  489. func (c *HisApiController) Get35081() {
  490. admin_user_id, _ := c.GetInt64("admin_user_id")
  491. drug_id, _ := c.GetInt64("id")
  492. //start_time := c.GetString("start_time")
  493. //end_time := c.GetString("end_time")
  494. page, _ := c.GetInt("page")
  495. adminUser := c.GetAdminUserInfo()
  496. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  497. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  498. drug, _ := service.GetDrugByID(drug_id)
  499. var struct3508 models.Struct35081
  500. struct3508.FixmedinsCode = miConfig.Code
  501. struct3508.OrgName = miConfig.OrgName
  502. struct3508.AccessKey = miConfig.AccessKey
  503. struct3508.Opter = curRoles.UserName
  504. struct3508.RequestUrl = miConfig.Url
  505. struct3508.Url = miConfig.Url
  506. struct3508.AppId = miConfig.Cainfo
  507. struct3508.AppSecret = miConfig.AppSecret
  508. struct3508.Enckey = miConfig.EncKey
  509. struct3508.SignKey = miConfig.SignKey
  510. struct3508.SecretKey = miConfig.SecretKey
  511. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  512. struct3508.PageNum = page
  513. struct3508.PageSize = 10
  514. result1, result2, _ := service.FJyb35081(struct3508)
  515. saveLog(result1, result2, "35081", "35081")
  516. var res models.Result35081
  517. var respJSON2 map[string]interface{}
  518. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  521. return
  522. }
  523. userJSONBytes2, _ := json.Marshal(respJSON2)
  524. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  525. utils.ErrorLog("解析失败:%v", err)
  526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  527. return
  528. }
  529. if res.Infcode == -1 {
  530. c.ServeSuccessJSON(map[string]interface{}{
  531. "failed_code": -10,
  532. "msg": res.ErrMsg,
  533. })
  534. } else {
  535. c.ServeSuccessJSON(map[string]interface{}{
  536. "info": res.Output,
  537. })
  538. }
  539. }
  540. func (c *HisApiController) Get35082() {
  541. admin_user_id, _ := c.GetInt64("admin_user_id")
  542. drug_id, _ := c.GetInt64("id")
  543. //start_time := c.GetString("start_time")
  544. //end_time := c.GetString("end_time")
  545. page, _ := c.GetInt("page")
  546. adminUser := c.GetAdminUserInfo()
  547. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  548. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  549. drug, _ := service.GetDrugByID(drug_id)
  550. var struct3508 models.Struct35082
  551. struct3508.FixmedinsCode = miConfig.Code
  552. struct3508.OrgName = miConfig.OrgName
  553. struct3508.AccessKey = miConfig.AccessKey
  554. struct3508.Opter = curRoles.UserName
  555. struct3508.RequestUrl = miConfig.Url
  556. struct3508.Url = miConfig.Url
  557. struct3508.AppId = miConfig.Cainfo
  558. struct3508.AppSecret = miConfig.AppSecret
  559. struct3508.Enckey = miConfig.EncKey
  560. struct3508.SignKey = miConfig.SignKey
  561. struct3508.SecretKey = miConfig.SecretKey
  562. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  563. struct3508.PageNum = page
  564. struct3508.PageSize = 10
  565. result1, result2, _ := service.FJyb35082(struct3508)
  566. saveLog(result1, result2, "35082", "35082")
  567. var res models.Result35082
  568. var respJSON2 map[string]interface{}
  569. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  572. return
  573. }
  574. userJSONBytes2, _ := json.Marshal(respJSON2)
  575. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  576. utils.ErrorLog("解析失败:%v", err)
  577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  578. return
  579. }
  580. if res.Infcode == -1 {
  581. c.ServeSuccessJSON(map[string]interface{}{
  582. "failed_code": -10,
  583. "msg": res.ErrMsg,
  584. })
  585. } else {
  586. c.ServeSuccessJSON(map[string]interface{}{
  587. "info": res.Output,
  588. })
  589. }
  590. }
  591. func (c *HisApiController) FJ3501AND3502() {
  592. ids := c.GetString("ids")
  593. admin_user_id, _ := c.GetInt64("admin_user_id")
  594. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  595. id_arr := strings.Split(ids, ",")
  596. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  597. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  598. //库盘
  599. var errs []string
  600. for _, drug := range drugs {
  601. if drug.IsPc == 0 {
  602. var res2 ResultSix
  603. var res3 ResultSix
  604. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  605. var struct3501 models.Struct3501
  606. struct3501.Code = miConfig.Code
  607. struct3501.OrgName = miConfig.OrgName
  608. struct3501.AccessKey = miConfig.AccessKey
  609. struct3501.Opter = roles.UserName
  610. struct3501.RequestUrl = miConfig.Url
  611. struct3501.Url = miConfig.Url
  612. struct3501.AppId = miConfig.Cainfo
  613. struct3501.AppSecret = miConfig.AppSecret
  614. struct3501.Enckey = miConfig.EncKey
  615. struct3501.SignKey = miConfig.SignKey
  616. struct3501.SecretKey = miConfig.SecretKey
  617. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  618. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  619. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  620. struct3501.RxFlag = "1"
  621. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  622. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  623. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  624. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  625. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  626. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  627. struct3501.FixmedinsBchno = number
  628. struct3501.DrugTracCodg = drug.DrugCode
  629. memo := make(map[string]interface{})
  630. memo["pric"] = drug.Price
  631. bytesData, _ := json.Marshal(memo)
  632. struct3501.Memo = string(bytesData)
  633. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  634. result1, result2, _ := service.FJyb3501(struct3501)
  635. saveLog(result1, result2, "3501", "3501")
  636. //saveLog(result, requestLog, "2201", "挂号")
  637. var respJSON2 map[string]interface{}
  638. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  641. return
  642. }
  643. userJSONBytes2, _ := json.Marshal(respJSON2)
  644. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  645. utils.ErrorLog("解析失败:%v", err)
  646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  647. return
  648. }
  649. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  650. data := make(map[string]interface{})
  651. data["struct_3501s"] = struct3501
  652. client := &http.Client{}
  653. bytesData, _ := json.Marshal(data)
  654. var req *http.Request
  655. if miConfig.MdtrtareaAdmvs == "320921" {
  656. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  657. } else {
  658. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  659. }
  660. resp, _ := client.Do(req)
  661. defer resp.Body.Close()
  662. body, ioErr := ioutil.ReadAll(resp.Body)
  663. if ioErr != nil {
  664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  665. }
  666. var respJSON map[string]interface{}
  667. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  670. return
  671. }
  672. var resSix10265 ResultSix10265 //1101结果
  673. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  674. result, _ := json.Marshal(respJSON)
  675. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  676. utils.ErrorLog("解析失败:%v", err)
  677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  678. return
  679. }
  680. res2.InfRefmsgid = resSix10265.InfRefmsgid
  681. res2.Output = resSix10265.Output
  682. res2.ErrMsg = resSix10265.ErrMsg
  683. res2.Cainfo = resSix10265.Cainfo
  684. res2.WarnMsg = resSix10265.WarnMsg
  685. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  686. res2.Infcode = infocode
  687. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  688. data := make(map[string]interface{})
  689. data["struct_3501s"] = struct3501
  690. client := &http.Client{}
  691. bytesData, _ := json.Marshal(data)
  692. var req *http.Request
  693. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  694. resp, _ := client.Do(req)
  695. defer resp.Body.Close()
  696. body, ioErr := ioutil.ReadAll(resp.Body)
  697. if ioErr != nil {
  698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  699. }
  700. var respJSON map[string]interface{}
  701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  704. return
  705. }
  706. var resSix10265 ResultSix10265 //1101结果
  707. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  708. result, _ := json.Marshal(respJSON)
  709. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  710. utils.ErrorLog("解析失败:%v", err)
  711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  712. return
  713. }
  714. res2.InfRefmsgid = resSix10265.InfRefmsgid
  715. res2.Output = resSix10265.Output
  716. res2.ErrMsg = resSix10265.ErrMsg
  717. res2.Cainfo = resSix10265.Cainfo
  718. res2.WarnMsg = resSix10265.WarnMsg
  719. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  720. res2.Infcode = infocode
  721. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  722. data := make(map[string]interface{})
  723. data["struct_3501s"] = struct3501
  724. client := &http.Client{}
  725. bytesData, _ := json.Marshal(data)
  726. var req *http.Request
  727. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  728. resp, _ := client.Do(req)
  729. defer resp.Body.Close()
  730. body, ioErr := ioutil.ReadAll(resp.Body)
  731. if ioErr != nil {
  732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  733. }
  734. var respJSON map[string]interface{}
  735. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  738. return
  739. }
  740. var resSix10265 ResultSix10265 //1101结果
  741. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  742. result, _ := json.Marshal(respJSON)
  743. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  744. utils.ErrorLog("解析失败:%v", err)
  745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  746. return
  747. }
  748. res2.InfRefmsgid = resSix10265.InfRefmsgid
  749. res2.Output = resSix10265.Output
  750. res2.ErrMsg = resSix10265.ErrMsg
  751. res2.Cainfo = resSix10265.Cainfo
  752. res2.WarnMsg = resSix10265.WarnMsg
  753. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  754. res2.Infcode = infocode
  755. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  756. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  757. saveLog(result1, result2, "3501", "3501")
  758. //saveLog(result, requestLog, "2201", "挂号")
  759. var respJSON2 map[string]interface{}
  760. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  763. return
  764. }
  765. userJSONBytes2, _ := json.Marshal(respJSON2)
  766. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  767. utils.ErrorLog("解析失败:%v", err)
  768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  769. return
  770. }
  771. }
  772. if res2.Infcode != -1 {
  773. drug.IsPc = 1
  774. drug.Bchno = number
  775. drug.PcDate = time.Now().Unix()
  776. err := service.SaveW(drug)
  777. if err == nil {
  778. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  779. var struct3502 models.Struct3502
  780. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  781. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  782. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  783. struct3502.FixmedinsCode = miConfig.Code
  784. struct3502.Code = miConfig.Code
  785. struct3502.RxFlag = "0"
  786. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  787. struct3502.OrgName = miConfig.OrgName
  788. struct3502.Opter = roles.UserName
  789. struct3502.AccessKey = miConfig.AccessKey
  790. struct3502.RequestUrl = miConfig.Url
  791. struct3502.SecretKey = miConfig.SecretKey
  792. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  793. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  794. struct3502.Url = miConfig.Url
  795. struct3502.AppId = miConfig.Cainfo
  796. struct3502.AppSecret = miConfig.AppSecret
  797. struct3502.Enckey = miConfig.EncKey
  798. struct3502.SignKey = miConfig.SignKey
  799. struct3502.SecretKey = miConfig.SecretKey
  800. struct3502.DrugTracCodg = drug.DrugCode
  801. struct3502.Memo = ""
  802. struct3502.InvChgType = "108"
  803. struct3502.FixmedinsBchno = bg_number
  804. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  805. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  806. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  807. result11, result22, _ := service.FJyb3502(struct3502)
  808. saveLog(result11, result22, "3502", "3502")
  809. var respJSON3 map[string]interface{}
  810. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  813. return
  814. }
  815. userJSONBytes3, _ := json.Marshal(respJSON3)
  816. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  817. utils.ErrorLog("解析失败:%v", err)
  818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  819. return
  820. }
  821. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  822. data := make(map[string]interface{})
  823. data["struct_3502s"] = struct3502
  824. client := &http.Client{}
  825. bytesData, _ := json.Marshal(data)
  826. var req *http.Request
  827. if miConfig.MdtrtareaAdmvs == "320921" {
  828. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  829. } else {
  830. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  831. }
  832. resp, _ := client.Do(req)
  833. defer resp.Body.Close()
  834. body, ioErr := ioutil.ReadAll(resp.Body)
  835. if ioErr != nil {
  836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  837. }
  838. var respJSON map[string]interface{}
  839. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  842. return
  843. }
  844. var resSix10265 ResultSix10265 //1101结果
  845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  846. result, _ := json.Marshal(respJSON)
  847. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  848. utils.ErrorLog("解析失败:%v", err)
  849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  850. return
  851. }
  852. res3.InfRefmsgid = resSix10265.InfRefmsgid
  853. res3.Output = resSix10265.Output
  854. res3.ErrMsg = resSix10265.ErrMsg
  855. res3.Cainfo = resSix10265.Cainfo
  856. res3.WarnMsg = resSix10265.WarnMsg
  857. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  858. res3.Infcode = infocode
  859. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  860. data := make(map[string]interface{})
  861. data["struct_3502s"] = struct3502
  862. client := &http.Client{}
  863. bytesData, _ := json.Marshal(data)
  864. var req *http.Request
  865. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  866. resp, _ := client.Do(req)
  867. defer resp.Body.Close()
  868. body, ioErr := ioutil.ReadAll(resp.Body)
  869. if ioErr != nil {
  870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  871. }
  872. var respJSON map[string]interface{}
  873. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  876. return
  877. }
  878. var resSix10265 ResultSix10265 //1101结果
  879. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  880. result, _ := json.Marshal(respJSON)
  881. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  882. utils.ErrorLog("解析失败:%v", err)
  883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  884. return
  885. }
  886. res3.InfRefmsgid = resSix10265.InfRefmsgid
  887. res3.Output = resSix10265.Output
  888. res3.ErrMsg = resSix10265.ErrMsg
  889. res3.Cainfo = resSix10265.Cainfo
  890. res3.WarnMsg = resSix10265.WarnMsg
  891. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  892. res3.Infcode = infocode
  893. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  894. data := make(map[string]interface{})
  895. data["struct_3501s"] = struct3501
  896. client := &http.Client{}
  897. bytesData, _ := json.Marshal(data)
  898. var req *http.Request
  899. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  900. resp, _ := client.Do(req)
  901. defer resp.Body.Close()
  902. body, ioErr := ioutil.ReadAll(resp.Body)
  903. if ioErr != nil {
  904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  905. }
  906. var respJSON map[string]interface{}
  907. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  910. return
  911. }
  912. var resSix10265 ResultSix10265 //1101结果
  913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  914. result, _ := json.Marshal(respJSON)
  915. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  916. utils.ErrorLog("解析失败:%v", err)
  917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  918. return
  919. }
  920. res2.InfRefmsgid = resSix10265.InfRefmsgid
  921. res2.Output = resSix10265.Output
  922. res2.ErrMsg = resSix10265.ErrMsg
  923. res2.Cainfo = resSix10265.Cainfo
  924. res2.WarnMsg = resSix10265.WarnMsg
  925. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  926. res2.Infcode = infocode
  927. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  928. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  929. saveLog(result11, result22, "3502", "3502")
  930. var respJSON3 map[string]interface{}
  931. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  934. return
  935. }
  936. userJSONBytes3, _ := json.Marshal(respJSON3)
  937. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  938. utils.ErrorLog("解析失败:%v", err)
  939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  940. return
  941. }
  942. }
  943. if res3.Infcode == -1 {
  944. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  945. c.ServeSuccessJSON(map[string]interface{}{
  946. "failed_code": -10,
  947. "msg": res3.ErrMsg,
  948. })
  949. } else {
  950. drug.IsBg = 1
  951. drug.BgBchno = bg_number
  952. service.SaveW(drug)
  953. }
  954. }
  955. } else {
  956. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  957. }
  958. }
  959. //变更
  960. }
  961. if len(errs) == 0 {
  962. c.ServeSuccessJSON(map[string]interface{}{
  963. "msg": "盘存变更成功",
  964. })
  965. } else {
  966. c.ServeSuccessJSON(map[string]interface{}{
  967. "failed_code": -10,
  968. "msg": errs,
  969. })
  970. }
  971. }
  972. func (c *HisApiController) DeletePCandBG() {
  973. ids := c.GetString("ids")
  974. id_arr := strings.Split(ids, ",")
  975. admin_user_id, _ := c.GetInt64("admin_user_id")
  976. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  977. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  978. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  979. var err []string
  980. for _, item := range drugs {
  981. if item.IsPc == 1 && item.IsBg == 1 {
  982. var res FJ3507Result
  983. var res2 FJ3507Result
  984. var struct3507 models.Struct3507
  985. struct3507.FixmedinsBchno = item.Bchno
  986. struct3507.InvDataType = "1"
  987. struct3507.Opter = roles.UserName
  988. struct3507.OrgName = miConfig.OrgName
  989. struct3507.AccessKey = miConfig.AccessKey
  990. struct3507.RequestUrl = miConfig.Url
  991. struct3507.FixmedinsCode = miConfig.Code
  992. struct3507.Code = miConfig.Code
  993. struct3507.SecretKey = miConfig.SecretKey
  994. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  995. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  996. struct3507.Url = miConfig.Url
  997. struct3507.AppId = miConfig.Cainfo
  998. struct3507.AppSecret = miConfig.AppSecret
  999. struct3507.Enckey = miConfig.EncKey
  1000. struct3507.SignKey = miConfig.SignKey
  1001. struct3507.SecretKey = miConfig.SecretKey
  1002. if miConfig.MdtrtareaAdmvs == "350500" {
  1003. result, result1, _ := service.FJyb3507(struct3507)
  1004. saveLog(result, result1, "3507", "3507")
  1005. var respJSON2 map[string]interface{}
  1006. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1009. return
  1010. }
  1011. userJSONBytes2, _ := json.Marshal(respJSON2)
  1012. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1013. utils.ErrorLog("解析失败:%v", err)
  1014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1015. return
  1016. }
  1017. } else {
  1018. data := make(map[string]interface{})
  1019. data["struct_3507s"] = struct3507
  1020. client := &http.Client{}
  1021. bytesData, _ := json.Marshal(data)
  1022. var req *http.Request
  1023. if miConfig.MdtrtareaAdmvs == "320921" {
  1024. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1025. } else {
  1026. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1027. }
  1028. resp, _ := client.Do(req)
  1029. defer resp.Body.Close()
  1030. body, ioErr := ioutil.ReadAll(resp.Body)
  1031. if ioErr != nil {
  1032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1033. }
  1034. var respJSON map[string]interface{}
  1035. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1038. return
  1039. }
  1040. var resSix10265 ResultSix10265 //1101结果
  1041. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1042. result, _ := json.Marshal(respJSON)
  1043. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1044. utils.ErrorLog("解析失败:%v", err)
  1045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1046. return
  1047. }
  1048. res.InfRefmsgid = resSix10265.InfRefmsgid
  1049. //res.Output = resSix10265.Output
  1050. res.ErrMsg = resSix10265.ErrMsg
  1051. res.Cainfo = resSix10265.Cainfo
  1052. res.WarnMsg = resSix10265.WarnMsg
  1053. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1054. res.Infcode = infocode
  1055. }
  1056. if res.Infcode == 0 {
  1057. item.IsPc = 0
  1058. err2 := service.SaveW(item)
  1059. if err2 == nil {
  1060. var struct3507_2 models.Struct3507
  1061. struct3507_2.OrgName = miConfig.OrgName
  1062. struct3507_2.AccessKey = miConfig.AccessKey
  1063. struct3507_2.RequestUrl = miConfig.Url
  1064. struct3507_2.Opter = roles.UserName
  1065. struct3507_2.FixmedinsCode = miConfig.Code
  1066. struct3507_2.Code = miConfig.Code
  1067. struct3507_2.SecretKey = miConfig.SecretKey
  1068. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1069. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1070. struct3507_2.Url = miConfig.Url
  1071. struct3507_2.AppId = miConfig.Cainfo
  1072. struct3507_2.AppSecret = miConfig.AppSecret
  1073. struct3507_2.Enckey = miConfig.EncKey
  1074. struct3507_2.SignKey = miConfig.SignKey
  1075. struct3507_2.SecretKey = miConfig.SecretKey
  1076. struct3507_2.FixmedinsBchno = item.BgBchno
  1077. struct3507_2.InvDataType = "2"
  1078. if miConfig.MdtrtareaAdmvs == "350500" {
  1079. result11, result22, _ := service.FJyb3507(struct3507_2)
  1080. saveLog(result11, result22, "3507", "3507")
  1081. var respJSON3 map[string]interface{}
  1082. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1085. return
  1086. }
  1087. userJSONBytes3, _ := json.Marshal(respJSON3)
  1088. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1089. utils.ErrorLog("解析失败:%v", err)
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. } else {
  1094. data := make(map[string]interface{})
  1095. data["struct_3507s"] = struct3507_2
  1096. client := &http.Client{}
  1097. bytesData, _ := json.Marshal(data)
  1098. var req *http.Request
  1099. if miConfig.MdtrtareaAdmvs == "320921" {
  1100. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1101. } else {
  1102. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1103. }
  1104. resp, _ := client.Do(req)
  1105. defer resp.Body.Close()
  1106. body, ioErr := ioutil.ReadAll(resp.Body)
  1107. if ioErr != nil {
  1108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1109. }
  1110. var respJSON map[string]interface{}
  1111. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1114. return
  1115. }
  1116. var resSix10265 ResultSix10265 //1101结果
  1117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1118. result, _ := json.Marshal(respJSON)
  1119. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1120. utils.ErrorLog("解析失败:%v", err)
  1121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1122. return
  1123. }
  1124. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1125. //res2.Output = resSix10265.Output
  1126. res2.ErrMsg = resSix10265.ErrMsg
  1127. res2.Cainfo = resSix10265.Cainfo
  1128. res2.WarnMsg = resSix10265.WarnMsg
  1129. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1130. res2.Infcode = infocode
  1131. }
  1132. if res2.Infcode != -1 {
  1133. item.IsBg = 0
  1134. item.Bchno = ""
  1135. item.BgBchno = ""
  1136. item.PcDate = 0
  1137. service.SaveW(item)
  1138. } else {
  1139. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1140. }
  1141. }
  1142. } else {
  1143. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1144. }
  1145. }
  1146. if item.IsPc == 1 && item.IsBg == 0 {
  1147. var res FJ3507Result
  1148. var struct3507 models.Struct3507
  1149. struct3507.FixmedinsBchno = item.Bchno
  1150. struct3507.InvDataType = "1"
  1151. struct3507.Opter = roles.UserName
  1152. struct3507.FixmedinsCode = miConfig.Code
  1153. struct3507.Code = miConfig.Code
  1154. struct3507.OrgName = miConfig.OrgName
  1155. struct3507.AccessKey = miConfig.AccessKey
  1156. struct3507.RequestUrl = miConfig.Url
  1157. struct3507.SecretKey = miConfig.SecretKey
  1158. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1159. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1160. struct3507.Url = miConfig.Url
  1161. struct3507.AppId = miConfig.Cainfo
  1162. struct3507.AppSecret = miConfig.AppSecret
  1163. struct3507.Enckey = miConfig.EncKey
  1164. struct3507.SignKey = miConfig.SignKey
  1165. struct3507.SecretKey = miConfig.SecretKey
  1166. //result, result1, _ := service.FJyb3507(struct3507)
  1167. //saveLog(result, result1, "3507", "3507")
  1168. if miConfig.MdtrtareaAdmvs == "350500" {
  1169. result, result1, _ := service.FJyb3507(struct3507)
  1170. saveLog(result, result1, "3507", "3507")
  1171. var respJSON2 map[string]interface{}
  1172. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1175. return
  1176. }
  1177. userJSONBytes2, _ := json.Marshal(respJSON2)
  1178. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1179. utils.ErrorLog("解析失败:%v", err)
  1180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1181. return
  1182. }
  1183. } else {
  1184. data := make(map[string]interface{})
  1185. data["struct_3507s"] = struct3507
  1186. client := &http.Client{}
  1187. bytesData, _ := json.Marshal(data)
  1188. var req *http.Request
  1189. if miConfig.MdtrtareaAdmvs == "320921" {
  1190. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1191. } else {
  1192. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1193. }
  1194. resp, _ := client.Do(req)
  1195. defer resp.Body.Close()
  1196. body, ioErr := ioutil.ReadAll(resp.Body)
  1197. if ioErr != nil {
  1198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1199. }
  1200. var respJSON map[string]interface{}
  1201. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1204. return
  1205. }
  1206. var resSix10265 ResultSix10265 //1101结果
  1207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1208. result, _ := json.Marshal(respJSON)
  1209. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1210. utils.ErrorLog("解析失败:%v", err)
  1211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1212. return
  1213. }
  1214. res.InfRefmsgid = resSix10265.InfRefmsgid
  1215. //res.Output = resSix10265.Output
  1216. res.ErrMsg = resSix10265.ErrMsg
  1217. res.Cainfo = resSix10265.Cainfo
  1218. res.WarnMsg = resSix10265.WarnMsg
  1219. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1220. res.Infcode = infocode
  1221. }
  1222. if res.Infcode == 0 {
  1223. item.IsPc = 0
  1224. item.Bchno = ""
  1225. item.BgBchno = ""
  1226. item.PcDate = 0
  1227. service.SaveW(item)
  1228. } else {
  1229. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1230. }
  1231. }
  1232. if item.IsPc == 0 && item.IsBg == 1 {
  1233. var res FJ3507Result
  1234. var struct3507 models.Struct3507
  1235. struct3507.FixmedinsBchno = item.BgBchno
  1236. struct3507.InvDataType = "2"
  1237. struct3507.Opter = roles.UserName
  1238. struct3507.FixmedinsCode = miConfig.Code
  1239. struct3507.OrgName = miConfig.OrgName
  1240. struct3507.AccessKey = miConfig.AccessKey
  1241. struct3507.RequestUrl = miConfig.Url
  1242. struct3507.SecretKey = miConfig.SecretKey
  1243. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1244. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1245. struct3507.Url = miConfig.Url
  1246. struct3507.AppId = miConfig.Cainfo
  1247. struct3507.AppSecret = miConfig.AppSecret
  1248. struct3507.Enckey = miConfig.EncKey
  1249. struct3507.SignKey = miConfig.SignKey
  1250. struct3507.SecretKey = miConfig.SecretKey
  1251. //result, result1, _ := service.FJyb3507(struct3507)
  1252. //saveLog(result, result1, "3507", "3507")
  1253. if miConfig.MdtrtareaAdmvs == "350500" {
  1254. result, result1, _ := service.FJyb3507(struct3507)
  1255. saveLog(result, result1, "3507", "3507")
  1256. var respJSON2 map[string]interface{}
  1257. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1260. return
  1261. }
  1262. userJSONBytes2, _ := json.Marshal(respJSON2)
  1263. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1264. utils.ErrorLog("解析失败:%v", err)
  1265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1266. return
  1267. }
  1268. } else {
  1269. data := make(map[string]interface{})
  1270. data["struct_3507s"] = struct3507
  1271. client := &http.Client{}
  1272. bytesData, _ := json.Marshal(data)
  1273. var req *http.Request
  1274. if miConfig.MdtrtareaAdmvs == "320921" {
  1275. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1276. } else {
  1277. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1278. }
  1279. resp, _ := client.Do(req)
  1280. defer resp.Body.Close()
  1281. body, ioErr := ioutil.ReadAll(resp.Body)
  1282. if ioErr != nil {
  1283. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1284. }
  1285. var respJSON map[string]interface{}
  1286. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1289. return
  1290. }
  1291. var resSix10265 ResultSix10265 //1101结果
  1292. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1293. result, _ := json.Marshal(respJSON)
  1294. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1295. utils.ErrorLog("解析失败:%v", err)
  1296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1297. return
  1298. }
  1299. res.InfRefmsgid = resSix10265.InfRefmsgid
  1300. //res.Output = resSix10265.Output
  1301. res.ErrMsg = resSix10265.ErrMsg
  1302. res.Cainfo = resSix10265.Cainfo
  1303. res.WarnMsg = resSix10265.WarnMsg
  1304. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1305. res.Infcode = infocode
  1306. }
  1307. if res.Infcode == 0 {
  1308. item.IsBg = 0
  1309. item.Bchno = ""
  1310. item.BgBchno = ""
  1311. item.PcDate = 0
  1312. service.SaveW(item)
  1313. } else {
  1314. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1315. }
  1316. }
  1317. }
  1318. if len(err) == 0 {
  1319. c.ServeSuccessJSON(map[string]interface{}{
  1320. "msg": "删除盘存变更成功",
  1321. })
  1322. } else {
  1323. c.ServeSuccessJSON(map[string]interface{}{
  1324. "failed_code": -10,
  1325. "msg": err,
  1326. })
  1327. }
  1328. }
  1329. func (c *HisApiController) DeleteXSandBG() {
  1330. ids := c.GetString("ids")
  1331. id_arr := strings.Split(ids, ",")
  1332. admin_user_id, _ := c.GetInt64("admin_user_id")
  1333. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1334. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1335. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1336. var err []string
  1337. for _, item := range flows {
  1338. if item.IsSale == 1 && item.IsChange == 1 {
  1339. var res FJ3507Result
  1340. var res2 FJ3507Result
  1341. var struct3507 models.Struct3507
  1342. struct3507.FixmedinsBchno = item.Bchno
  1343. struct3507.InvDataType = "4"
  1344. struct3507.Opter = roles.UserName
  1345. struct3507.OrgName = miConfig.OrgName
  1346. struct3507.AccessKey = miConfig.AccessKey
  1347. struct3507.RequestUrl = miConfig.Url
  1348. struct3507.FixmedinsCode = miConfig.Code
  1349. struct3507.SecretKey = miConfig.SecretKey
  1350. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1351. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1352. struct3507.Url = miConfig.Url
  1353. struct3507.AppId = miConfig.Cainfo
  1354. struct3507.AppSecret = miConfig.AppSecret
  1355. struct3507.Enckey = miConfig.EncKey
  1356. struct3507.SignKey = miConfig.SignKey
  1357. struct3507.SecretKey = miConfig.SecretKey
  1358. //result, result1, _ := service.FJyb3507(struct3507)
  1359. //saveLog(result, result1, "3507", "3507")
  1360. if miConfig.MdtrtareaAdmvs == "350500" {
  1361. result, result1, _ := service.FJyb3507(struct3507)
  1362. saveLog(result, result1, "3507", "3507")
  1363. var respJSON2 map[string]interface{}
  1364. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1367. return
  1368. }
  1369. userJSONBytes2, _ := json.Marshal(respJSON2)
  1370. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1371. utils.ErrorLog("解析失败:%v", err)
  1372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1373. return
  1374. }
  1375. } else {
  1376. data := make(map[string]interface{})
  1377. data["struct_3507s"] = struct3507
  1378. client := &http.Client{}
  1379. bytesData, _ := json.Marshal(data)
  1380. var req *http.Request
  1381. if miConfig.MdtrtareaAdmvs == "320921" {
  1382. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1383. } else {
  1384. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1385. }
  1386. resp, _ := client.Do(req)
  1387. defer resp.Body.Close()
  1388. body, ioErr := ioutil.ReadAll(resp.Body)
  1389. if ioErr != nil {
  1390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1391. }
  1392. var respJSON map[string]interface{}
  1393. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1396. return
  1397. }
  1398. var resSix10265 ResultSix10265 //1101结果
  1399. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1400. result, _ := json.Marshal(respJSON)
  1401. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1402. utils.ErrorLog("解析失败:%v", err)
  1403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1404. return
  1405. }
  1406. res.InfRefmsgid = resSix10265.InfRefmsgid
  1407. //res.Output = resSix10265.Output
  1408. res.ErrMsg = resSix10265.ErrMsg
  1409. res.Cainfo = resSix10265.Cainfo
  1410. res.WarnMsg = resSix10265.WarnMsg
  1411. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1412. res.Infcode = infocode
  1413. }
  1414. if res.Infcode == 0 {
  1415. item.IsSale = 0
  1416. item.SaleDate = ""
  1417. item.Bchno = ""
  1418. err2 := service.SaveDF(item)
  1419. if err2 == nil {
  1420. var struct3507_2 models.Struct3507
  1421. struct3507_2.OrgName = miConfig.OrgName
  1422. struct3507_2.AccessKey = miConfig.AccessKey
  1423. struct3507_2.RequestUrl = miConfig.Url
  1424. struct3507_2.Opter = roles.UserName
  1425. struct3507_2.FixmedinsCode = miConfig.Code
  1426. struct3507_2.Code = miConfig.Code
  1427. struct3507_2.SecretKey = miConfig.SecretKey
  1428. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1429. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1430. struct3507_2.Url = miConfig.Url
  1431. struct3507_2.AppId = miConfig.Cainfo
  1432. struct3507_2.AppSecret = miConfig.AppSecret
  1433. struct3507_2.Enckey = miConfig.EncKey
  1434. struct3507_2.SignKey = miConfig.SignKey
  1435. struct3507_2.SecretKey = miConfig.SecretKey
  1436. struct3507_2.FixmedinsBchno = item.BgBchno
  1437. struct3507_2.InvDataType = "2"
  1438. if miConfig.MdtrtareaAdmvs == "350500" {
  1439. result11, result22, _ := service.FJyb3507(struct3507_2)
  1440. saveLog(result11, result22, "3507", "3507")
  1441. var respJSON3 map[string]interface{}
  1442. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1445. return
  1446. }
  1447. userJSONBytes3, _ := json.Marshal(respJSON3)
  1448. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1449. utils.ErrorLog("解析失败:%v", err)
  1450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1451. return
  1452. }
  1453. } else {
  1454. data := make(map[string]interface{})
  1455. data["struct_3507s"] = struct3507_2
  1456. client := &http.Client{}
  1457. bytesData, _ := json.Marshal(data)
  1458. var req *http.Request
  1459. if miConfig.MdtrtareaAdmvs == "320921" {
  1460. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1461. } else {
  1462. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1463. }
  1464. resp, _ := client.Do(req)
  1465. defer resp.Body.Close()
  1466. body, ioErr := ioutil.ReadAll(resp.Body)
  1467. if ioErr != nil {
  1468. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1469. }
  1470. var respJSON map[string]interface{}
  1471. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1474. return
  1475. }
  1476. var resSix10265 ResultSix10265 //1101结果
  1477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1478. result, _ := json.Marshal(respJSON)
  1479. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1480. utils.ErrorLog("解析失败:%v", err)
  1481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1482. return
  1483. }
  1484. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1485. //res.Output = resSix10265.Output
  1486. res2.ErrMsg = resSix10265.ErrMsg
  1487. res2.Cainfo = resSix10265.Cainfo
  1488. res2.WarnMsg = resSix10265.WarnMsg
  1489. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1490. res2.Infcode = infocode
  1491. }
  1492. if res2.Infcode == 0 {
  1493. item.IsChange = 0
  1494. item.BgBchno = ""
  1495. service.SaveDF2(item)
  1496. } else {
  1497. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1498. }
  1499. }
  1500. } else {
  1501. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1502. }
  1503. }
  1504. if item.IsSale == 2 && item.IsChange == 1 {
  1505. var res FJ3507Result
  1506. var res2 FJ3507Result
  1507. var struct3507 models.Struct3507
  1508. struct3507.FixmedinsBchno = item.Bchno
  1509. struct3507.InvDataType = "4"
  1510. struct3507.Opter = roles.UserName
  1511. struct3507.OrgName = miConfig.OrgName
  1512. struct3507.AccessKey = miConfig.AccessKey
  1513. struct3507.RequestUrl = miConfig.Url
  1514. struct3507.FixmedinsCode = miConfig.Code
  1515. struct3507.Code = miConfig.Code
  1516. struct3507.SecretKey = miConfig.SecretKey
  1517. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1518. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1519. struct3507.Url = miConfig.Url
  1520. struct3507.AppId = miConfig.Cainfo
  1521. struct3507.AppSecret = miConfig.AppSecret
  1522. struct3507.Enckey = miConfig.EncKey
  1523. struct3507.SignKey = miConfig.SignKey
  1524. struct3507.SecretKey = miConfig.SecretKey
  1525. //result, result1, _ := service.FJyb3507(struct3507)
  1526. //saveLog(result, result1, "3507", "3507")
  1527. //
  1528. //var respJSON2 map[string]interface{}
  1529. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1530. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1531. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1532. // return
  1533. //}
  1534. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1535. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1536. // utils.ErrorLog("解析失败:%v", err)
  1537. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1538. // return
  1539. //}
  1540. if miConfig.MdtrtareaAdmvs == "350500" {
  1541. result, result1, _ := service.FJyb3507(struct3507)
  1542. saveLog(result, result1, "3507", "3507")
  1543. var respJSON2 map[string]interface{}
  1544. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1547. return
  1548. }
  1549. userJSONBytes2, _ := json.Marshal(respJSON2)
  1550. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1551. utils.ErrorLog("解析失败:%v", err)
  1552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1553. return
  1554. }
  1555. } else {
  1556. data := make(map[string]interface{})
  1557. data["struct_3507s"] = struct3507
  1558. client := &http.Client{}
  1559. bytesData, _ := json.Marshal(data)
  1560. var req *http.Request
  1561. if miConfig.MdtrtareaAdmvs == "320921" {
  1562. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1563. } else {
  1564. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1565. }
  1566. resp, _ := client.Do(req)
  1567. defer resp.Body.Close()
  1568. body, ioErr := ioutil.ReadAll(resp.Body)
  1569. if ioErr != nil {
  1570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1571. }
  1572. var respJSON map[string]interface{}
  1573. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1576. return
  1577. }
  1578. var resSix10265 ResultSix10265 //1101结果
  1579. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1580. result, _ := json.Marshal(respJSON)
  1581. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1582. utils.ErrorLog("解析失败:%v", err)
  1583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1584. return
  1585. }
  1586. res.InfRefmsgid = resSix10265.InfRefmsgid
  1587. //res.Output = resSix10265.Output
  1588. res.ErrMsg = resSix10265.ErrMsg
  1589. res.Cainfo = resSix10265.Cainfo
  1590. res.WarnMsg = resSix10265.WarnMsg
  1591. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1592. res.Infcode = infocode
  1593. }
  1594. if res.Infcode == 0 {
  1595. item.IsSale = 0
  1596. item.SaleDate = ""
  1597. item.Bchno = ""
  1598. err2 := service.SaveDF(item)
  1599. if err2 == nil {
  1600. var struct3507_2 models.Struct3507
  1601. struct3507_2.OrgName = miConfig.OrgName
  1602. struct3507_2.AccessKey = miConfig.AccessKey
  1603. struct3507_2.RequestUrl = miConfig.Url
  1604. struct3507_2.Opter = roles.UserName
  1605. struct3507_2.FixmedinsCode = miConfig.Code
  1606. struct3507_2.Code = miConfig.Code
  1607. struct3507_2.SecretKey = miConfig.SecretKey
  1608. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1609. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1610. struct3507_2.Url = miConfig.Url
  1611. struct3507_2.AppId = miConfig.Cainfo
  1612. struct3507_2.AppSecret = miConfig.AppSecret
  1613. struct3507_2.Enckey = miConfig.EncKey
  1614. struct3507_2.SignKey = miConfig.SignKey
  1615. struct3507_2.SecretKey = miConfig.SecretKey
  1616. struct3507_2.FixmedinsBchno = item.BgBchno
  1617. struct3507_2.InvDataType = "2"
  1618. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1619. //saveLog(result11, result22, "3507", "3507")
  1620. //var respJSON3 map[string]interface{}
  1621. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1622. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1624. // return
  1625. //}
  1626. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1627. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1628. // utils.ErrorLog("解析失败:%v", err)
  1629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1630. // return
  1631. //}
  1632. if miConfig.MdtrtareaAdmvs == "350500" {
  1633. result11, result22, _ := service.FJyb3507(struct3507_2)
  1634. saveLog(result11, result22, "3507", "3507")
  1635. var respJSON3 map[string]interface{}
  1636. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1639. return
  1640. }
  1641. userJSONBytes3, _ := json.Marshal(respJSON3)
  1642. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1643. utils.ErrorLog("解析失败:%v", err)
  1644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1645. return
  1646. }
  1647. } else {
  1648. data := make(map[string]interface{})
  1649. data["struct_3507s"] = struct3507_2
  1650. client := &http.Client{}
  1651. bytesData, _ := json.Marshal(data)
  1652. var req *http.Request
  1653. if miConfig.MdtrtareaAdmvs == "320921" {
  1654. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1655. } else {
  1656. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1657. }
  1658. resp, _ := client.Do(req)
  1659. defer resp.Body.Close()
  1660. body, ioErr := ioutil.ReadAll(resp.Body)
  1661. if ioErr != nil {
  1662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1663. }
  1664. var respJSON map[string]interface{}
  1665. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1668. return
  1669. }
  1670. var resSix10265 ResultSix10265 //1101结果
  1671. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1672. result, _ := json.Marshal(respJSON)
  1673. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1674. utils.ErrorLog("解析失败:%v", err)
  1675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1676. return
  1677. }
  1678. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1679. //res.Output = resSix10265.Output
  1680. res2.ErrMsg = resSix10265.ErrMsg
  1681. res2.Cainfo = resSix10265.Cainfo
  1682. res2.WarnMsg = resSix10265.WarnMsg
  1683. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1684. res2.Infcode = infocode
  1685. }
  1686. if res2.Infcode == 0 {
  1687. item.IsChange = 0
  1688. item.BgBchno = ""
  1689. service.SaveDF2(item)
  1690. } else {
  1691. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1692. }
  1693. }
  1694. } else {
  1695. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1696. }
  1697. }
  1698. if item.IsSale == 1 && item.IsChange == 0 {
  1699. var res FJ3507Result
  1700. var struct3507 models.Struct3507
  1701. struct3507.FixmedinsBchno = item.Bchno
  1702. struct3507.InvDataType = "4"
  1703. struct3507.Opter = roles.UserName
  1704. struct3507.FixmedinsCode = miConfig.Code
  1705. struct3507.Code = miConfig.Code
  1706. struct3507.OrgName = miConfig.OrgName
  1707. struct3507.AccessKey = miConfig.AccessKey
  1708. struct3507.RequestUrl = miConfig.Url
  1709. struct3507.SecretKey = miConfig.SecretKey
  1710. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1711. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1712. struct3507.Url = miConfig.Url
  1713. struct3507.AppId = miConfig.Cainfo
  1714. struct3507.AppSecret = miConfig.AppSecret
  1715. struct3507.Enckey = miConfig.EncKey
  1716. struct3507.SignKey = miConfig.SignKey
  1717. struct3507.SecretKey = miConfig.SecretKey
  1718. //result, result1, _ := service.FJyb3507(struct3507)
  1719. //saveLog(result, result1, "3507", "3507")
  1720. //
  1721. //var respJSON3 map[string]interface{}
  1722. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1723. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1724. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1725. // return
  1726. //}
  1727. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1728. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1729. // utils.ErrorLog("解析失败:%v", err)
  1730. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1731. // return
  1732. //}
  1733. if miConfig.MdtrtareaAdmvs == "350500" {
  1734. result, result1, _ := service.FJyb3507(struct3507)
  1735. saveLog(result, result1, "3507", "3507")
  1736. var respJSON2 map[string]interface{}
  1737. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1740. return
  1741. }
  1742. userJSONBytes2, _ := json.Marshal(respJSON2)
  1743. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1744. utils.ErrorLog("解析失败:%v", err)
  1745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1746. return
  1747. }
  1748. } else {
  1749. data := make(map[string]interface{})
  1750. data["struct_3507s"] = struct3507
  1751. client := &http.Client{}
  1752. bytesData, _ := json.Marshal(data)
  1753. var req *http.Request
  1754. if miConfig.MdtrtareaAdmvs == "320921" {
  1755. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1756. } else {
  1757. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1758. }
  1759. resp, _ := client.Do(req)
  1760. defer resp.Body.Close()
  1761. body, ioErr := ioutil.ReadAll(resp.Body)
  1762. if ioErr != nil {
  1763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1764. }
  1765. var respJSON map[string]interface{}
  1766. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1769. return
  1770. }
  1771. var resSix10265 ResultSix10265 //1101结果
  1772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1773. result, _ := json.Marshal(respJSON)
  1774. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1775. utils.ErrorLog("解析失败:%v", err)
  1776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1777. return
  1778. }
  1779. res.InfRefmsgid = resSix10265.InfRefmsgid
  1780. //res.Output = resSix10265.Output
  1781. res.ErrMsg = resSix10265.ErrMsg
  1782. res.Cainfo = resSix10265.Cainfo
  1783. res.WarnMsg = resSix10265.WarnMsg
  1784. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1785. res.Infcode = infocode
  1786. }
  1787. if res.Infcode == 0 {
  1788. item.IsSale = 0
  1789. item.SaleDate = ""
  1790. service.SaveDF(item)
  1791. } else {
  1792. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1793. }
  1794. }
  1795. if item.IsSale == 2 && item.IsChange == 0 {
  1796. var res FJ3507Result
  1797. var struct3507 models.Struct3507
  1798. struct3507.FixmedinsBchno = item.Bchno
  1799. struct3507.InvDataType = "4"
  1800. struct3507.Opter = roles.UserName
  1801. struct3507.FixmedinsCode = miConfig.Code
  1802. struct3507.Code = miConfig.Code
  1803. struct3507.OrgName = miConfig.OrgName
  1804. struct3507.AccessKey = miConfig.AccessKey
  1805. struct3507.RequestUrl = miConfig.Url
  1806. struct3507.SecretKey = miConfig.SecretKey
  1807. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1808. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1809. struct3507.Url = miConfig.Url
  1810. struct3507.AppId = miConfig.Cainfo
  1811. struct3507.AppSecret = miConfig.AppSecret
  1812. struct3507.Enckey = miConfig.EncKey
  1813. struct3507.SignKey = miConfig.SignKey
  1814. struct3507.SecretKey = miConfig.SecretKey
  1815. //result, result1, _ := service.FJyb3507(struct3507)
  1816. //saveLog(result, result1, "3507", "3507")
  1817. //
  1818. //var respJSON3 map[string]interface{}
  1819. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1820. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1822. // return
  1823. //}
  1824. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1825. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1826. // utils.ErrorLog("解析失败:%v", err)
  1827. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1828. // return
  1829. //}
  1830. if miConfig.MdtrtareaAdmvs == "350500" {
  1831. result, result1, _ := service.FJyb3507(struct3507)
  1832. saveLog(result, result1, "3507", "3507")
  1833. var respJSON2 map[string]interface{}
  1834. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1837. return
  1838. }
  1839. userJSONBytes2, _ := json.Marshal(respJSON2)
  1840. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1841. utils.ErrorLog("解析失败:%v", err)
  1842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1843. return
  1844. }
  1845. } else {
  1846. data := make(map[string]interface{})
  1847. data["struct_3507s"] = struct3507
  1848. client := &http.Client{}
  1849. bytesData, _ := json.Marshal(data)
  1850. var req *http.Request
  1851. if miConfig.MdtrtareaAdmvs == "320921" {
  1852. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1853. } else {
  1854. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1855. }
  1856. resp, _ := client.Do(req)
  1857. defer resp.Body.Close()
  1858. body, ioErr := ioutil.ReadAll(resp.Body)
  1859. if ioErr != nil {
  1860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1861. }
  1862. var respJSON map[string]interface{}
  1863. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1866. return
  1867. }
  1868. var resSix10265 ResultSix10265 //1101结果
  1869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1870. result, _ := json.Marshal(respJSON)
  1871. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1872. utils.ErrorLog("解析失败:%v", err)
  1873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1874. return
  1875. }
  1876. res.InfRefmsgid = resSix10265.InfRefmsgid
  1877. //res.Output = resSix10265.Output
  1878. res.ErrMsg = resSix10265.ErrMsg
  1879. res.Cainfo = resSix10265.Cainfo
  1880. res.WarnMsg = resSix10265.WarnMsg
  1881. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1882. res.Infcode = infocode
  1883. }
  1884. if res.Infcode == 0 {
  1885. item.IsSale = 0
  1886. item.SaleDate = ""
  1887. item.Bchno = ""
  1888. service.SaveDF(item)
  1889. } else {
  1890. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1891. }
  1892. }
  1893. if item.IsSale == 0 && item.IsChange == 1 {
  1894. var res FJ3507Result
  1895. var struct3507 models.Struct3507
  1896. struct3507.FixmedinsBchno = item.BgBchno
  1897. struct3507.InvDataType = "2"
  1898. struct3507.Opter = roles.UserName
  1899. struct3507.FixmedinsCode = miConfig.Code
  1900. struct3507.Code = miConfig.Code
  1901. struct3507.OrgName = miConfig.OrgName
  1902. struct3507.AccessKey = miConfig.AccessKey
  1903. struct3507.RequestUrl = miConfig.Url
  1904. struct3507.SecretKey = miConfig.SecretKey
  1905. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1906. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1907. struct3507.Url = miConfig.Url
  1908. struct3507.AppId = miConfig.Cainfo
  1909. struct3507.AppSecret = miConfig.AppSecret
  1910. struct3507.Enckey = miConfig.EncKey
  1911. struct3507.SignKey = miConfig.SignKey
  1912. struct3507.SecretKey = miConfig.SecretKey
  1913. //result, result1, _ := service.FJyb3507(struct3507)
  1914. //saveLog(result, result1, "3507", "3507")
  1915. //
  1916. //var respJSON3 map[string]interface{}
  1917. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1918. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1919. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1920. // return
  1921. //}
  1922. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1923. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1924. // utils.ErrorLog("解析失败:%v", err)
  1925. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1926. // return
  1927. //}
  1928. if miConfig.MdtrtareaAdmvs == "350500" {
  1929. result, result1, _ := service.FJyb3507(struct3507)
  1930. saveLog(result, result1, "3507", "3507")
  1931. var respJSON2 map[string]interface{}
  1932. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1935. return
  1936. }
  1937. userJSONBytes2, _ := json.Marshal(respJSON2)
  1938. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1939. utils.ErrorLog("解析失败:%v", err)
  1940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1941. return
  1942. }
  1943. } else {
  1944. data := make(map[string]interface{})
  1945. data["struct_3507s"] = struct3507
  1946. client := &http.Client{}
  1947. bytesData, _ := json.Marshal(data)
  1948. var req *http.Request
  1949. if miConfig.MdtrtareaAdmvs == "320921" {
  1950. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1951. } else {
  1952. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1953. }
  1954. resp, _ := client.Do(req)
  1955. defer resp.Body.Close()
  1956. body, ioErr := ioutil.ReadAll(resp.Body)
  1957. if ioErr != nil {
  1958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1959. }
  1960. var respJSON map[string]interface{}
  1961. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1964. return
  1965. }
  1966. var resSix10265 ResultSix10265 //1101结果
  1967. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1968. result, _ := json.Marshal(respJSON)
  1969. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1970. utils.ErrorLog("解析失败:%v", err)
  1971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1972. return
  1973. }
  1974. res.InfRefmsgid = resSix10265.InfRefmsgid
  1975. //res.Output = resSix10265.Output
  1976. res.ErrMsg = resSix10265.ErrMsg
  1977. res.Cainfo = resSix10265.Cainfo
  1978. res.WarnMsg = resSix10265.WarnMsg
  1979. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1980. res.Infcode = infocode
  1981. }
  1982. if res.Infcode == 0 {
  1983. item.IsChange = 0
  1984. item.BgBchno = ""
  1985. service.SaveDF2(item)
  1986. } else {
  1987. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1988. }
  1989. }
  1990. }
  1991. if len(err) == 0 {
  1992. c.ServeSuccessJSON(map[string]interface{}{
  1993. "msg": "删除销售变更成功",
  1994. })
  1995. } else {
  1996. c.ServeSuccessJSON(map[string]interface{}{
  1997. "failed_code": -10,
  1998. "msg": err,
  1999. })
  2000. }
  2001. }
  2002. //func (c *HisApiController) BatchFJ3501AND3502() {
  2003. // //ids := c.GetString("ids")
  2004. // start_time := c.GetString("start_time")
  2005. // end_time := c.GetString("end_time")
  2006. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2007. //
  2008. //
  2009. // timeLayout := "2006-01-02"
  2010. // loc, _ := time.LoadLocation("Local")
  2011. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2012. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2013. //
  2014. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2015. // //id_arr := strings.Split(ids, ",")
  2016. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2017. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2018. // //库盘
  2019. // var errs []string
  2020. // for _, drug := range drugs {
  2021. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2022. // var res2 ResultSix
  2023. // var res3 ResultSix
  2024. //
  2025. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2026. // var struct3501 models.Struct3501
  2027. // struct3501.Code = miConfig.Code
  2028. // struct3501.OrgName = miConfig.OrgName
  2029. // struct3501.AccessKey = miConfig.AccessKey
  2030. // struct3501.Opter = roles.UserName
  2031. // struct3501.RequestUrl = miConfig.Url
  2032. // struct3501.Url = miConfig.Url
  2033. // struct3501.AppId = miConfig.Cainfo
  2034. // struct3501.AppSecret = miConfig.AppSecret
  2035. // struct3501.Enckey = miConfig.EncKey
  2036. // struct3501.SignKey = miConfig.SignKey
  2037. // struct3501.SecretKey = miConfig.SecretKey
  2038. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2039. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2040. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2041. // struct3501.RxFlag = "1"
  2042. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2043. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2044. //
  2045. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2046. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2047. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2048. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2049. // struct3501.FixmedinsBchno = number
  2050. // struct3501.DrugTracCodg = drug.DrugCode
  2051. // memo := make(map[string]interface{})
  2052. // memo["pric"] = drug.Price
  2053. // bytesData, _ := json.Marshal(memo)
  2054. // struct3501.Memo = string(bytesData)
  2055. //
  2056. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2057. //
  2058. // result1, result2, _ := service.FJyb3501(struct3501)
  2059. // saveLog(result1, result2, "3501", "3501")
  2060. // //saveLog(result, requestLog, "2201", "挂号")
  2061. //
  2062. // var respJSON2 map[string]interface{}
  2063. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2064. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2065. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2066. // return
  2067. // }
  2068. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2069. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2070. // utils.ErrorLog("解析失败:%v", err)
  2071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2072. // return
  2073. // }
  2074. //
  2075. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2076. // data := make(map[string]interface{})
  2077. // data["struct_3501s"] = struct3501
  2078. // client := &http.Client{}
  2079. // bytesData, _ := json.Marshal(data)
  2080. // var req *http.Request
  2081. // if miConfig.MdtrtareaAdmvs == "320921" {
  2082. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2083. // } else {
  2084. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2085. // }
  2086. //
  2087. // resp, _ := client.Do(req)
  2088. // defer resp.Body.Close()
  2089. // body, ioErr := ioutil.ReadAll(resp.Body)
  2090. // if ioErr != nil {
  2091. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2092. // }
  2093. // var respJSON map[string]interface{}
  2094. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2095. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2096. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2097. // return
  2098. // }
  2099. // var resSix10265 ResultSix10265 //1101结果
  2100. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2101. // result, _ := json.Marshal(respJSON)
  2102. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2103. // utils.ErrorLog("解析失败:%v", err)
  2104. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2105. // return
  2106. // }
  2107. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2108. // res2.Output = resSix10265.Output
  2109. // res2.ErrMsg = resSix10265.ErrMsg
  2110. // res2.Cainfo = resSix10265.Cainfo
  2111. // res2.WarnMsg = resSix10265.WarnMsg
  2112. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2113. // res2.Infcode = infocode
  2114. //
  2115. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2116. // data := make(map[string]interface{})
  2117. // data["struct_3501s"] = struct3501
  2118. // client := &http.Client{}
  2119. // bytesData, _ := json.Marshal(data)
  2120. // var req *http.Request
  2121. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2122. // resp, _ := client.Do(req)
  2123. // defer resp.Body.Close()
  2124. // body, ioErr := ioutil.ReadAll(resp.Body)
  2125. // if ioErr != nil {
  2126. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2127. // }
  2128. // var respJSON map[string]interface{}
  2129. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2130. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2131. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2132. // return
  2133. // }
  2134. // var resSix10265 ResultSix10265 //1101结果
  2135. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2136. // result, _ := json.Marshal(respJSON)
  2137. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2138. // utils.ErrorLog("解析失败:%v", err)
  2139. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2140. // return
  2141. // }
  2142. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2143. // res2.Output = resSix10265.Output
  2144. // res2.ErrMsg = resSix10265.ErrMsg
  2145. // res2.Cainfo = resSix10265.Cainfo
  2146. // res2.WarnMsg = resSix10265.WarnMsg
  2147. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2148. // res2.Infcode = infocode
  2149. //
  2150. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2151. // data := make(map[string]interface{})
  2152. // data["struct_3501s"] = struct3501
  2153. // client := &http.Client{}
  2154. // bytesData, _ := json.Marshal(data)
  2155. // var req *http.Request
  2156. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2157. // resp, _ := client.Do(req)
  2158. // defer resp.Body.Close()
  2159. // body, ioErr := ioutil.ReadAll(resp.Body)
  2160. // if ioErr != nil {
  2161. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2162. // }
  2163. // var respJSON map[string]interface{}
  2164. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2165. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2167. // return
  2168. // }
  2169. // var resSix10265 ResultSix10265 //1101结果
  2170. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2171. // result, _ := json.Marshal(respJSON)
  2172. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2173. // utils.ErrorLog("解析失败:%v", err)
  2174. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2175. // return
  2176. // }
  2177. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2178. // res2.Output = resSix10265.Output
  2179. // res2.ErrMsg = resSix10265.ErrMsg
  2180. // res2.Cainfo = resSix10265.Cainfo
  2181. // res2.WarnMsg = resSix10265.WarnMsg
  2182. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2183. // res2.Infcode = infocode
  2184. //
  2185. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2186. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2187. // saveLog(result1, result2, "3501", "3501")
  2188. // //saveLog(result, requestLog, "2201", "挂号")
  2189. //
  2190. // var respJSON2 map[string]interface{}
  2191. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2192. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2194. // return
  2195. // }
  2196. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2197. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2198. // utils.ErrorLog("解析失败:%v", err)
  2199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2200. // return
  2201. // }
  2202. //
  2203. // }
  2204. //
  2205. // if res2.Infcode != -1 {
  2206. // drug.IsPc = 1
  2207. // drug.Bchno = number
  2208. // drug.PcDate = time.Now().Unix()
  2209. // err := service.SaveW(drug)
  2210. // if err == nil {
  2211. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2212. // var struct3502 models.Struct3502
  2213. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2214. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2215. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2216. // struct3502.FixmedinsCode = miConfig.Code
  2217. // struct3502.Code = miConfig.Code
  2218. //
  2219. // struct3502.RxFlag = "0"
  2220. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2221. // struct3502.OrgName = miConfig.OrgName
  2222. // struct3502.Opter = roles.UserName
  2223. // struct3502.AccessKey = miConfig.AccessKey
  2224. // struct3502.RequestUrl = miConfig.Url
  2225. // struct3502.SecretKey = miConfig.SecretKey
  2226. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2227. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2228. // struct3502.Url = miConfig.Url
  2229. // struct3502.AppId = miConfig.Cainfo
  2230. // struct3502.AppSecret = miConfig.AppSecret
  2231. // struct3502.Enckey = miConfig.EncKey
  2232. // struct3502.SignKey = miConfig.SignKey
  2233. // struct3502.SecretKey = miConfig.SecretKey
  2234. // struct3502.DrugTracCodg = drug.DrugCode
  2235. //
  2236. // struct3502.Memo = ""
  2237. // struct3502.InvChgType = "108"
  2238. // struct3502.FixmedinsBchno = bg_number
  2239. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2240. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2241. //
  2242. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2243. // result11, result22, _ := service.FJyb3502(struct3502)
  2244. // saveLog(result11, result22, "3502", "3502")
  2245. //
  2246. // var respJSON3 map[string]interface{}
  2247. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2248. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2249. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2250. // return
  2251. // }
  2252. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2253. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2254. // utils.ErrorLog("解析失败:%v", err)
  2255. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2256. // return
  2257. // }
  2258. //
  2259. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2260. // data := make(map[string]interface{})
  2261. // data["struct_3502s"] = struct3502
  2262. // client := &http.Client{}
  2263. // bytesData, _ := json.Marshal(data)
  2264. // var req *http.Request
  2265. // if miConfig.MdtrtareaAdmvs == "320921" {
  2266. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2267. // } else {
  2268. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2269. // }
  2270. //
  2271. // resp, _ := client.Do(req)
  2272. // defer resp.Body.Close()
  2273. // body, ioErr := ioutil.ReadAll(resp.Body)
  2274. // if ioErr != nil {
  2275. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2276. // }
  2277. // var respJSON map[string]interface{}
  2278. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2279. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2280. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2281. // return
  2282. // }
  2283. // var resSix10265 ResultSix10265 //1101结果
  2284. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2285. // result, _ := json.Marshal(respJSON)
  2286. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2287. // utils.ErrorLog("解析失败:%v", err)
  2288. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2289. // return
  2290. // }
  2291. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2292. // res3.Output = resSix10265.Output
  2293. // res3.ErrMsg = resSix10265.ErrMsg
  2294. // res3.Cainfo = resSix10265.Cainfo
  2295. // res3.WarnMsg = resSix10265.WarnMsg
  2296. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2297. // res3.Infcode = infocode
  2298. //
  2299. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2300. //
  2301. // data := make(map[string]interface{})
  2302. // data["struct_3502s"] = struct3502
  2303. // client := &http.Client{}
  2304. // bytesData, _ := json.Marshal(data)
  2305. // var req *http.Request
  2306. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2307. // resp, _ := client.Do(req)
  2308. // defer resp.Body.Close()
  2309. // body, ioErr := ioutil.ReadAll(resp.Body)
  2310. // if ioErr != nil {
  2311. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2312. // }
  2313. // var respJSON map[string]interface{}
  2314. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2315. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2316. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2317. // return
  2318. // }
  2319. // var resSix10265 ResultSix10265 //1101结果
  2320. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2321. // result, _ := json.Marshal(respJSON)
  2322. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2323. // utils.ErrorLog("解析失败:%v", err)
  2324. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2325. // return
  2326. // }
  2327. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2328. // res3.Output = resSix10265.Output
  2329. // res3.ErrMsg = resSix10265.ErrMsg
  2330. // res3.Cainfo = resSix10265.Cainfo
  2331. // res3.WarnMsg = resSix10265.WarnMsg
  2332. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2333. // res3.Infcode = infocode
  2334. //
  2335. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2336. //
  2337. // data := make(map[string]interface{})
  2338. // data["struct_3501s"] = struct3501
  2339. // client := &http.Client{}
  2340. // bytesData, _ := json.Marshal(data)
  2341. // var req *http.Request
  2342. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2343. // resp, _ := client.Do(req)
  2344. // defer resp.Body.Close()
  2345. // body, ioErr := ioutil.ReadAll(resp.Body)
  2346. // if ioErr != nil {
  2347. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2348. // }
  2349. // var respJSON map[string]interface{}
  2350. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2351. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2353. // return
  2354. // }
  2355. // var resSix10265 ResultSix10265 //1101结果
  2356. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2357. // result, _ := json.Marshal(respJSON)
  2358. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2359. // utils.ErrorLog("解析失败:%v", err)
  2360. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2361. // return
  2362. // }
  2363. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2364. // res2.Output = resSix10265.Output
  2365. // res2.ErrMsg = resSix10265.ErrMsg
  2366. // res2.Cainfo = resSix10265.Cainfo
  2367. // res2.WarnMsg = resSix10265.WarnMsg
  2368. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2369. // res2.Infcode = infocode
  2370. //
  2371. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2372. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2373. // saveLog(result11, result22, "3502", "3502")
  2374. //
  2375. // var respJSON3 map[string]interface{}
  2376. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2377. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2378. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2379. // return
  2380. // }
  2381. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2382. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2383. // utils.ErrorLog("解析失败:%v", err)
  2384. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2385. // return
  2386. // }
  2387. // }
  2388. // if res3.Infcode == -1 {
  2389. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2390. // c.ServeSuccessJSON(map[string]interface{}{
  2391. // "failed_code": -10,
  2392. // "msg": res3.ErrMsg,
  2393. // })
  2394. // } else {
  2395. // drug.IsBg = 1
  2396. // drug.BgBchno = bg_number
  2397. // service.SaveW(drug)
  2398. // }
  2399. // }
  2400. // } else {
  2401. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2402. // }
  2403. // }
  2404. // //变更
  2405. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2406. // var res3 ResultSix
  2407. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2408. //
  2409. // var struct3502 models.Struct3502
  2410. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2411. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2412. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2413. // struct3502.FixmedinsCode = miConfig.Code
  2414. // struct3502.Code = miConfig.Code
  2415. //
  2416. // struct3502.Opter = roles.UserName
  2417. // struct3502.RxFlag = "0"
  2418. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2419. // struct3502.OrgName = miConfig.OrgName
  2420. // struct3502.AccessKey = miConfig.AccessKey
  2421. // struct3502.RequestUrl = miConfig.Url
  2422. // struct3502.SecretKey = miConfig.SecretKey
  2423. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2424. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2425. // struct3502.InvChgType = "108"
  2426. // struct3502.DrugTracCodg = drug.DrugCode
  2427. //
  2428. // struct3502.Url = miConfig.Url
  2429. // struct3502.AppId = miConfig.Cainfo
  2430. // struct3502.AppSecret = miConfig.AppSecret
  2431. // struct3502.Enckey = miConfig.EncKey
  2432. // struct3502.SignKey = miConfig.SignKey
  2433. // struct3502.SecretKey = miConfig.SecretKey
  2434. //
  2435. // struct3502.FixmedinsBchno = bg_number
  2436. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2437. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2438. //
  2439. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2440. // result1, result2, _ := service.FJyb3502(struct3502)
  2441. // saveLog(result1, result2, "3502", "3502")
  2442. // var respJSON3 map[string]interface{}
  2443. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2444. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2446. // return
  2447. // }
  2448. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2449. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2450. // utils.ErrorLog("解析失败:%v", err)
  2451. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2452. // return
  2453. // }
  2454. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2455. // data := make(map[string]interface{})
  2456. // data["struct_3502s"] = struct3502
  2457. // client := &http.Client{}
  2458. // bytesData, _ := json.Marshal(data)
  2459. // var req *http.Request
  2460. // if miConfig.MdtrtareaAdmvs == "320921" {
  2461. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2462. // } else {
  2463. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2464. // }
  2465. // resp, _ := client.Do(req)
  2466. // defer resp.Body.Close()
  2467. // body, ioErr := ioutil.ReadAll(resp.Body)
  2468. // if ioErr != nil {
  2469. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2470. // }
  2471. // var respJSON map[string]interface{}
  2472. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2473. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2475. // return
  2476. // }
  2477. // var resSix10265 ResultSix10265 //1101结果
  2478. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2479. // result, _ := json.Marshal(respJSON)
  2480. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2481. // utils.ErrorLog("解析失败:%v", err)
  2482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2483. // return
  2484. // }
  2485. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2486. // res3.Output = resSix10265.Output
  2487. // res3.ErrMsg = resSix10265.ErrMsg
  2488. // res3.Cainfo = resSix10265.Cainfo
  2489. // res3.WarnMsg = resSix10265.WarnMsg
  2490. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2491. // res3.Infcode = infocode
  2492. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2493. //
  2494. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2495. //
  2496. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2497. //
  2498. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2499. //
  2500. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2501. // saveLog(result1, result2, "3501", "3501")
  2502. // //saveLog(result, requestLog, "2201", "挂号")
  2503. //
  2504. // var respJSON2 map[string]interface{}
  2505. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2506. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2508. // return
  2509. // }
  2510. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2511. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2512. // utils.ErrorLog("解析失败:%v", err)
  2513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2514. // return
  2515. // }
  2516. //
  2517. // }
  2518. // if res3.Infcode == -1 {
  2519. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2520. // } else {
  2521. // drug.IsBg = 1
  2522. // drug.BgBchno = bg_number
  2523. // service.SaveW(drug)
  2524. // }
  2525. // }
  2526. // }
  2527. //
  2528. // if len(errs) == 0 {
  2529. // c.ServeSuccessJSON(map[string]interface{}{
  2530. // "msg": "盘存变更成功",
  2531. // })
  2532. // } else {
  2533. // c.ServeSuccessJSON(map[string]interface{}{
  2534. // "failed_code": -10,
  2535. // "msg": errs,
  2536. // })
  2537. // }
  2538. //}
  2539. func (c *HisApiController) DeleteXSandBGTwo() {
  2540. patient_id, _ := c.GetInt64("patient_id")
  2541. admin_user_id, _ := c.GetInt64("admin_user_id")
  2542. times := c.GetString("time", "")
  2543. timeLayout := "2006-01-02"
  2544. loc, _ := time.LoadLocation("Local")
  2545. var stime, etime int64
  2546. if times == "" {
  2547. stime, etime = GetNowTime()
  2548. } else {
  2549. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2550. stime = stmp.Unix()
  2551. etime = stime + 86399
  2552. }
  2553. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2554. var flows []*models.DrugFlow
  2555. for _, item := range advicelist {
  2556. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2557. flows = append(flows, flow...)
  2558. }
  2559. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2560. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2561. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2562. var err []string
  2563. for _, item := range flows {
  2564. if item.IsSale == 1 {
  2565. var res FJ3507Result
  2566. var struct3507 models.Struct3507
  2567. struct3507.FixmedinsBchno = item.Bchno
  2568. struct3507.InvDataType = "4"
  2569. struct3507.Opter = roles.UserName
  2570. struct3507.OrgName = miConfig.OrgName
  2571. struct3507.AccessKey = miConfig.AccessKey
  2572. struct3507.RequestUrl = miConfig.Url
  2573. struct3507.FixmedinsCode = miConfig.Code
  2574. struct3507.SecretKey = miConfig.SecretKey
  2575. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2576. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2577. struct3507.Url = miConfig.Url
  2578. struct3507.AppId = miConfig.Cainfo
  2579. struct3507.AppSecret = miConfig.AppSecret
  2580. struct3507.Enckey = miConfig.EncKey
  2581. struct3507.SignKey = miConfig.SignKey
  2582. struct3507.SecretKey = miConfig.SecretKey
  2583. if miConfig.MdtrtareaAdmvs == "350500" {
  2584. result, result1, _ := service.FJyb3507(struct3507)
  2585. saveLog(result, result1, "3507", "3507")
  2586. var respJSON2 map[string]interface{}
  2587. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2590. return
  2591. }
  2592. userJSONBytes2, _ := json.Marshal(respJSON2)
  2593. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2594. utils.ErrorLog("解析失败:%v", err)
  2595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2596. return
  2597. }
  2598. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2599. data := make(map[string]interface{})
  2600. data["struct_3507s"] = struct3507
  2601. client := &http.Client{}
  2602. bytesData, _ := json.Marshal(data)
  2603. var req *http.Request
  2604. if miConfig.MdtrtareaAdmvs == "320921" {
  2605. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2606. } else {
  2607. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2608. }
  2609. resp, _ := client.Do(req)
  2610. defer resp.Body.Close()
  2611. body, ioErr := ioutil.ReadAll(resp.Body)
  2612. if ioErr != nil {
  2613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2614. }
  2615. var respJSON map[string]interface{}
  2616. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2619. return
  2620. }
  2621. var resSix10265 ResultSix10265 //1101结果
  2622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2623. result, _ := json.Marshal(respJSON)
  2624. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2625. utils.ErrorLog("解析失败:%v", err)
  2626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2627. return
  2628. }
  2629. res.InfRefmsgid = resSix10265.InfRefmsgid
  2630. //res.Output = resSix10265.Output
  2631. res.ErrMsg = resSix10265.ErrMsg
  2632. res.Cainfo = resSix10265.Cainfo
  2633. res.WarnMsg = resSix10265.WarnMsg
  2634. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2635. res.Infcode = infocode
  2636. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2637. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2638. saveLog(result2, result1, "3507", "3507")
  2639. var respJSON2 map[string]interface{}
  2640. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2643. return
  2644. }
  2645. userJSONBytes2, _ := json.Marshal(respJSON2)
  2646. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2647. utils.ErrorLog("解析失败:%v", err)
  2648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2649. return
  2650. }
  2651. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2652. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2653. saveLog(result2, result1, "3507", "3507")
  2654. var respJSON2 map[string]interface{}
  2655. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2658. return
  2659. }
  2660. userJSONBytes2, _ := json.Marshal(respJSON2)
  2661. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2662. utils.ErrorLog("解析失败:%v", err)
  2663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2664. return
  2665. }
  2666. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2667. result1, result2 := service.Jxyb3507(struct3507)
  2668. saveLog(result2, result1, "3507", "3507")
  2669. var respJSON2 map[string]interface{}
  2670. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2673. return
  2674. }
  2675. userJSONBytes2, _ := json.Marshal(respJSON2)
  2676. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2677. utils.ErrorLog("解析失败:%v", err)
  2678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2679. return
  2680. }
  2681. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2682. result1, result2 := service.AHyb3507(struct3507)
  2683. saveLog(result2, result1, "3507", "3507")
  2684. var respJSON2 map[string]interface{}
  2685. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2688. return
  2689. }
  2690. userJSONBytes2, _ := json.Marshal(respJSON2)
  2691. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2692. utils.ErrorLog("解析失败:%v", err)
  2693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2694. return
  2695. }
  2696. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2697. data := make(map[string]interface{})
  2698. data["struct_3507s"] = struct3507
  2699. client := &http.Client{}
  2700. bytesData, _ := json.Marshal(data)
  2701. var req *http.Request
  2702. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2703. resp, _ := client.Do(req)
  2704. defer resp.Body.Close()
  2705. body, ioErr := ioutil.ReadAll(resp.Body)
  2706. if ioErr != nil {
  2707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2708. }
  2709. var respJSON map[string]interface{}
  2710. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2712. }
  2713. var resSix10265 ResultSix10265 //1101结果
  2714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2715. result, _ := json.Marshal(respJSON)
  2716. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2717. utils.ErrorLog("解析失败:%v", err)
  2718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2719. return
  2720. }
  2721. res.InfRefmsgid = resSix10265.InfRefmsgid
  2722. res.ErrMsg = resSix10265.ErrMsg
  2723. res.Cainfo = resSix10265.Cainfo
  2724. res.WarnMsg = resSix10265.WarnMsg
  2725. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2726. res.Infcode = infocode
  2727. }
  2728. if res.Infcode == 0 {
  2729. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2730. item.IsSale = 0
  2731. item.SaleDate = ""
  2732. item.Bchno = ""
  2733. service.SaveDF(item)
  2734. } else {
  2735. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2736. }
  2737. }
  2738. }
  2739. c.ServeSuccessJSON(map[string]interface{}{
  2740. "msg": "删除销售数据成功",
  2741. })
  2742. }
  2743. // 删除
  2744. func (c *HisApiController) DeleteXSandBGThree() {
  2745. id, _ := c.GetInt64("id")
  2746. admin_user_id, _ := c.GetInt64("admin_user_id")
  2747. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  2748. var flows []*models.DrugFlow
  2749. for _, item := range advicelist {
  2750. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  2751. flows = append(flows, flow...)
  2752. }
  2753. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2754. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2755. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2756. var err []string
  2757. for _, item := range flows {
  2758. if item.IsSale == 1 {
  2759. var res FJ3507Result
  2760. var struct3507 models.Struct3507
  2761. struct3507.FixmedinsBchno = item.Bchno
  2762. struct3507.InvDataType = "4"
  2763. struct3507.Opter = roles.UserName
  2764. struct3507.OrgName = miConfig.OrgName
  2765. struct3507.AccessKey = miConfig.AccessKey
  2766. struct3507.RequestUrl = miConfig.Url
  2767. struct3507.FixmedinsCode = miConfig.Code
  2768. struct3507.SecretKey = miConfig.SecretKey
  2769. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2770. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2771. struct3507.Url = miConfig.Url
  2772. struct3507.AppId = miConfig.Cainfo
  2773. struct3507.AppSecret = miConfig.AppSecret
  2774. struct3507.Enckey = miConfig.EncKey
  2775. struct3507.SignKey = miConfig.SignKey
  2776. struct3507.SecretKey = miConfig.SecretKey
  2777. if miConfig.MdtrtareaAdmvs == "350500" {
  2778. result, result1, _ := service.FJyb3507(struct3507)
  2779. saveLog(result, result1, "3507", "3507")
  2780. var respJSON2 map[string]interface{}
  2781. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2784. return
  2785. }
  2786. userJSONBytes2, _ := json.Marshal(respJSON2)
  2787. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2788. utils.ErrorLog("解析失败:%v", err)
  2789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2790. return
  2791. }
  2792. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2793. data := make(map[string]interface{})
  2794. data["struct_3507s"] = struct3507
  2795. client := &http.Client{}
  2796. bytesData, _ := json.Marshal(data)
  2797. var req *http.Request
  2798. if miConfig.MdtrtareaAdmvs == "320921" {
  2799. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2800. } else {
  2801. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2802. }
  2803. resp, _ := client.Do(req)
  2804. defer resp.Body.Close()
  2805. body, ioErr := ioutil.ReadAll(resp.Body)
  2806. if ioErr != nil {
  2807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2808. }
  2809. var respJSON map[string]interface{}
  2810. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2813. return
  2814. }
  2815. var resSix10265 ResultSix10265 //1101结果
  2816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2817. result, _ := json.Marshal(respJSON)
  2818. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2819. utils.ErrorLog("解析失败:%v", err)
  2820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2821. return
  2822. }
  2823. res.InfRefmsgid = resSix10265.InfRefmsgid
  2824. //res.Output = resSix10265.Output
  2825. res.ErrMsg = resSix10265.ErrMsg
  2826. res.Cainfo = resSix10265.Cainfo
  2827. res.WarnMsg = resSix10265.WarnMsg
  2828. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2829. res.Infcode = infocode
  2830. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2831. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2832. saveLog(result2, result1, "3507", "3507")
  2833. var respJSON2 map[string]interface{}
  2834. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2837. return
  2838. }
  2839. userJSONBytes2, _ := json.Marshal(respJSON2)
  2840. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2841. utils.ErrorLog("解析失败:%v", err)
  2842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2843. return
  2844. }
  2845. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2846. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2847. saveLog(result2, result1, "3507", "3507")
  2848. var respJSON2 map[string]interface{}
  2849. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2852. return
  2853. }
  2854. userJSONBytes2, _ := json.Marshal(respJSON2)
  2855. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2856. utils.ErrorLog("解析失败:%v", err)
  2857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2858. return
  2859. }
  2860. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2861. result1, result2 := service.Jxyb3507(struct3507)
  2862. saveLog(result2, result1, "3507", "3507")
  2863. var respJSON2 map[string]interface{}
  2864. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2867. return
  2868. }
  2869. userJSONBytes2, _ := json.Marshal(respJSON2)
  2870. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2871. utils.ErrorLog("解析失败:%v", err)
  2872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2873. return
  2874. }
  2875. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2876. result1, result2 := service.AHyb3507(struct3507)
  2877. saveLog(result2, result1, "3507", "3507")
  2878. var respJSON2 map[string]interface{}
  2879. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2882. return
  2883. }
  2884. userJSONBytes2, _ := json.Marshal(respJSON2)
  2885. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2886. utils.ErrorLog("解析失败:%v", err)
  2887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2888. return
  2889. }
  2890. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2891. data := make(map[string]interface{})
  2892. data["struct_3507s"] = struct3507
  2893. client := &http.Client{}
  2894. bytesData, _ := json.Marshal(data)
  2895. var req *http.Request
  2896. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2897. resp, _ := client.Do(req)
  2898. defer resp.Body.Close()
  2899. body, ioErr := ioutil.ReadAll(resp.Body)
  2900. if ioErr != nil {
  2901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2902. }
  2903. var respJSON map[string]interface{}
  2904. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2906. }
  2907. var resSix10265 ResultSix10265 //1101结果
  2908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2909. result, _ := json.Marshal(respJSON)
  2910. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2911. utils.ErrorLog("解析失败:%v", err)
  2912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2913. return
  2914. }
  2915. res.InfRefmsgid = resSix10265.InfRefmsgid
  2916. res.ErrMsg = resSix10265.ErrMsg
  2917. res.Cainfo = resSix10265.Cainfo
  2918. res.WarnMsg = resSix10265.WarnMsg
  2919. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2920. res.Infcode = infocode
  2921. }
  2922. if res.Infcode == 0 {
  2923. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2924. item.IsSale = 0
  2925. item.SaleDate = ""
  2926. item.Bchno = ""
  2927. service.SaveDF(item)
  2928. } else {
  2929. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2930. }
  2931. }
  2932. }
  2933. c.ServeSuccessJSON(map[string]interface{}{
  2934. "msg": "删除销售数据成功",
  2935. })
  2936. }
  2937. // 获取当天起止时间戳
  2938. func GetNowTime() (int64, int64) {
  2939. t := time.Now()
  2940. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2941. timesamp := addTime.Unix()
  2942. return timesamp, timesamp + 86399
  2943. }
  2944. func (c *HisApiController) ChangeDrugfour() {
  2945. patient_id, _ := c.GetInt64("patient_id")
  2946. admin_user_id, _ := c.GetInt64("admin_user_id")
  2947. times := c.GetString("time", "")
  2948. timeLayout := "2006-01-02"
  2949. loc, _ := time.LoadLocation("Local")
  2950. var stime, etime int64
  2951. if times == "" {
  2952. stime, etime = GetNowTime()
  2953. } else {
  2954. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2955. stime = stmp.Unix()
  2956. etime = stime + 86399
  2957. }
  2958. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2959. var flows []*models.DrugFlow
  2960. for _, item := range advicelist {
  2961. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2962. flows = append(flows, flow...)
  2963. }
  2964. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2965. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2966. var err []string
  2967. for _, item := range flows {
  2968. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2969. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2970. if prescription.OrderStatus == 2 {
  2971. if item.IsSale == 0 {
  2972. var res FJ3507Result
  2973. var res3507for10188 FJ3507ResultFor10188
  2974. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2975. //进行商品销售接口
  2976. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2977. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2978. var respJSON3 map[string]interface{}
  2979. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2982. return
  2983. }
  2984. userJSONBytes3, _ := json.Marshal(respJSON3)
  2985. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2986. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2987. utils.ErrorLog("解析失败:%v", err)
  2988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2989. return
  2990. }
  2991. //if res3507for10188.Infcode
  2992. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2993. //res.Output = resSix10265.Output
  2994. res.ErrMsg = res3507for10188.ErrMsg
  2995. res.Cainfo = res3507for10188.Cainfo
  2996. res.WarnMsg = res3507for10188.WarnMsg
  2997. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2998. res.Infcode = infocode
  2999. } else {
  3000. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3001. utils.ErrorLog("解析失败:%v", err)
  3002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3003. return
  3004. }
  3005. }
  3006. if res.Infcode == 0 {
  3007. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3008. item.IsSale = 1
  3009. item.Bchno = number
  3010. item.SaleDate = time.Now().Format("2006-01-02")
  3011. service.SaveDF(item)
  3012. } else {
  3013. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3014. }
  3015. }
  3016. } else { //还没结,提示用户去结算,并药品追溯上传
  3017. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3018. }
  3019. }
  3020. }
  3021. str := strings.Join(err, " ")
  3022. saveLog(str, str, "3505", "3505自动上传日志")
  3023. c.ServeSuccessJSON(map[string]interface{}{
  3024. "status": "1",
  3025. "msg": err,
  3026. })
  3027. }
  3028. func (c *HisApiController) ChangeDrugFive() {
  3029. id, _ := c.GetInt64("id")
  3030. admin_user_id, _ := c.GetInt64("admin_user_id")
  3031. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  3032. var flows []*models.DrugFlow
  3033. for _, item := range advicelist {
  3034. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3035. flows = append(flows, flow...)
  3036. }
  3037. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3038. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3039. var err []string
  3040. for _, item := range flows {
  3041. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3042. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3043. if prescription.OrderStatus == 2 {
  3044. if item.IsSale == 0 {
  3045. var res FJ3507Result
  3046. var res3507for10188 FJ3507ResultFor10188
  3047. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3048. //进行商品销售接口
  3049. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3050. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3051. var respJSON3 map[string]interface{}
  3052. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3055. return
  3056. }
  3057. userJSONBytes3, _ := json.Marshal(respJSON3)
  3058. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3059. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3060. utils.ErrorLog("解析失败:%v", err)
  3061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3062. return
  3063. }
  3064. //if res3507for10188.Infcode
  3065. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3066. //res.Output = resSix10265.Output
  3067. res.ErrMsg = res3507for10188.ErrMsg
  3068. res.Cainfo = res3507for10188.Cainfo
  3069. res.WarnMsg = res3507for10188.WarnMsg
  3070. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3071. res.Infcode = infocode
  3072. } else {
  3073. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3074. utils.ErrorLog("解析失败:%v", err)
  3075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3076. return
  3077. }
  3078. }
  3079. if res.Infcode == 0 {
  3080. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3081. item.IsSale = 1
  3082. item.Bchno = number
  3083. item.SaleDate = time.Now().Format("2006-01-02")
  3084. service.SaveDF(item)
  3085. } else {
  3086. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3087. }
  3088. }
  3089. } else { //还没结,提示用户去结算,并药品追溯上传
  3090. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3091. }
  3092. }
  3093. }
  3094. str := strings.Join(err, " ")
  3095. saveLog(str, str, "3505", "3505自动上传日志")
  3096. c.ServeSuccessJSON(map[string]interface{}{
  3097. "status": "1",
  3098. "msg": err,
  3099. })
  3100. }
  3101. //func (c *HisApiController) ChangeDrugfour() {
  3102. // patient_id, _ := c.GetInt64("patient_id")
  3103. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3104. // //id_arr := strings.Split(ids, ",")
  3105. // times := c.GetString("time", "")
  3106. // timeLayout := "2006-01-02"
  3107. // loc, _ := time.LoadLocation("Local")
  3108. // var stime, etime int64
  3109. // if times == "" {
  3110. // stime, etime = GetNowTime()
  3111. // } else {
  3112. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3113. // stime = stmp.Unix()
  3114. // etime = stime + 86399
  3115. // }
  3116. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3117. // var flows []*models.DrugFlow
  3118. // for _, item := range advicelist {
  3119. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3120. // flows = append(flows, flow...)
  3121. // }
  3122. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3123. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3124. // var err []string
  3125. //
  3126. // for _, item := range flows {
  3127. // var res3 ResultSix
  3128. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3129. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3130. // if prescription.OrderStatus == 2 {
  3131. // //已经结算
  3132. // //判断是否已经销售
  3133. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3134. // //是否已经变更 1是 0否
  3135. // if item.IsChange == 0 { //没变更,进行变更操作
  3136. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3137. //
  3138. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3139. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3140. // var respJSON3 map[string]interface{}
  3141. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3142. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3143. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3144. // return
  3145. // }
  3146. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3147. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3148. // utils.ErrorLog("解析失败:%v", err)
  3149. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3150. // return
  3151. // }
  3152. // if res3.Infcode == 0 {
  3153. // item.IsChange = 1
  3154. // item.BgBchno = bg_number
  3155. // service.SaveDF2(item)
  3156. // } else {
  3157. //
  3158. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3159. // }
  3160. // }
  3161. // } else { //没销售,
  3162. // var res FJ3507Result
  3163. // var res3507for10188 FJ3507ResultFor10188
  3164. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3165. //
  3166. // //进行商品销售接口
  3167. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3168. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3169. // var respJSON3 map[string]interface{}
  3170. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3171. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3172. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3173. // return
  3174. // }
  3175. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3176. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3177. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3178. // utils.ErrorLog("解析失败:%v", err)
  3179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3180. // return
  3181. // }
  3182. // //if res3507for10188.Infcode
  3183. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3184. // //res.Output = resSix10265.Output
  3185. // res.ErrMsg = res3507for10188.ErrMsg
  3186. // res.Cainfo = res3507for10188.Cainfo
  3187. // res.WarnMsg = res3507for10188.WarnMsg
  3188. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3189. // res.Infcode = infocode
  3190. // } else {
  3191. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3192. // utils.ErrorLog("解析失败:%v", err)
  3193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3194. // return
  3195. // }
  3196. //
  3197. // }
  3198. // if res.Infcode == 0 {
  3199. // item.IsSale = 1
  3200. // item.Bchno = number
  3201. // item.SaleDate = time.Now().Format("2006-01-02")
  3202. //
  3203. // err5 := service.SaveDF(item)
  3204. // if err5 == nil {
  3205. // if item.IsChange == 0 { //没变更,进行变更操作
  3206. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3207. //
  3208. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3209. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3210. //
  3211. // var respJSON3 map[string]interface{}
  3212. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3213. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3214. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3215. // return
  3216. // }
  3217. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3218. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3219. // utils.ErrorLog("解析失败:%v", err)
  3220. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3221. // return
  3222. // }
  3223. // //if res3507for10188.Infcode
  3224. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3225. // //res.Output = resSix10265.Output
  3226. // res3.ErrMsg = res3507for10188.ErrMsg
  3227. // res3.Cainfo = res3507for10188.Cainfo
  3228. // res3.WarnMsg = res3507for10188.WarnMsg
  3229. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3230. // res3.Infcode = infocode
  3231. // } else {
  3232. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3233. // utils.ErrorLog("解析失败:%v", err)
  3234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3235. // return
  3236. // }
  3237. // }
  3238. // if res3.Infcode == 0 {
  3239. // item.IsChange = 1
  3240. // item.BgBchno = bg_number
  3241. // service.SaveDF2(item)
  3242. // } else {
  3243. //
  3244. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3245. // }
  3246. // }
  3247. // }
  3248. // } else {
  3249. //
  3250. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3251. // }
  3252. // }
  3253. //
  3254. // } else { //还没结,提示用户去结算,并药品追溯上传
  3255. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3256. // }
  3257. // }
  3258. // }
  3259. // if len(err) == 0 {
  3260. // c.ServeSuccessJSON(map[string]interface{}{
  3261. // "msg": "销售变更成功",
  3262. // })
  3263. // } else {
  3264. // c.ServeSuccessJSON(map[string]interface{}{
  3265. // "failed_code": -10,
  3266. // "msg": err,
  3267. // })
  3268. // }
  3269. //}
  3270. func (c *HisApiController) ChangeDrug() {
  3271. ids := c.GetString("ids")
  3272. id_arr := strings.Split(ids, ",")
  3273. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3274. admin_user_id, _ := c.GetInt64("admin_user_id")
  3275. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3276. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3277. var err []string
  3278. for _, item := range flows {
  3279. var res3 ResultSix
  3280. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3281. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3282. if prescription.OrderStatus == 2 {
  3283. //已经结算
  3284. //判断是否已经销售
  3285. if item.IsSale == 1 { //是否已经销售,1是 0否
  3286. //是否已经变更 1是 0否
  3287. if item.IsChange == 0 { //没变更,进行变更操作
  3288. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3289. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3290. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3291. var respJSON3 map[string]interface{}
  3292. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3295. return
  3296. }
  3297. userJSONBytes3, _ := json.Marshal(respJSON3)
  3298. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3299. utils.ErrorLog("解析失败:%v", err)
  3300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3301. return
  3302. }
  3303. if res3.Infcode == 0 {
  3304. item.IsChange = 1
  3305. item.BgBchno = bg_number
  3306. service.SaveDF2(item)
  3307. } else {
  3308. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3309. }
  3310. }
  3311. } else { //没销售,
  3312. var res FJ3507Result
  3313. var res3507for10188 FJ3507ResultFor10188
  3314. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3315. //进行商品销售接口
  3316. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3317. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3318. var respJSON3 map[string]interface{}
  3319. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3322. return
  3323. }
  3324. userJSONBytes3, _ := json.Marshal(respJSON3)
  3325. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3326. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3327. utils.ErrorLog("解析失败:%v", err)
  3328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3329. return
  3330. }
  3331. //if res3507for10188.Infcode
  3332. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3333. //res.Output = resSix10265.Output
  3334. res.ErrMsg = res3507for10188.ErrMsg
  3335. res.Cainfo = res3507for10188.Cainfo
  3336. res.WarnMsg = res3507for10188.WarnMsg
  3337. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3338. res.Infcode = infocode
  3339. } else {
  3340. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3341. utils.ErrorLog("解析失败:%v", err)
  3342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3343. return
  3344. }
  3345. }
  3346. if res.Infcode == 0 {
  3347. item.IsSale = 1
  3348. item.Bchno = number
  3349. item.SaleDate = time.Now().Format("2006-01-02")
  3350. err5 := service.SaveDF(item)
  3351. if err5 == nil {
  3352. if item.IsChange == 0 { //没变更,进行变更操作
  3353. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3354. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3355. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3356. var respJSON3 map[string]interface{}
  3357. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3360. return
  3361. }
  3362. userJSONBytes3, _ := json.Marshal(respJSON3)
  3363. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3364. utils.ErrorLog("解析失败:%v", err)
  3365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3366. return
  3367. }
  3368. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3369. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3370. utils.ErrorLog("解析失败:%v", err)
  3371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3372. return
  3373. }
  3374. //if res3507for10188.Infcode
  3375. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3376. //res.Output = resSix10265.Output
  3377. res3.ErrMsg = res3507for10188.ErrMsg
  3378. res3.Cainfo = res3507for10188.Cainfo
  3379. res3.WarnMsg = res3507for10188.WarnMsg
  3380. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3381. res3.Infcode = infocode
  3382. } else {
  3383. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3384. utils.ErrorLog("解析失败:%v", err)
  3385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3386. return
  3387. }
  3388. }
  3389. if res3.Infcode == 0 {
  3390. item.IsChange = 1
  3391. item.BgBchno = bg_number
  3392. service.SaveDF2(item)
  3393. } else {
  3394. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3395. }
  3396. }
  3397. }
  3398. } else {
  3399. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3400. }
  3401. }
  3402. } else { //还没结算
  3403. var res3507for10188 FJ3507ResultFor10188
  3404. if item.IsChange == 0 { //没变更,进行变更操作
  3405. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3406. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3407. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3408. var respJSON3 map[string]interface{}
  3409. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3412. return
  3413. }
  3414. userJSONBytes3, _ := json.Marshal(respJSON3)
  3415. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3416. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3417. utils.ErrorLog("解析失败:%v", err)
  3418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3419. return
  3420. }
  3421. //if res3507for10188.Infcode
  3422. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3423. //res.Output = resSix10265.Output
  3424. res3.ErrMsg = res3507for10188.ErrMsg
  3425. res3.Cainfo = res3507for10188.Cainfo
  3426. res3.WarnMsg = res3507for10188.WarnMsg
  3427. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3428. res3.Infcode = infocode
  3429. } else {
  3430. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3431. utils.ErrorLog("解析失败:%v", err)
  3432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3433. return
  3434. }
  3435. }
  3436. if res3.Infcode == 0 {
  3437. item.IsChange = 1
  3438. item.BgBchno = bg_number
  3439. service.SaveDF2(item)
  3440. } else {
  3441. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3442. }
  3443. }
  3444. }
  3445. } else if item.ConsumableType == 7 {
  3446. var res3507for10188 FJ3507ResultFor10188
  3447. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3448. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3449. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3450. //判断是否已经销售
  3451. if item.IsSale == 2 { //是否已经销售,1是 0否
  3452. //是否已经变更 1是 0否
  3453. if item.IsChange == 0 { //没变更,进行变更操作
  3454. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3455. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3456. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3457. var respJSON3 map[string]interface{}
  3458. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3461. return
  3462. }
  3463. userJSONBytes3, _ := json.Marshal(respJSON3)
  3464. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3465. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3466. utils.ErrorLog("解析失败:%v", err)
  3467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3468. return
  3469. }
  3470. //if res3507for10188.Infcode
  3471. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3472. //res.Output = resSix10265.Output
  3473. res3.ErrMsg = res3507for10188.ErrMsg
  3474. res3.Cainfo = res3507for10188.Cainfo
  3475. res3.WarnMsg = res3507for10188.WarnMsg
  3476. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3477. res3.Infcode = infocode
  3478. } else {
  3479. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3480. utils.ErrorLog("解析失败:%v", err)
  3481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3482. return
  3483. }
  3484. }
  3485. if res3.Infcode == 0 {
  3486. item.IsChange = 1
  3487. item.BgBchno = bg_number
  3488. service.SaveDF2(item)
  3489. } else {
  3490. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3491. }
  3492. }
  3493. } else { //没销售,
  3494. //进行商品销售退货接口
  3495. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3496. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3497. saveLog(result111, result222, "3506", "销售退货")
  3498. var res7 FJ3507Result
  3499. //进行商品销售接口
  3500. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3501. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3502. var respJSON3 map[string]interface{}
  3503. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3506. return
  3507. }
  3508. userJSONBytes3, _ := json.Marshal(respJSON3)
  3509. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3510. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3511. utils.ErrorLog("解析失败:%v", err)
  3512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3513. return
  3514. }
  3515. //if res3507for10188.Infcode
  3516. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3517. //res.Output = resSix10265.Output
  3518. res7.ErrMsg = res3507for10188.ErrMsg
  3519. res7.Cainfo = res3507for10188.Cainfo
  3520. res7.WarnMsg = res3507for10188.WarnMsg
  3521. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3522. res7.Infcode = infocode
  3523. } else {
  3524. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3525. utils.ErrorLog("解析失败:%v", err)
  3526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3527. return
  3528. }
  3529. }
  3530. if res7.Infcode == 0 {
  3531. item.IsSale = 2
  3532. item.SaleDate = item.SaleDate
  3533. item.Bchno = number
  3534. service.SaveDF(item)
  3535. if item.IsChange == 0 { //没变更,进行变更操作
  3536. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3537. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3538. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3539. var respJSON3 map[string]interface{}
  3540. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3543. return
  3544. }
  3545. userJSONBytes3, _ := json.Marshal(respJSON3)
  3546. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3547. // utils.ErrorLog("解析失败:%v", err)
  3548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3549. // return
  3550. //}
  3551. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3552. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3553. utils.ErrorLog("解析失败:%v", err)
  3554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3555. return
  3556. }
  3557. //if res3507for10188.Infcode
  3558. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3559. //res.Output = resSix10265.Output
  3560. res3.ErrMsg = res3507for10188.ErrMsg
  3561. res3.Cainfo = res3507for10188.Cainfo
  3562. res3.WarnMsg = res3507for10188.WarnMsg
  3563. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3564. res3.Infcode = infocode
  3565. } else {
  3566. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3567. utils.ErrorLog("解析失败:%v", err)
  3568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3569. return
  3570. }
  3571. }
  3572. if res3.Infcode == 0 {
  3573. item.IsChange = 1
  3574. item.BgBchno = bg_number
  3575. service.SaveDF2(item)
  3576. } else {
  3577. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3578. }
  3579. }
  3580. } else {
  3581. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3582. }
  3583. }
  3584. } else { //还没结算
  3585. if item.IsChange == 0 { //没变更,进行变更操作
  3586. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3587. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3588. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3589. var respJSON3 map[string]interface{}
  3590. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3593. return
  3594. }
  3595. userJSONBytes3, _ := json.Marshal(respJSON3)
  3596. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3597. // utils.ErrorLog("解析失败:%v", err)
  3598. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3599. // return
  3600. //}
  3601. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3602. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3603. utils.ErrorLog("解析失败:%v", err)
  3604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3605. return
  3606. }
  3607. //if res3507for10188.Infcode
  3608. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3609. //res.Output = resSix10265.Output
  3610. res3.ErrMsg = res3507for10188.ErrMsg
  3611. res3.Cainfo = res3507for10188.Cainfo
  3612. res3.WarnMsg = res3507for10188.WarnMsg
  3613. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3614. res3.Infcode = infocode
  3615. } else {
  3616. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3617. utils.ErrorLog("解析失败:%v", err)
  3618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3619. return
  3620. }
  3621. }
  3622. if res3.Infcode == 0 {
  3623. item.IsChange = 1
  3624. item.BgBchno = bg_number
  3625. service.SaveDF2(item)
  3626. } else {
  3627. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3628. }
  3629. }
  3630. }
  3631. }
  3632. }
  3633. if len(err) == 0 {
  3634. c.ServeSuccessJSON(map[string]interface{}{
  3635. "msg": "销售变更成功",
  3636. })
  3637. } else {
  3638. c.ServeSuccessJSON(map[string]interface{}{
  3639. "failed_code": -10,
  3640. "msg": err,
  3641. })
  3642. }
  3643. }
  3644. func (c *HisApiController) ChangeDrugtwo() {
  3645. //ids := c.GetString("ids")
  3646. //id_arr := strings.Split(ids, ",")
  3647. flows, _ := service.GetNewDrugFlowInfothree123()
  3648. admin_user_id, _ := c.GetInt64("admin_user_id")
  3649. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3650. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3651. var err []string
  3652. for _, item := range flows {
  3653. var res3 ResultSix
  3654. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3655. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3656. if prescription.OrderStatus == 2 {
  3657. //已经结算
  3658. //判断是否已经销售
  3659. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3660. // //是否已经变更 1是 0否
  3661. // if item.IsChange == 0 { //没变更,进行变更操作
  3662. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3663. //
  3664. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3665. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3666. // var respJSON3 map[string]interface{}
  3667. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3668. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3669. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3670. // return
  3671. // }
  3672. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3673. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3674. // utils.ErrorLog("解析失败:%v", err)
  3675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3676. // return
  3677. // }
  3678. // if res3.Infcode == 0 {
  3679. // item.IsChange = 1
  3680. // item.BgBchno = bg_number
  3681. // service.SaveDF2(item)
  3682. // } else {
  3683. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3684. // }
  3685. // }
  3686. //}
  3687. //else
  3688. { //没销售,
  3689. var res FJ3507Result
  3690. var res3507for10188 FJ3507ResultFor10188
  3691. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3692. //进行商品销售接口
  3693. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3694. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3695. var respJSON3 map[string]interface{}
  3696. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3699. return
  3700. }
  3701. userJSONBytes3, _ := json.Marshal(respJSON3)
  3702. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3703. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3704. utils.ErrorLog("解析失败:%v", err)
  3705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3706. return
  3707. }
  3708. //if res3507for10188.Infcode
  3709. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3710. //res.Output = resSix10265.Output
  3711. res.ErrMsg = res3507for10188.ErrMsg
  3712. res.Cainfo = res3507for10188.Cainfo
  3713. res.WarnMsg = res3507for10188.WarnMsg
  3714. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3715. res.Infcode = infocode
  3716. } else {
  3717. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3718. utils.ErrorLog("解析失败:%v", err)
  3719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3720. return
  3721. }
  3722. }
  3723. if res.Infcode == 0 {
  3724. item.IsSale = 1
  3725. item.Bchno = number
  3726. item.SaleDate = time.Now().Format("2006-01-02")
  3727. service.SaveDF(item)
  3728. //if err5 == nil {
  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, "102", 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. //
  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. //
  3766. // if res3.Infcode == 0 {
  3767. // item.IsChange = 1
  3768. // item.BgBchno = bg_number
  3769. // service.SaveDF2(item)
  3770. // } else {
  3771. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3772. // }
  3773. // }
  3774. //}
  3775. } else {
  3776. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3777. }
  3778. }
  3779. } else { //还没结算
  3780. var res3507for10188 FJ3507ResultFor10188
  3781. if item.IsChange == 0 { //没变更,进行变更操作
  3782. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3783. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3784. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3785. var respJSON3 map[string]interface{}
  3786. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3789. return
  3790. }
  3791. userJSONBytes3, _ := json.Marshal(respJSON3)
  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. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3800. //res.Output = resSix10265.Output
  3801. res3.ErrMsg = res3507for10188.ErrMsg
  3802. res3.Cainfo = res3507for10188.Cainfo
  3803. res3.WarnMsg = res3507for10188.WarnMsg
  3804. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3805. res3.Infcode = infocode
  3806. } else {
  3807. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3808. utils.ErrorLog("解析失败:%v", err)
  3809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3810. return
  3811. }
  3812. }
  3813. if res3.Infcode == 0 {
  3814. item.IsChange = 1
  3815. item.BgBchno = bg_number
  3816. service.SaveDF2(item)
  3817. } else {
  3818. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3819. }
  3820. }
  3821. }
  3822. }
  3823. //if item.ConsumableType == 7 {
  3824. // var res3507for10188 FJ3507ResultFor10188
  3825. //
  3826. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3827. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3828. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3829. // //判断是否已经销售
  3830. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3831. // //是否已经变更 1是 0否
  3832. // if item.IsChange == 0 { //没变更,进行变更操作
  3833. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3834. //
  3835. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3836. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3837. //
  3838. // var respJSON3 map[string]interface{}
  3839. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3840. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3841. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3842. // return
  3843. // }
  3844. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3845. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3846. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3847. // utils.ErrorLog("解析失败:%v", err)
  3848. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3849. // return
  3850. // }
  3851. // //if res3507for10188.Infcode
  3852. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3853. // //res.Output = resSix10265.Output
  3854. // res3.ErrMsg = res3507for10188.ErrMsg
  3855. // res3.Cainfo = res3507for10188.Cainfo
  3856. // res3.WarnMsg = res3507for10188.WarnMsg
  3857. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3858. // res3.Infcode = infocode
  3859. // } else {
  3860. //
  3861. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3862. // utils.ErrorLog("解析失败:%v", err)
  3863. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3864. // return
  3865. // }
  3866. //
  3867. // }
  3868. // if res3.Infcode == 0 {
  3869. // item.IsChange = 1
  3870. // item.BgBchno = bg_number
  3871. // service.SaveDF2(item)
  3872. // } else {
  3873. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3874. // }
  3875. // }
  3876. // } else { //没销售,
  3877. // //进行商品销售退货接口
  3878. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3879. //
  3880. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3881. // saveLog(result111, result222, "3506", "销售退货")
  3882. // var res7 FJ3507Result
  3883. //
  3884. // //进行商品销售接口
  3885. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3886. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3887. // var respJSON3 map[string]interface{}
  3888. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3889. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3890. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3891. // return
  3892. // }
  3893. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3894. //
  3895. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3896. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3897. // utils.ErrorLog("解析失败:%v", err)
  3898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3899. // return
  3900. // }
  3901. // //if res3507for10188.Infcode
  3902. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3903. // //res.Output = resSix10265.Output
  3904. // res7.ErrMsg = res3507for10188.ErrMsg
  3905. // res7.Cainfo = res3507for10188.Cainfo
  3906. // res7.WarnMsg = res3507for10188.WarnMsg
  3907. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3908. // res7.Infcode = infocode
  3909. // } else {
  3910. //
  3911. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3912. // utils.ErrorLog("解析失败:%v", err)
  3913. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3914. // return
  3915. // }
  3916. //
  3917. // }
  3918. // if res7.Infcode == 0 {
  3919. // item.IsSale = 2
  3920. // item.SaleDate = item.SaleDate
  3921. // item.Bchno = number
  3922. // service.SaveDF(item)
  3923. // if item.IsChange == 0 { //没变更,进行变更操作
  3924. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3925. //
  3926. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3927. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3928. //
  3929. // var respJSON3 map[string]interface{}
  3930. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3931. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3933. // return
  3934. // }
  3935. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3936. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3937. // // utils.ErrorLog("解析失败:%v", err)
  3938. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3939. // // return
  3940. // //}
  3941. //
  3942. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3943. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3944. // utils.ErrorLog("解析失败:%v", err)
  3945. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3946. // return
  3947. // }
  3948. // //if res3507for10188.Infcode
  3949. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3950. // //res.Output = resSix10265.Output
  3951. // res3.ErrMsg = res3507for10188.ErrMsg
  3952. // res3.Cainfo = res3507for10188.Cainfo
  3953. // res3.WarnMsg = res3507for10188.WarnMsg
  3954. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3955. // res3.Infcode = infocode
  3956. // } else {
  3957. //
  3958. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3959. // utils.ErrorLog("解析失败:%v", err)
  3960. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3961. // return
  3962. // }
  3963. //
  3964. // }
  3965. // if res3.Infcode == 0 {
  3966. // item.IsChange = 1
  3967. // item.BgBchno = bg_number
  3968. // service.SaveDF2(item)
  3969. // } else {
  3970. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3971. // }
  3972. // }
  3973. // } else {
  3974. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3975. // }
  3976. // }
  3977. // } else { //还没结算
  3978. // if item.IsChange == 0 { //没变更,进行变更操作
  3979. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3980. //
  3981. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3982. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3983. //
  3984. // var respJSON3 map[string]interface{}
  3985. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3986. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3987. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3988. // return
  3989. // }
  3990. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3991. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3992. // // utils.ErrorLog("解析失败:%v", err)
  3993. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3994. // // return
  3995. // //}
  3996. //
  3997. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3998. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3999. // utils.ErrorLog("解析失败:%v", err)
  4000. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4001. // return
  4002. // }
  4003. // //if res3507for10188.Infcode
  4004. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4005. // //res.Output = resSix10265.Output
  4006. // res3.ErrMsg = res3507for10188.ErrMsg
  4007. // res3.Cainfo = res3507for10188.Cainfo
  4008. // res3.WarnMsg = res3507for10188.WarnMsg
  4009. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4010. // res3.Infcode = infocode
  4011. // } else {
  4012. //
  4013. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4014. // utils.ErrorLog("解析失败:%v", err)
  4015. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4016. // return
  4017. // }
  4018. //
  4019. // }
  4020. // if res3.Infcode == 0 {
  4021. // item.IsChange = 1
  4022. // item.BgBchno = bg_number
  4023. // service.SaveDF2(item)
  4024. // } else {
  4025. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4026. // }
  4027. // }
  4028. // }
  4029. //}
  4030. }
  4031. if len(err) == 0 {
  4032. c.ServeSuccessJSON(map[string]interface{}{
  4033. "msg": "销售变更成功",
  4034. })
  4035. } else {
  4036. c.ServeSuccessJSON(map[string]interface{}{
  4037. "failed_code": -10,
  4038. "msg": err,
  4039. })
  4040. }
  4041. }
  4042. func (c *HisApiController) ChangeDrugthree() {
  4043. //ids := c.GetString("ids")
  4044. //id_arr := strings.Split(ids, ",")
  4045. flows, _ := service.GetNewDrugFlowInfothree()
  4046. admin_user_id, _ := c.GetInt64("admin_user_id")
  4047. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4048. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4049. var err []string
  4050. for _, item := range flows {
  4051. var res3 ResultSix
  4052. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4053. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4054. if prescription.OrderStatus == 2 {
  4055. //已经结算
  4056. //判断是否已经销售
  4057. if item.IsSale == 1 { //是否已经销售,1是 0否
  4058. //是否已经变更 1是 0否
  4059. if item.IsChange == 0 { //没变更,进行变更操作
  4060. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4061. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4062. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4063. var respJSON3 map[string]interface{}
  4064. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4067. return
  4068. }
  4069. userJSONBytes3, _ := json.Marshal(respJSON3)
  4070. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4071. utils.ErrorLog("解析失败:%v", err)
  4072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4073. return
  4074. }
  4075. if res3.Infcode == 0 {
  4076. item.IsChange = 1
  4077. item.BgBchno = bg_number
  4078. service.SaveDF2(item)
  4079. } else {
  4080. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4081. }
  4082. }
  4083. } else { //没销售,
  4084. var res FJ3507Result
  4085. var res3507for10188 FJ3507ResultFor10188
  4086. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4087. //进行商品销售接口
  4088. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4089. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4090. var respJSON3 map[string]interface{}
  4091. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4094. return
  4095. }
  4096. userJSONBytes3, _ := json.Marshal(respJSON3)
  4097. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4098. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4099. utils.ErrorLog("解析失败:%v", err)
  4100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4101. return
  4102. }
  4103. //if res3507for10188.Infcode
  4104. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4105. //res.Output = resSix10265.Output
  4106. res.ErrMsg = res3507for10188.ErrMsg
  4107. res.Cainfo = res3507for10188.Cainfo
  4108. res.WarnMsg = res3507for10188.WarnMsg
  4109. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4110. res.Infcode = infocode
  4111. } else {
  4112. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4113. utils.ErrorLog("解析失败:%v", err)
  4114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4115. return
  4116. }
  4117. }
  4118. if res.Infcode == 0 {
  4119. item.IsSale = 1
  4120. item.Bchno = number
  4121. item.SaleDate = time.Now().Format("2006-01-02")
  4122. err5 := service.SaveDF(item)
  4123. if err5 == nil {
  4124. if item.IsChange == 0 { //没变更,进行变更操作
  4125. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4126. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4127. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4128. var respJSON3 map[string]interface{}
  4129. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4132. return
  4133. }
  4134. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4135. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4136. utils.ErrorLog("解析失败:%v", err)
  4137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4138. return
  4139. }
  4140. //if res3507for10188.Infcode
  4141. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4142. //res.Output = resSix10265.Output
  4143. res3.ErrMsg = res3507for10188.ErrMsg
  4144. res3.Cainfo = res3507for10188.Cainfo
  4145. res3.WarnMsg = res3507for10188.WarnMsg
  4146. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4147. res3.Infcode = infocode
  4148. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4149. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4150. utils.ErrorLog("解析失败:%v", err)
  4151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4152. return
  4153. }
  4154. //if res3507for10188.Infcode
  4155. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4156. //res.Output = resSix10265.Output
  4157. res3.ErrMsg = res3507for10188.ErrMsg
  4158. res3.Cainfo = res3507for10188.Cainfo
  4159. res3.WarnMsg = res3507for10188.WarnMsg
  4160. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4161. res3.Infcode = infocode
  4162. } else {
  4163. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4164. utils.ErrorLog("解析失败:%v", err)
  4165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4166. return
  4167. }
  4168. }
  4169. if res3.Infcode == 0 {
  4170. item.IsChange = 1
  4171. item.BgBchno = bg_number
  4172. service.SaveDF2(item)
  4173. } else {
  4174. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4175. }
  4176. }
  4177. }
  4178. } else {
  4179. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4180. }
  4181. }
  4182. } else { //还没结算
  4183. var res3507for10188 FJ3507ResultFor10188
  4184. if item.IsChange == 0 { //没变更,进行变更操作
  4185. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4186. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4187. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4188. var respJSON3 map[string]interface{}
  4189. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4192. return
  4193. }
  4194. userJSONBytes3, _ := json.Marshal(respJSON3)
  4195. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4196. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4197. utils.ErrorLog("解析失败:%v", err)
  4198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4199. return
  4200. }
  4201. //if res3507for10188.Infcode
  4202. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4203. //res.Output = resSix10265.Output
  4204. res3.ErrMsg = res3507for10188.ErrMsg
  4205. res3.Cainfo = res3507for10188.Cainfo
  4206. res3.WarnMsg = res3507for10188.WarnMsg
  4207. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4208. res3.Infcode = infocode
  4209. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4210. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4211. utils.ErrorLog("解析失败:%v", err)
  4212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4213. return
  4214. }
  4215. //if res3507for10188.Infcode
  4216. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4217. //res.Output = resSix10265.Output
  4218. res3.ErrMsg = res3507for10188.ErrMsg
  4219. res3.Cainfo = res3507for10188.Cainfo
  4220. res3.WarnMsg = res3507for10188.WarnMsg
  4221. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4222. res3.Infcode = infocode
  4223. } else {
  4224. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4225. utils.ErrorLog("解析失败:%v", err)
  4226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4227. return
  4228. }
  4229. }
  4230. if res3.Infcode == 0 {
  4231. item.IsChange = 1
  4232. item.BgBchno = bg_number
  4233. service.SaveDF2(item)
  4234. } else {
  4235. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4236. }
  4237. }
  4238. }
  4239. } else if item.ConsumableType == 7 {
  4240. var res3507for10188 FJ3507ResultFor10188
  4241. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4242. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4243. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4244. //判断是否已经销售
  4245. if item.IsSale == 2 { //是否已经销售,1是 0否
  4246. //是否已经变更 1是 0否
  4247. if item.IsChange == 0 { //没变更,进行变更操作
  4248. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4249. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4250. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4251. var respJSON3 map[string]interface{}
  4252. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4255. return
  4256. }
  4257. userJSONBytes3, _ := json.Marshal(respJSON3)
  4258. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4259. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4260. utils.ErrorLog("解析失败:%v", err)
  4261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4262. return
  4263. }
  4264. //if res3507for10188.Infcode
  4265. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4266. //res.Output = resSix10265.Output
  4267. res3.ErrMsg = res3507for10188.ErrMsg
  4268. res3.Cainfo = res3507for10188.Cainfo
  4269. res3.WarnMsg = res3507for10188.WarnMsg
  4270. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4271. res3.Infcode = infocode
  4272. } else {
  4273. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4274. utils.ErrorLog("解析失败:%v", err)
  4275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4276. return
  4277. }
  4278. }
  4279. if res3.Infcode == 0 {
  4280. item.IsChange = 1
  4281. item.BgBchno = bg_number
  4282. service.SaveDF2(item)
  4283. } else {
  4284. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4285. }
  4286. }
  4287. } else { //没销售,
  4288. //进行商品销售退货接口
  4289. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4290. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4291. saveLog(result111, result222, "3506", "销售退货")
  4292. var res7 FJ3507Result
  4293. //进行商品销售接口
  4294. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4295. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4296. var respJSON3 map[string]interface{}
  4297. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4300. return
  4301. }
  4302. userJSONBytes3, _ := json.Marshal(respJSON3)
  4303. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4304. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4305. utils.ErrorLog("解析失败:%v", err)
  4306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4307. return
  4308. }
  4309. //if res3507for10188.Infcode
  4310. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4311. //res.Output = resSix10265.Output
  4312. res7.ErrMsg = res3507for10188.ErrMsg
  4313. res7.Cainfo = res3507for10188.Cainfo
  4314. res7.WarnMsg = res3507for10188.WarnMsg
  4315. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4316. res7.Infcode = infocode
  4317. } else {
  4318. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4319. utils.ErrorLog("解析失败:%v", err)
  4320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4321. return
  4322. }
  4323. }
  4324. if res7.Infcode == 0 {
  4325. item.IsSale = 2
  4326. item.SaleDate = item.SaleDate
  4327. item.Bchno = number
  4328. service.SaveDF(item)
  4329. if item.IsChange == 0 { //没变更,进行变更操作
  4330. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4331. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4332. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4333. var respJSON3 map[string]interface{}
  4334. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4337. return
  4338. }
  4339. userJSONBytes3, _ := json.Marshal(respJSON3)
  4340. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4341. // utils.ErrorLog("解析失败:%v", err)
  4342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4343. // return
  4344. //}
  4345. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4346. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4347. utils.ErrorLog("解析失败:%v", err)
  4348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4349. return
  4350. }
  4351. //if res3507for10188.Infcode
  4352. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4353. //res.Output = resSix10265.Output
  4354. res3.ErrMsg = res3507for10188.ErrMsg
  4355. res3.Cainfo = res3507for10188.Cainfo
  4356. res3.WarnMsg = res3507for10188.WarnMsg
  4357. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4358. res3.Infcode = infocode
  4359. } else {
  4360. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4361. utils.ErrorLog("解析失败:%v", err)
  4362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4363. return
  4364. }
  4365. }
  4366. if res3.Infcode == 0 {
  4367. item.IsChange = 1
  4368. item.BgBchno = bg_number
  4369. service.SaveDF2(item)
  4370. } else {
  4371. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4372. }
  4373. }
  4374. } else {
  4375. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4376. }
  4377. }
  4378. } else { //还没结算
  4379. if item.IsChange == 0 { //没变更,进行变更操作
  4380. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4381. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4382. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4383. var respJSON3 map[string]interface{}
  4384. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4387. return
  4388. }
  4389. userJSONBytes3, _ := json.Marshal(respJSON3)
  4390. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4391. // utils.ErrorLog("解析失败:%v", err)
  4392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4393. // return
  4394. //}
  4395. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4396. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4397. utils.ErrorLog("解析失败:%v", err)
  4398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4399. return
  4400. }
  4401. //if res3507for10188.Infcode
  4402. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4403. //res.Output = resSix10265.Output
  4404. res3.ErrMsg = res3507for10188.ErrMsg
  4405. res3.Cainfo = res3507for10188.Cainfo
  4406. res3.WarnMsg = res3507for10188.WarnMsg
  4407. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4408. res3.Infcode = infocode
  4409. } else {
  4410. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4411. utils.ErrorLog("解析失败:%v", err)
  4412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4413. return
  4414. }
  4415. }
  4416. if res3.Infcode == 0 {
  4417. item.IsChange = 1
  4418. item.BgBchno = bg_number
  4419. service.SaveDF2(item)
  4420. } else {
  4421. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4422. }
  4423. }
  4424. }
  4425. }
  4426. }
  4427. if len(err) == 0 {
  4428. c.ServeSuccessJSON(map[string]interface{}{
  4429. "msg": "销售变更成功",
  4430. })
  4431. } else {
  4432. c.ServeSuccessJSON(map[string]interface{}{
  4433. "failed_code": -10,
  4434. "msg": err,
  4435. })
  4436. }
  4437. }
  4438. func (c *HisApiController) ChangeDrugTen() {
  4439. start_time_str := c.GetString("start_time")
  4440. end_time_str := c.GetString("end_time")
  4441. //ids := c.GetString("ids")
  4442. //id_arr := strings.Split(ids, ",")
  4443. timeLayout := "2006-01-02"
  4444. loc, _ := time.LoadLocation("Local")
  4445. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4446. recordStartTime := theStartTime.Unix()
  4447. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4448. recordEndTime := theEndTime.Unix()
  4449. //timestamp := int64(1729612800)
  4450. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4451. admin_user_id, _ := c.GetInt64("admin_user_id")
  4452. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4453. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4454. var err []string
  4455. for _, item := range flows {
  4456. var res3 ResultSix
  4457. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4458. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4459. continue
  4460. }
  4461. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4462. continue
  4463. }
  4464. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4465. if prescription.OrderStatus == 2 {
  4466. //已经结算
  4467. //判断 是否已经销售
  4468. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4469. ////是否已经变更 1是 0否
  4470. //if item.IsChange == 0 { //没变更,进行变更操作
  4471. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4472. //
  4473. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4474. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4475. // var respJSON3 map[string]interface{}
  4476. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4477. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4478. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4479. // return
  4480. // }
  4481. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4482. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4483. // utils.ErrorLog("解析失败:%v", err)
  4484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4485. // return
  4486. // }
  4487. // if res3.Infcode == 0 {
  4488. // item.IsChange = 1
  4489. // item.BgBchno = bg_number
  4490. // service.SaveDF2(item)
  4491. // } else {
  4492. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4493. // }
  4494. //}
  4495. //} else
  4496. if item.IsSale == 0 { //没销售,
  4497. var res FJ3507Result
  4498. var res3507for10188 FJ3507ResultFor10188
  4499. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4500. //进行商品销售接口
  4501. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4502. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4503. var respJSON3 map[string]interface{}
  4504. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4507. return
  4508. }
  4509. userJSONBytes3, _ := json.Marshal(respJSON3)
  4510. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4511. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4512. utils.ErrorLog("解析失败:%v", err)
  4513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4514. return
  4515. }
  4516. //if res3507for10188.Infcode
  4517. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4518. //res.Output = resSix10265.Output
  4519. res.ErrMsg = res3507for10188.ErrMsg
  4520. res.Cainfo = res3507for10188.Cainfo
  4521. res.WarnMsg = res3507for10188.WarnMsg
  4522. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4523. res.Infcode = infocode
  4524. } else {
  4525. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4526. utils.ErrorLog("解析失败:%v", err)
  4527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4528. return
  4529. }
  4530. }
  4531. if res.Infcode == 0 {
  4532. item.IsSale = 1
  4533. item.Bchno = number
  4534. item.SaleDate = time.Now().Format("2006-01-02")
  4535. err5 := service.SaveDF(item)
  4536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4537. //if err5 == nil {
  4538. //
  4539. // if item.IsChange == 1 { //没变更,进行变更操作
  4540. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4541. //
  4542. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4543. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4544. //
  4545. // var respJSON3 map[string]interface{}
  4546. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4547. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4549. // return
  4550. // }
  4551. //
  4552. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4553. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4554. // utils.ErrorLog("解析失败:%v", err)
  4555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4556. // return
  4557. // }
  4558. // //if res3507for10188.Infcode
  4559. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4560. // //res.Output = resSix10265.Output
  4561. // res3.ErrMsg = res3507for10188.ErrMsg
  4562. // res3.Cainfo = res3507for10188.Cainfo
  4563. // res3.WarnMsg = res3507for10188.WarnMsg
  4564. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4565. // res3.Infcode = infocode
  4566. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4567. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4568. // utils.ErrorLog("解析失败:%v", err)
  4569. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4570. // return
  4571. // }
  4572. // //if res3507for10188.Infcode
  4573. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4574. // //res.Output = resSix10265.Output
  4575. // res3.ErrMsg = res3507for10188.ErrMsg
  4576. // res3.Cainfo = res3507for10188.Cainfo
  4577. // res3.WarnMsg = res3507for10188.WarnMsg
  4578. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4579. // res3.Infcode = infocode
  4580. //
  4581. // } else {
  4582. //
  4583. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4584. // utils.ErrorLog("解析失败:%v", err)
  4585. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4586. // return
  4587. // }
  4588. //
  4589. // }
  4590. //
  4591. // if res3.Infcode == 0 {
  4592. // item.IsChange = 1
  4593. // item.BgBchno = bg_number
  4594. // service.SaveDF2(item)
  4595. // return
  4596. // } else {
  4597. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4598. // }
  4599. // }
  4600. //}
  4601. } else {
  4602. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4603. }
  4604. }
  4605. }
  4606. } else if item.ConsumableType == 7 {
  4607. var res3507for10188 FJ3507ResultFor10188
  4608. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4609. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4610. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4611. //判断是否已经销售
  4612. if item.IsSale == 2 { //是否已经销售,1是 0否
  4613. //是否已经变更 1是 0否
  4614. if item.IsChange == 0 { //没变更,进行变更操作
  4615. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4616. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4617. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4618. var respJSON3 map[string]interface{}
  4619. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4622. return
  4623. }
  4624. userJSONBytes3, _ := json.Marshal(respJSON3)
  4625. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4626. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4627. utils.ErrorLog("解析失败:%v", err)
  4628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4629. return
  4630. }
  4631. //if res3507for10188.Infcode
  4632. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4633. //res.Output = resSix10265.Output
  4634. res3.ErrMsg = res3507for10188.ErrMsg
  4635. res3.Cainfo = res3507for10188.Cainfo
  4636. res3.WarnMsg = res3507for10188.WarnMsg
  4637. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4638. res3.Infcode = infocode
  4639. } else {
  4640. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4641. utils.ErrorLog("解析失败:%v", err)
  4642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4643. return
  4644. }
  4645. }
  4646. if res3.Infcode == 0 {
  4647. item.IsChange = 1
  4648. item.BgBchno = bg_number
  4649. service.SaveDF2(item)
  4650. } else {
  4651. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4652. }
  4653. }
  4654. } else { //没销售,
  4655. //进行商品销售退货接口
  4656. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4657. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4658. saveLog(result111, result222, "3506", "销售退货")
  4659. var res7 FJ3507Result
  4660. //进行商品销售接口
  4661. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4662. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4663. var respJSON3 map[string]interface{}
  4664. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4667. return
  4668. }
  4669. userJSONBytes3, _ := json.Marshal(respJSON3)
  4670. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4671. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4672. utils.ErrorLog("解析失败:%v", err)
  4673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4674. return
  4675. }
  4676. //if res3507for10188.Infcode
  4677. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4678. //res.Output = resSix10265.Output
  4679. res7.ErrMsg = res3507for10188.ErrMsg
  4680. res7.Cainfo = res3507for10188.Cainfo
  4681. res7.WarnMsg = res3507for10188.WarnMsg
  4682. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4683. res7.Infcode = infocode
  4684. } else {
  4685. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4686. utils.ErrorLog("解析失败:%v", err)
  4687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4688. return
  4689. }
  4690. }
  4691. if res7.Infcode == 0 {
  4692. item.IsSale = 2
  4693. item.SaleDate = item.SaleDate
  4694. item.Bchno = number
  4695. service.SaveDF(item)
  4696. if item.IsChange == 0 { //没变更,进行变更操作
  4697. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4698. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4699. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4700. var respJSON3 map[string]interface{}
  4701. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4704. return
  4705. }
  4706. userJSONBytes3, _ := json.Marshal(respJSON3)
  4707. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4708. // utils.ErrorLog("解析失败:%v", err)
  4709. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4710. // return
  4711. //}
  4712. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4713. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4714. utils.ErrorLog("解析失败:%v", err)
  4715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4716. return
  4717. }
  4718. //if res3507for10188.Infcode
  4719. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4720. //res.Output = resSix10265.Output
  4721. res3.ErrMsg = res3507for10188.ErrMsg
  4722. res3.Cainfo = res3507for10188.Cainfo
  4723. res3.WarnMsg = res3507for10188.WarnMsg
  4724. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4725. res3.Infcode = infocode
  4726. } else {
  4727. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4728. utils.ErrorLog("解析失败:%v", err)
  4729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4730. return
  4731. }
  4732. }
  4733. if res3.Infcode == 0 {
  4734. item.IsChange = 1
  4735. item.BgBchno = bg_number
  4736. service.SaveDF2(item)
  4737. } else {
  4738. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4739. }
  4740. }
  4741. } else {
  4742. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4743. }
  4744. }
  4745. } else { //还没结算
  4746. if item.IsChange == 0 { //没变更,进行变更操作
  4747. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4748. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4749. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4750. var respJSON3 map[string]interface{}
  4751. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4754. return
  4755. }
  4756. userJSONBytes3, _ := json.Marshal(respJSON3)
  4757. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4758. // utils.ErrorLog("解析失败:%v", err)
  4759. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4760. // return
  4761. //}
  4762. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4763. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4764. utils.ErrorLog("解析失败:%v", err)
  4765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4766. return
  4767. }
  4768. //if res3507for10188.Infcode
  4769. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4770. //res.Output = resSix10265.Output
  4771. res3.ErrMsg = res3507for10188.ErrMsg
  4772. res3.Cainfo = res3507for10188.Cainfo
  4773. res3.WarnMsg = res3507for10188.WarnMsg
  4774. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4775. res3.Infcode = infocode
  4776. } else {
  4777. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4778. utils.ErrorLog("解析失败:%v", err)
  4779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4780. return
  4781. }
  4782. }
  4783. if res3.Infcode == 0 {
  4784. item.IsChange = 1
  4785. item.BgBchno = bg_number
  4786. service.SaveDF2(item)
  4787. } else {
  4788. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4789. }
  4790. }
  4791. }
  4792. }
  4793. }
  4794. if len(err) == 0 {
  4795. c.ServeSuccessJSON(map[string]interface{}{
  4796. "msg": "销售变更成功",
  4797. })
  4798. } else {
  4799. c.ServeSuccessJSON(map[string]interface{}{
  4800. "failed_code": -10,
  4801. "msg": err,
  4802. })
  4803. }
  4804. }
  4805. func ChangeDrugTenone() {
  4806. //ids := c.GetString("ids")
  4807. //id_arr := strings.Split(ids, ",")
  4808. now := time.Now()
  4809. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4810. //timestamp := int64(1729612800)
  4811. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  4812. admin_user_id := int64(2463)
  4813. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  4814. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  4815. var err []string
  4816. for _, item := range flows {
  4817. var res3 ResultSix
  4818. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4819. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4820. continue
  4821. }
  4822. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4823. continue
  4824. }
  4825. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4826. if prescription.OrderStatus == 2 {
  4827. //已经结算
  4828. //判断是否已经销售
  4829. if item.IsSale == 1 { //是否已经销售,1是 0否
  4830. //是否已经变更 1是 0否
  4831. if item.IsChange == 0 { //没变更,进行变更操作
  4832. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4833. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4834. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4835. var respJSON3 map[string]interface{}
  4836. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4838. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4839. return
  4840. }
  4841. userJSONBytes3, _ := json.Marshal(respJSON3)
  4842. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4843. utils.ErrorLog("解析失败:%v", err)
  4844. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4845. return
  4846. }
  4847. if res3.Infcode == 0 {
  4848. item.IsChange = 1
  4849. item.BgBchno = bg_number
  4850. service.SaveDF2(item)
  4851. } else {
  4852. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4853. }
  4854. }
  4855. } else { //没销售,
  4856. var res FJ3507Result
  4857. var res3507for10188 FJ3507ResultFor10188
  4858. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4859. //进行商品销售接口
  4860. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  4861. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4862. var respJSON3 map[string]interface{}
  4863. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4865. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4866. return
  4867. }
  4868. userJSONBytes3, _ := json.Marshal(respJSON3)
  4869. {
  4870. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4871. utils.ErrorLog("解析失败:%v", err)
  4872. return
  4873. }
  4874. //if res3507for10188.Infcode
  4875. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4876. //res.Output = resSix10265.Output
  4877. res.ErrMsg = res3507for10188.ErrMsg
  4878. res.Cainfo = res3507for10188.Cainfo
  4879. res.WarnMsg = res3507for10188.WarnMsg
  4880. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4881. res.Infcode = infocode
  4882. }
  4883. if res.Infcode == 0 {
  4884. item.IsSale = 1
  4885. item.Bchno = number
  4886. item.SaleDate = time.Now().Format("2006-01-02")
  4887. err5 := service.SaveDF(item)
  4888. if err5 == nil {
  4889. if item.IsChange == 1 { //没变更,进行变更操作
  4890. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4891. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4892. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4893. var respJSON3 map[string]interface{}
  4894. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4896. return
  4897. }
  4898. {
  4899. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4900. utils.ErrorLog("解析失败:%v", err)
  4901. return
  4902. }
  4903. //if res3507for10188.Infcode
  4904. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4905. //res.Output = resSix10265.Output
  4906. res3.ErrMsg = res3507for10188.ErrMsg
  4907. res3.Cainfo = res3507for10188.Cainfo
  4908. res3.WarnMsg = res3507for10188.WarnMsg
  4909. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4910. res3.Infcode = infocode
  4911. }
  4912. if res3.Infcode == 0 {
  4913. item.IsChange = 1
  4914. item.BgBchno = bg_number
  4915. service.SaveDF2(item)
  4916. } else {
  4917. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4918. }
  4919. }
  4920. }
  4921. } else {
  4922. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4923. }
  4924. }
  4925. }
  4926. }
  4927. }
  4928. }
  4929. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4930. var struct3502 models.Struct3502
  4931. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4932. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4933. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4934. struct3502.FixmedinsCode = miConfig.Code
  4935. struct3502.Code = miConfig.Code
  4936. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4937. struct3502.Opter = role.UserName
  4938. struct3502.RxFlag = "1"
  4939. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4940. struct3502.OrgName = miConfig.OrgName
  4941. struct3502.AccessKey = miConfig.AccessKey
  4942. struct3502.RequestUrl = miConfig.Url
  4943. struct3502.SecretKey = miConfig.SecretKey
  4944. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4945. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4946. struct3502.Url = miConfig.Url
  4947. struct3502.AppId = miConfig.Cainfo
  4948. struct3502.AppSecret = miConfig.AppSecret
  4949. struct3502.Enckey = miConfig.EncKey
  4950. struct3502.SignKey = miConfig.SignKey
  4951. struct3502.SecretKey = miConfig.SecretKey
  4952. struct3502.InvChgType = chgType
  4953. struct3502.FixmedinsBchno = number
  4954. struct3502.Cnt = strconv.FormatInt(count, 10)
  4955. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4956. //result1, result2, _ := service.FJyb3502(struct3502)
  4957. if miConfig.MdtrtareaAdmvs == "350500" {
  4958. result1, result2, _ := service.FJyb3502(struct3502)
  4959. //saveLog(result1, result2, "3502", "3502")
  4960. return result1, result2
  4961. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4962. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4963. return result1, result2
  4964. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4965. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4966. return result1, result2
  4967. } else {
  4968. data := make(map[string]interface{})
  4969. data["struct_3502s"] = struct3502
  4970. client := &http.Client{}
  4971. bytesData, _ := json.Marshal(data)
  4972. var req *http.Request
  4973. if miConfig.MdtrtareaAdmvs == "320921" {
  4974. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4975. } else {
  4976. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4977. }
  4978. resp, _ := client.Do(req)
  4979. defer resp.Body.Close()
  4980. body, ioErr := ioutil.ReadAll(resp.Body)
  4981. if ioErr != nil {
  4982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4983. }
  4984. var respJSON map[string]interface{}
  4985. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4987. }
  4988. //var resSix10265 ResultSix10265 //1101结果
  4989. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4990. result, _ := json.Marshal(respJSON)
  4991. return string(result), ""
  4992. }
  4993. }
  4994. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4995. var struct3505 models.Struct3505
  4996. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4997. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4998. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4999. struct3505.FixmedinsBchno = number
  5000. struct3505.Opter = role.UserName
  5001. struct3505.Bchno = "---"
  5002. struct3505.FixmedinsCode = miConfig.Code
  5003. struct3505.Code = miConfig.Code
  5004. struct3505.FinlTrnsPric = drug.HisDoctorAdviceInfo.Price
  5005. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5006. struct3505.PrscDrName = roles.UserName
  5007. if org_id == 10191 {
  5008. struct3505.PharName = "刘水山"
  5009. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5010. }
  5011. if org_id == 10188 {
  5012. struct3505.PharName = "李汉清"
  5013. struct3505.PharPracCertNo = "30220200932022010034"
  5014. }
  5015. if org_id == 10217 {
  5016. struct3505.PharName = "张敏"
  5017. struct3505.PharPracCertNo = "30220230432090100108"
  5018. }
  5019. if org_id == 10318 {
  5020. struct3505.PharName = "邹刘阳"
  5021. struct3505.PharPracCertNo = "210441200001378"
  5022. }
  5023. if org_id == 10402 {
  5024. struct3505.PharName = "刘韶健"
  5025. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5026. }
  5027. if org_id == 9919 {
  5028. struct3505.PharName = "周君权"
  5029. struct3505.PharPracCertNo = "089644396094401375"
  5030. }
  5031. if org_id == 10644 {
  5032. struct3505.PharName = "陈金娣"
  5033. struct3505.PharPracCertNo = "20181441500320100066"
  5034. }
  5035. if org_id == 10567 {
  5036. struct3505.PharName = "范小兰"
  5037. struct3505.PharPracCertNo = "0200102079485"
  5038. }
  5039. if org_id == 10721 {
  5040. struct3505.PharName = "孙莉侠"
  5041. struct3505.PharPracCertNo = "060399"
  5042. }
  5043. if org_id == 10726 {
  5044. struct3505.PharName = "彭建福"
  5045. struct3505.PharPracCertNo = "D445281006261"
  5046. }
  5047. if org_id == 10265 {
  5048. struct3505.PharName = "李彩星"
  5049. struct3505.PharPracCertNo = "20171110600110100019"
  5050. }
  5051. if org_id == 10028 {
  5052. struct3505.PharName = "曾细平"
  5053. struct3505.PharPracCertNo = "D440307022134"
  5054. }
  5055. if org_id == 10138 {
  5056. struct3505.PharName = "彭斯遥"
  5057. struct3505.PharPracCertNo = "30220200943042010052"
  5058. }
  5059. if org_id == 10278 {
  5060. struct3505.PharName = "彭斯遥"
  5061. struct3505.PharPracCertNo = "30220200943042010052"
  5062. }
  5063. if org_id == 10610 {
  5064. struct3505.PharName = "彭斯遥"
  5065. struct3505.PharPracCertNo = "30220200943042010052"
  5066. }
  5067. if org_id == 10537 {
  5068. struct3505.PharName = "彭斯遥"
  5069. struct3505.PharPracCertNo = "30220200943042010052"
  5070. }
  5071. if org_id == 9504 {
  5072. struct3505.PharName = "资美红"
  5073. struct3505.PharPracCertNo = "D440904006635"
  5074. }
  5075. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5076. struct3505.SetlId = order.SetlId
  5077. struct3505.MdtrtSn = order.MdtrtId
  5078. struct3505.ManuLotnum = drug.BatchNumber
  5079. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5080. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5081. struct3505.RxFlag = "1"
  5082. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5083. struct3505.TrdnFlag = "0"
  5084. } else {
  5085. struct3505.TrdnFlag = "1"
  5086. }
  5087. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5088. struct3505.TrdnFlag = "1"
  5089. }
  5090. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5091. struct3505.TrdnFlag = "0"
  5092. }
  5093. struct3505.RtalDocno = order.Number
  5094. struct3505.PsnCertType = "01"
  5095. struct3505.CertNo = order.Certno
  5096. struct3505.PsnNo = order.PsnNo
  5097. struct3505.PsnName = order.PsnName
  5098. struct3505.Url = miConfig.Url
  5099. struct3505.AppId = miConfig.Cainfo
  5100. struct3505.AppSecret = miConfig.AppSecret
  5101. struct3505.Enckey = miConfig.EncKey
  5102. struct3505.SignKey = miConfig.SignKey
  5103. struct3505.SecretKey = miConfig.SecretKey
  5104. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5105. struct3505.SelRetnCnt = strValue
  5106. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5107. struct3505.SelRetnOpterName = role.UserName
  5108. if order.IsMedicineInsurance == 1 {
  5109. struct3505.MdtrtSetlType = "1"
  5110. } else {
  5111. struct3505.MdtrtSetlType = "2"
  5112. }
  5113. struct3505.OrgName = miConfig.OrgName
  5114. struct3505.AccessKey = miConfig.AccessKey
  5115. struct3505.RequestUrl = miConfig.Url
  5116. struct3505.SecretKey = miConfig.SecretKey
  5117. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5118. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5119. struct3505.Cainfo = miConfig.Cainfo
  5120. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5121. if miConfig.MdtrtareaAdmvs == "350500" {
  5122. result1, result2, _ := service.FJyb3505(struct3505)
  5123. return result1, result2
  5124. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5125. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5126. return result1, result2
  5127. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5128. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5129. return result1, result2
  5130. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5131. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5132. return result1, result2
  5133. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5134. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5135. return result1, result2
  5136. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5137. data := make(map[string]interface{})
  5138. data["struct_3505s"] = struct3505
  5139. client := &http.Client{}
  5140. bytesData, _ := json.Marshal(data)
  5141. var req *http.Request
  5142. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5143. resp, _ := client.Do(req)
  5144. defer resp.Body.Close()
  5145. body, ioErr := ioutil.ReadAll(resp.Body)
  5146. if ioErr != nil {
  5147. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5148. }
  5149. var respJSON map[string]interface{}
  5150. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5152. }
  5153. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5154. result, _ := json.Marshal(respJSON)
  5155. return string(result), ""
  5156. } else {
  5157. data := make(map[string]interface{})
  5158. data["struct_3505s"] = struct3505
  5159. client := &http.Client{}
  5160. bytesData, _ := json.Marshal(data)
  5161. var req *http.Request
  5162. if miConfig.MdtrtareaAdmvs == "320921" {
  5163. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5164. } else {
  5165. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5166. }
  5167. resp, _ := client.Do(req)
  5168. defer resp.Body.Close()
  5169. body, ioErr := ioutil.ReadAll(resp.Body)
  5170. if ioErr != nil {
  5171. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5172. }
  5173. var respJSON map[string]interface{}
  5174. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5176. }
  5177. //var resSix10265 ResultSix10265 //1101结果
  5178. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5179. result, _ := json.Marshal(respJSON)
  5180. return string(result), ""
  5181. }
  5182. }
  5183. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5184. var struct3505 models.Struct3505
  5185. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5186. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5187. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5188. struct3505.FixmedinsBchno = number
  5189. struct3505.Opter = role.UserName
  5190. struct3505.FixmedinsCode = miConfig.Code
  5191. struct3505.Code = miConfig.Code
  5192. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5193. struct3505.PrscDrName = roles.UserName
  5194. if org_id == 10191 {
  5195. struct3505.PharName = "刘水山"
  5196. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5197. }
  5198. if org_id == 10188 {
  5199. struct3505.PharName = "李汉清"
  5200. struct3505.PharPracCertNo = "30220200932022010034"
  5201. }
  5202. if org_id == 10217 {
  5203. struct3505.PharName = "张敏"
  5204. struct3505.PharPracCertNo = "30220230432090100108"
  5205. }
  5206. if org_id == 10318 {
  5207. struct3505.PharName = "邹刘阳"
  5208. struct3505.PharPracCertNo = "210441200001378"
  5209. }
  5210. if org_id == 10402 {
  5211. struct3505.PharName = "刘韶健"
  5212. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5213. }
  5214. if org_id == 9919 {
  5215. struct3505.PharName = "周君权"
  5216. struct3505.PharPracCertNo = "089644396094401375"
  5217. }
  5218. if org_id == 10644 {
  5219. struct3505.PharName = "陈金娣"
  5220. struct3505.PharPracCertNo = "20181441500320100066"
  5221. }
  5222. if org_id == 10567 {
  5223. struct3505.PharName = "范小兰"
  5224. struct3505.PharPracCertNo = "0200102079485"
  5225. }
  5226. if org_id == 10721 {
  5227. struct3505.PharName = "孙莉侠"
  5228. struct3505.PharPracCertNo = "060399"
  5229. }
  5230. if org_id == 10726 {
  5231. struct3505.PharName = "彭建福"
  5232. struct3505.PharPracCertNo = "D445281006261"
  5233. }
  5234. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5235. struct3505.SetlId = order.SetlId
  5236. struct3505.MdtrtSn = order.MdtrtId
  5237. struct3505.ManuLotnum = drug.Number
  5238. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5239. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5240. struct3505.RxFlag = "1"
  5241. struct3505.TrdnFlag = "0"
  5242. struct3505.RtalDocno = order.Number
  5243. struct3505.PsnCertType = "01"
  5244. struct3505.CertNo = order.Certno
  5245. struct3505.PsnNo = order.PsnNo
  5246. struct3505.PsnName = order.PsnName
  5247. struct3505.Url = miConfig.Url
  5248. struct3505.AppId = miConfig.Cainfo
  5249. struct3505.AppSecret = miConfig.AppSecret
  5250. struct3505.Enckey = miConfig.EncKey
  5251. struct3505.SignKey = miConfig.SignKey
  5252. struct3505.SecretKey = miConfig.SecretKey
  5253. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5254. struct3505.SelRetnCnt = strValue
  5255. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5256. struct3505.SelRetnOpterName = role.UserName
  5257. if order.IsMedicineInsurance == 1 {
  5258. struct3505.MdtrtSetlType = "1"
  5259. } else {
  5260. struct3505.MdtrtSetlType = "2"
  5261. }
  5262. struct3505.OrgName = miConfig.OrgName
  5263. struct3505.AccessKey = miConfig.AccessKey
  5264. struct3505.RequestUrl = miConfig.Url
  5265. struct3505.SecretKey = miConfig.SecretKey
  5266. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5267. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5268. struct3505.Cainfo = miConfig.Cainfo
  5269. struct3505.DrugTracCodg = drug.DrugCode
  5270. if miConfig.MdtrtareaAdmvs == "350500" {
  5271. result1, result2, _ := service.FJyb3505(struct3505)
  5272. return result1, result2
  5273. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5274. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5275. return result1, result2
  5276. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5277. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5278. return result1, result2
  5279. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5280. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5281. return result1, result2
  5282. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5283. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5284. return result1, result2
  5285. } else {
  5286. data := make(map[string]interface{})
  5287. data["struct_3505s"] = struct3505
  5288. client := &http.Client{}
  5289. bytesData, _ := json.Marshal(data)
  5290. var req *http.Request
  5291. if miConfig.MdtrtareaAdmvs == "320921" {
  5292. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5293. } else {
  5294. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5295. }
  5296. resp, _ := client.Do(req)
  5297. defer resp.Body.Close()
  5298. body, ioErr := ioutil.ReadAll(resp.Body)
  5299. if ioErr != nil {
  5300. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5301. }
  5302. var respJSON map[string]interface{}
  5303. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5305. }
  5306. //var resSix10265 ResultSix10265 //1101结果
  5307. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5308. result, _ := json.Marshal(respJSON)
  5309. return string(result), ""
  5310. }
  5311. }
  5312. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5313. var struct3506 models.Struct3506
  5314. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5315. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5316. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5317. struct3506.FixmedinsCode = miConfig.Code
  5318. struct3506.Code = miConfig.Code
  5319. struct3506.FixmedinsBchno = number
  5320. struct3506.Opter = role.UserName
  5321. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5322. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5323. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5324. struct3506.MdtrtSn = order.MdtrtId
  5325. struct3506.ExpyEnd = ""
  5326. struct3506.RxFlag = "0"
  5327. struct3506.TrdnFlag = "1"
  5328. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5329. struct3506.SelRetnCnt = strValue
  5330. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5331. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5332. struct3506.SelRetnOpterName = role.UserName
  5333. struct3506.OrgName = miConfig.OrgName
  5334. struct3506.AccessKey = miConfig.AccessKey
  5335. struct3506.RequestUrl = miConfig.Url
  5336. struct3506.SecretKey = miConfig.SecretKey
  5337. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5338. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5339. struct3506.Url = miConfig.Url
  5340. struct3506.AppId = miConfig.Cainfo
  5341. struct3506.AppSecret = miConfig.AppSecret
  5342. struct3506.Enckey = miConfig.EncKey
  5343. struct3506.SignKey = miConfig.SignKey
  5344. struct3506.SecretKey = miConfig.SecretKey
  5345. struct3506.DrugTracCodg = drug.DrugCode
  5346. if miConfig.MdtrtareaAdmvs == "350500" {
  5347. result1, result2, _ := service.FJyb3506(struct3506)
  5348. return result1, result2
  5349. } else {
  5350. data := make(map[string]interface{})
  5351. data["struct_3506s"] = struct3506
  5352. client := &http.Client{}
  5353. bytesData, _ := json.Marshal(data)
  5354. var req *http.Request
  5355. if miConfig.MdtrtareaAdmvs == "320921" {
  5356. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5357. } else {
  5358. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5359. }
  5360. resp, _ := client.Do(req)
  5361. defer resp.Body.Close()
  5362. body, ioErr := ioutil.ReadAll(resp.Body)
  5363. if ioErr != nil {
  5364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5365. }
  5366. var respJSON map[string]interface{}
  5367. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5369. }
  5370. //var resSix10265 ResultSix10265 //1101结果
  5371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5372. result, _ := json.Marshal(respJSON)
  5373. return string(result), ""
  5374. }
  5375. }
  5376. func (c *HisApiController) Get1318() {
  5377. adminUser := c.GetAdminUserInfo()
  5378. admin_user_id, _ := c.GetInt64("admin_user_id")
  5379. code := c.GetString("code")
  5380. code = ""
  5381. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5382. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5383. api := ""
  5384. if miConfig.MdtrtareaAdmvs == "320921" {
  5385. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5386. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5387. } else {
  5388. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5389. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5390. }
  5391. resp, requestErr := http.Get(api)
  5392. if requestErr != nil {
  5393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5394. return
  5395. }
  5396. body, ioErr := ioutil.ReadAll(resp.Body)
  5397. if ioErr != nil {
  5398. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5400. return
  5401. }
  5402. var respJSON map[string]interface{}
  5403. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5406. return
  5407. }
  5408. //var res Result2406
  5409. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5410. result, _ := json.Marshal(respJSON)
  5411. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5412. utils.ErrorLog("解析失败:%v", err)
  5413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5414. return
  5415. }
  5416. if res.Infcode == "0" {
  5417. c.ServeSuccessJSON(map[string]interface{}{
  5418. "result": "",
  5419. })
  5420. } else {
  5421. c.ServeSuccessJSON(map[string]interface{}{
  5422. "failed_code": -10,
  5423. "msg": res.ErrMsg,
  5424. })
  5425. */return
  5426. //}
  5427. }
  5428. func (c *HisApiController) Get2503() {
  5429. adminUser := c.GetAdminUserInfo()
  5430. admin_user_id, _ := c.GetInt64("admin_user_id")
  5431. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5432. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5433. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5434. }
  5435. func (c *HisApiController) Get2406() {
  5436. id, _ := c.GetInt64("id")
  5437. record_time := c.GetString("record_time")
  5438. his_patient_id, _ := c.GetInt64("his_patient_id")
  5439. admin_user_id, _ := c.GetInt64("admin_user_id")
  5440. diagnosis_id := c.GetString("diagnosis")
  5441. timeLayout := "2006-01-02"
  5442. loc, _ := time.LoadLocation("Local")
  5443. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5444. if err != nil {
  5445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5446. return
  5447. }
  5448. recordDateTime := theTime.Unix()
  5449. adminUser := c.GetAdminUserInfo()
  5450. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5451. var config []*models.HisXtDiagnoseConfig
  5452. for _, item := range diagnosis_ids {
  5453. id, _ := strconv.ParseInt(item, 10, 64)
  5454. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5455. config = append(config, &diagnosisConfig)
  5456. }
  5457. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5458. fmt.Println(his_patient_id)
  5459. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5460. //timestamp := time.Now().Unix()
  5461. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5462. var patientPrescription models.HisPrescriptionInfo
  5463. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5464. if patientPrescription.ID == 0 {
  5465. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5466. }
  5467. var res2 Result2406
  5468. if miConfig.MdtrtareaAdmvs == "341203" {
  5469. data := make(map[string]interface{})
  5470. client := &http.Client{}
  5471. data["psn_no"] = his.PsnNo
  5472. data["mdtrt_id"] = his.Number
  5473. data["operator"] = roles.UserName
  5474. data["cert_no"] = his.IdCardNo
  5475. data["org_name"] = miConfig.OrgName
  5476. data["psn_name"] = his.Name
  5477. data["ipt_otp_no"] = his.IptOtpNo
  5478. data["ipt_psn_sp_flag_type"] = "0901"
  5479. data["ipt_psn_sp_flag"] = "1"
  5480. data["fixmedins_code"] = miConfig.Code
  5481. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5482. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5483. data["url"] = miConfig.Url
  5484. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5485. bytesData, _ := json.Marshal(data)
  5486. var req *http.Request
  5487. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5488. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5489. resp, _ := client.Do(req)
  5490. defer resp.Body.Close()
  5491. body, ioErr := ioutil.ReadAll(resp.Body)
  5492. if ioErr != nil {
  5493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5495. return
  5496. }
  5497. var respJSON map[string]interface{}
  5498. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5501. return
  5502. }
  5503. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5504. if status == "0" {
  5505. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5506. c.ServeSuccessJSON(map[string]interface{}{
  5507. "failed_code": -10,
  5508. "msg": err_msg,
  5509. })
  5510. return
  5511. }
  5512. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5513. userJSONBytes, _ := json.Marshal(respJSON)
  5514. fmt.Println("log")
  5515. fmt.Println(string(userJSONBytes))
  5516. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5517. utils.ErrorLog("解析失败:%v", err)
  5518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5519. return
  5520. }
  5521. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5522. data := make(map[string]interface{})
  5523. client := &http.Client{}
  5524. data["psn_no"] = his.PsnNo
  5525. data["mdtrt_id"] = his.Number
  5526. data["operator"] = roles.UserName
  5527. data["cert_no"] = his.IdCardNo
  5528. data["org_name"] = miConfig.OrgName
  5529. data["psn_name"] = his.Name
  5530. data["ipt_otp_no"] = his.IptOtpNo
  5531. data["ipt_psn_sp_flag_type"] = "0901"
  5532. data["ipt_psn_sp_flag"] = "1"
  5533. data["fixmedins_code"] = miConfig.Code
  5534. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5535. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5536. data["url"] = miConfig.Url
  5537. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5538. bytesData, _ := json.Marshal(data)
  5539. var req *http.Request
  5540. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5541. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5542. resp, _ := client.Do(req)
  5543. defer resp.Body.Close()
  5544. body, ioErr := ioutil.ReadAll(resp.Body)
  5545. if ioErr != nil {
  5546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5548. return
  5549. }
  5550. var respJSON map[string]interface{}
  5551. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5554. return
  5555. }
  5556. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5557. if status == "0" {
  5558. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5559. c.ServeSuccessJSON(map[string]interface{}{
  5560. "failed_code": -10,
  5561. "msg": err_msg,
  5562. })
  5563. return
  5564. }
  5565. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5566. userJSONBytes, _ := json.Marshal(respJSON)
  5567. fmt.Println("log")
  5568. fmt.Println(string(userJSONBytes))
  5569. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5570. utils.ErrorLog("解析失败:%v", err)
  5571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5572. return
  5573. }
  5574. }
  5575. if res2.Infcode != 0 {
  5576. adminUser := c.GetAdminUserInfo()
  5577. errlog := &models.HisOrderError{
  5578. UserOrgId: adminUser.CurrentOrgId,
  5579. Ctime: time.Now().Unix(),
  5580. Mtime: time.Now().Unix(),
  5581. ErrMsg: res2.ErrMsg,
  5582. Status: 1,
  5583. PatientId: id,
  5584. RecordTime: recordDateTime,
  5585. Stage: 3,
  5586. }
  5587. service.CreateErrMsgLog(errlog)
  5588. c.ServeSuccessJSON(map[string]interface{}{
  5589. "failed_code": -10,
  5590. "msg": res2.ErrMsg,
  5591. })
  5592. return
  5593. } else {
  5594. c.ServeSuccessJSON(map[string]interface{}{
  5595. "msg": "上传成功",
  5596. })
  5597. return
  5598. }
  5599. }
  5600. func (c *HisApiController) Get4105() {
  5601. }
  5602. func (c *HisApiController) Post5302() {
  5603. patient_id, _ := c.GetInt64("id")
  5604. admin_user_id, _ := c.GetInt64("admin_user_id")
  5605. p, _ := service.GetHisPatientById(patient_id)
  5606. adminUser := c.GetAdminUserInfo()
  5607. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5608. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5609. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5610. }
  5611. func (c *HisApiController) Get4104() {
  5612. }
  5613. type Output struct {
  5614. CertNo string `json:"certno"`
  5615. PsnName string `json:"psn_name"`
  5616. CardNo string `json:"card_no"`
  5617. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5618. CardSN string `json:"card_sn"`
  5619. PsnCertType string `json:"psn_cert_type"`
  5620. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5621. MdtrtCertType string `json:"mdtrt_cert_type"`
  5622. QRCode string `json:"qrCode"`
  5623. EcToken string `json:"ecToken"`
  5624. }
  5625. type AHResponse struct {
  5626. Body AHBody `json:"body"`
  5627. Code int `json:"code"`
  5628. CSBCode int `json:"csbCode"`
  5629. Message string `json:"message"`
  5630. RequestID string `json:"requestId"`
  5631. State struct{} `json:"state"`
  5632. }
  5633. type AHBody struct {
  5634. ErrMsg string `json:"err_msg"`
  5635. InfRefMsgID string `json:"inf_refmsgid"`
  5636. InfCode int `json:"infcode"`
  5637. Output struct {
  5638. Result []struct {
  5639. BasMednFlag string `json:"bas_medn_flag"`
  5640. ChldMedcFlag string `json:"chld_medc_flag"`
  5641. ChrgitmLv string `json:"chrgitm_lv"`
  5642. Cnt float64 `json:"cnt"`
  5643. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5644. DrtReimFlag string `json:"drt_reim_flag"`
  5645. FeedetlSn string `json:"feedetl_sn"`
  5646. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5647. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5648. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5649. ListSpItemFlag string `json:"list_sp_item_flag"`
  5650. LmtUsedFlag string `json:"lmt_used_flag"`
  5651. MedChrgitmType string `json:"med_chrgitm_type"`
  5652. Memo string `json:"memo"`
  5653. OverlmtAmt float64 `json:"overlmt_amt"`
  5654. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5655. Pric float64 `json:"pric"`
  5656. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5657. SelfpayProp float64 `json:"selfpay_prop"`
  5658. } `json:"result"`
  5659. } `json:"output"`
  5660. }
  5661. type Response struct {
  5662. Output Output `json:"output"`
  5663. Infcode int `json:"infcode"`
  5664. InfRefMsgID string `json:"inf_refmsgid"`
  5665. RefMsgTime string `json:"refmsg_time"`
  5666. RespondTime string `json:"respond_time"`
  5667. ErrMsg string `json:"err_msg"`
  5668. WarnMsg string `json:"warn_msg"`
  5669. SignType string `json:"signtype"`
  5670. CAInfo string `json:"cainfo"`
  5671. }
  5672. func (c *HisApiController) Getquerydata() {
  5673. query_type, _ := c.GetInt64("type")
  5674. refd_setl_flag := c.GetString("refd_setl_flag")
  5675. med_type := c.GetString("med_type")
  5676. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5677. cert_no := c.GetString("cert_no")
  5678. psn_no := c.GetString("psn_no")
  5679. start_time := c.GetString("start_time")
  5680. end_time := c.GetString("end_time")
  5681. page, _ := c.GetInt64("page")
  5682. limit, _ := c.GetInt64("limit")
  5683. var bp models.BusinessParams5262
  5684. bp.RefdSetlFlag = refd_setl_flag
  5685. bp.MedType = med_type
  5686. bp.Certno = cert_no
  5687. bp.Psnno = psn_no
  5688. bp.QBegntime = start_time
  5689. bp.QEndtime = end_time
  5690. if query_type == 1 { //本地
  5691. Post5262(c, bp, page, limit)
  5692. } else { //异地
  5693. Post5267(c, bp, page, limit)
  5694. }
  5695. }
  5696. func (c *HisApiController) Drugscheck() {
  5697. admin_user_id, _ := c.GetInt64("admin_user_id")
  5698. adminUser := c.GetAdminUserInfo()
  5699. var queryResult []QueryResult
  5700. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5701. for _, item := range drugs {
  5702. result := QueryResult{
  5703. ID: item.ID,
  5704. Name: item.DrugName,
  5705. Code: item.MedicalInsuranceNumber,
  5706. List_type_code: "101",
  5707. }
  5708. queryResult = append(queryResult, result)
  5709. }
  5710. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5711. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5712. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5713. for _, item := range queryResult {
  5714. 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)
  5715. }
  5716. }
  5717. func (c *HisApiController) Goodcheck() {
  5718. admin_user_id, _ := c.GetInt64("admin_user_id")
  5719. adminUser := c.GetAdminUserInfo()
  5720. var queryResult []QueryResult
  5721. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5722. for _, item := range goods {
  5723. result := QueryResult{
  5724. ID: item.ID,
  5725. Name: item.GoodName,
  5726. Code: item.SocialSecurityDirectoryCode,
  5727. List_type_code: "301",
  5728. }
  5729. queryResult = append(queryResult, result)
  5730. }
  5731. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5732. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5733. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5734. for _, item := range queryResult {
  5735. service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2022-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  5736. //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)
  5737. }
  5738. }
  5739. func (c *HisApiController) Projectcheck() {
  5740. admin_user_id, _ := c.GetInt64("admin_user_id")
  5741. adminUser := c.GetAdminUserInfo()
  5742. var queryResult []QueryResult
  5743. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5744. for _, item := range projects {
  5745. result := QueryResult{
  5746. ID: item.ID,
  5747. Name: item.ProjectName,
  5748. Code: item.MedicalCode,
  5749. List_type_code: "201",
  5750. }
  5751. queryResult = append(queryResult, result)
  5752. }
  5753. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5754. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5755. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5756. for _, item := range queryResult {
  5757. 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)
  5758. }
  5759. }
  5760. //func (c *HisApiController)CancleDia(){
  5761. //
  5762. // id, _ := c.GetInt64("id")
  5763. // record_time := c.GetString("record_time")
  5764. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5765. //
  5766. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5767. //
  5768. // diagnosis_id := c.GetString("diagnosis")
  5769. // sick_type, _ := c.GetInt64("sick_type")
  5770. // reg_type, _ := c.GetInt64("p_type")
  5771. // begin_time := c.GetString("begin_time")
  5772. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5773. //
  5774. //
  5775. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5776. //
  5777. // fmt.Println(acct_used_flag)
  5778. //
  5779. //
  5780. // timeLayout := "2006-01-02"
  5781. // loc, _ := time.LoadLocation("Local")
  5782. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5783. // if err != nil {
  5784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5785. // return
  5786. // }
  5787. // recordDateTime := theTime.Unix()
  5788. // adminUser := c.GetAdminUserInfo()
  5789. //
  5790. //
  5791. //
  5792. //
  5793. //
  5794. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5795. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5796. // var patientPrescription models.HisPrescriptionInfo
  5797. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5798. // if patientPrescription.ID == 0 {
  5799. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5800. // }
  5801. // //if patientPrescription.Do
  5802. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5803. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5804. //
  5805. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5806. //
  5807. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5808. //
  5809. // var config []*models.HisXtDiagnoseConfig
  5810. // for _, item := range diagnosis_ids {
  5811. // id, _ := strconv.ParseInt(item, 10, 64)
  5812. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5813. // config = append(config, &diagnosisConfig)
  5814. // }
  5815. //
  5816. // sickConfig, _ := service.FindSickById(sick_type)
  5817. //
  5818. //
  5819. // data := make(map[string]interface{})
  5820. // client := &http.Client{}
  5821. // data["psn_no"] = his.PsnNo
  5822. // data["mdtrt_id"] = his.Number
  5823. // data["doctor"] = roles.UserName
  5824. // data["department"] = department.Name
  5825. // data["org_name"] = miConfig.OrgName
  5826. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5827. // data["doctor_id"] = doctor_info.DoctorNumber
  5828. // data["new_doctor_name"] = doctor_info.UserName
  5829. // data["fixmedins_code"] = miConfig.Code
  5830. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5831. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5832. // data["secret_key"] = miConfig.SecretKey
  5833. // data["sick_code"] = sickConfig.CountryCode
  5834. // data["sick_name"] = sickConfig.ClassName
  5835. // data["url"] = miConfig.Url
  5836. // data["ak"] = miConfig.AccessKey
  5837. // data["begin_time"] = begin_time
  5838. // data["cainfo"] = miConfig.Cainfo
  5839. // data["is_vaild"] = "0"
  5840. //
  5841. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5842. // data["config"] = config
  5843. // bytesData, _ := json.Marshal(data)
  5844. //
  5845. // var req *http.Request
  5846. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5847. // resp, _ := client.Do(req)
  5848. // defer resp.Body.Close()
  5849. // body, ioErr := ioutil.ReadAll(resp.Body)
  5850. // if ioErr != nil {
  5851. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5852. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5853. // return
  5854. // }
  5855. // var respJSON map[string]interface{}
  5856. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5857. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5858. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5859. // return
  5860. // }
  5861. //
  5862. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5863. // userJSONBytes, _ := json.Marshal(respJSON)
  5864. // fmt.Println("log")
  5865. // fmt.Println(string(userJSONBytes))
  5866. //
  5867. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5868. // utils.ErrorLog("解析失败:%v", err)
  5869. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5870. // return
  5871. // }
  5872. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5873. // res2.Output = ressix10265.Output
  5874. // res2.ErrMsg = ressix10265.ErrMsg
  5875. // res2.Cainfo = ressix10265.Cainfo
  5876. // res2.WarnMsg = ressix10265.WarnMsg
  5877. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5878. // res2.Infcode = infocode
  5879. //
  5880. //}
  5881. func (c *HisApiController) Get4102() {
  5882. order_id, _ := c.GetInt64("order_id")
  5883. admin_user_id, _ := c.GetInt64("admin_user_id")
  5884. stas_type := c.GetString("stas_type")
  5885. order, _ := service.GetHisOrderByIDTwo(order_id)
  5886. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5887. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5888. var pp models.PublicParams
  5889. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5890. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5891. pp.FixmedinsName = miConfig.OrgName
  5892. pp.FixmedinsCode = miConfig.Code
  5893. pp.RequestUrl = miConfig.Url
  5894. pp.Cainfo = miConfig.Cainfo
  5895. pp.SecretKey = miConfig.SecretKey
  5896. pp.AccessKey = miConfig.AccessKey
  5897. pp.OpterName = curRoles.UserName
  5898. if miConfig.MdtrtareaAdmvs == "350500" {
  5899. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5900. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5901. saveLog(result, request, "4102", "清单确认")
  5902. var dat map[string]interface{}
  5903. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5904. fmt.Println(dat)
  5905. } else {
  5906. fmt.Println(err)
  5907. }
  5908. var empty ResultFourteen
  5909. userJSONBytes, _ := json.Marshal(dat)
  5910. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5911. utils.ErrorLog("解析失败:%v", err)
  5912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5913. return
  5914. }
  5915. if empty.Infcode == 0 {
  5916. c.ServeSuccessJSON(map[string]interface{}{
  5917. "msg": "确认成功",
  5918. })
  5919. return
  5920. }
  5921. } else {
  5922. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5923. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5924. result3, request3 := service.Jxyb4105(pp)
  5925. saveLog(result, request, "4102", "清单确认")
  5926. saveLog(result2, request2, "4103", "清单确认")
  5927. saveLog(result3, request3, "4105", "清单统计")
  5928. var dat map[string]interface{}
  5929. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5930. fmt.Println(dat)
  5931. } else {
  5932. fmt.Println(err)
  5933. }
  5934. var empty ResultFourteen
  5935. userJSONBytes, _ := json.Marshal(dat)
  5936. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5937. utils.ErrorLog("解析失败:%v", err)
  5938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5939. return
  5940. }
  5941. if empty.Infcode == 0 {
  5942. c.ServeSuccessJSON(map[string]interface{}{
  5943. "msg": "确认成功",
  5944. })
  5945. return
  5946. }
  5947. }
  5948. }
  5949. // 对账权限查询
  5950. func (c *HisApiController) Get3260() {
  5951. admin_user_id, _ := c.GetInt64("admin_user_id")
  5952. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5953. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5954. var api string
  5955. var res models.JSResult3260
  5956. if miConfig.MdtrtareaAdmvs == "320921" {
  5957. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5958. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5959. } else {
  5960. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5961. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5962. }
  5963. resp, requestErr := http.Get(api)
  5964. if requestErr != nil {
  5965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5966. return
  5967. }
  5968. body, ioErr := ioutil.ReadAll(resp.Body)
  5969. if ioErr != nil {
  5970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5972. return
  5973. }
  5974. var respJSON map[string]interface{}
  5975. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5978. return
  5979. }
  5980. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5981. result, _ := json.Marshal(respJSON)
  5982. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5983. utils.ErrorLog("解析失败:%v", err)
  5984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5985. return
  5986. }
  5987. if res.Infcode == "0" {
  5988. c.ServeSuccessJSON(map[string]interface{}{
  5989. "result": res.Output.Data,
  5990. })
  5991. } else {
  5992. c.ServeSuccessJSON(map[string]interface{}{
  5993. "failed_code": -10,
  5994. "msg": res.ErrMsg,
  5995. })
  5996. return
  5997. }
  5998. }
  5999. func (c *HisApiController) Get3261() {
  6000. admin_user_id, _ := c.GetInt64("admin_user_id")
  6001. //month := c.GetString("month")
  6002. startTime := c.GetString("start_time")
  6003. //endTime, _ := c.GetString("end_time")
  6004. times := strings.Split(startTime, "-")
  6005. stmt_mon := times[0] + times[1]
  6006. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6007. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6008. var api string
  6009. var res models.JSResult3261
  6010. //var res10265 Result5301For10265
  6011. if miConfig.MdtrtareaAdmvs == "320921" {
  6012. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6013. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6014. } else {
  6015. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6016. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6017. }
  6018. resp, requestErr := http.Get(api)
  6019. if requestErr != nil {
  6020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6021. return
  6022. }
  6023. body, ioErr := ioutil.ReadAll(resp.Body)
  6024. if ioErr != nil {
  6025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6027. return
  6028. }
  6029. var respJSON map[string]interface{}
  6030. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6033. return
  6034. }
  6035. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6036. result, _ := json.Marshal(respJSON)
  6037. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6038. utils.ErrorLog("解析失败:%v", err)
  6039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6040. return
  6041. }
  6042. if res.Infcode == "0" {
  6043. c.ServeSuccessJSON(map[string]interface{}{
  6044. "result": res.Output,
  6045. })
  6046. } else {
  6047. c.ServeSuccessJSON(map[string]interface{}{
  6048. "failed_code": -10,
  6049. "msg": res.ErrMsg,
  6050. })
  6051. return
  6052. }
  6053. }
  6054. type TempFun struct {
  6055. FundKey string
  6056. FundCode string
  6057. }
  6058. func (c *HisApiController) Get3262() {
  6059. admin_user_id, _ := c.GetInt64("admin_user_id")
  6060. startTime := c.GetString("start_time")
  6061. endTime := c.GetString("end_time")
  6062. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6063. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6064. //timeLayout := "2006-01-02"
  6065. //loc, _ := time.LoadLocation("Local")
  6066. //var theStartTIme int64
  6067. //if len(startTime) > 0 {
  6068. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6069. // if err != nil {
  6070. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6071. // return
  6072. // }
  6073. // theStartTIme = theTime.Unix()
  6074. //}
  6075. //var theEndtTIme int64
  6076. //if len(endTime) > 0 {
  6077. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6078. // if err != nil {
  6079. // utils.ErrorLog(err.Error())
  6080. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6081. // return
  6082. // }
  6083. // theEndtTIme = theTime.Unix()
  6084. //}
  6085. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6086. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6087. for _, team := range datas {
  6088. fmt.Println(team.PsnTime)
  6089. for _, team_two := range datas_two {
  6090. fmt.Println(team_two.PsnTime)
  6091. if team.FundKey == team_two.FundKey {
  6092. fmt.Println(team_two.PsnTime)
  6093. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6094. fmt.Println(team.PsnTime)
  6095. }
  6096. }
  6097. }
  6098. fmt.Println("1111")
  6099. fmt.Println(datas)
  6100. fmt.Println("1111")
  6101. var twos []models.FixMonRecDetailFileInTwo
  6102. for _, team := range datas {
  6103. var two models.FixMonRecDetailFileInTwo
  6104. two.MedType = team.MedType
  6105. two.Insutype = team.Insutype
  6106. two.PsnType = team.PsnType
  6107. two.MedType = team.MedType
  6108. two.FixBlngAdmdvs = "999999"
  6109. two.InsuAdmdvs = "555555"
  6110. two.PsnTime = team.PsnTime
  6111. two.PsnCnt = team.PsnCnt
  6112. two.FundKey = team.FundKey
  6113. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6114. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6115. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6116. two.MedfeeSumAmt = ms
  6117. two.InscpAmt = ia
  6118. two.FundPaySumAmt = fps
  6119. twos = append(twos, two)
  6120. }
  6121. //startTime := c.GetString("start_time")
  6122. //endTime, _ := c.GetString("end_time")
  6123. times := strings.Split(startTime, "-")
  6124. stmt_mon := times[0] + times[1]
  6125. var funs []models.FundDetail
  6126. for _, item := range datas {
  6127. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6128. funs = append(funs, fun...)
  6129. }
  6130. var funInfos []models.Fund
  6131. //for _, item := range funs {
  6132. // var rf []models.FundInfo
  6133. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6134. // for _, subitem := range rf {
  6135. // var fund models.Fund
  6136. // fund.FundCode = subitem.FundPayType
  6137. // fund.FundName = subitem.FundPayTypeName
  6138. // fund.FundAmt = subitem.FundPayAmt
  6139. // fund.FundKey = item.FundKey
  6140. // fund.InsuAdmdvs = "555555"
  6141. // fund.FixBlngAdmdvs = "999999"
  6142. // funInfos = append(funInfos, fund)
  6143. // }
  6144. //}
  6145. var tempFuns []TempFun
  6146. for _, funInfo := range funInfos {
  6147. var tempFun TempFun
  6148. tempFun.FundKey = funInfo.FundKey
  6149. tempFun.FundCode = funInfo.FundCode
  6150. tempFuns = append(tempFuns, tempFun)
  6151. }
  6152. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6153. fmt.Println(tempFuns)
  6154. var funInfosTwo []models.Fund
  6155. decimal.DivisionPrecision = 2
  6156. for _, item := range tempFuns {
  6157. var fund models.Fund
  6158. for _, subItem := range funInfos {
  6159. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6160. fund.FundKey = subItem.FundKey
  6161. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6162. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6163. fund.FundName = subItem.FundName
  6164. fund.FundCode = subItem.FundCode
  6165. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6166. }
  6167. }
  6168. funInfosTwo = append(funInfosTwo, fund)
  6169. }
  6170. fmt.Println("funInfosTwo")
  6171. fmt.Println(funInfosTwo)
  6172. var upld_btch string
  6173. var empty models.JSResultEmpty
  6174. data := make(map[string]interface{})
  6175. data["org_name"] = miConfig.OrgName
  6176. data["doctor"] = curRoles.UserName
  6177. data["doctor_name"] = curRoles.UserName
  6178. data["fixmedins_code"] = miConfig.Code
  6179. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6180. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6181. data["secret_key"] = miConfig.SecretKey
  6182. data["url"] = miConfig.Url
  6183. data["ak"] = miConfig.AccessKey
  6184. data["cainfo"] = miConfig.Cainfo
  6185. data["datas"] = twos
  6186. data["fund"] = funInfosTwo
  6187. fmt.Println(twos)
  6188. month := time.Unix(1557042972, 0).Format("1")
  6189. year := time.Now().Format("2006")
  6190. month = time.Now().Format("01")
  6191. day := time.Now().Format("02")
  6192. hour := time.Now().Format("15")
  6193. min := time.Now().Format("04")
  6194. sec := time.Now().Format("05")
  6195. fix_fill_date := year + month + day + hour + min + sec
  6196. data["fix_fill_dept"] = miConfig.OrgName
  6197. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6198. data["fix_fill_psn"] = curRoles.UserName
  6199. data["fix_fill_date"] = fix_fill_date
  6200. data["stmt_loc"] = "2"
  6201. data["setl_mon"] = stmt_mon
  6202. upld_btch = "0"
  6203. data["upld_btch"] = upld_btch
  6204. //fmt.Println(data)
  6205. client := &http.Client{}
  6206. bytesData, _ := json.Marshal(data)
  6207. var req *http.Request
  6208. if miConfig.MdtrtareaAdmvs == "320921" {
  6209. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6210. } else {
  6211. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6212. }
  6213. resp, _ := client.Do(req)
  6214. defer resp.Body.Close()
  6215. body, ioErr := ioutil.ReadAll(resp.Body)
  6216. if ioErr != nil {
  6217. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6219. }
  6220. var respJSON map[string]interface{}
  6221. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6222. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6224. }
  6225. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6226. //fmt.Println(respJSON)
  6227. result, _ := json.Marshal(respJSON)
  6228. //fmt.Println(result)
  6229. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6230. utils.ErrorLog("解析失败:%v", err)
  6231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6232. }
  6233. if empty.Infcode != "0" {
  6234. c.ServeSuccessJSON(map[string]interface{}{
  6235. "failed_code": -10,
  6236. "msg": empty.ErrMsg,
  6237. })
  6238. return
  6239. } else {
  6240. c.ServeSuccessJSON(map[string]interface{}{
  6241. "msg": "上传成功",
  6242. })
  6243. return
  6244. }
  6245. }
  6246. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6247. newArr = make([]TempFun, 0)
  6248. for i := 0; i < len(arr); i++ {
  6249. repeat := false
  6250. for j := i + 1; j < len(arr); j++ {
  6251. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6252. repeat = true
  6253. break
  6254. }
  6255. }
  6256. if !repeat {
  6257. newArr = append(newArr, arr[i])
  6258. }
  6259. }
  6260. return
  6261. }
  6262. func (c *HisApiController) Get3263() {
  6263. admin_user_id, _ := c.GetInt64("admin_user_id")
  6264. startTime := c.GetString("start_time")
  6265. //endTime, _ := c.GetString("end_time")
  6266. times := strings.Split(startTime, "-")
  6267. setl_mon := times[0] + times[1]
  6268. upld_btch := "0"
  6269. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6270. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6271. var result3263 models.JSResult3263
  6272. data := make(map[string]interface{})
  6273. data["org_name"] = miConfig.OrgName
  6274. data["doctor"] = curRoles.UserName
  6275. data["doctor_name"] = curRoles.UserName
  6276. data["fixmedins_code"] = miConfig.Code
  6277. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6278. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6279. data["secret_key"] = miConfig.SecretKey
  6280. data["url"] = miConfig.Url
  6281. data["ak"] = miConfig.AccessKey
  6282. data["cainfo"] = miConfig.Cainfo
  6283. data["setl_mon"] = setl_mon
  6284. data["stmt_loc"] = "2"
  6285. data["upld_btch"] = upld_btch
  6286. client := &http.Client{}
  6287. bytesData, _ := json.Marshal(data)
  6288. var req *http.Request
  6289. if miConfig.MdtrtareaAdmvs == "320921" {
  6290. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6291. } else {
  6292. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6293. }
  6294. resp, _ := client.Do(req)
  6295. defer resp.Body.Close()
  6296. body, ioErr := ioutil.ReadAll(resp.Body)
  6297. if ioErr != nil {
  6298. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6300. }
  6301. var respJSON map[string]interface{}
  6302. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6305. }
  6306. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6307. fmt.Println(respJSON)
  6308. result, _ := json.Marshal(respJSON)
  6309. fmt.Println(result)
  6310. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6311. utils.ErrorLog("解析失败:%v", err)
  6312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6313. }
  6314. if result3263.Infcode != "0" {
  6315. c.ServeSuccessJSON(map[string]interface{}{
  6316. "failed_code": -10,
  6317. "msg": result3263.ErrMsg,
  6318. })
  6319. return
  6320. } else {
  6321. c.ServeSuccessJSON(map[string]interface{}{
  6322. "list": result3263.Output,
  6323. })
  6324. return
  6325. }
  6326. }
  6327. func (c *HisApiController) Get3264() {
  6328. admin_user_id, _ := c.GetInt64("admin_user_id")
  6329. startTime := c.GetString("start_time")
  6330. //endTime, _ := c.GetString("end_time")
  6331. times := strings.Split(startTime, "-")
  6332. setl_mon := times[0] + times[1]
  6333. upld_btch := "0"
  6334. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6335. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6336. //solidify_id := []
  6337. var result3263 models.JSResult3263
  6338. data := make(map[string]interface{})
  6339. data["org_name"] = miConfig.OrgName
  6340. data["doctor"] = curRoles.UserName
  6341. data["doctor_name"] = curRoles.UserName
  6342. data["fixmedins_code"] = miConfig.Code
  6343. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6344. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6345. data["secret_key"] = miConfig.SecretKey
  6346. data["url"] = miConfig.Url
  6347. data["ak"] = miConfig.AccessKey
  6348. data["cainfo"] = miConfig.Cainfo
  6349. data["setl_mon"] = setl_mon
  6350. data["stmt_loc"] = "2"
  6351. data["upld_btch"] = upld_btch
  6352. client := &http.Client{}
  6353. bytesData, _ := json.Marshal(data)
  6354. var req3263 *http.Request
  6355. if miConfig.MdtrtareaAdmvs == "320921" {
  6356. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6357. } else {
  6358. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6359. }
  6360. resp, _ := client.Do(req3263)
  6361. defer resp.Body.Close()
  6362. body, ioErr := ioutil.ReadAll(resp.Body)
  6363. if ioErr != nil {
  6364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6366. }
  6367. var respJSON3263 map[string]interface{}
  6368. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6371. }
  6372. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6373. fmt.Println(respJSON3263)
  6374. result, _ := json.Marshal(respJSON3263)
  6375. fmt.Println(result)
  6376. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6377. utils.ErrorLog("解析失败:%v", err)
  6378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6379. }
  6380. var ids []string
  6381. for _, item := range result3263.Output {
  6382. ids = append(ids, item.SolidifyID)
  6383. }
  6384. var empty models.JSResultEmpty
  6385. data2 := make(map[string]interface{})
  6386. data2["org_name"] = miConfig.OrgName
  6387. data2["doctor"] = curRoles.UserName
  6388. data2["doctor_name"] = curRoles.UserName
  6389. data2["fixmedins_code"] = miConfig.Code
  6390. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6391. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6392. data2["secret_key"] = miConfig.SecretKey
  6393. data2["url"] = miConfig.Url
  6394. data2["ak"] = miConfig.AccessKey
  6395. data2["cainfo"] = miConfig.Cainfo
  6396. data2["setl_mon"] = setl_mon
  6397. data2["stmt_loc"] = "2"
  6398. data2["upld_btch"] = upld_btch
  6399. data2["solidify_id"] = ids
  6400. client2 := &http.Client{}
  6401. bytesData2, _ := json.Marshal(data2)
  6402. var req *http.Request
  6403. if miConfig.MdtrtareaAdmvs == "320921" {
  6404. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6405. } else {
  6406. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6407. }
  6408. resp2, _ := client2.Do(req)
  6409. defer resp.Body.Close()
  6410. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6411. if ioErr2 != nil {
  6412. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6414. }
  6415. var respJSON map[string]interface{}
  6416. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6419. }
  6420. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6421. fmt.Println(respJSON)
  6422. result2, _ := json.Marshal(respJSON)
  6423. fmt.Println(result2)
  6424. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6425. utils.ErrorLog("解析失败:%v", err)
  6426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6427. }
  6428. if empty.Infcode != "0" {
  6429. c.ServeSuccessJSON(map[string]interface{}{
  6430. "failed_code": -10,
  6431. "msg": empty.ErrMsg,
  6432. })
  6433. return
  6434. } else {
  6435. c.ServeSuccessJSON(map[string]interface{}{
  6436. "msg": "",
  6437. })
  6438. return
  6439. }
  6440. }
  6441. func (c *HisApiController) Get3265() {
  6442. admin_user_id, _ := c.GetInt64("admin_user_id")
  6443. startTime := c.GetString("start_time")
  6444. //endTime, _ := c.GetString("end_time")
  6445. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6446. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6447. times := strings.Split(startTime, "-")
  6448. setl_mon := times[0] + times[1]
  6449. var upld_btch string
  6450. upld_btch = "0"
  6451. //var empty models.JSResultEmpty
  6452. var result3265 models.JSResult3264
  6453. var result3263 models.JSResult3263
  6454. data2 := make(map[string]interface{})
  6455. data2["org_name"] = miConfig.OrgName
  6456. data2["doctor"] = curRoles.UserName
  6457. data2["doctor_name"] = curRoles.UserName
  6458. data2["fixmedins_code"] = miConfig.Code
  6459. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6460. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6461. data2["secret_key"] = miConfig.SecretKey
  6462. data2["url"] = miConfig.Url
  6463. data2["ak"] = miConfig.AccessKey
  6464. data2["cainfo"] = miConfig.Cainfo
  6465. data2["setl_mon"] = setl_mon
  6466. data2["stmt_loc"] = "2"
  6467. data2["upld_btch"] = upld_btch
  6468. client2 := &http.Client{}
  6469. bytesData2, _ := json.Marshal(data2)
  6470. var req3263 *http.Request
  6471. if miConfig.MdtrtareaAdmvs == "320921" {
  6472. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6473. } else {
  6474. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6475. }
  6476. resp2, _ := client2.Do(req3263)
  6477. defer resp2.Body.Close()
  6478. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6479. if ioErr2 != nil {
  6480. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6482. }
  6483. var respJSON3263 map[string]interface{}
  6484. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6485. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6487. }
  6488. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6489. fmt.Println(respJSON3263)
  6490. result2, _ := json.Marshal(respJSON3263)
  6491. fmt.Println(result2)
  6492. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6493. utils.ErrorLog("解析失败:%v", err)
  6494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6495. }
  6496. var ids []string
  6497. for _, item := range result3263.Output {
  6498. ids = append(ids, item.SolidifyID)
  6499. }
  6500. data := make(map[string]interface{})
  6501. data["org_name"] = miConfig.OrgName
  6502. data["doctor"] = curRoles.UserName
  6503. data["doctor_name"] = curRoles.UserName
  6504. data["fixmedins_code"] = miConfig.Code
  6505. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6506. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6507. data["secret_key"] = miConfig.SecretKey
  6508. data["url"] = miConfig.Url
  6509. data["ak"] = miConfig.AccessKey
  6510. data["cainfo"] = miConfig.Cainfo
  6511. data["setl_mon"] = setl_mon
  6512. data["solidify_id"] = ids
  6513. month := time.Unix(1557042972, 0).Format("1")
  6514. year := time.Now().Format("2006")
  6515. month = time.Now().Format("01")
  6516. day := time.Now().Format("02")
  6517. hour := time.Now().Format("15")
  6518. min := time.Now().Format("04")
  6519. sec := time.Now().Format("05")
  6520. fix_fill_date := year + month + day + hour + min + sec
  6521. data["fix_fill_dept"] = miConfig.OrgName
  6522. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6523. data["fix_fill_psn"] = curRoles.UserName
  6524. data["fix_fill_date"] = fix_fill_date
  6525. data["stmt_loc"] = "2"
  6526. data["upld_btch"] = upld_btch
  6527. client := &http.Client{}
  6528. bytesData, _ := json.Marshal(data)
  6529. var req *http.Request
  6530. if miConfig.MdtrtareaAdmvs == "320921" {
  6531. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6532. } else {
  6533. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6534. }
  6535. resp, _ := client.Do(req)
  6536. defer resp.Body.Close()
  6537. body, ioErr := ioutil.ReadAll(resp.Body)
  6538. if ioErr != nil {
  6539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6541. }
  6542. var respJSON map[string]interface{}
  6543. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6544. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6546. }
  6547. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6548. fmt.Println(respJSON)
  6549. result, _ := json.Marshal(respJSON)
  6550. fmt.Println(result)
  6551. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6552. utils.ErrorLog("解析失败:%v", err)
  6553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6554. }
  6555. if result3265.Infcode != "0" {
  6556. c.ServeSuccessJSON(map[string]interface{}{
  6557. "failed_code": -10,
  6558. "msg": result3265.ErrMsg,
  6559. })
  6560. return
  6561. } else {
  6562. c.ServeSuccessJSON(map[string]interface{}{
  6563. "info": result3265.Output,
  6564. })
  6565. return
  6566. }
  6567. }
  6568. func (c *HisApiController) Get3266() {
  6569. admin_user_id, _ := c.GetInt64("admin_user_id")
  6570. startTime := c.GetString("start_time")
  6571. //endTime, _ := c.GetString("end_time")
  6572. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6573. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6574. times := strings.Split(startTime, "-")
  6575. stmt_mon := times[0] + times[1]
  6576. var upld_btch string
  6577. //var empty models.JSResultEmpty
  6578. var result3265 models.JSResult3264
  6579. data := make(map[string]interface{})
  6580. data["org_name"] = miConfig.OrgName
  6581. data["doctor"] = curRoles.UserName
  6582. data["doctor_name"] = curRoles.UserName
  6583. data["fixmedins_code"] = miConfig.Code
  6584. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6585. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6586. data["secret_key"] = miConfig.SecretKey
  6587. data["url"] = miConfig.Url
  6588. data["ak"] = miConfig.AccessKey
  6589. data["cainfo"] = miConfig.Cainfo
  6590. data["setl_mon"] = stmt_mon
  6591. month := time.Unix(1557042972, 0).Format("1")
  6592. year := time.Now().Format("2006")
  6593. month = time.Now().Format("01")
  6594. day := time.Now().Format("02")
  6595. hour := time.Now().Format("15")
  6596. min := time.Now().Format("04")
  6597. sec := time.Now().Format("05")
  6598. fix_fill_date := year + month + day + hour + min + sec
  6599. data["fix_fill_dept"] = miConfig.OrgName
  6600. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6601. data["fix_fill_psn"] = curRoles.UserName
  6602. data["fix_fill_date"] = fix_fill_date
  6603. data["stmt_loc"] = "2"
  6604. upld_btch = "0"
  6605. data["upld_btch"] = upld_btch
  6606. client := &http.Client{}
  6607. bytesData, _ := json.Marshal(data)
  6608. var req *http.Request
  6609. if miConfig.MdtrtareaAdmvs == "320921" {
  6610. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6611. } else {
  6612. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6613. }
  6614. resp, _ := client.Do(req)
  6615. defer resp.Body.Close()
  6616. body, ioErr := ioutil.ReadAll(resp.Body)
  6617. if ioErr != nil {
  6618. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6620. }
  6621. var respJSON map[string]interface{}
  6622. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6625. }
  6626. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6627. fmt.Println(respJSON)
  6628. result, _ := json.Marshal(respJSON)
  6629. fmt.Println(result)
  6630. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6631. utils.ErrorLog("解析失败:%v", err)
  6632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6633. }
  6634. if result3265.Infcode != "0" {
  6635. c.ServeSuccessJSON(map[string]interface{}{
  6636. "failed_code": -10,
  6637. "msg": result3265.ErrMsg,
  6638. })
  6639. return
  6640. } else {
  6641. c.ServeSuccessJSON(map[string]interface{}{
  6642. "info": result3265.Output,
  6643. })
  6644. return
  6645. }
  6646. }
  6647. func (c *HisApiController) Get3267() {
  6648. admin_user_id, _ := c.GetInt64("admin_user_id")
  6649. startTime := c.GetString("start_time")
  6650. //endTime, _ := c.GetString("end_time")
  6651. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6652. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6653. times := strings.Split(startTime, "-")
  6654. setl_mon := times[0] + times[1]
  6655. var upld_btch string
  6656. //var empty models.JSResultEmpty
  6657. var result3265 models.JSResult3264
  6658. upld_btch = "0"
  6659. data := make(map[string]interface{})
  6660. data["org_name"] = miConfig.OrgName
  6661. data["doctor"] = curRoles.UserName
  6662. data["doctor_name"] = curRoles.UserName
  6663. data["fixmedins_code"] = miConfig.Code
  6664. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6665. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6666. data["secret_key"] = miConfig.SecretKey
  6667. data["url"] = miConfig.Url
  6668. data["ak"] = miConfig.AccessKey
  6669. data["cainfo"] = miConfig.Cainfo
  6670. data["setl_mon"] = setl_mon
  6671. data["stmt_loc"] = "2"
  6672. data["upld_btch"] = upld_btch
  6673. client := &http.Client{}
  6674. bytesData, _ := json.Marshal(data)
  6675. var req *http.Request
  6676. if miConfig.MdtrtareaAdmvs == "320921" {
  6677. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6678. } else {
  6679. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6680. }
  6681. resp, _ := client.Do(req)
  6682. defer resp.Body.Close()
  6683. body, ioErr := ioutil.ReadAll(resp.Body)
  6684. if ioErr != nil {
  6685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6687. }
  6688. var respJSON map[string]interface{}
  6689. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6692. }
  6693. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6694. fmt.Println(respJSON)
  6695. result, _ := json.Marshal(respJSON)
  6696. fmt.Println(result)
  6697. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6698. utils.ErrorLog("解析失败:%v", err)
  6699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6700. }
  6701. if result3265.Infcode != "0" {
  6702. c.ServeSuccessJSON(map[string]interface{}{
  6703. "failed_code": -10,
  6704. "msg": result3265.ErrMsg,
  6705. })
  6706. return
  6707. } else {
  6708. c.ServeSuccessJSON(map[string]interface{}{
  6709. "info": result3265.Output.Data,
  6710. })
  6711. return
  6712. }
  6713. }
  6714. func (c *HisApiController) Get3268() {
  6715. admin_user_id, _ := c.GetInt64("admin_user_id")
  6716. startTime := c.GetString("start_time")
  6717. endTime := c.GetString("end_time")
  6718. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6719. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6720. times := strings.Split(startTime, "-")
  6721. setl_mon := times[0] + times[1]
  6722. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6723. var twos []models.FixMonRecDetailFileInTwo
  6724. var funs []models.FundDetail
  6725. for _, item := range datas {
  6726. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6727. funs = append(funs, fun...)
  6728. }
  6729. var funInfos []models.Fund
  6730. //for _, item := range funs {
  6731. // var rf []models.FundInfo
  6732. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6733. // for _, subitem := range rf {
  6734. // var fund models.Fund
  6735. // fund.FundCode = subitem.FundPayType
  6736. // fund.FundName = subitem.FundPayTypeName
  6737. // fund.FundAmt = subitem.FundPayAmt
  6738. // fund.FundKey = item.FundKey
  6739. // fund.InsuAdmdvs = "555555"
  6740. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6741. // funInfos = append(funInfos, fund)
  6742. // }
  6743. //}
  6744. for _, team := range datas {
  6745. var two models.FixMonRecDetailFileInTwo
  6746. two.SetlDate = time.Now().Format("2006-01-02")
  6747. two.MedType = team.MedType
  6748. two.Insutype = team.Insutype
  6749. two.PsnType = team.PsnType
  6750. two.MedType = team.MedType
  6751. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6752. two.InsuAdmdvs = team.InsuAdmdvs
  6753. two.PsnTime = team.PsnTime
  6754. two.PsnCnt = team.PsnCnt
  6755. two.FundKey = team.FundKey
  6756. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6757. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6758. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6759. two.MedfeeSumAmt = ms
  6760. two.InscpAmt = ia
  6761. two.FundPaySumAmt = fps
  6762. twos = append(twos, two)
  6763. }
  6764. var upld_btch string
  6765. upld_btch = "0"
  6766. var empty models.JSResultEmpty
  6767. data := make(map[string]interface{})
  6768. data["org_name"] = miConfig.OrgName
  6769. data["doctor"] = curRoles.UserName
  6770. data["doctor_name"] = curRoles.UserName
  6771. data["fixmedins_code"] = miConfig.Code
  6772. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6773. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6774. data["secret_key"] = miConfig.SecretKey
  6775. data["url"] = miConfig.Url
  6776. data["ak"] = miConfig.AccessKey
  6777. data["cainfo"] = miConfig.Cainfo
  6778. data["datas"] = twos
  6779. data["fund"] = funInfos
  6780. data["setl_mon"] = setl_mon
  6781. month := time.Unix(1557042972, 0).Format("1")
  6782. year := time.Now().Format("2006")
  6783. month = time.Now().Format("01")
  6784. day := time.Now().Format("02")
  6785. hour := time.Now().Format("15")
  6786. min := time.Now().Format("04")
  6787. sec := time.Now().Format("05")
  6788. fix_fill_date := year + month + day + hour + min + sec
  6789. data["fix_fill_dept"] = miConfig.OrgName
  6790. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6791. data["fix_fill_psn"] = curRoles.UserName
  6792. data["fix_fill_date"] = fix_fill_date
  6793. data["stmt_loc"] = "2"
  6794. data["upld_btch"] = upld_btch
  6795. client := &http.Client{}
  6796. bytesData, _ := json.Marshal(data)
  6797. var req *http.Request
  6798. if miConfig.MdtrtareaAdmvs == "320921" {
  6799. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6800. } else {
  6801. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6802. }
  6803. resp, _ := client.Do(req)
  6804. defer resp.Body.Close()
  6805. body, ioErr := ioutil.ReadAll(resp.Body)
  6806. if ioErr != nil {
  6807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6809. }
  6810. var respJSON map[string]interface{}
  6811. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6814. }
  6815. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6816. fmt.Println(respJSON)
  6817. result, _ := json.Marshal(respJSON)
  6818. fmt.Println(result)
  6819. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6820. utils.ErrorLog("解析失败:%v", err)
  6821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6822. }
  6823. if empty.Infcode != "0" {
  6824. c.ServeSuccessJSON(map[string]interface{}{
  6825. "failed_code": -10,
  6826. "msg": empty.ErrMsg,
  6827. })
  6828. return
  6829. } else {
  6830. c.ServeSuccessJSON(map[string]interface{}{
  6831. "msg": "上传成功",
  6832. })
  6833. return
  6834. }
  6835. }
  6836. func (c *HisApiController) Get3269() {
  6837. admin_user_id, _ := c.GetInt64("admin_user_id")
  6838. startTime := c.GetString("start_time")
  6839. //endTime, _ := c.GetString("end_time")
  6840. times := strings.Split(startTime, "-")
  6841. setl_mon := times[0] + times[1]
  6842. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6843. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6844. var result3263 models.JSResult3263
  6845. data := make(map[string]interface{})
  6846. data["org_name"] = miConfig.OrgName
  6847. data["doctor"] = curRoles.UserName
  6848. data["doctor_name"] = curRoles.UserName
  6849. data["fixmedins_code"] = miConfig.Code
  6850. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6851. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6852. data["secret_key"] = miConfig.SecretKey
  6853. data["url"] = miConfig.Url
  6854. data["ak"] = miConfig.AccessKey
  6855. data["cainfo"] = miConfig.Cainfo
  6856. data["setl_mon"] = setl_mon
  6857. data["stmt_loc"] = "2"
  6858. client := &http.Client{}
  6859. bytesData, _ := json.Marshal(data)
  6860. var req *http.Request
  6861. if miConfig.MdtrtareaAdmvs == "320921" {
  6862. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6863. } else {
  6864. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6865. }
  6866. resp, _ := client.Do(req)
  6867. defer resp.Body.Close()
  6868. body, ioErr := ioutil.ReadAll(resp.Body)
  6869. if ioErr != nil {
  6870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6872. }
  6873. var respJSON map[string]interface{}
  6874. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6877. }
  6878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6879. fmt.Println(respJSON)
  6880. result, _ := json.Marshal(respJSON)
  6881. fmt.Println(result)
  6882. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6883. utils.ErrorLog("解析失败:%v", err)
  6884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6885. }
  6886. if result3263.Infcode != "0" {
  6887. c.ServeSuccessJSON(map[string]interface{}{
  6888. "failed_code": -10,
  6889. "msg": result3263.ErrMsg,
  6890. })
  6891. return
  6892. } else {
  6893. c.ServeSuccessJSON(map[string]interface{}{
  6894. "msg": "上传成功",
  6895. })
  6896. return
  6897. }
  6898. }
  6899. func (c *HisApiController) Get3270() {
  6900. admin_user_id, _ := c.GetInt64("admin_user_id")
  6901. startTime := c.GetString("start_time")
  6902. //endTime, _ := c.GetString("end_time")
  6903. times := strings.Split(startTime, "-")
  6904. setl_mon := times[0] + times[1]
  6905. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6906. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6907. var result3263 models.JSResult3263
  6908. data2 := make(map[string]interface{})
  6909. data2["org_name"] = miConfig.OrgName
  6910. data2["doctor"] = curRoles.UserName
  6911. data2["doctor_name"] = curRoles.UserName
  6912. data2["fixmedins_code"] = miConfig.Code
  6913. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6914. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6915. data2["secret_key"] = miConfig.SecretKey
  6916. data2["url"] = miConfig.Url
  6917. data2["ak"] = miConfig.AccessKey
  6918. data2["cainfo"] = miConfig.Cainfo
  6919. data2["setl_mon"] = setl_mon
  6920. data2["stmt_loc"] = "2"
  6921. client2 := &http.Client{}
  6922. bytesData2, _ := json.Marshal(data2)
  6923. var req3263 *http.Request
  6924. if miConfig.MdtrtareaAdmvs == "320921" {
  6925. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6926. } else {
  6927. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6928. }
  6929. resp2, _ := client2.Do(req3263)
  6930. defer resp2.Body.Close()
  6931. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6932. if ioErr2 != nil {
  6933. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6935. }
  6936. var respJSON3263 map[string]interface{}
  6937. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6940. }
  6941. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6942. fmt.Println(respJSON3263)
  6943. result2, _ := json.Marshal(respJSON3263)
  6944. fmt.Println(result2)
  6945. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6946. utils.ErrorLog("解析失败:%v", err)
  6947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6948. }
  6949. var ids []string
  6950. for _, item := range result3263.Output {
  6951. ids = append(ids, item.SolidifyID)
  6952. }
  6953. var result3264 models.JSResult3264
  6954. data := make(map[string]interface{})
  6955. data["org_name"] = miConfig.OrgName
  6956. data["doctor"] = curRoles.UserName
  6957. data["doctor_name"] = curRoles.UserName
  6958. data["fixmedins_code"] = miConfig.Code
  6959. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6960. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6961. data["secret_key"] = miConfig.SecretKey
  6962. data["url"] = miConfig.Url
  6963. data["ak"] = miConfig.AccessKey
  6964. data["cainfo"] = miConfig.Cainfo
  6965. data["setl_mon"] = setl_mon
  6966. data["stmt_loc"] = "2"
  6967. data["solidify_id"] = ids
  6968. client := &http.Client{}
  6969. bytesData, _ := json.Marshal(data)
  6970. var req *http.Request
  6971. if miConfig.MdtrtareaAdmvs == "320921" {
  6972. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6973. } else {
  6974. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6975. }
  6976. resp, _ := client.Do(req)
  6977. defer resp.Body.Close()
  6978. body, ioErr := ioutil.ReadAll(resp.Body)
  6979. if ioErr != nil {
  6980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6982. }
  6983. var respJSON map[string]interface{}
  6984. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6987. }
  6988. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6989. fmt.Println(respJSON)
  6990. result, _ := json.Marshal(respJSON)
  6991. fmt.Println(result)
  6992. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  6993. utils.ErrorLog("解析失败:%v", err)
  6994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6995. }
  6996. if result3264.Infcode != "0" {
  6997. c.ServeSuccessJSON(map[string]interface{}{
  6998. "failed_code": -10,
  6999. "msg": result3264.ErrMsg,
  7000. })
  7001. return
  7002. } else {
  7003. c.ServeSuccessJSON(map[string]interface{}{
  7004. "info": result3264.Output,
  7005. })
  7006. return
  7007. }
  7008. }
  7009. func (c *HisApiController) Get3271() {
  7010. admin_user_id, _ := c.GetInt64("admin_user_id")
  7011. startTime := c.GetString("start_time")
  7012. //endTime, _ := c.GetString("end_time")
  7013. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7014. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7015. times := strings.Split(startTime, "-")
  7016. setl_mon := times[0] + times[1]
  7017. //var empty models.JSResultEmpty
  7018. var result3265 models.JSResult3264
  7019. var result3263 models.JSResult3263
  7020. data2 := make(map[string]interface{})
  7021. data2["org_name"] = miConfig.OrgName
  7022. data2["doctor"] = curRoles.UserName
  7023. data2["doctor_name"] = curRoles.UserName
  7024. data2["fixmedins_code"] = miConfig.Code
  7025. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7026. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7027. data2["secret_key"] = miConfig.SecretKey
  7028. data2["url"] = miConfig.Url
  7029. data2["ak"] = miConfig.AccessKey
  7030. data2["cainfo"] = miConfig.Cainfo
  7031. data2["setl_mon"] = setl_mon
  7032. data2["stmt_loc"] = "2"
  7033. client2 := &http.Client{}
  7034. bytesData2, _ := json.Marshal(data2)
  7035. var req3263 *http.Request
  7036. if miConfig.MdtrtareaAdmvs == "320921" {
  7037. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7038. } else {
  7039. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7040. }
  7041. resp2, _ := client2.Do(req3263)
  7042. defer resp2.Body.Close()
  7043. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7044. if ioErr2 != nil {
  7045. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7047. }
  7048. var respJSON3263 map[string]interface{}
  7049. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7050. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7052. }
  7053. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7054. fmt.Println(respJSON3263)
  7055. result2, _ := json.Marshal(respJSON3263)
  7056. fmt.Println(result2)
  7057. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7058. utils.ErrorLog("解析失败:%v", err)
  7059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7060. }
  7061. var ids []string
  7062. for _, item := range result3263.Output {
  7063. ids = append(ids, item.SolidifyID)
  7064. }
  7065. data := make(map[string]interface{})
  7066. data["org_name"] = miConfig.OrgName
  7067. data["doctor"] = curRoles.UserName
  7068. data["doctor_name"] = curRoles.UserName
  7069. data["fixmedins_code"] = miConfig.Code
  7070. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7071. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7072. data["secret_key"] = miConfig.SecretKey
  7073. data["url"] = miConfig.Url
  7074. data["ak"] = miConfig.AccessKey
  7075. data["cainfo"] = miConfig.Cainfo
  7076. data["setl_mon"] = setl_mon
  7077. data["solidify_id"] = ids
  7078. month := time.Unix(1557042972, 0).Format("1")
  7079. year := time.Now().Format("2006")
  7080. month = time.Now().Format("01")
  7081. day := time.Now().Format("02")
  7082. hour := time.Now().Format("15")
  7083. min := time.Now().Format("04")
  7084. sec := time.Now().Format("05")
  7085. fix_fill_date := year + month + day + hour + min + sec
  7086. data["fix_fill_dept"] = miConfig.OrgName
  7087. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7088. data["fix_fill_psn"] = curRoles.UserName
  7089. data["fix_fill_date"] = fix_fill_date
  7090. data["stmt_loc"] = "2"
  7091. client := &http.Client{}
  7092. bytesData, _ := json.Marshal(data)
  7093. var req *http.Request
  7094. if miConfig.MdtrtareaAdmvs == "320921" {
  7095. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7096. } else {
  7097. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7098. }
  7099. resp, _ := client.Do(req)
  7100. defer resp.Body.Close()
  7101. body, ioErr := ioutil.ReadAll(resp.Body)
  7102. if ioErr != nil {
  7103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7105. }
  7106. var respJSON map[string]interface{}
  7107. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7110. }
  7111. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7112. fmt.Println(respJSON)
  7113. result, _ := json.Marshal(respJSON)
  7114. fmt.Println(result)
  7115. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7116. utils.ErrorLog("解析失败:%v", err)
  7117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7118. }
  7119. if result3265.Infcode != "0" {
  7120. c.ServeSuccessJSON(map[string]interface{}{
  7121. "failed_code": -10,
  7122. "msg": result3265.ErrMsg,
  7123. })
  7124. return
  7125. } else {
  7126. c.ServeSuccessJSON(map[string]interface{}{
  7127. "info": result3265.Output.Data,
  7128. })
  7129. return
  7130. }
  7131. }
  7132. func (c *HisApiController) Get3272() {
  7133. admin_user_id, _ := c.GetInt64("admin_user_id")
  7134. startTime := c.GetString("start_time")
  7135. //endTime, _ := c.GetString("end_time")
  7136. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7137. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7138. times := strings.Split(startTime, "-")
  7139. setl_mon := times[0] + times[1]
  7140. var upld_btch string
  7141. //var empty models.JSResultEmpty
  7142. var result3265 models.JSResult3264
  7143. data := make(map[string]interface{})
  7144. data["org_name"] = miConfig.OrgName
  7145. data["doctor"] = curRoles.UserName
  7146. data["doctor_name"] = curRoles.UserName
  7147. data["fixmedins_code"] = miConfig.Code
  7148. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7149. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7150. data["secret_key"] = miConfig.SecretKey
  7151. data["url"] = miConfig.Url
  7152. data["ak"] = miConfig.AccessKey
  7153. data["cainfo"] = miConfig.Cainfo
  7154. data["setl_mon"] = setl_mon
  7155. month := time.Unix(1557042972, 0).Format("1")
  7156. year := time.Now().Format("2006")
  7157. month = time.Now().Format("01")
  7158. day := time.Now().Format("02")
  7159. hour := time.Now().Format("15")
  7160. min := time.Now().Format("04")
  7161. sec := time.Now().Format("05")
  7162. fix_fill_date := year + month + day + hour + min + sec
  7163. data["fix_fill_dept"] = miConfig.OrgName
  7164. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7165. data["fix_fill_psn"] = curRoles.UserName
  7166. data["fix_fill_date"] = fix_fill_date
  7167. data["stmt_loc"] = "2"
  7168. data["upld_btch"] = upld_btch
  7169. client := &http.Client{}
  7170. bytesData, _ := json.Marshal(data)
  7171. var req *http.Request
  7172. if miConfig.MdtrtareaAdmvs == "320921" {
  7173. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7174. } else {
  7175. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7176. }
  7177. resp, _ := client.Do(req)
  7178. defer resp.Body.Close()
  7179. body, ioErr := ioutil.ReadAll(resp.Body)
  7180. if ioErr != nil {
  7181. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7183. }
  7184. var respJSON map[string]interface{}
  7185. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7188. }
  7189. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7190. fmt.Println(respJSON)
  7191. result, _ := json.Marshal(respJSON)
  7192. fmt.Println(result)
  7193. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7194. utils.ErrorLog("解析失败:%v", err)
  7195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7196. }
  7197. if result3265.Infcode != "0" {
  7198. c.ServeSuccessJSON(map[string]interface{}{
  7199. "failed_code": -10,
  7200. "msg": result3265.ErrMsg,
  7201. })
  7202. return
  7203. } else {
  7204. c.ServeSuccessJSON(map[string]interface{}{
  7205. "info": result3265.Output,
  7206. })
  7207. return
  7208. }
  7209. }
  7210. func (c *HisApiController) Get3273() {
  7211. admin_user_id, _ := c.GetInt64("admin_user_id")
  7212. startTime := c.GetString("start_time")
  7213. //endTime, _ := c.GetString("end_time")
  7214. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7215. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7216. times := strings.Split(startTime, "-")
  7217. setl_mon := times[0] + times[1]
  7218. var result3265 models.JSResult3264
  7219. data := make(map[string]interface{})
  7220. data["org_name"] = miConfig.OrgName
  7221. data["doctor"] = curRoles.UserName
  7222. data["doctor_name"] = curRoles.UserName
  7223. data["fixmedins_code"] = miConfig.Code
  7224. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7225. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7226. data["secret_key"] = miConfig.SecretKey
  7227. data["url"] = miConfig.Url
  7228. data["ak"] = miConfig.AccessKey
  7229. data["cainfo"] = miConfig.Cainfo
  7230. data["setl_mon"] = setl_mon
  7231. data["stmt_loc"] = "2"
  7232. client := &http.Client{}
  7233. bytesData, _ := json.Marshal(data)
  7234. var req *http.Request
  7235. if miConfig.MdtrtareaAdmvs == "320921" {
  7236. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7237. } else {
  7238. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7239. }
  7240. resp, _ := client.Do(req)
  7241. defer resp.Body.Close()
  7242. body, ioErr := ioutil.ReadAll(resp.Body)
  7243. if ioErr != nil {
  7244. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7246. }
  7247. var respJSON map[string]interface{}
  7248. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7251. }
  7252. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7253. fmt.Println(respJSON)
  7254. result, _ := json.Marshal(respJSON)
  7255. fmt.Println(result)
  7256. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7257. utils.ErrorLog("解析失败:%v", err)
  7258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7259. }
  7260. if result3265.Infcode != "0" {
  7261. c.ServeSuccessJSON(map[string]interface{}{
  7262. "failed_code": -10,
  7263. "msg": result3265.ErrMsg,
  7264. })
  7265. return
  7266. } else {
  7267. c.ServeSuccessJSON(map[string]interface{}{
  7268. "info": result3265.Output.Data,
  7269. })
  7270. return
  7271. }
  7272. }
  7273. func (c *HisApiController) Get3274() {
  7274. //if miConfig.MdtrtareaAdmvs == "320921" {
  7275. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7276. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7277. // "&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
  7278. //
  7279. //} else {
  7280. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7281. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7282. // "&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
  7283. //
  7284. //}
  7285. }
  7286. func (c *HisApiController) Get3275() {
  7287. //if miConfig.MdtrtareaAdmvs == "320921" {
  7288. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7289. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7290. // "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  7291. //
  7292. //} else {
  7293. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7294. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7295. // "&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
  7296. //
  7297. //}
  7298. }
  7299. func (c *HisApiController) Get3276() {
  7300. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7301. //month := c.GetString("month")
  7302. //
  7303. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7304. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7305. //var api string
  7306. //var res Result5301
  7307. //
  7308. //if miConfig.MdtrtareaAdmvs == "320921" {
  7309. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7310. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7311. //} else {
  7312. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7313. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7314. //}
  7315. //
  7316. //resp, requestErr := http.Get(api)
  7317. //if requestErr != nil {
  7318. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7319. // return
  7320. //}
  7321. //
  7322. //body, ioErr := ioutil.ReadAll(resp.Body)
  7323. //if ioErr != nil {
  7324. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7325. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7326. // return
  7327. //}
  7328. //var respJSON map[string]interface{}
  7329. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7330. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7331. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7332. // return
  7333. //}
  7334. //
  7335. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7336. //result, _ := json.Marshal(respJSON)
  7337. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7338. // utils.ErrorLog("解析失败:%v", err)
  7339. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7340. // return
  7341. //}
  7342. }
  7343. func (c *HisApiController) Get3277() {
  7344. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7345. //month := c.GetString("month")
  7346. //
  7347. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7348. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7349. //var api string
  7350. //var res Result5301
  7351. //
  7352. //if miConfig.MdtrtareaAdmvs == "320921" {
  7353. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7354. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7355. //} else {
  7356. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7357. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7358. //}
  7359. //
  7360. //resp, requestErr := http.Get(api)
  7361. //if requestErr != nil {
  7362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7363. // return
  7364. //}
  7365. //
  7366. //body, ioErr := ioutil.ReadAll(resp.Body)
  7367. //if ioErr != nil {
  7368. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7369. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7370. // return
  7371. //}
  7372. //var respJSON map[string]interface{}
  7373. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7374. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7375. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7376. // return
  7377. //}
  7378. //
  7379. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7380. //result, _ := json.Marshal(respJSON)
  7381. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7382. // utils.ErrorLog("解析失败:%v", err)
  7383. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7384. // return
  7385. //}
  7386. }
  7387. func (c *HisApiController) GetCFYLJG001() {
  7388. admin_user_id, _ := c.GetInt64("admin_user_id")
  7389. patient_id, _ := c.GetInt64("patient_id")
  7390. his_patient_id, _ := c.GetInt64("his_patient_id")
  7391. record_time := c.GetString("record_time")
  7392. admin_user_id = 3626
  7393. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7394. psn, _ := service.GetPsnByPatientId(patient_id)
  7395. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7396. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7397. var cFYLJG001 models.CFYLJG001
  7398. timeLayout := "2006-01-02"
  7399. loc, _ := time.LoadLocation("Local")
  7400. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7401. if err != nil {
  7402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7403. return
  7404. }
  7405. recordDateTime := theTime.Unix()
  7406. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7407. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7408. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7409. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7410. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7411. for _, item := range prescriptions {
  7412. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7413. if his.IdCardType == 1 {
  7414. bas := strings.Split(psn.CardInfo, "|")
  7415. basNumber := bas[1]
  7416. fmt.Println(basNumber)
  7417. card_sn := bas[3]
  7418. card_no := bas[2]
  7419. cFYLJG001.MdtrtCertType = "03"
  7420. cFYLJG001.CardSn = card_sn
  7421. cFYLJG001.MdtrtCertNo = card_no
  7422. cFYLJG001.EcToken = ""
  7423. cFYLJG001.AuthNo = ""
  7424. } else if his.IdCardType == 2 {
  7425. cFYLJG001.MdtrtCertType = "02"
  7426. cFYLJG001.CardSn = ""
  7427. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7428. cFYLJG001.EcToken = ""
  7429. cFYLJG001.AuthNo = ""
  7430. } else if his.IdCardType == 4 {
  7431. cFYLJG001.MdtrtCertType = "01"
  7432. cFYLJG001.CardSn = ""
  7433. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7434. cFYLJG001.EcToken = psn.VerifyNumber
  7435. cFYLJG001.AuthNo = ""
  7436. }
  7437. cFYLJG001.BizTypeCode = "01"
  7438. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7439. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7440. cFYLJG001.RxTypeCode = "1"
  7441. tempTime := time.Unix(item.PreTime, 0)
  7442. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7443. cFYLJG001.PrscTime = timeFormatOne
  7444. var count float64
  7445. if item.Type == 1 {
  7446. for _, sumItem := range item.HisDoctorAdviceInfo {
  7447. count = count + sumItem.PrescribingNumber
  7448. }
  7449. }
  7450. cFYLJG001.RxDrugCnt = count
  7451. cFYLJG001.ValiDays = "5"
  7452. ts := time.Unix(item.PreTime, 0)
  7453. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7454. tempTime3 := time.Unix(record_time2, 0)
  7455. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7456. cFYLJG001.ValiEndTime = timeFormat3
  7457. cFYLJG001.RxCotnFlag = "0"
  7458. for _, subItem := range item.HisDoctorAdviceInfo {
  7459. var drug models.RxDrug
  7460. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7461. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7462. drug.RxItemTypeCode = "11"
  7463. drug.DrugDosform = "乳膏剂" //TODO
  7464. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7465. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7466. }
  7467. drug.MedcWayDscr = subItem.DeliveryWay
  7468. tempTime2 := time.Unix(subItem.StartTime, 0)
  7469. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7470. drug.MedcBegntime = timeFormatTwo
  7471. if subItem.Day > 0 {
  7472. ts := time.Unix(subItem.StartTime, 0)
  7473. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7474. tempTime4 := time.Unix(record_time, 0)
  7475. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7476. drug.MedcEndtime = timeFormat5
  7477. } else {
  7478. tempTime2 := time.Unix(subItem.StartTime, 0)
  7479. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7480. drug.MedcEndtime = timeFormatTwo
  7481. }
  7482. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7483. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7484. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7485. drug.DrugCnt = subItem.PrescribingNumber
  7486. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7487. drug.DrugGenname = subItem.AdviceName
  7488. drug.MedcWayCodg = subItem.DeliveryWay
  7489. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7490. drug.SinDoscnt = subItem.SingleDose
  7491. drug.SinDosunt = subItem.SingleDoseUnit
  7492. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7493. drug.UsedFrquName = subItem.ExecutionFrequency
  7494. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7495. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7496. drug.HospApprFlag = "1"
  7497. cFYLJG001.List = append(cFYLJG001.List, drug)
  7498. }
  7499. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7500. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7501. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7502. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7503. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7504. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7505. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7506. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7507. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7508. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7509. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7510. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7511. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7512. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7513. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7514. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7515. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7516. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7517. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7518. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7519. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7520. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7521. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7522. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7523. tempTime2 := time.Now().Unix()
  7524. tempTime6 := time.Unix(tempTime2, 0)
  7525. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7526. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7527. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7528. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7529. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7530. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7531. //memo := make(map[string]interface{})
  7532. //inputData := make(map[string]interface{}, 0)
  7533. //type MyData struct {
  7534. // Insutype string `json:"insutype"`
  7535. //}
  7536. //
  7537. // data := MyData{
  7538. // Insutype: his.Insutype,
  7539. //}
  7540. //
  7541. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7542. var config []*models.HisXtDiagnoseConfig
  7543. for _, item := range diagnosis_ids {
  7544. id, _ := strconv.ParseInt(item, 10, 64)
  7545. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7546. config = append(config, &diagnosisConfig)
  7547. }
  7548. for index, subitem := range config {
  7549. if index == 0 {
  7550. var dia models.DiseInfo
  7551. dia.DiagType = "1"
  7552. dia.MaindiagFlag = "1"
  7553. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7554. dia.DiagCode = subitem.CountryCode
  7555. dia.DiagName = subitem.ClassName
  7556. dia.DiagDept = "肾内科"
  7557. dia.DiagDrNo = doctor.DoctorNumber
  7558. dia.DiagDrName = doctor.UserName
  7559. tempTime3 := time.Unix(item.PreTime, 0)
  7560. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7561. dia.DiagTime = timeFormatTwo
  7562. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7563. } else {
  7564. var dia models.DiseInfo
  7565. dia.DiagType = "1"
  7566. dia.MaindiagFlag = "0"
  7567. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7568. dia.DiagCode = subitem.CountryCode
  7569. dia.DiagName = subitem.ClassName
  7570. dia.DiagDept = "肾内科"
  7571. dia.DiagDrNo = doctor.DoctorNumber
  7572. dia.DiagDrName = doctor.UserName
  7573. tempTime3 := time.Unix(item.PreTime, 0)
  7574. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7575. dia.DiagTime = timeFormatTwo
  7576. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7577. }
  7578. }
  7579. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7580. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7581. var res ResultCFYLJG001
  7582. var respJSON2 map[string]interface{}
  7583. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7586. return
  7587. }
  7588. userJSONBytes2, _ := json.Marshal(respJSON2)
  7589. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7590. utils.ErrorLog("解析失败:%v", err)
  7591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7592. return
  7593. }
  7594. if res.Infcode == -1 {
  7595. c.ServeSuccessJSON(map[string]interface{}{
  7596. "failed_code": -10,
  7597. "msg": res.ErrMsg,
  7598. })
  7599. return
  7600. } else {
  7601. var flow models.HisPrescriptionFlow
  7602. flow.Ctime = time.Now().Unix()
  7603. flow.SignDigest = ""
  7604. flow.RxTraceCode = res.Output.RxTraceCode
  7605. flow.HiRxno = res.Output.HiRxno
  7606. flow.MID = his.Number
  7607. flow.Status = 1
  7608. flow.DCode = doctor_info.DoctorNumber
  7609. flow.OriginalRxFile = ""
  7610. flow.OriginalValue = ""
  7611. flow.SignCertDn = ""
  7612. flow.UserOrgId = 10454
  7613. flow.SignCertSn = ""
  7614. flow.Mtime = time.Now().Unix()
  7615. service.Createflow(&flow)
  7616. c.ServeSuccessJSON(map[string]interface{}{
  7617. "msg": "上传成功",
  7618. })
  7619. }
  7620. }
  7621. }
  7622. func (c *HisApiController) GetCFYLJG002() {
  7623. admin_user_id, _ := c.GetInt64("admin_user_id")
  7624. his_patient_id, _ := c.GetInt64("his_patient_id")
  7625. record_time := c.GetString("record_time")
  7626. admin_user_id = 3626
  7627. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7628. //id, _ := c.GetInt64("id")
  7629. admin_user_id = 3626
  7630. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7631. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7632. flow, _ := service.Getflowtwo(his.Number)
  7633. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7634. //record_time := c.GetString("record_time")
  7635. patient_id, _ := c.GetInt64("patient_id")
  7636. //patient_id = 23834
  7637. //record_time = "2023-09-18"
  7638. timeLayout := "2006-01-02"
  7639. loc, _ := time.LoadLocation("Local")
  7640. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7641. if err != nil {
  7642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7643. return
  7644. }
  7645. recordDateTime := theTime.Unix()
  7646. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7647. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7648. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7649. dept, _ := service.GetDepartMentDetail(info.Departments)
  7650. inputData := make(map[string]interface{})
  7651. inputData["rxTraceCode"] = flow.RxTraceCode
  7652. inputData["hiRxno"] = flow.HiRxno
  7653. inputData["mdtrtId"] = flow.MID
  7654. inputData["patnName"] = his.PsnName
  7655. inputData["psnCertType"] = his.PsnCertType
  7656. inputData["certno"] = his.Certno
  7657. inputData["fixmedinsName"] = miConfig.OrgName
  7658. inputData["fixmedinsCode"] = miConfig.Code
  7659. inputData["drCode"] = doctor_info.DoctorNumber
  7660. inputData["prscDrName"] = doctor_info.UserName
  7661. inputData["pharDeptName"] = dept.Name
  7662. inputData["pharDeptCode"] = dept.Number
  7663. inputData["pharProfttlCodg"] = dept.Name
  7664. inputData["pharProfttlName"] = ""
  7665. inputData["pharCode"] = "HY440309002107"
  7666. inputData["pharCertType"] = "01"
  7667. inputData["pharCertno"] = "430482199408260023"
  7668. inputData["pharName"] = "彭斯遥"
  7669. inputData["pharPracCertNo"] = ""
  7670. tempTime2 := time.Unix(info.Ctime, 0)
  7671. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7672. inputData["pharChkTime"] = timeFormatTwo
  7673. bytesData, _ := json.Marshal(inputData)
  7674. fmt.Println(string(bytesData))
  7675. encoded := base64.StdEncoding.EncodeToString(bytesData)
  7676. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7677. if err != nil {
  7678. fmt.Println("Error reading PDF file:", err)
  7679. return
  7680. }
  7681. // 将 PDF 文件内容进行 Base64 编码
  7682. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7683. fmt.Println(err)
  7684. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7685. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7686. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7687. var res2 Result002
  7688. var respJSON2 map[string]interface{}
  7689. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7692. return
  7693. }
  7694. userJSONBytes2, _ := json.Marshal(respJSON2)
  7695. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7696. utils.ErrorLog("解析失败:%v", err)
  7697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7698. return
  7699. }
  7700. if res2.Infcode == 0 {
  7701. flow.Ctime = time.Now().Unix()
  7702. flow.SignDigest = res2.Output.SignDigest
  7703. flow.RxFile = res2.Output.RxFile
  7704. flow.MID = his.Number
  7705. flow.Status = 1
  7706. flow.DCode = doctor_info.DoctorNumber
  7707. flow.OriginalRxFile = rx_encoded
  7708. flow.OriginalValue = encoded
  7709. flow.SignCertDn = res2.Output.SignCertDn
  7710. flow.SignCertSn = res2.Output.SignCertSn
  7711. flow.Mtime = time.Now().Unix()
  7712. service.Saveflow(flow)
  7713. c.ServeSuccessJSON(map[string]interface{}{
  7714. "msg": "预签名成功",
  7715. })
  7716. } else {
  7717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7718. return
  7719. }
  7720. }
  7721. func (c *HisApiController) GetCFYLJG003() {
  7722. admin_user_id, _ := c.GetInt64("admin_user_id")
  7723. his_patient_id, _ := c.GetInt64("his_patient_id")
  7724. record_time := c.GetString("record_time")
  7725. admin_user_id = 3626
  7726. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7727. //id, _ := c.GetInt64("id")
  7728. admin_user_id = 3626
  7729. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7730. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7731. flow, _ := service.Getflowtwo(his.Number)
  7732. //id = 3
  7733. patient_id, _ := c.GetInt64("patient_id")
  7734. //patient_id = 23834
  7735. //record_time = "2023-09-18"
  7736. timeLayout := "2006-01-02"
  7737. loc, _ := time.LoadLocation("Local")
  7738. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7739. if err != nil {
  7740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7741. return
  7742. }
  7743. recordDateTime := theTime.Unix()
  7744. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7745. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7746. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7747. dept, _ := service.GetDepartMentDetail(info.Departments)
  7748. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7749. var cFYLJG003 models.CFYLJG003
  7750. cFYLJG003.RxTraceCode = flow.RxTraceCode
  7751. cFYLJG003.HiRxno = flow.HiRxno
  7752. cFYLJG003.MdtrtID = flow.MID
  7753. cFYLJG003.PatnName = his.Name
  7754. cFYLJG003.Certno = his.Certno
  7755. cFYLJG003.FixmedinsName = miConfig.OrgName
  7756. cFYLJG003.FixmedinsCode = miConfig.Code
  7757. cFYLJG003.DrCode = doctor_info.DoctorNumber
  7758. cFYLJG003.PrscDrName = doctor_info.UserName
  7759. cFYLJG003.PharDeptName = dept.Name
  7760. cFYLJG003.PharDeptCode = dept.Number
  7761. cFYLJG003.PharCode = "HY440309002107"
  7762. cFYLJG003.PharCertType = "01"
  7763. cFYLJG003.PharCertno = "430482199408260023"
  7764. cFYLJG003.PharName = "彭斯遥"
  7765. cFYLJG003.PsnCertType = "01"
  7766. cFYLJG003.RxFile = flow.RxFile
  7767. cFYLJG003.SignDigest = flow.SignDigest
  7768. cFYLJG003.FixmedinsCode = miConfig.Code
  7769. cFYLJG003.PsnCertType = "01"
  7770. cFYLJG003.PharProfttlCodg = dept.Name
  7771. //inputData["pharProfttlCodg"] =dept.Name
  7772. tempTime2 := time.Unix(info.Ctime, 0)
  7773. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7774. cFYLJG003.PharChkTime = timeFormatTwo
  7775. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7776. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7777. var res ResultCFYLJG003
  7778. var respJSON2 map[string]interface{}
  7779. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7782. return
  7783. }
  7784. userJSONBytes2, _ := json.Marshal(respJSON2)
  7785. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7786. utils.ErrorLog("解析失败:%v", err)
  7787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7788. return
  7789. }
  7790. if res.Infcode == -1 {
  7791. c.ServeSuccessJSON(map[string]interface{}{
  7792. "failed_code": -10,
  7793. "msg": res.ErrMsg,
  7794. })
  7795. return
  7796. } else {
  7797. c.ServeSuccessJSON(map[string]interface{}{
  7798. "info": res.Output,
  7799. })
  7800. }
  7801. }
  7802. func (c *HisApiController) GetCFYLJG004() {
  7803. admin_user_id, _ := c.GetInt64("admin_user_id")
  7804. his_patient_id, _ := c.GetInt64("his_patient_id")
  7805. record_time := c.GetString("record_time")
  7806. admin_user_id = 3626
  7807. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7808. //id, _ := c.GetInt64("id")
  7809. admin_user_id = 3626
  7810. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7811. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7812. flow, _ := service.Getflowtwo(his.Number)
  7813. //id = 3
  7814. patient_id, _ := c.GetInt64("patient_id")
  7815. //patient_id = 23834
  7816. //record_time = "2023-09-18"
  7817. timeLayout := "2006-01-02"
  7818. loc, _ := time.LoadLocation("Local")
  7819. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7820. if err != nil {
  7821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7822. return
  7823. }
  7824. recordDateTime := theTime.Unix()
  7825. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7826. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7827. var cFYLJG004 models.CFYLJG004
  7828. cFYLJG004.HiRxno = flow.HiRxno
  7829. cFYLJG004.FixmedinsCode = miConfig.Code
  7830. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7831. cFYLJG004.UndoDrCertType = "01"
  7832. cFYLJG004.UndoRea = "撤销处方"
  7833. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7834. cFYLJG004.UndoDrName = doctor_info.UserName
  7835. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7836. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7837. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7838. var res ResultCFYLJG004
  7839. var respJSON2 map[string]interface{}
  7840. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7843. return
  7844. }
  7845. userJSONBytes2, _ := json.Marshal(respJSON2)
  7846. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7847. utils.ErrorLog("解析失败:%v", err)
  7848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7849. return
  7850. }
  7851. if res.Infcode == -1 {
  7852. c.ServeSuccessJSON(map[string]interface{}{
  7853. "failed_code": -10,
  7854. "msg": res.ErrMsg,
  7855. })
  7856. return
  7857. } else {
  7858. flow.Status = 0
  7859. service.Saveflow(flow)
  7860. c.ServeSuccessJSON(map[string]interface{}{
  7861. "msg": "撤销成功",
  7862. })
  7863. return
  7864. }
  7865. }
  7866. func (c *HisApiController) GetCFYLJG005() {
  7867. admin_user_id, _ := c.GetInt64("admin_user_id")
  7868. his_patient_id, _ := c.GetInt64("his_patient_id")
  7869. //record_time := c.GetString("record_time")
  7870. admin_user_id = 3626
  7871. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7872. //id, _ := c.GetInt64("id")
  7873. admin_user_id = 3626
  7874. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7875. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7876. flow, _ := service.Getflowtwo(his.Number)
  7877. //id = 3
  7878. var cFYLJG005 models.CFYLJG005
  7879. //patient_id, _ := c.GetInt64("patient_id")
  7880. cFYLJG005.HiRxno = flow.HiRxno
  7881. cFYLJG005.MdtrtID = flow.MID
  7882. cFYLJG005.EcToken = ""
  7883. cFYLJG005.PsnName = his.Name
  7884. cFYLJG005.PsnCertType = "01"
  7885. cFYLJG005.Certno = his.IdCardNo
  7886. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7887. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7888. var res ResultCFYLJG005
  7889. var respJSON2 map[string]interface{}
  7890. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7893. return
  7894. }
  7895. userJSONBytes2, _ := json.Marshal(respJSON2)
  7896. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7897. utils.ErrorLog("解析失败:%v", err)
  7898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7899. return
  7900. }
  7901. if res.Infcode == -1 {
  7902. c.ServeSuccessJSON(map[string]interface{}{
  7903. "failed_code": -10,
  7904. "msg": res.ErrMsg,
  7905. })
  7906. return
  7907. } else {
  7908. c.ServeSuccessJSON(map[string]interface{}{
  7909. "info": res.Output,
  7910. })
  7911. return
  7912. }
  7913. }
  7914. func (c *HisApiController) GetCFYLJG006() {
  7915. admin_user_id, _ := c.GetInt64("admin_user_id")
  7916. his_patient_id, _ := c.GetInt64("his_patient_id")
  7917. admin_user_id = 3626
  7918. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7919. //id, _ := c.GetInt64("id")
  7920. admin_user_id = 3626
  7921. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7922. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7923. flow, _ := service.Getflowtwo(his.Number)
  7924. //id = 3
  7925. patient_id, _ := c.GetInt64("patient_id")
  7926. var cFYLJG006 models.CFYLJG006
  7927. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7928. cFYLJG006.HiRxno = flow.HiRxno
  7929. cFYLJG006.MdtrtID = flow.MID
  7930. cFYLJG006.PsnName = patient.Name
  7931. cFYLJG006.PsnCertType = "01"
  7932. cFYLJG006.Certno = patient.IdCardNo
  7933. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  7934. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  7935. var res ResultCFYLJG006
  7936. var respJSON2 map[string]interface{}
  7937. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7940. return
  7941. }
  7942. userJSONBytes2, _ := json.Marshal(respJSON2)
  7943. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7944. utils.ErrorLog("解析失败:%v", err)
  7945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7946. return
  7947. }
  7948. if res.Infcode == -1 {
  7949. c.ServeSuccessJSON(map[string]interface{}{
  7950. "failed_code": -10,
  7951. "msg": res.ErrMsg,
  7952. })
  7953. return
  7954. } else {
  7955. c.ServeSuccessJSON(map[string]interface{}{
  7956. "info": res.Output,
  7957. })
  7958. return
  7959. }
  7960. }
  7961. func (c *HisApiController) GetCFYLJG007() {
  7962. admin_user_id, _ := c.GetInt64("admin_user_id")
  7963. his_patient_id, _ := c.GetInt64("his_patient_id")
  7964. admin_user_id = 3626
  7965. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7966. //id, _ := c.GetInt64("id")
  7967. admin_user_id = 3626
  7968. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7969. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7970. flow, _ := service.Getflowtwo(his.Number)
  7971. //id = 3
  7972. patient_id, _ := c.GetInt64("patient_id")
  7973. var cFYLJG007 models.CFYLJG007
  7974. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7975. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7976. cFYLJG007.HiRxno = flow.HiRxno
  7977. cFYLJG007.MdtrtID = flow.MID
  7978. cFYLJG007.PsnNo = his.PsnNo
  7979. cFYLJG007.PsnCertType = "01"
  7980. cFYLJG007.Certno = patient.IdCardNo
  7981. cFYLJG007.PsnName = patient.Name
  7982. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  7983. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  7984. var res ResultCFYLJG007
  7985. var respJSON2 map[string]interface{}
  7986. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7989. return
  7990. }
  7991. userJSONBytes2, _ := json.Marshal(respJSON2)
  7992. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7993. utils.ErrorLog("解析失败:%v", err)
  7994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7995. return
  7996. }
  7997. if res.Infcode == -1 {
  7998. c.ServeSuccessJSON(map[string]interface{}{
  7999. "failed_code": -10,
  8000. "msg": res.ErrMsg,
  8001. })
  8002. return
  8003. } else {
  8004. c.ServeSuccessJSON(map[string]interface{}{
  8005. "info": res,
  8006. })
  8007. return
  8008. }
  8009. }
  8010. func (c *HisApiController) GetCFYLJG008() {
  8011. admin_user_id, _ := c.GetInt64("admin_user_id")
  8012. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8013. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8014. var cFYLJG008 models.CFYLJG008
  8015. //id, _ := c.GetInt64("id")
  8016. patient_id, _ := c.GetInt64("patient_id")
  8017. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8018. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8019. //id = 3
  8020. //flow, _ := service.Getflow(id)
  8021. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8022. //
  8023. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8024. //patient_id, _ := c.GetInt64("patient_id")
  8025. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8026. record_time := c.GetString("record_time")
  8027. admin_user_id = 3626
  8028. patient_id = 19424
  8029. //his_patient_id = 263947
  8030. record_time = "2023-08-29"
  8031. timeLayout := "2006-01-02"
  8032. loc, _ := time.LoadLocation("Local")
  8033. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8034. if err != nil {
  8035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8036. return
  8037. }
  8038. recordDateTime := theTime.Unix()
  8039. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8040. cFYLJG008.FixmedinsName = ""
  8041. cFYLJG008.Lat = ""
  8042. cFYLJG008.Lng = ""
  8043. cFYLJG008.OrderType = "1"
  8044. cFYLJG008.PoolareaNo = ""
  8045. cFYLJG008.Lng = ""
  8046. cFYLJG008.PageNum = 1
  8047. cFYLJG008.PageSize = 10
  8048. var MPI models.MedinsProdInvChgDDTO
  8049. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8050. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8051. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8052. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8053. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8054. var res ResultCFYLJG008
  8055. var respJSON2 map[string]interface{}
  8056. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8059. return
  8060. }
  8061. userJSONBytes2, _ := json.Marshal(respJSON2)
  8062. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8063. utils.ErrorLog("解析失败:%v", err)
  8064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8065. return
  8066. }
  8067. if res.Infcode == -1 {
  8068. c.ServeSuccessJSON(map[string]interface{}{
  8069. "failed_code": -10,
  8070. "msg": res.ErrMsg,
  8071. })
  8072. return
  8073. } else {
  8074. c.ServeSuccessJSON(map[string]interface{}{
  8075. "info": res.Output,
  8076. })
  8077. return
  8078. }
  8079. }
  8080. func (c *HisApiController) GetBL4201A() {
  8081. order_id, _ := c.GetInt64("order_id")
  8082. admin_user_id, _ := c.GetInt64("admin_user_id")
  8083. order, _ := service.GetHisOrderByIDTwo(order_id)
  8084. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8085. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8086. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8087. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8088. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8089. department, _ := service.GetDepartMentDetail(his.Departments)
  8090. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8091. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8092. if order.ID == 0 {
  8093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8094. return
  8095. }
  8096. var struct4201A models.Struct4201A
  8097. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8098. for _, items := range order_info {
  8099. memo := make(map[string]interface{})
  8100. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8101. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8102. fsiOPFLD.MedType = "14"
  8103. fsiOPFLD.BkkpSn = items.FeedetlSn
  8104. fsiOPFLD.FixmedinsCode = miConfig.Code
  8105. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8106. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8107. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8108. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8109. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8110. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8111. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8112. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8113. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8114. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8115. fsiOPFLD.BilgDeptName = department.Name
  8116. fsiOPFLD.BilgDeptCodg = department.Number
  8117. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8118. fsiOPFLD.BilgDrName = doctor.UserName
  8119. fsiOPFLD.MedChrgitmType = "09"
  8120. memo["hosp_appr_flag"] = "1"
  8121. memo["invoice_no"] = order.MdtrtId
  8122. memo["memo"] = "自费"
  8123. bytesData, _ := json.Marshal(memo)
  8124. fsiOPFLD.Memo = string(bytesData)
  8125. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8126. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8127. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8128. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8129. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8130. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8131. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8132. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8133. fsiOPFLD.BilgDeptName = department.Name
  8134. fsiOPFLD.BilgDeptCodg = department.Number
  8135. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8136. fsiOPFLD.BilgDrName = doctor.UserName
  8137. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8138. case 0:
  8139. break
  8140. case 1:
  8141. fsiOPFLD.MedChrgitmType = "14"
  8142. break
  8143. case 2:
  8144. fsiOPFLD.MedChrgitmType = "05"
  8145. break
  8146. case 3:
  8147. fsiOPFLD.MedChrgitmType = "03"
  8148. break
  8149. case 4:
  8150. fsiOPFLD.MedChrgitmType = "03"
  8151. break
  8152. case 5:
  8153. fsiOPFLD.MedChrgitmType = "08"
  8154. break
  8155. case 6:
  8156. fsiOPFLD.MedChrgitmType = "14"
  8157. break
  8158. case 7:
  8159. fsiOPFLD.MedChrgitmType = "14"
  8160. break
  8161. case 8:
  8162. fsiOPFLD.MedChrgitmType = "03"
  8163. break
  8164. case 9:
  8165. fsiOPFLD.MedChrgitmType = "14"
  8166. break
  8167. case 10:
  8168. fsiOPFLD.MedChrgitmType = "14"
  8169. break
  8170. case 11:
  8171. fsiOPFLD.MedChrgitmType = "06"
  8172. break
  8173. case 12:
  8174. fsiOPFLD.MedChrgitmType = "12"
  8175. break
  8176. case 13:
  8177. fsiOPFLD.MedChrgitmType = "01"
  8178. break
  8179. case 14:
  8180. fsiOPFLD.MedChrgitmType = "04"
  8181. break
  8182. case 15:
  8183. fsiOPFLD.MedChrgitmType = "14"
  8184. break
  8185. }
  8186. memo["hosp_appr_flag"] = "1"
  8187. memo["invoice_no"] = order.MdtrtId
  8188. memo["memo"] = "自费"
  8189. bytesData, _ := json.Marshal(memo)
  8190. fsiOPFLD.Memo = string(bytesData)
  8191. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8192. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8193. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8194. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8195. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8196. fsiOPFLD.BilgDeptName = department.Name
  8197. fsiOPFLD.BilgDeptCodg = department.Number
  8198. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8199. fsiOPFLD.BilgDrName = doctor.UserName
  8200. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8201. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8202. fsiOPFLD.MedChrgitmType = "08"
  8203. memo["hosp_appr_flag"] = "1"
  8204. memo["invoice_no"] = order.MdtrtId
  8205. memo["memo"] = "自费"
  8206. bytesData, _ := json.Marshal(memo)
  8207. fsiOPFLD.Memo = string(bytesData)
  8208. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8209. }
  8210. }
  8211. }
  8212. for _, items := range order_info_two {
  8213. memo := make(map[string]interface{})
  8214. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8215. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8216. fsiOPFLD.MedType = "14"
  8217. fsiOPFLD.BkkpSn = items.FeedetlSn
  8218. fsiOPFLD.FixmedinsCode = miConfig.Code
  8219. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8220. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8221. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8222. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8223. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8224. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8225. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8226. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8227. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8228. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8229. fsiOPFLD.BilgDeptName = department.Name
  8230. fsiOPFLD.BilgDeptCodg = department.Number
  8231. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8232. fsiOPFLD.BilgDrName = doctor.UserName
  8233. fsiOPFLD.MedChrgitmType = "09"
  8234. memo["hosp_appr_flag"] = "1"
  8235. memo["invoice_no"] = order.MdtrtId
  8236. memo["memo"] = "自费"
  8237. bytesData, _ := json.Marshal(memo)
  8238. fsiOPFLD.Memo = string(bytesData)
  8239. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8240. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8241. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8242. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8243. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8244. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8245. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8246. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8247. fsiOPFLD.BilgDeptName = department.Name
  8248. fsiOPFLD.BilgDeptCodg = department.Number
  8249. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8250. fsiOPFLD.BilgDrName = doctor.UserName
  8251. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8252. case 0:
  8253. break
  8254. case 1:
  8255. fsiOPFLD.MedChrgitmType = "14"
  8256. break
  8257. case 2:
  8258. fsiOPFLD.MedChrgitmType = "05"
  8259. break
  8260. case 3:
  8261. fsiOPFLD.MedChrgitmType = "03"
  8262. break
  8263. case 4:
  8264. fsiOPFLD.MedChrgitmType = "03"
  8265. break
  8266. case 5:
  8267. fsiOPFLD.MedChrgitmType = "08"
  8268. break
  8269. case 6:
  8270. fsiOPFLD.MedChrgitmType = "14"
  8271. break
  8272. case 7:
  8273. fsiOPFLD.MedChrgitmType = "14"
  8274. break
  8275. case 8:
  8276. fsiOPFLD.MedChrgitmType = "03"
  8277. break
  8278. case 9:
  8279. fsiOPFLD.MedChrgitmType = "14"
  8280. break
  8281. case 10:
  8282. fsiOPFLD.MedChrgitmType = "14"
  8283. break
  8284. case 11:
  8285. fsiOPFLD.MedChrgitmType = "06"
  8286. break
  8287. case 12:
  8288. fsiOPFLD.MedChrgitmType = "12"
  8289. break
  8290. case 13:
  8291. fsiOPFLD.MedChrgitmType = "01"
  8292. break
  8293. case 14:
  8294. fsiOPFLD.MedChrgitmType = "04"
  8295. break
  8296. case 15:
  8297. fsiOPFLD.MedChrgitmType = "14"
  8298. break
  8299. }
  8300. memo["hosp_appr_flag"] = "1"
  8301. memo["invoice_no"] = order.MdtrtId
  8302. memo["memo"] = "自费"
  8303. bytesData, _ := json.Marshal(memo)
  8304. fsiOPFLD.Memo = string(bytesData)
  8305. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8306. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8307. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8308. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8309. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8310. fsiOPFLD.BilgDeptName = department.Name
  8311. fsiOPFLD.BilgDeptCodg = department.Number
  8312. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8313. fsiOPFLD.BilgDrName = doctor.UserName
  8314. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8315. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8316. fsiOPFLD.MedChrgitmType = "08"
  8317. memo["hosp_appr_flag"] = "1"
  8318. memo["invoice_no"] = order.MdtrtId
  8319. memo["memo"] = "自费"
  8320. bytesData, _ := json.Marshal(memo)
  8321. fsiOPFLD.Memo = string(bytesData)
  8322. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8323. }
  8324. }
  8325. }
  8326. fmt.Println(fsiOPFLDs)
  8327. struct4201A.Fopfd = fsiOPFLDs
  8328. fmt.Println(struct4201A.Fopfd)
  8329. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8330. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8331. var res2 ResultSix
  8332. var respJSON2 map[string]interface{}
  8333. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8336. return
  8337. }
  8338. userJSONBytes2, _ := json.Marshal(respJSON2)
  8339. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8340. utils.ErrorLog("解析失败:%v", err)
  8341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8342. return
  8343. }
  8344. if res2.Infcode != 0 {
  8345. c.ServeSuccessJSON(map[string]interface{}{
  8346. "failed_code": -10,
  8347. "msg": res2.ErrMsg,
  8348. })
  8349. return
  8350. } else {
  8351. order.IsUploadOrderInfo = 1
  8352. service.UpdateOrder(order)
  8353. c.ServeSuccessJSON(map[string]interface{}{
  8354. "msg": "上传成功",
  8355. })
  8356. }
  8357. }
  8358. func (c *HisApiController) Get2505() {
  8359. admin_user_id, _ := c.GetInt64("admin_user_id")
  8360. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  8361. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8362. 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)
  8363. }
  8364. func (c *HisApiController) Get4201A() {
  8365. order_id, _ := c.GetInt64("order_id")
  8366. admin_user_id, _ := c.GetInt64("admin_user_id")
  8367. order, _ := service.GetHisOrderByIDTwo(order_id)
  8368. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8369. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8370. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8371. //order_info = append(order_info, order_info_two...)
  8372. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8373. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8374. department, _ := service.GetDepartMentDetail(his.Departments)
  8375. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8376. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8377. if order.ID == 0 {
  8378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8379. return
  8380. }
  8381. var struct4201A models.Struct4201A
  8382. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8383. for _, items := range order_info {
  8384. memo := make(map[string]interface{})
  8385. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8386. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8387. fsiOPFLD.MedType = "14"
  8388. fsiOPFLD.BkkpSn = items.FeedetlSn
  8389. fsiOPFLD.FixmedinsCode = miConfig.Code
  8390. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8391. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8392. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8393. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8394. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8395. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8396. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8397. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8398. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8399. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8400. fsiOPFLD.BilgDeptName = department.Name
  8401. fsiOPFLD.BilgDeptCodg = department.Number
  8402. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8403. fsiOPFLD.BilgDrName = doctor.UserName
  8404. fsiOPFLD.MedChrgitmType = "09"
  8405. memo["hosp_appr_flag"] = "1"
  8406. memo["invoice_no"] = order.MdtrtId
  8407. memo["memo"] = "自费"
  8408. bytesData, _ := json.Marshal(memo)
  8409. fsiOPFLD.Memo = string(bytesData)
  8410. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8411. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8412. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8413. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8414. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8415. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8416. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8417. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8418. fsiOPFLD.BilgDeptName = department.Name
  8419. fsiOPFLD.BilgDeptCodg = department.Number
  8420. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8421. fsiOPFLD.BilgDrName = doctor.UserName
  8422. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8423. case 0:
  8424. break
  8425. case 1:
  8426. fsiOPFLD.MedChrgitmType = "14"
  8427. break
  8428. case 2:
  8429. fsiOPFLD.MedChrgitmType = "05"
  8430. break
  8431. case 3:
  8432. fsiOPFLD.MedChrgitmType = "03"
  8433. break
  8434. case 4:
  8435. fsiOPFLD.MedChrgitmType = "03"
  8436. break
  8437. case 5:
  8438. fsiOPFLD.MedChrgitmType = "08"
  8439. break
  8440. case 6:
  8441. fsiOPFLD.MedChrgitmType = "14"
  8442. break
  8443. case 7:
  8444. fsiOPFLD.MedChrgitmType = "14"
  8445. break
  8446. case 8:
  8447. fsiOPFLD.MedChrgitmType = "03"
  8448. break
  8449. case 9:
  8450. fsiOPFLD.MedChrgitmType = "14"
  8451. break
  8452. case 10:
  8453. fsiOPFLD.MedChrgitmType = "14"
  8454. break
  8455. case 11:
  8456. fsiOPFLD.MedChrgitmType = "06"
  8457. break
  8458. case 12:
  8459. fsiOPFLD.MedChrgitmType = "12"
  8460. break
  8461. case 13:
  8462. fsiOPFLD.MedChrgitmType = "01"
  8463. break
  8464. case 14:
  8465. fsiOPFLD.MedChrgitmType = "04"
  8466. break
  8467. case 15:
  8468. fsiOPFLD.MedChrgitmType = "14"
  8469. break
  8470. }
  8471. memo["hosp_appr_flag"] = "1"
  8472. memo["invoice_no"] = order.MdtrtId
  8473. memo["memo"] = "自费"
  8474. bytesData, _ := json.Marshal(memo)
  8475. fsiOPFLD.Memo = string(bytesData)
  8476. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8477. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8478. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8479. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8480. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8481. fsiOPFLD.BilgDeptName = department.Name
  8482. fsiOPFLD.BilgDeptCodg = department.Number
  8483. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8484. fsiOPFLD.BilgDrName = doctor.UserName
  8485. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8486. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8487. fsiOPFLD.MedChrgitmType = "08"
  8488. memo["hosp_appr_flag"] = "1"
  8489. memo["invoice_no"] = order.MdtrtId
  8490. memo["memo"] = "自费"
  8491. bytesData, _ := json.Marshal(memo)
  8492. fsiOPFLD.Memo = string(bytesData)
  8493. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8494. }
  8495. }
  8496. }
  8497. for _, items := range order_info_two {
  8498. memo := make(map[string]interface{})
  8499. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8500. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8501. fsiOPFLD.MedType = "14"
  8502. fsiOPFLD.BkkpSn = items.FeedetlSn
  8503. fsiOPFLD.FixmedinsCode = miConfig.Code
  8504. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8505. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8506. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8507. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8508. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8509. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8510. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8511. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8512. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8513. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8514. fsiOPFLD.BilgDeptName = department.Name
  8515. fsiOPFLD.BilgDeptCodg = department.Number
  8516. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8517. fsiOPFLD.BilgDrName = doctor.UserName
  8518. fsiOPFLD.MedChrgitmType = "09"
  8519. memo["hosp_appr_flag"] = "1"
  8520. memo["invoice_no"] = order.MdtrtId
  8521. memo["memo"] = "自费"
  8522. bytesData, _ := json.Marshal(memo)
  8523. fsiOPFLD.Memo = string(bytesData)
  8524. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8525. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8526. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8527. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8528. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8529. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8530. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8531. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8532. fsiOPFLD.BilgDeptName = department.Name
  8533. fsiOPFLD.BilgDeptCodg = department.Number
  8534. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8535. fsiOPFLD.BilgDrName = doctor.UserName
  8536. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8537. case 0:
  8538. break
  8539. case 1:
  8540. fsiOPFLD.MedChrgitmType = "14"
  8541. break
  8542. case 2:
  8543. fsiOPFLD.MedChrgitmType = "05"
  8544. break
  8545. case 3:
  8546. fsiOPFLD.MedChrgitmType = "03"
  8547. break
  8548. case 4:
  8549. fsiOPFLD.MedChrgitmType = "03"
  8550. break
  8551. case 5:
  8552. fsiOPFLD.MedChrgitmType = "08"
  8553. break
  8554. case 6:
  8555. fsiOPFLD.MedChrgitmType = "14"
  8556. break
  8557. case 7:
  8558. fsiOPFLD.MedChrgitmType = "14"
  8559. break
  8560. case 8:
  8561. fsiOPFLD.MedChrgitmType = "03"
  8562. break
  8563. case 9:
  8564. fsiOPFLD.MedChrgitmType = "14"
  8565. break
  8566. case 10:
  8567. fsiOPFLD.MedChrgitmType = "14"
  8568. break
  8569. case 11:
  8570. fsiOPFLD.MedChrgitmType = "06"
  8571. break
  8572. case 12:
  8573. fsiOPFLD.MedChrgitmType = "12"
  8574. break
  8575. case 13:
  8576. fsiOPFLD.MedChrgitmType = "01"
  8577. break
  8578. case 14:
  8579. fsiOPFLD.MedChrgitmType = "04"
  8580. break
  8581. case 15:
  8582. fsiOPFLD.MedChrgitmType = "14"
  8583. break
  8584. }
  8585. memo["hosp_appr_flag"] = "1"
  8586. memo["invoice_no"] = order.MdtrtId
  8587. memo["memo"] = "自费"
  8588. bytesData, _ := json.Marshal(memo)
  8589. fsiOPFLD.Memo = string(bytesData)
  8590. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8591. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8592. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8593. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8594. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8595. fsiOPFLD.BilgDeptName = department.Name
  8596. fsiOPFLD.BilgDeptCodg = department.Number
  8597. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8598. fsiOPFLD.BilgDrName = doctor.UserName
  8599. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8600. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8601. fsiOPFLD.MedChrgitmType = "08"
  8602. memo["hosp_appr_flag"] = "1"
  8603. memo["invoice_no"] = order.MdtrtId
  8604. memo["memo"] = "自费"
  8605. bytesData, _ := json.Marshal(memo)
  8606. fsiOPFLD.Memo = string(bytesData)
  8607. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8608. }
  8609. }
  8610. }
  8611. fmt.Println(fsiOPFLDs)
  8612. struct4201A.Fopfd = fsiOPFLDs
  8613. fmt.Println(struct4201A.Fopfd)
  8614. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8615. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8616. var res2 ResultSix
  8617. var respJSON2 map[string]interface{}
  8618. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8621. return
  8622. }
  8623. userJSONBytes2, _ := json.Marshal(respJSON2)
  8624. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8625. utils.ErrorLog("解析失败:%v", err)
  8626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8627. return
  8628. }
  8629. if res2.Infcode != 0 {
  8630. c.ServeSuccessJSON(map[string]interface{}{
  8631. "failed_code": -10,
  8632. "msg": res2.ErrMsg,
  8633. })
  8634. return
  8635. } else {
  8636. order.IsUploadOrderInfo = 1
  8637. service.UpdateOrder(order)
  8638. c.ServeSuccessJSON(map[string]interface{}{
  8639. "msg": "上传成功",
  8640. })
  8641. }
  8642. }
  8643. func (c *HisApiController) Get4202() {
  8644. order_id, _ := c.GetInt64("order_id")
  8645. admin_user_id, _ := c.GetInt64("admin_user_id")
  8646. order, _ := service.GetHisOrderByIDTwo(order_id)
  8647. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8648. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8649. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8650. if order.ID == 0 {
  8651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8652. return
  8653. }
  8654. var struct4202 models.Struct4202
  8655. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8656. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8657. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8658. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8659. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8660. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8661. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8662. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8663. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8664. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8665. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8666. var config []*models.HisXtDiagnoseConfig
  8667. for _, item := range diagnosis_ids {
  8668. id, _ := strconv.ParseInt(item, 10, 64)
  8669. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8670. config = append(config, &diagnosisConfig)
  8671. }
  8672. var tempDiaginfos []models.OwnPayPatnDiagListD
  8673. for index, item := range config {
  8674. if index == 0 {
  8675. var tempDiaginfo models.OwnPayPatnDiagListD
  8676. tempDiaginfo.InoutDiagType = "1"
  8677. tempDiaginfo.DiagCode = item.CountryCode
  8678. tempDiaginfo.DiagName = item.CountryContentName
  8679. tempDiaginfo.DiagType = "1"
  8680. tempDiaginfo.DiagSrtNo = "1"
  8681. tempDiaginfo.MaindiagFlag = "1"
  8682. tempDiaginfo.ValiFlag = "1"
  8683. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8684. } else {
  8685. var tempDiaginfo models.OwnPayPatnDiagListD
  8686. tempDiaginfo.DiagCode = item.CountryCode
  8687. tempDiaginfo.DiagName = item.CountryContentName
  8688. tempDiaginfo.DiagType = "2"
  8689. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8690. tempDiaginfo.MaindiagFlag = "0"
  8691. tempDiaginfo.ValiFlag = "1"
  8692. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8693. }
  8694. }
  8695. struct4202.ODiagListD = tempDiaginfos
  8696. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8697. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8698. var res2 ResultSix
  8699. var respJSON2 map[string]interface{}
  8700. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8703. return
  8704. }
  8705. userJSONBytes2, _ := json.Marshal(respJSON2)
  8706. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8707. utils.ErrorLog("解析失败:%v", err)
  8708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8709. return
  8710. }
  8711. if res2.Infcode != 0 {
  8712. c.ServeSuccessJSON(map[string]interface{}{
  8713. "failed_code": -10,
  8714. "msg": res2.ErrMsg,
  8715. })
  8716. return
  8717. } else {
  8718. order.IsUploadDiagnose = 1
  8719. service.UpdateOrder(order)
  8720. c.ServeSuccessJSON(map[string]interface{}{
  8721. "msg": "上传成功",
  8722. })
  8723. }
  8724. }
  8725. func (c *HisApiController) Get4203() {
  8726. admin_user_id, _ := c.GetInt64("admin_user_id")
  8727. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8728. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8729. order_id, _ := c.GetInt64("order_id")
  8730. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8731. number := ""
  8732. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8733. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8734. if his.ID == 0 {
  8735. number = hospital.Number
  8736. } else {
  8737. number = his.Number
  8738. }
  8739. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8740. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8741. var res2 ResultSix
  8742. var respJSON2 map[string]interface{}
  8743. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8746. return
  8747. }
  8748. userJSONBytes2, _ := json.Marshal(respJSON2)
  8749. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8750. utils.ErrorLog("解析失败:%v", err)
  8751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8752. return
  8753. }
  8754. if res2.Infcode != 0 {
  8755. c.ServeSuccessJSON(map[string]interface{}{
  8756. "failed_code": -10,
  8757. "msg": res2.ErrMsg,
  8758. })
  8759. return
  8760. } else {
  8761. order.IsUploadSuccess = 1
  8762. service.UpdateOrderTwo(order)
  8763. c.ServeSuccessJSON(map[string]interface{}{
  8764. "msg": "上传成功",
  8765. })
  8766. }
  8767. }
  8768. func (c *HisApiController) Get4205() {
  8769. order_id, _ := c.GetInt64("order_id")
  8770. admin_user_id, _ := c.GetInt64("admin_user_id")
  8771. fapiao_code := c.GetString("fapiao_code")
  8772. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8773. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8774. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8775. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8776. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8777. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8778. //order_info = append(order_info, order_info_two...)
  8779. department, _ := service.GetDepartMentDetail(his.Departments)
  8780. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8781. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8782. if order.ID == 0 {
  8783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8784. return
  8785. }
  8786. var struct4201A models.Struct4201A
  8787. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8788. for _, items := range order_info {
  8789. memo := make(map[string]interface{})
  8790. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8791. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8792. fsiOPFLD.MedType = pre.MedType
  8793. fsiOPFLD.FixmedinsCode = miConfig.Code
  8794. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8795. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8796. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8797. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8798. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8799. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8800. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8801. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8802. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8803. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8804. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8805. fsiOPFLD.BilgDeptName = department.Name
  8806. fsiOPFLD.BilgDeptCodg = department.Number
  8807. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8808. fsiOPFLD.BilgDrName = doctor.UserName
  8809. fsiOPFLD.MedChrgitmType = "09"
  8810. memo["hosp_appr_flag"] = "1"
  8811. memo["invoice_no"] = fapiao_code
  8812. memo["memo"] = "自费"
  8813. bytesData, _ := json.Marshal(memo)
  8814. fsiOPFLD.Memo = string(bytesData)
  8815. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8816. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8817. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8818. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8819. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8820. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8821. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8822. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8823. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8824. fsiOPFLD.BilgDeptName = department.Name
  8825. fsiOPFLD.BilgDeptCodg = department.Number
  8826. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8827. fsiOPFLD.BilgDrName = doctor.UserName
  8828. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8829. case 0:
  8830. break
  8831. case 1:
  8832. fsiOPFLD.MedChrgitmType = "14"
  8833. break
  8834. case 2:
  8835. fsiOPFLD.MedChrgitmType = "05"
  8836. break
  8837. case 3:
  8838. fsiOPFLD.MedChrgitmType = "03"
  8839. break
  8840. case 4:
  8841. fsiOPFLD.MedChrgitmType = "03"
  8842. break
  8843. case 5:
  8844. fsiOPFLD.MedChrgitmType = "08"
  8845. break
  8846. case 6:
  8847. fsiOPFLD.MedChrgitmType = "14"
  8848. break
  8849. case 7:
  8850. fsiOPFLD.MedChrgitmType = "14"
  8851. break
  8852. case 8:
  8853. fsiOPFLD.MedChrgitmType = "03"
  8854. break
  8855. case 9:
  8856. fsiOPFLD.MedChrgitmType = "14"
  8857. break
  8858. case 10:
  8859. fsiOPFLD.MedChrgitmType = "14"
  8860. break
  8861. case 11:
  8862. fsiOPFLD.MedChrgitmType = "06"
  8863. break
  8864. case 12:
  8865. fsiOPFLD.MedChrgitmType = "12"
  8866. break
  8867. case 13:
  8868. fsiOPFLD.MedChrgitmType = "01"
  8869. break
  8870. case 14:
  8871. fsiOPFLD.MedChrgitmType = "04"
  8872. break
  8873. case 15:
  8874. fsiOPFLD.MedChrgitmType = "14"
  8875. break
  8876. }
  8877. memo["hosp_appr_flag"] = "1"
  8878. memo["invoice_no"] = fapiao_code
  8879. memo["memo"] = "自费"
  8880. bytesData, _ := json.Marshal(memo)
  8881. fsiOPFLD.Memo = string(bytesData)
  8882. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8883. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8884. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8885. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8886. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8887. fsiOPFLD.BilgDeptName = department.Name
  8888. fsiOPFLD.BilgDeptCodg = department.Number
  8889. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8890. fsiOPFLD.BilgDrName = doctor.UserName
  8891. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8892. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8893. fsiOPFLD.MedChrgitmType = "08"
  8894. memo["hosp_appr_flag"] = "1"
  8895. memo["invoice_no"] = fapiao_code
  8896. memo["memo"] = "自费"
  8897. bytesData, _ := json.Marshal(memo)
  8898. fsiOPFLD.Memo = string(bytesData)
  8899. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8900. }
  8901. }
  8902. }
  8903. for _, items := range order_info_two {
  8904. memo := make(map[string]interface{})
  8905. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8906. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8907. fsiOPFLD.MedType = pre.MedType
  8908. fsiOPFLD.BkkpSn = items.FeedetlSn
  8909. fsiOPFLD.FixmedinsCode = miConfig.Code
  8910. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8911. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8912. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8913. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8914. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8915. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8916. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8917. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8918. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8919. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8920. fsiOPFLD.BilgDeptName = department.Name
  8921. fsiOPFLD.BilgDeptCodg = department.Number
  8922. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8923. fsiOPFLD.BilgDrName = doctor.UserName
  8924. fsiOPFLD.MedChrgitmType = "09"
  8925. memo["hosp_appr_flag"] = "1"
  8926. memo["invoice_no"] = fapiao_code
  8927. memo["memo"] = "自费"
  8928. bytesData, _ := json.Marshal(memo)
  8929. fsiOPFLD.Memo = string(bytesData)
  8930. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8931. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8932. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8933. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8934. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8935. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8936. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8937. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8938. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8939. fsiOPFLD.BilgDeptName = department.Name
  8940. fsiOPFLD.BilgDeptCodg = department.Number
  8941. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8942. fsiOPFLD.BilgDrName = doctor.UserName
  8943. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8944. case 0:
  8945. break
  8946. case 1:
  8947. fsiOPFLD.MedChrgitmType = "14"
  8948. break
  8949. case 2:
  8950. fsiOPFLD.MedChrgitmType = "05"
  8951. break
  8952. case 3:
  8953. fsiOPFLD.MedChrgitmType = "03"
  8954. break
  8955. case 4:
  8956. fsiOPFLD.MedChrgitmType = "03"
  8957. break
  8958. case 5:
  8959. fsiOPFLD.MedChrgitmType = "08"
  8960. break
  8961. case 6:
  8962. fsiOPFLD.MedChrgitmType = "14"
  8963. break
  8964. case 7:
  8965. fsiOPFLD.MedChrgitmType = "14"
  8966. break
  8967. case 8:
  8968. fsiOPFLD.MedChrgitmType = "03"
  8969. break
  8970. case 9:
  8971. fsiOPFLD.MedChrgitmType = "14"
  8972. break
  8973. case 10:
  8974. fsiOPFLD.MedChrgitmType = "14"
  8975. break
  8976. case 11:
  8977. fsiOPFLD.MedChrgitmType = "06"
  8978. break
  8979. case 12:
  8980. fsiOPFLD.MedChrgitmType = "12"
  8981. break
  8982. case 13:
  8983. fsiOPFLD.MedChrgitmType = "01"
  8984. break
  8985. case 14:
  8986. fsiOPFLD.MedChrgitmType = "04"
  8987. break
  8988. case 15:
  8989. fsiOPFLD.MedChrgitmType = "14"
  8990. break
  8991. }
  8992. memo["hosp_appr_flag"] = "1"
  8993. memo["invoice_no"] = fapiao_code
  8994. memo["memo"] = "自费"
  8995. bytesData, _ := json.Marshal(memo)
  8996. fsiOPFLD.Memo = string(bytesData)
  8997. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8998. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8999. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9000. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9001. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9002. fsiOPFLD.BilgDeptName = department.Name
  9003. fsiOPFLD.BilgDeptCodg = department.Number
  9004. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9005. fsiOPFLD.BilgDrName = doctor.UserName
  9006. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9007. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9008. fsiOPFLD.MedChrgitmType = "08"
  9009. memo["hosp_appr_flag"] = "1"
  9010. memo["invoice_no"] = fapiao_code
  9011. memo["memo"] = "自费"
  9012. bytesData, _ := json.Marshal(memo)
  9013. fsiOPFLD.Memo = string(bytesData)
  9014. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9015. }
  9016. }
  9017. }
  9018. fmt.Println(fsiOPFLDs)
  9019. struct4201A.Fopfd = fsiOPFLDs
  9020. fmt.Println(struct4201A.Fopfd)
  9021. var struct4202 models.Struct4202
  9022. timeLayout := "2006-01-02 15:04:05"
  9023. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9024. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9025. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9026. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9027. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9028. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9029. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9030. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9031. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9032. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9033. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9034. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9035. var config []*models.HisXtDiagnoseConfig
  9036. for _, item := range diagnosis_ids {
  9037. id, _ := strconv.ParseInt(item, 10, 64)
  9038. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9039. config = append(config, &diagnosisConfig)
  9040. }
  9041. var tempDiaginfos []models.OwnPayPatnDiagListD
  9042. for index, item := range config {
  9043. if index == 0 {
  9044. var tempDiaginfo models.OwnPayPatnDiagListD
  9045. tempDiaginfo.InoutDiagType = "1"
  9046. tempDiaginfo.DiagCode = item.CountryCode
  9047. tempDiaginfo.DiagName = item.CountryContentName
  9048. tempDiaginfo.DiagType = "1"
  9049. tempDiaginfo.DiagSrtNo = "1"
  9050. tempDiaginfo.MaindiagFlag = "1"
  9051. tempDiaginfo.ValiFlag = "1"
  9052. tempDiaginfo.DiagDrName = doctor.UserName
  9053. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9054. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9055. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9056. } else {
  9057. var tempDiaginfo models.OwnPayPatnDiagListD
  9058. tempDiaginfo.DiagCode = item.CountryCode
  9059. tempDiaginfo.DiagName = item.CountryContentName
  9060. tempDiaginfo.DiagType = "2"
  9061. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9062. tempDiaginfo.MaindiagFlag = "0"
  9063. tempDiaginfo.ValiFlag = "1"
  9064. tempDiaginfo.DiagDrName = doctor.UserName
  9065. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9066. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9067. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9068. }
  9069. }
  9070. struct4202.ODiagListD = tempDiaginfos
  9071. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9072. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9073. var res2 ResultSix
  9074. var respJSON2 map[string]interface{}
  9075. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9078. return
  9079. }
  9080. userJSONBytes2, _ := json.Marshal(respJSON2)
  9081. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9082. utils.ErrorLog("解析失败:%v", err)
  9083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9084. return
  9085. }
  9086. if res2.Infcode != 0 {
  9087. c.ServeSuccessJSON(map[string]interface{}{
  9088. "failed_code": -10,
  9089. "msg": res2.ErrMsg,
  9090. })
  9091. return
  9092. } else {
  9093. order.IsUploadDiagnose = 1
  9094. order.IsUploadOrderInfo = 1
  9095. service.UpdateOrderTwo(order)
  9096. c.ServeSuccessJSON(map[string]interface{}{
  9097. "msg": "上传成功",
  9098. })
  9099. }
  9100. }
  9101. func (c *HisApiController) Get4207() {
  9102. admin_user_id, _ := c.GetInt64("admin_user_id")
  9103. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9104. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9105. order_id, _ := c.GetInt64("order_id")
  9106. order, _ := service.GetHisOrderByIDTwo(order_id)
  9107. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9108. var struct4207 models.Struct4207
  9109. struct4207.PageNum = "1"
  9110. struct4207.PageSize = "1000"
  9111. struct4207.FixmedinsCode = miConfig.Code
  9112. struct4207.FixmedinsMdtrtID = order.Number
  9113. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9114. saveLog(result, requestLog, "4207", "查询")
  9115. var res2 ResultSix
  9116. var respJSON2 map[string]interface{}
  9117. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9118. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9120. return
  9121. }
  9122. userJSONBytes2, _ := json.Marshal(respJSON2)
  9123. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9124. utils.ErrorLog("解析失败:%v", err)
  9125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9126. return
  9127. }
  9128. if res2.Infcode != 0 {
  9129. c.ServeSuccessJSON(map[string]interface{}{
  9130. "failed_code": -10,
  9131. "msg": res2.ErrMsg,
  9132. })
  9133. return
  9134. } else {
  9135. c.ServeSuccessJSON(map[string]interface{}{
  9136. "msg": "查询成功",
  9137. })
  9138. }
  9139. }
  9140. func (c *HisApiController) Get4208() {
  9141. admin_user_id, _ := c.GetInt64("admin_user_id")
  9142. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9143. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9144. order_id, _ := c.GetInt64("order_id")
  9145. order, _ := service.GetHisOrderByIDTwo(order_id)
  9146. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9147. var struct4208 models.Struct4208
  9148. struct4208.PageNum = "1"
  9149. struct4208.PageSize = "1000"
  9150. struct4208.PsnCertType = "01"
  9151. struct4208.Certno = his.Certno
  9152. struct4208.MedType = order.MedType
  9153. struct4208.PsnName = his.Name
  9154. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9155. saveLog(result, requestLog, "4208", "查询")
  9156. var res2 ResultSix
  9157. var respJSON2 map[string]interface{}
  9158. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9161. return
  9162. }
  9163. userJSONBytes2, _ := json.Marshal(respJSON2)
  9164. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9165. utils.ErrorLog("解析失败:%v", err)
  9166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9167. return
  9168. }
  9169. if res2.Infcode != 0 {
  9170. c.ServeSuccessJSON(map[string]interface{}{
  9171. "failed_code": -10,
  9172. "msg": res2.ErrMsg,
  9173. })
  9174. return
  9175. } else {
  9176. c.ServeSuccessJSON(map[string]interface{}{
  9177. "msg": "查询成功",
  9178. })
  9179. }
  9180. }
  9181. func (c *HisApiController) Get4209() {
  9182. admin_user_id, _ := c.GetInt64("admin_user_id")
  9183. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9184. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9185. order_id, _ := c.GetInt64("order_id")
  9186. order, _ := service.GetHisOrderByIDTwo(order_id)
  9187. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9188. var struct4209 models.Struct4209
  9189. struct4209.FixmedinsMdtrtID = order.Number
  9190. struct4209.FixmedinsCode = miConfig.Code
  9191. struct4209.PageSize = "1000"
  9192. struct4209.PageNum = "1"
  9193. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9194. saveLog(result, requestLog, "4209", "查询")
  9195. var res2 ResultSix
  9196. var respJSON2 map[string]interface{}
  9197. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9200. return
  9201. }
  9202. userJSONBytes2, _ := json.Marshal(respJSON2)
  9203. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9204. utils.ErrorLog("解析失败:%v", err)
  9205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9206. return
  9207. }
  9208. if res2.Infcode != 0 {
  9209. c.ServeSuccessJSON(map[string]interface{}{
  9210. "failed_code": -10,
  9211. "msg": res2.ErrMsg,
  9212. })
  9213. return
  9214. } else {
  9215. c.ServeSuccessJSON(map[string]interface{}{
  9216. "msg": "查询成功",
  9217. })
  9218. }
  9219. }
  9220. type Result3101 struct {
  9221. Infcode string `json:"infcode"`
  9222. InfRefmsgid string `json:"inf_refmsgid"`
  9223. RefmsgTime string `json:"refmsg_time"`
  9224. RespondTime string `json:"respond_time"`
  9225. Enctype string `json:"enctype"`
  9226. Signtype string `json:"signtype"`
  9227. ErrMsg string `json:"err_msg"`
  9228. Output struct {
  9229. Result []struct {
  9230. JudgeResultDetailDtos []struct {
  9231. VolaItemType string `json:"vola_item_type"`
  9232. MdtrtID string `json:"mdtrt_id"`
  9233. JrdID string `json:"jrd_id"`
  9234. PatnID string `json:"patn_id"`
  9235. RxID string `json:"rx_id"`
  9236. VolaAmt interface{} `json:"vola_amt"`
  9237. } `json:"judge_result_detail_dtos"`
  9238. RuleID string `json:"rule_id"`
  9239. VolaEvid string `json:"vola_evid"`
  9240. MdtrtID string `json:"mdtrt_id"`
  9241. RuleName string `json:"rule_name"`
  9242. VolaAmtStas string `json:"vola_amt_stas"`
  9243. JrID string `json:"jr_id"`
  9244. PatnID string `json:"patn_id"`
  9245. SevDeg string `json:"sev_deg"`
  9246. VolaAmt float64 `json:"vola_amt"`
  9247. VolaBhvrType string `json:"vola_bhvr_type"`
  9248. VolaCont string `json:"vola_cont"`
  9249. } `json:"result"`
  9250. } `json:"output"`
  9251. }
  9252. type Resultgd3101 struct {
  9253. Infcode int64 `json:"infcode"`
  9254. InfRefmsgid string `json:"inf_refmsgid"`
  9255. RefmsgTime string `json:"refmsg_time"`
  9256. RespondTime string `json:"respond_time"`
  9257. Enctype string `json:"enctype"`
  9258. Signtype string `json:"signtype"`
  9259. ErrMsg string `json:"err_msg"`
  9260. Output struct {
  9261. Result []struct {
  9262. JudgeResultDetailDtos []struct {
  9263. VolaItemType string `json:"vola_item_type"`
  9264. MdtrtID string `json:"mdtrt_id"`
  9265. JrdID string `json:"jrd_id"`
  9266. PatnID string `json:"patn_id"`
  9267. RxID string `json:"rx_id"`
  9268. VolaAmt interface{} `json:"vola_amt"`
  9269. } `json:"judge_result_detail_dtos"`
  9270. RuleID string `json:"rule_id"`
  9271. VolaEvid string `json:"vola_evid"`
  9272. MdtrtID string `json:"mdtrt_id"`
  9273. RuleName string `json:"rule_name"`
  9274. VolaAmtStas string `json:"vola_amt_stas"`
  9275. JrID string `json:"jr_id"`
  9276. PatnID string `json:"patn_id"`
  9277. SevDeg string `json:"sev_deg"`
  9278. VolaAmt float64 `json:"vola_amt"`
  9279. VolaBhvrType string `json:"vola_bhvr_type"`
  9280. VolaCont string `json:"vola_cont"`
  9281. } `json:"result"`
  9282. } `json:"output"`
  9283. }
  9284. func (c *HisApiController) ReadEleToken() {
  9285. admin_user_id, _ := c.GetInt64("admin_user_id")
  9286. his_patient_id, _ := c.GetInt64("his_patient_id")
  9287. adminUser := c.GetAdminUserInfo()
  9288. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9289. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9290. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9291. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9292. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9293. if len(tokens) > 0 {
  9294. c.ServeSuccessJSON(map[string]interface{}{
  9295. "msg": "读取成功",
  9296. })
  9297. } else {
  9298. c.ServeSuccessJSON(map[string]interface{}{
  9299. "failed_code": -10,
  9300. "msg": "读取失败",
  9301. })
  9302. }
  9303. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9304. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9305. if len(tokens) > 0 {
  9306. c.ServeSuccessJSON(map[string]interface{}{
  9307. "msg": "读取成功",
  9308. })
  9309. } else {
  9310. c.ServeSuccessJSON(map[string]interface{}{
  9311. "failed_code": -10,
  9312. "msg": "读取失败",
  9313. })
  9314. }
  9315. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9316. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9317. if len(tokens) > 0 {
  9318. c.ServeSuccessJSON(map[string]interface{}{
  9319. "msg": "读取成功",
  9320. })
  9321. } else {
  9322. c.ServeSuccessJSON(map[string]interface{}{
  9323. "failed_code": -10,
  9324. "msg": "读取失败",
  9325. })
  9326. }
  9327. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9328. var api string
  9329. 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 +
  9330. "&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"
  9331. resp, requestErr := http.Get(api)
  9332. if requestErr != nil {
  9333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9334. }
  9335. body, ioErr := ioutil.ReadAll(resp.Body)
  9336. if ioErr != nil {
  9337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9339. }
  9340. var respJSON map[string]interface{}
  9341. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9344. return
  9345. }
  9346. var status string
  9347. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9348. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9349. var token string
  9350. var res ResultTwo //1101结果
  9351. var res10265 ResultTwo10265 //1101结果
  9352. if status == "0" { //读卡成功
  9353. var card_info string //卡信息
  9354. var busi_card_info string
  9355. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9356. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9357. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9358. fmt.Println(card_info)
  9359. fmt.Println(busi_card_info)
  9360. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9361. result, _ := json.Marshal(respJSON)
  9362. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9363. utils.ErrorLog("解析失败:%v", err)
  9364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9365. return
  9366. }
  9367. res.ErrMsg = res10265.ErrMsg
  9368. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9369. res.Infcode = infocode
  9370. res.Output = res10265.Output
  9371. res.InfRefmsgid = res10265.InfRefmsgid
  9372. if res.Infcode == 0 {
  9373. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9374. if err == gorm.ErrRecordNotFound {
  9375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9376. return
  9377. } else if err != nil {
  9378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9379. return
  9380. } else {
  9381. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9382. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9383. infoStr := string(Iinfos)
  9384. idetinfoStr := string(Idetinfos)
  9385. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9386. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9387. psn := &models.HisPsn{
  9388. PsnNo: res.Output.Baseinfo.PsnNo,
  9389. PatientId: patient.ID,
  9390. Certno: res.Output.Baseinfo.Certno,
  9391. Gend: res.Output.Baseinfo.Gend,
  9392. Naty: res.Output.Baseinfo.Naty,
  9393. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9394. PsnName: res.Output.Baseinfo.PsnName,
  9395. Age: float64(age),
  9396. Brdy: b,
  9397. Idetinfo: idetinfoStr,
  9398. Insuinfo: infoStr,
  9399. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9400. CardInfo: card_info,
  9401. VerifyNumber: token,
  9402. IdCardType: 4,
  9403. }
  9404. var rf []*ResultFive
  9405. json.Unmarshal([]byte(infoStr), &rf)
  9406. var insutypes []*ResultFive
  9407. var insutype string
  9408. var is390 int = 0
  9409. var is310 int = 0
  9410. for _, item := range rf {
  9411. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9412. insutypes = append(insutypes, item)
  9413. }
  9414. }
  9415. if len(insutypes) == 1 {
  9416. insutype = insutypes[0].Insutype
  9417. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9418. } else {
  9419. for _, i := range insutypes {
  9420. if i.Insutype == "390" {
  9421. is390 = 1
  9422. }
  9423. if i.Insutype == "310" {
  9424. is310 = 1
  9425. }
  9426. }
  9427. }
  9428. if is390 == 1 {
  9429. insutype = "390"
  9430. }
  9431. if is310 == 1 {
  9432. insutype = "310"
  9433. }
  9434. if len(insutypes) == 0 {
  9435. insutype = "310"
  9436. }
  9437. service.CreateHisPsn(psn)
  9438. c.ServeSuccessJSON(map[string]interface{}{
  9439. "patient": patient,
  9440. "number": token,
  9441. "insutype": insutype,
  9442. })
  9443. }
  9444. } else {
  9445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9446. return
  9447. }
  9448. } else { //读卡失败
  9449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9450. return
  9451. }
  9452. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9453. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9454. if len(errMsg) == 0 {
  9455. type ELeData struct {
  9456. Data struct {
  9457. IdNo string `json:"idNo"`
  9458. IdType string `json:"idType"`
  9459. UserName string `json:"userName"`
  9460. EcToken string `json:"ecToken"`
  9461. InsuOrg string `json:"insuOrg"`
  9462. Gender string `json:"gender"`
  9463. Birthday string `json:"birthday"`
  9464. Nationality string `json:"nationality"`
  9465. Email string `json:"email"`
  9466. Extra string `json:"extra"`
  9467. } `json:"data"`
  9468. Code int `json:"code"`
  9469. Message string `json:"message"`
  9470. }
  9471. var ele ELeData
  9472. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9473. if err != nil {
  9474. utils.ErrorLog("解析失败:%v", err)
  9475. }
  9476. token := ele.Data.EcToken
  9477. if len(token) > 0 {
  9478. psn := &models.HisPsn{
  9479. PsnNo: his.PsnNo,
  9480. Age: 0,
  9481. PatientId: his.PatientId,
  9482. Certno: his.Certno,
  9483. Brdy: his.Brdy,
  9484. Gend: his.Gend,
  9485. Naty: his.Naty,
  9486. PsnCertType: his.PsnCertType,
  9487. PsnName: his.PsnName,
  9488. Idetinfo: his.Idetinfo,
  9489. Insuinfo: his.Iinfo,
  9490. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9491. CardInfo: outPutInfo,
  9492. VerifyNumber: token,
  9493. }
  9494. service.CreateHisPsn(psn)
  9495. }
  9496. if len(token) > 0 {
  9497. c.ServeSuccessJSON(map[string]interface{}{
  9498. "msg": "读取成功",
  9499. })
  9500. } else {
  9501. c.ServeSuccessJSON(map[string]interface{}{
  9502. "failed_code": -10,
  9503. "msg": "读取失败",
  9504. })
  9505. }
  9506. }
  9507. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9508. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9509. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9510. type ELeData struct {
  9511. Data struct {
  9512. IdNo string `json:"idNo"`
  9513. IdType string `json:"idType"`
  9514. UserName string `json:"userName"`
  9515. EcToken string `json:"ecToken"`
  9516. InsuOrg string `json:"insuOrg"`
  9517. Gender string `json:"gender"`
  9518. Birthday string `json:"birthday"`
  9519. Nationality string `json:"nationality"`
  9520. Email string `json:"email"`
  9521. Extra string `json:"extra"`
  9522. } `json:"data"`
  9523. Code int `json:"code"`
  9524. Message string `json:"message"`
  9525. }
  9526. var ele ELeData
  9527. err := json.Unmarshal([]byte(result), &ele)
  9528. if err != nil {
  9529. utils.ErrorLog("解析失败:%v", err)
  9530. }
  9531. token := ele.Data.EcToken
  9532. token = Remove0000(token)
  9533. fmt.Println(ele.Data.UserName)
  9534. 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)
  9535. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9536. var res ResultTwo
  9537. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9538. utils.ErrorLog("解析失败:%v", err)
  9539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9540. return
  9541. }
  9542. if res.Infcode == 0 {
  9543. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9544. if err == gorm.ErrRecordNotFound {
  9545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9546. return
  9547. } else if err != nil {
  9548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9549. return
  9550. } else {
  9551. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9552. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9553. infoStr := string(Iinfos)
  9554. idetinfoStr := string(Idetinfos)
  9555. psn := &models.HisPsn{
  9556. PsnNo: res.Output.Baseinfo.PsnNo,
  9557. PatientId: patient.ID,
  9558. Certno: res.Output.Baseinfo.Certno,
  9559. Gend: res.Output.Baseinfo.Gend,
  9560. Naty: res.Output.Baseinfo.Naty,
  9561. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9562. PsnName: res.Output.Baseinfo.PsnName,
  9563. Idetinfo: idetinfoStr,
  9564. Insuinfo: infoStr,
  9565. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9566. CardInfo: "",
  9567. VerifyNumber: token,
  9568. }
  9569. service.CreateHisPsn(psn)
  9570. c.ServeSuccessJSON(map[string]interface{}{
  9571. "patient": patient,
  9572. "number": token,
  9573. })
  9574. }
  9575. } else {
  9576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9577. return
  9578. }
  9579. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9580. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9581. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9582. type ELeData struct {
  9583. Data struct {
  9584. IdNo string `json:"idNo"`
  9585. IdType string `json:"idType"`
  9586. UserName string `json:"userName"`
  9587. EcToken string `json:"ecToken"`
  9588. InsuOrg string `json:"insuOrg"`
  9589. Gender string `json:"gender"`
  9590. Birthday string `json:"birthday"`
  9591. Nationality string `json:"nationality"`
  9592. Email string `json:"email"`
  9593. Extra string `json:"extra"`
  9594. } `json:"data"`
  9595. Code int `json:"code"`
  9596. Message string `json:"message"`
  9597. }
  9598. var ele ELeData
  9599. err := json.Unmarshal([]byte(result), &ele)
  9600. if err != nil {
  9601. utils.ErrorLog("解析失败:%v", err)
  9602. }
  9603. token := ele.Data.EcToken
  9604. token = Remove0000(token)
  9605. fmt.Println(ele.Data.UserName)
  9606. 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)
  9607. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9608. var res ResultTwo
  9609. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9610. utils.ErrorLog("解析失败:%v", err)
  9611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9612. return
  9613. }
  9614. if res.Infcode == 0 {
  9615. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9616. if err == gorm.ErrRecordNotFound {
  9617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9618. return
  9619. } else if err != nil {
  9620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9621. return
  9622. } else {
  9623. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9624. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9625. infoStr := string(Iinfos)
  9626. idetinfoStr := string(Idetinfos)
  9627. psn := &models.HisPsn{
  9628. PsnNo: res.Output.Baseinfo.PsnNo,
  9629. PatientId: patient.ID,
  9630. Certno: res.Output.Baseinfo.Certno,
  9631. Gend: res.Output.Baseinfo.Gend,
  9632. Naty: res.Output.Baseinfo.Naty,
  9633. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9634. PsnName: res.Output.Baseinfo.PsnName,
  9635. Idetinfo: idetinfoStr,
  9636. Insuinfo: infoStr,
  9637. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9638. CardInfo: "",
  9639. VerifyNumber: token,
  9640. }
  9641. service.CreateHisPsn(psn)
  9642. c.ServeSuccessJSON(map[string]interface{}{
  9643. "patient": patient,
  9644. "number": token,
  9645. })
  9646. }
  9647. } else {
  9648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9649. return
  9650. }
  9651. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9652. //if initFlag == 0 {
  9653. //c.TestGetJiangXiBasBaseInit()
  9654. //}
  9655. //if initEleFlag == 0 {
  9656. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9657. //}
  9658. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9659. utils.ErrorLog("解析失败:%v", json_result)
  9660. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9661. type ELeData struct {
  9662. Data struct {
  9663. IdNo string `json:"idNo"`
  9664. IdType string `json:"idType"`
  9665. UserName string `json:"userName"`
  9666. EcToken string `json:"ecToken"`
  9667. InsuOrg string `json:"insuOrg"`
  9668. Gender string `json:"gender"`
  9669. Birthday string `json:"birthday"`
  9670. Nationality string `json:"nationality"`
  9671. Email string `json:"email"`
  9672. Extra string `json:"extra"`
  9673. } `json:"data"`
  9674. Code int `json:"code"`
  9675. Message string `json:"message"`
  9676. }
  9677. var ele ELeData
  9678. err := json.Unmarshal([]byte(json_result), &ele)
  9679. if err != nil {
  9680. utils.ErrorLog("解析失败:%v", err)
  9681. }
  9682. token := ele.Data.EcToken
  9683. token = Remove0000(token)
  9684. //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)
  9685. 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)
  9686. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9687. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9688. var res ResultTwo
  9689. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9690. utils.ErrorLog("解析失败:%v", err)
  9691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9692. return
  9693. }
  9694. if res.Infcode == 0 {
  9695. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9696. if err == gorm.ErrRecordNotFound {
  9697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9698. return
  9699. } else if err != nil {
  9700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9701. return
  9702. } else {
  9703. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9704. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9705. infoStr := string(Iinfos)
  9706. idetinfoStr := string(Idetinfos)
  9707. psn := &models.HisPsn{
  9708. PsnNo: res.Output.Baseinfo.PsnNo,
  9709. PatientId: patient.ID,
  9710. Certno: res.Output.Baseinfo.Certno,
  9711. Gend: res.Output.Baseinfo.Gend,
  9712. Naty: res.Output.Baseinfo.Naty,
  9713. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9714. PsnName: res.Output.Baseinfo.PsnName,
  9715. Idetinfo: idetinfoStr,
  9716. Insuinfo: infoStr,
  9717. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9718. CardInfo: "",
  9719. VerifyNumber: token,
  9720. InsuplcAdmdvs: ele.Data.InsuOrg,
  9721. }
  9722. service.CreateHisPsn(psn)
  9723. c.ServeSuccessJSON(map[string]interface{}{
  9724. "patient": patient,
  9725. "number": token,
  9726. })
  9727. }
  9728. } else {
  9729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9730. return
  9731. }
  9732. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9733. res := c.GetoleInfo()
  9734. if res.Infcode == 0 {
  9735. var result string
  9736. if res.Output.MdtrtCertType == "01" {
  9737. 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)
  9738. } else if res.Output.MdtrtCertType == "02" {
  9739. 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)
  9740. } else if res.Output.MdtrtCertType == "03" {
  9741. 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)
  9742. }
  9743. var dat map[string]interface{}
  9744. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9745. fmt.Println(dat)
  9746. } else {
  9747. fmt.Println(err)
  9748. }
  9749. userJSONBytes, _ := json.Marshal(dat)
  9750. var res2 ResultTwo
  9751. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9752. utils.ErrorLog("解析失败:%v", err)
  9753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9754. return
  9755. }
  9756. if res2.Infcode == 0 {
  9757. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9758. if err == gorm.ErrRecordNotFound {
  9759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9760. return
  9761. } else if err != nil {
  9762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9763. return
  9764. } else {
  9765. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9766. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9767. infoStr := string(Iinfos)
  9768. idetinfoStr := string(Idetinfos)
  9769. var rf []*ResultFive
  9770. json.Unmarshal([]byte(infoStr), &rf)
  9771. var insutypes []*ResultFive
  9772. var insutype string
  9773. var is390 int = 0
  9774. var is310 int = 0
  9775. //var insuplc_admdvs string
  9776. for _, item := range rf {
  9777. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9778. insutypes = append(insutypes, item)
  9779. }
  9780. }
  9781. if len(insutypes) == 1 {
  9782. insutype = insutypes[0].Insutype
  9783. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9784. } else {
  9785. for _, i := range insutypes {
  9786. if i.Insutype == "390" {
  9787. is390 = 1
  9788. }
  9789. if i.Insutype == "310" {
  9790. is310 = 1
  9791. }
  9792. }
  9793. }
  9794. if is390 == 1 {
  9795. insutype = "390"
  9796. }
  9797. if is310 == 1 {
  9798. insutype = "310"
  9799. }
  9800. if len(insutypes) == 0 {
  9801. insutype = "310"
  9802. }
  9803. psn := &models.HisPsn{
  9804. PsnNo: res2.Output.Baseinfo.PsnNo,
  9805. PatientId: patient.ID,
  9806. Certno: res2.Output.Baseinfo.Certno,
  9807. Gend: res2.Output.Baseinfo.Gend,
  9808. Naty: res2.Output.Baseinfo.Naty,
  9809. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9810. PsnName: res2.Output.Baseinfo.PsnName,
  9811. Idetinfo: idetinfoStr,
  9812. Insuinfo: infoStr,
  9813. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9814. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9815. VerifyNumber: res.Output.EcToken,
  9816. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9817. }
  9818. service.CreateHisPsn(psn)
  9819. c.ServeSuccessJSON(map[string]interface{}{
  9820. "patient": patient,
  9821. "number": res.Output.CardNo,
  9822. "insutype": insutype,
  9823. })
  9824. }
  9825. } else {
  9826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9827. return
  9828. }
  9829. } else {
  9830. c.ServeSuccessJSON(map[string]interface{}{
  9831. "failed_code": -10,
  9832. "msg": res.ErrMsg,
  9833. })
  9834. }
  9835. } else {
  9836. //if initFlag == 0 {
  9837. // c.TestGetBasBaseInit()
  9838. //}
  9839. //token := c.GetEleBaseInfo()
  9840. //token = Remove0000(token)
  9841. type ELeData struct {
  9842. Code string `json:"code"`
  9843. Data struct {
  9844. Aac002 string `json:"aac002"`
  9845. Aaz500 string `json:"aaz500"`
  9846. ActCardNo string `json:"actCardNo"`
  9847. Bab520 string `json:"bab520"`
  9848. Bkz543 string `json:"bkz543"`
  9849. BusinessType string `json:"businessType"`
  9850. CertfCodg string `json:"certfCodg"`
  9851. EcIndexNo string `json:"ecIndexNo"`
  9852. EcToken string `json:"ecToken"`
  9853. ID0000 string `json:"id0000"`
  9854. IDNo string `json:"idNo"`
  9855. IDType string `json:"idType"`
  9856. Idcode string `json:"idcode"`
  9857. IdentityToken string `json:"identity_token"`
  9858. InsuOrg string `json:"insuOrg"`
  9859. OfficeID string `json:"officeId"`
  9860. OfficeName string `json:"officeName"`
  9861. OperatorID string `json:"operatorId"`
  9862. OperatorName string `json:"operatorName"`
  9863. OrgID string `json:"orgId"`
  9864. UserName string `json:"userName"`
  9865. } `json:"data"`
  9866. Infno interface{} `json:"infno"`
  9867. Message string `json:"message"`
  9868. OrgID string `json:"orgId"`
  9869. TransType string `json:"transType"`
  9870. }
  9871. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9872. fmt.Println(result)
  9873. outPutInfo := Remove0000(result)
  9874. fmt.Println(outPutInfo)
  9875. var ele ELeData
  9876. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9877. if err != nil {
  9878. utils.ErrorLog("解析失败:%v", err)
  9879. }
  9880. token := ele.Data.EcToken
  9881. var result2 string
  9882. var requestLog2 string
  9883. if len(token) > 0 {
  9884. if strings.Contains(ele.Data.IDNo, "HKG") {
  9885. 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)
  9886. } else {
  9887. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  9888. }
  9889. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9890. var res ResultTwo
  9891. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9892. utils.ErrorLog("解析失败:%v", err)
  9893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9894. return
  9895. }
  9896. if res.Infcode == 0 {
  9897. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9898. if err == gorm.ErrRecordNotFound {
  9899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9900. return
  9901. } else if err != nil {
  9902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9903. return
  9904. } else {
  9905. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9906. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9907. infoStr := string(Iinfos)
  9908. idetinfoStr := string(Idetinfos)
  9909. psn := &models.HisPsn{
  9910. PsnNo: res.Output.Baseinfo.PsnNo,
  9911. PatientId: patient.ID,
  9912. Certno: res.Output.Baseinfo.Certno,
  9913. Gend: res.Output.Baseinfo.Gend,
  9914. Naty: res.Output.Baseinfo.Naty,
  9915. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9916. PsnName: res.Output.Baseinfo.PsnName,
  9917. Idetinfo: idetinfoStr,
  9918. Insuinfo: infoStr,
  9919. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9920. CardInfo: "",
  9921. VerifyNumber: token,
  9922. }
  9923. service.CreateHisPsn(psn)
  9924. c.ServeSuccessJSON(map[string]interface{}{
  9925. "msg": "读取成功",
  9926. })
  9927. }
  9928. } else {
  9929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9930. return
  9931. }
  9932. } else {
  9933. c.ServeSuccessJSON(map[string]interface{}{
  9934. "failed_code": -10,
  9935. "msg": "读取失败",
  9936. })
  9937. }
  9938. }
  9939. }
  9940. func (c *HisApiController) ReadEleFace() {
  9941. admin_user_id, _ := c.GetInt64("admin_user_id")
  9942. //his_patient_id, _ := c.GetInt64("his_patient_id")
  9943. adminUser := c.GetAdminUserInfo()
  9944. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9945. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9946. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9947. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9948. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9949. if len(tokens) > 0 {
  9950. c.ServeSuccessJSON(map[string]interface{}{
  9951. "msg": "读取成功",
  9952. })
  9953. } else {
  9954. c.ServeSuccessJSON(map[string]interface{}{
  9955. "failed_code": -10,
  9956. "msg": "读取失败",
  9957. })
  9958. }
  9959. }
  9960. }
  9961. func (c *HisApiController) Get9001() {
  9962. adminUser := c.GetAdminUserInfo()
  9963. admin_user_id, _ := c.GetInt64("admin_user_id")
  9964. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9965. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9966. if miConfig.MdtrtareaAdmvs == "350500" {
  9967. service.GetFjAuthorizationInfo(miConfig.Code)
  9968. } else if miConfig.MdtrtareaAdmvs == "131023" {
  9969. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9970. var dat map[string]interface{}
  9971. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9972. fmt.Println(dat)
  9973. } else {
  9974. fmt.Println(err)
  9975. }
  9976. userJSONBytes, _ := json.Marshal(dat)
  9977. var res models.Result9001
  9978. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9979. utils.ErrorLog("解析失败:%v", err)
  9980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9981. return
  9982. }
  9983. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9984. fmt.Println(miConfig.SecretKey)
  9985. var res models.Result9001Two
  9986. 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 +
  9987. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  9988. resp, requestErr := http.Get(api)
  9989. if requestErr != nil {
  9990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9991. return
  9992. }
  9993. body, ioErr := ioutil.ReadAll(resp.Body)
  9994. if ioErr != nil {
  9995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9997. return
  9998. }
  9999. var respJSON map[string]interface{}
  10000. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10003. return
  10004. }
  10005. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10006. if status == "0" {
  10007. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10008. c.ServeSuccessJSON(map[string]interface{}{
  10009. "failed_code": -10,
  10010. "msg": err_msg,
  10011. })
  10012. return
  10013. }
  10014. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10015. result, _ := json.Marshal(respJSON)
  10016. fmt.Println("log")
  10017. fmt.Println(string(result))
  10018. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10019. utils.ErrorLog("解析失败:%v", err)
  10020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10021. return
  10022. }
  10023. if res.Infcode == 0 {
  10024. sign := models.HisSignIn{
  10025. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10026. SignNo: res.Output.Signinoutb.SignNo,
  10027. SignTime: "",
  10028. Ctime: time.Now().Unix(),
  10029. Mtime: time.Now().Unix(),
  10030. Status: 1,
  10031. InputLog: "",
  10032. OutputLog: "",
  10033. FixmedinsCode: miConfig.Code,
  10034. }
  10035. err := service.CreateSignIn(&sign)
  10036. if err == nil {
  10037. c.ServeSuccessJSON(map[string]interface{}{
  10038. "msg": "签到成功",
  10039. })
  10040. }
  10041. } else {
  10042. c.ServeSuccessJSON(map[string]interface{}{
  10043. "failed_code": -10,
  10044. "msg": res.ErrMsg,
  10045. })
  10046. return
  10047. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10048. //return
  10049. }
  10050. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10051. fmt.Println(miConfig.SecretKey)
  10052. var res models.Result9001Two
  10053. 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 +
  10054. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10055. resp, requestErr := http.Get(api)
  10056. if requestErr != nil {
  10057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10058. return
  10059. }
  10060. body, ioErr := ioutil.ReadAll(resp.Body)
  10061. if ioErr != nil {
  10062. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10064. return
  10065. }
  10066. var respJSON map[string]interface{}
  10067. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10068. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10070. return
  10071. }
  10072. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10073. if status == "0" {
  10074. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10075. c.ServeSuccessJSON(map[string]interface{}{
  10076. "failed_code": -10,
  10077. "msg": err_msg,
  10078. })
  10079. return
  10080. }
  10081. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10082. result, _ := json.Marshal(respJSON)
  10083. fmt.Println("log")
  10084. fmt.Println(string(result))
  10085. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10086. utils.ErrorLog("解析失败:%v", err)
  10087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10088. return
  10089. }
  10090. if res.Infcode == 0 {
  10091. sign := models.HisSignIn{
  10092. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10093. SignNo: res.Output.Signinoutb.SignNo,
  10094. SignTime: "",
  10095. Ctime: time.Now().Unix(),
  10096. Mtime: time.Now().Unix(),
  10097. Status: 1,
  10098. InputLog: "",
  10099. OutputLog: "",
  10100. FixmedinsCode: miConfig.Code,
  10101. }
  10102. err := service.CreateSignIn(&sign)
  10103. if err == nil {
  10104. c.ServeSuccessJSON(map[string]interface{}{
  10105. "msg": "签到成功",
  10106. })
  10107. }
  10108. } else {
  10109. c.ServeSuccessJSON(map[string]interface{}{
  10110. "failed_code": -10,
  10111. "msg": res.ErrMsg,
  10112. })
  10113. return
  10114. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10115. //return
  10116. }
  10117. } else {
  10118. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10119. var dat map[string]interface{}
  10120. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10121. fmt.Println(dat)
  10122. } else {
  10123. fmt.Println(err)
  10124. }
  10125. userJSONBytes, _ := json.Marshal(dat)
  10126. var res models.Result9001
  10127. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10128. utils.ErrorLog("解析失败:%v", err)
  10129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10130. return
  10131. }
  10132. if res.Infcode == 0 {
  10133. sign := models.HisSignIn{
  10134. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10135. SignNo: res.Output.Signinoutb.SignNo,
  10136. SignTime: res.Output.Signinoutb.SignTime,
  10137. Ctime: time.Now().Unix(),
  10138. Mtime: time.Now().Unix(),
  10139. Status: 1,
  10140. InputLog: "",
  10141. OutputLog: "",
  10142. FixmedinsCode: miConfig.Code,
  10143. }
  10144. err := service.CreateSignIn(&sign)
  10145. if err == nil {
  10146. c.ServeSuccessJSON(map[string]interface{}{
  10147. "msg": "签到成功",
  10148. })
  10149. }
  10150. }
  10151. }
  10152. }
  10153. 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) {
  10154. var res Result3101
  10155. adminUser := c.GetAdminUserInfo()
  10156. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10157. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10158. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10159. //record_time := c.GetString("record_time")
  10160. //trig_scen := c.GetString("trig_scen")
  10161. timeLayout := "2006-01-02"
  10162. loc, _ := time.LoadLocation("Local")
  10163. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10164. if err != nil {
  10165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10166. return res
  10167. }
  10168. recordDateTime := theTime.Unix()
  10169. var patientPrescription models.HisPrescriptionInfo
  10170. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10171. //if patientPrescription.ID == 0 {
  10172. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10173. //}
  10174. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10175. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10176. //
  10177. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10178. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10179. var pp models.PublicParams
  10180. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10181. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10182. pp.FixmedinsName = miConfig.OrgName
  10183. pp.FixmedinsCode = miConfig.Code
  10184. pp.RequestUrl = miConfig.Url
  10185. pp.Cainfo = miConfig.Cainfo
  10186. pp.SecretKey = miConfig.SecretKey
  10187. pp.AccessKey = miConfig.AccessKey
  10188. pp.OpterName = roles.UserName
  10189. var config []*models.HisXtDiagnoseConfig
  10190. for _, item := range diagnosis_ids {
  10191. id, _ := strconv.ParseInt(item, 10, 64)
  10192. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10193. config = append(config, &diagnosisConfig)
  10194. }
  10195. var pd models.PatientDtos
  10196. pd.PatnID = his.PsnNo
  10197. pd.PatnName = his.Name
  10198. pd.Gend = his.Gend
  10199. pd.Brdy = his.Brdy
  10200. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10201. pd.CurrMdtrtID = his.Number
  10202. var fed models.FsiEncounterDtos
  10203. fed.MdtrtID = his.Number
  10204. fed.MedinsID = miConfig.Code
  10205. fed.MedinsName = miConfig.OrgName
  10206. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10207. fed.MedMdtrtType = "1"
  10208. fed.MedinsType = "1"
  10209. fed.MedinsLv = "11"
  10210. tm := time.Unix(his.RecordDate, 0)
  10211. s_tm := tm.Format("2006-01-02 15:04:05")
  10212. fed.AdmDate = s_tm
  10213. fed.DscgDate = s_tm
  10214. fed.DscgMainDiseCodg = config[0].CountryCode
  10215. fed.DscgMainDiseName = config[0].CountryContentName
  10216. //诊断信息
  10217. var fdds []*models.FsiDiagnoseDtos
  10218. for index, item := range config {
  10219. if index == 0 {
  10220. var fdd models.FsiDiagnoseDtos
  10221. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10222. fdd.InoutDiseType = "1"
  10223. fdd.MaindiseFlag = "1"
  10224. fdd.DiseDate = s_tm
  10225. fdd.DiasSrtNo = "1"
  10226. fdd.DiseName = item.CountryContentName
  10227. fdd.DiseCodg = item.CountryCode
  10228. fdds = append(fdds, &fdd)
  10229. } else {
  10230. var fdd models.FsiDiagnoseDtos
  10231. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10232. fdd.InoutDiseType = "1"
  10233. fdd.MaindiseFlag = "1"
  10234. fdd.DiseDate = s_tm
  10235. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10236. fdd.DiseName = item.CountryContentName
  10237. fdd.DiseCodg = item.CountryCode
  10238. fdds = append(fdds, &fdd)
  10239. }
  10240. }
  10241. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10242. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10243. fed.AdmDeptName = de.Name
  10244. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10245. fed.DscgDeptName = de.Name
  10246. fed.MedMdtrtType = "1"
  10247. fed.MedType = "11"
  10248. //if his.Insutype == "390" {
  10249. // fed.MedType = "1402"
  10250. //} else {
  10251. // fed.MedType = "9933"
  10252. //}
  10253. var orders []*models.FsiOrderDtos
  10254. if trig_scen == "2" {
  10255. //处方医嘱信息
  10256. for _, item := range prescriptions {
  10257. for _, subItem := range item.HisDoctorAdviceInfo {
  10258. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10259. var order models.FsiOrderDtos
  10260. order.RxID = strconv.FormatInt(item.ID, 10)
  10261. order.Rxno = strconv.FormatInt(item.ID, 10)
  10262. order.LongDrordFlag = "0"
  10263. order.HilistType = "1"
  10264. order.ChrgType = "1"
  10265. order.DrordBhvr = "-"
  10266. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10267. order.HosplistName = subItem.BaseDrugLib.DrugName
  10268. order.HilistLv = "1"
  10269. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10270. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10271. order.HosplistName = subItem.BaseDrugLib.DrugName
  10272. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10273. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10274. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10275. order.OwnpayAmt = ""
  10276. order.SelfpayAmt = ""
  10277. order.Spec = ""
  10278. order.SpecUnt = ""
  10279. order.DrordBegnDate = s_tm
  10280. order.DrordStopDate = ""
  10281. order.DrordDrCodg = doctor_info.DoctorNumber
  10282. order.DrordDeptName = department.Name
  10283. order.DrordDeptCodg = department.Number
  10284. order.DrordDrName = doctor_info.UserName
  10285. order.DrordDrProfttl = "234"
  10286. order.CurrDrordFlag = "1"
  10287. orders = append(orders, &order)
  10288. }
  10289. }
  10290. for _, subItem := range item.HisPrescriptionProject {
  10291. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10292. var order models.FsiOrderDtos
  10293. order.RxID = strconv.FormatInt(item.ID, 10)
  10294. order.Rxno = strconv.FormatInt(item.ID, 10)
  10295. order.LongDrordFlag = "0"
  10296. order.HilistType = "1"
  10297. order.ChrgType = "1"
  10298. order.DrordBhvr = "-"
  10299. order.HilistCode = subItem.HisProject.MedicalCode
  10300. order.HosplistName = subItem.HisProject.ProjectName
  10301. order.HilistLv = "1"
  10302. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10303. order.HosplistCode = subItem.HisProject.MedicalCode
  10304. order.HosplistName = subItem.HisProject.ProjectName
  10305. order.Cnt = subItem.Count
  10306. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10307. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10308. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10309. order.OwnpayAmt = ""
  10310. order.SelfpayAmt = ""
  10311. order.Spec = ""
  10312. order.SpecUnt = ""
  10313. order.DrordBegnDate = s_tm
  10314. order.DrordStopDate = ""
  10315. order.DrordDrCodg = doctor_info.DoctorNumber
  10316. order.DrordDeptName = department.Name
  10317. order.DrordDeptCodg = department.Number
  10318. order.DrordDrName = doctor_info.UserName
  10319. order.DrordDrProfttl = "234"
  10320. order.CurrDrordFlag = "1"
  10321. orders = append(orders, &order)
  10322. }
  10323. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10324. var order models.FsiOrderDtos
  10325. order.RxID = strconv.FormatInt(item.ID, 10)
  10326. order.Rxno = strconv.FormatInt(item.ID, 10)
  10327. order.LongDrordFlag = "0"
  10328. order.HilistType = "1"
  10329. order.ChrgType = "1"
  10330. order.DrordBhvr = "-"
  10331. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10332. order.HosplistName = subItem.GoodInfo.GoodName
  10333. order.HilistLv = "1"
  10334. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10335. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10336. order.HosplistName = subItem.GoodInfo.GoodName
  10337. order.Cnt = subItem.Count
  10338. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10339. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10340. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10341. order.OwnpayAmt = ""
  10342. order.SelfpayAmt = ""
  10343. order.Spec = ""
  10344. order.SpecUnt = ""
  10345. order.DrordBegnDate = s_tm
  10346. order.DrordStopDate = ""
  10347. order.DrordDrCodg = doctor_info.DoctorNumber
  10348. order.DrordDeptName = department.Name
  10349. order.DrordDeptCodg = department.Number
  10350. order.DrordDrName = doctor_info.UserName
  10351. order.DrordDrProfttl = "234"
  10352. order.CurrDrordFlag = "1"
  10353. orders = append(orders, &order)
  10354. }
  10355. }
  10356. }
  10357. //处方医嘱信息
  10358. }
  10359. fed.MatnStas = "0"
  10360. fed.MedfeeSumamt = "0"
  10361. fed.OwnpayAmt = "0"
  10362. fed.SelfpayAmt = "0"
  10363. fed.AcctPayamt = "0"
  10364. fed.MaAmt = "0"
  10365. fed.HifpPayamt = "0"
  10366. fed.SetlTotlnum = "1"
  10367. fed.Insutype = his.Insutype
  10368. fed.ReimFlag = "0"
  10369. fed.OutSetlFlag = "0"
  10370. var fopd []*models.FsiOperationDtosData
  10371. data := make(map[string]interface{})
  10372. data["fed"] = fed
  10373. data["fdd"] = fdds
  10374. data["fod"] = orders
  10375. data["pd"] = pd
  10376. data["pp"] = pp
  10377. data["fopd"] = fopd
  10378. data["trig_scen"] = trig_scen
  10379. fmt.Println(data)
  10380. fmt.Println(fed)
  10381. fmt.Println(fdds)
  10382. fmt.Println(orders)
  10383. fmt.Println(pd)
  10384. fmt.Println(pp)
  10385. fmt.Println(fopd)
  10386. client := &http.Client{}
  10387. bytesData, _ := json.Marshal(data)
  10388. var req *http.Request
  10389. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10390. if miConfig.MdtrtareaAdmvs == "320921" {
  10391. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10392. } else {
  10393. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10394. }
  10395. resp, _ := client.Do(req)
  10396. defer resp.Body.Close()
  10397. body, ioErr := ioutil.ReadAll(resp.Body)
  10398. if ioErr != nil {
  10399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10401. return res
  10402. }
  10403. var respJSON map[string]interface{}
  10404. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10407. return res
  10408. }
  10409. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10410. fmt.Println(respJSON)
  10411. result, _ := json.Marshal(respJSON)
  10412. fmt.Println(result)
  10413. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10414. utils.ErrorLog("解析失败:%v", err)
  10415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10416. return res
  10417. }
  10418. return res
  10419. } else {
  10420. //if miConfig.MdtrtareaAdmvs == "441202" {
  10421. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10422. saveLog(output, input, "3101", "事前")
  10423. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10424. utils.ErrorLog("解析失败:%v", err)
  10425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10426. return
  10427. }
  10428. return res
  10429. //}
  10430. }
  10431. }
  10432. 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) {
  10433. adminUser := c.GetAdminUserInfo()
  10434. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10435. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10436. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10437. //record_time := c.GetString("record_time")
  10438. //trig_scen := c.GetString("trig_scen")
  10439. timeLayout := "2006-01-02"
  10440. loc, _ := time.LoadLocation("Local")
  10441. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10442. if err != nil {
  10443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10444. return res
  10445. }
  10446. recordDateTime := theTime.Unix()
  10447. var patientPrescription models.HisPrescriptionInfo
  10448. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10449. if patientPrescription.ID == 0 {
  10450. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10451. }
  10452. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10453. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10454. //
  10455. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10456. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10457. var pp models.PublicParams
  10458. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10459. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10460. pp.FixmedinsName = miConfig.OrgName
  10461. pp.FixmedinsCode = miConfig.Code
  10462. pp.RequestUrl = miConfig.Url
  10463. pp.Cainfo = miConfig.Cainfo
  10464. pp.SecretKey = miConfig.SecretKey
  10465. pp.AccessKey = miConfig.AccessKey
  10466. pp.OpterName = roles.UserName
  10467. var config []*models.HisXtDiagnoseConfig
  10468. for _, item := range diagnosis_ids {
  10469. id, _ := strconv.ParseInt(item, 10, 64)
  10470. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10471. config = append(config, &diagnosisConfig)
  10472. }
  10473. var pd models.PatientDtos
  10474. pd.PatnID = his.PsnNo
  10475. pd.PatnName = his.Name
  10476. pd.Gend = his.Gend
  10477. pd.Brdy = his.Brdy
  10478. pd.Poolarea = his.InsuplcAdmdvs
  10479. pd.CurrMdtrtID = his.Number
  10480. var fed models.FsiEncounterDtos
  10481. fed.MdtrtID = his.Number
  10482. fed.MedinsID = miConfig.Code
  10483. fed.MedinsName = miConfig.OrgName
  10484. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10485. fed.MedMdtrtType = "1"
  10486. fed.MedinsType = "1"
  10487. fed.MedinsLv = "11"
  10488. tm := time.Unix(his.RecordDate, 0)
  10489. s_tm := tm.Format("2006-01-02 15:04:05")
  10490. fed.AdmDate = s_tm
  10491. fed.DscgDate = s_tm
  10492. fed.DscgMainDiseCodg = config[0].CountryCode
  10493. fed.DscgMainDiseName = config[0].CountryContentName
  10494. //诊断信息
  10495. var fdds []*models.FsiDiagnoseDtos
  10496. for index, item := range config {
  10497. if index == 0 {
  10498. var fdd models.FsiDiagnoseDtos
  10499. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10500. fdd.InoutDiseType = "1"
  10501. fdd.MaindiseFlag = "1"
  10502. fdd.DiseDate = s_tm
  10503. fdd.DiasSrtNo = "1"
  10504. fdd.DiseName = item.CountryContentName
  10505. fdd.DiseCodg = item.CountryCode
  10506. fdds = append(fdds, &fdd)
  10507. } else {
  10508. var fdd models.FsiDiagnoseDtos
  10509. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10510. fdd.InoutDiseType = "1"
  10511. fdd.MaindiseFlag = "1"
  10512. fdd.DiseDate = s_tm
  10513. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10514. fdd.DiseName = item.CountryContentName
  10515. fdd.DiseCodg = item.CountryCode
  10516. fdds = append(fdds, &fdd)
  10517. }
  10518. }
  10519. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10520. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10521. fed.AdmDeptName = department.Name
  10522. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10523. fed.DscgDeptName = department.Name
  10524. fed.MedMdtrtType = "1"
  10525. fed.MedType = "11"
  10526. //if his.Insutype == "390" {
  10527. // fed.MedType = "1402"
  10528. //} else {
  10529. // fed.MedType = "9933"
  10530. //}
  10531. var orders []*models.FsiOrderDtos
  10532. if trig_scen == "2" {
  10533. //处方医嘱信息
  10534. for _, item := range prescriptions {
  10535. for _, subItem := range item.HisDoctorAdviceInfo {
  10536. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10537. var order models.FsiOrderDtos
  10538. order.RxID = strconv.FormatInt(item.ID, 10)
  10539. order.Rxno = strconv.FormatInt(item.ID, 10)
  10540. order.LongDrordFlag = "0"
  10541. order.HilistType = "1"
  10542. order.ChrgType = "1"
  10543. order.DrordBhvr = "-"
  10544. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10545. order.HosplistName = subItem.BaseDrugLib.DrugName
  10546. order.HilistLv = "1"
  10547. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10548. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10549. order.HosplistName = subItem.BaseDrugLib.DrugName
  10550. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10551. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10552. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10553. order.OwnpayAmt = ""
  10554. order.SelfpayAmt = ""
  10555. order.Spec = ""
  10556. order.SpecUnt = ""
  10557. order.DrordBegnDate = s_tm
  10558. order.DrordStopDate = ""
  10559. order.DrordDrCodg = doctor_info.DoctorNumber
  10560. order.DrordDeptName = department.Name
  10561. order.DrordDeptCodg = department.Number
  10562. order.DrordDrName = doctor_info.UserName
  10563. order.DrordDrProfttl = "234"
  10564. order.CurrDrordFlag = "1"
  10565. orders = append(orders, &order)
  10566. }
  10567. }
  10568. for _, subItem := range item.HisPrescriptionProject {
  10569. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10570. var order models.FsiOrderDtos
  10571. order.RxID = strconv.FormatInt(item.ID, 10)
  10572. order.Rxno = strconv.FormatInt(item.ID, 10)
  10573. order.LongDrordFlag = "0"
  10574. order.HilistType = "1"
  10575. order.ChrgType = "1"
  10576. order.DrordBhvr = "-"
  10577. order.HilistCode = subItem.HisProject.MedicalCode
  10578. order.HosplistName = subItem.HisProject.ProjectName
  10579. order.HilistLv = "1"
  10580. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10581. order.HosplistCode = subItem.HisProject.MedicalCode
  10582. order.HosplistName = subItem.HisProject.ProjectName
  10583. order.Cnt = subItem.Count
  10584. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10585. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10586. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10587. order.OwnpayAmt = ""
  10588. order.SelfpayAmt = ""
  10589. order.Spec = ""
  10590. order.SpecUnt = ""
  10591. order.DrordBegnDate = s_tm
  10592. order.DrordStopDate = ""
  10593. order.DrordDrCodg = doctor_info.DoctorNumber
  10594. order.DrordDeptName = department.Name
  10595. order.DrordDeptCodg = department.Number
  10596. order.DrordDrName = doctor_info.UserName
  10597. order.DrordDrProfttl = "234"
  10598. order.CurrDrordFlag = "1"
  10599. orders = append(orders, &order)
  10600. }
  10601. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10602. var order models.FsiOrderDtos
  10603. order.RxID = strconv.FormatInt(item.ID, 10)
  10604. order.Rxno = strconv.FormatInt(item.ID, 10)
  10605. order.LongDrordFlag = "0"
  10606. order.HilistType = "1"
  10607. order.ChrgType = "1"
  10608. order.DrordBhvr = "-"
  10609. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10610. order.HosplistName = subItem.GoodInfo.GoodName
  10611. order.HilistLv = "1"
  10612. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10613. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10614. order.HosplistName = subItem.GoodInfo.GoodName
  10615. order.Cnt = subItem.Count
  10616. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10617. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10618. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10619. order.OwnpayAmt = ""
  10620. order.SelfpayAmt = ""
  10621. order.Spec = ""
  10622. order.SpecUnt = ""
  10623. order.DrordBegnDate = s_tm
  10624. order.DrordStopDate = ""
  10625. order.DrordDrCodg = doctor_info.DoctorNumber
  10626. order.DrordDeptName = department.Name
  10627. order.DrordDeptCodg = department.Number
  10628. order.DrordDrName = doctor_info.UserName
  10629. order.DrordDrProfttl = "234"
  10630. order.CurrDrordFlag = "1"
  10631. orders = append(orders, &order)
  10632. }
  10633. }
  10634. }
  10635. //处方医嘱信息
  10636. }
  10637. fed.MatnStas = "0"
  10638. fed.MedfeeSumamt = "0"
  10639. fed.OwnpayAmt = "0"
  10640. fed.SelfpayAmt = "0"
  10641. fed.AcctPayamt = "0"
  10642. fed.MaAmt = "0"
  10643. fed.HifpPayamt = "0"
  10644. fed.SetlTotlnum = "1"
  10645. fed.Insutype = his.Insutype
  10646. fed.ReimFlag = "0"
  10647. fed.OutSetlFlag = "0"
  10648. var fopd []*models.FsiOperationDtosData
  10649. data := make(map[string]interface{})
  10650. data["fed"] = fed
  10651. data["fdd"] = fdds
  10652. data["fod"] = orders
  10653. data["pd"] = pd
  10654. data["pp"] = pp
  10655. data["fopd"] = fopd
  10656. data["trig_scen"] = trig_scen
  10657. fmt.Println(data)
  10658. fmt.Println(fed)
  10659. fmt.Println(fdds)
  10660. fmt.Println(orders)
  10661. fmt.Println(pd)
  10662. fmt.Println(pp)
  10663. fmt.Println(fopd)
  10664. client := &http.Client{}
  10665. bytesData, _ := json.Marshal(data)
  10666. var req *http.Request
  10667. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10668. if miConfig.MdtrtareaAdmvs == "320921" {
  10669. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10670. } else {
  10671. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10672. }
  10673. resp, _ := client.Do(req)
  10674. defer resp.Body.Close()
  10675. body, ioErr := ioutil.ReadAll(resp.Body)
  10676. if ioErr != nil {
  10677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10679. return res
  10680. }
  10681. var respJSON map[string]interface{}
  10682. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10685. return res
  10686. }
  10687. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10688. fmt.Println(respJSON)
  10689. result, _ := json.Marshal(respJSON)
  10690. fmt.Println(result)
  10691. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10692. utils.ErrorLog("解析失败:%v", err)
  10693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10694. return res
  10695. }
  10696. return res
  10697. } else {
  10698. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10699. saveLog(output, input, "3101", "事前")
  10700. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10701. utils.ErrorLog("解析失败:%v", err)
  10702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10703. return
  10704. }
  10705. return res
  10706. }
  10707. return res
  10708. }
  10709. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10710. ////patient_id, _ := c.GetInt64("patient_id")
  10711. //order_id, _ := c.GetInt64("order_id")
  10712. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10713. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10714. //trig_scen := c.GetString("trig_scen")
  10715. adminUser := c.GetAdminUserInfo()
  10716. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10717. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10718. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10719. record_time := c.GetString("record_time")
  10720. order, _ := service.GetHisOrderByID(order_id)
  10721. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10722. timeLayout := "2006-01-02"
  10723. loc, _ := time.LoadLocation("Local")
  10724. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10725. if err != nil {
  10726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10727. return
  10728. }
  10729. recordDateTime := theTime.Unix()
  10730. var patientPrescription models.HisPrescriptionInfo
  10731. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10732. if patientPrescription.ID == 0 {
  10733. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10734. }
  10735. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10736. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10737. //
  10738. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10739. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10740. var pp models.PublicParams
  10741. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10742. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10743. pp.FixmedinsName = miConfig.OrgName
  10744. pp.FixmedinsCode = miConfig.Code
  10745. pp.RequestUrl = miConfig.Url
  10746. pp.Cainfo = miConfig.Cainfo
  10747. pp.SecretKey = miConfig.SecretKey
  10748. pp.AccessKey = miConfig.AccessKey
  10749. pp.OpterName = roles.UserName
  10750. var config []*models.HisXtDiagnoseConfig
  10751. for _, item := range diagnosis_ids {
  10752. id, _ := strconv.ParseInt(item, 10, 64)
  10753. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10754. config = append(config, &diagnosisConfig)
  10755. }
  10756. var pd models.PatientDtos
  10757. pd.PatnID = his.PsnNo
  10758. pd.PatnName = his.Name
  10759. pd.Gend = his.Gend
  10760. pd.Brdy = psn_info.Brdy
  10761. pd.Poolarea = his.InsuplcAdmdvs
  10762. pd.CurrMdtrtID = his.Number
  10763. var fed models.FsiEncounterDtos
  10764. fed.MdtrtID = his.Number
  10765. fed.MedinsID = miConfig.Code
  10766. fed.MedinsName = miConfig.OrgName
  10767. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10768. fed.MedMdtrtType = "1"
  10769. fed.MedinsType = "1"
  10770. fed.MedinsLv = "11"
  10771. tm := time.Unix(his.RecordDate, 0)
  10772. s_tm := tm.Format("2006-01-02 15:04:05")
  10773. fed.AdmDate = s_tm
  10774. fed.DscgDate = s_tm
  10775. fed.DscgMainDiseCodg = config[0].CountryCode
  10776. fed.DscgMainDiseName = config[0].CountryContentName
  10777. //诊断信息
  10778. var fdds []*models.FsiDiagnoseDtos
  10779. for index, item := range config {
  10780. if index == 0 {
  10781. var fdd models.FsiDiagnoseDtos
  10782. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10783. fdd.InoutDiseType = "1"
  10784. fdd.MaindiseFlag = "1"
  10785. fdd.DiseDate = s_tm
  10786. fdd.DiasSrtNo = "1"
  10787. fdd.DiseName = item.CountryContentName
  10788. fdd.DiseCodg = item.CountryCode
  10789. fdds = append(fdds, &fdd)
  10790. } else {
  10791. var fdd models.FsiDiagnoseDtos
  10792. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10793. fdd.InoutDiseType = "1"
  10794. fdd.MaindiseFlag = "1"
  10795. fdd.DiseDate = s_tm
  10796. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10797. fdd.DiseName = item.CountryContentName
  10798. fdd.DiseCodg = item.CountryCode
  10799. fdds = append(fdds, &fdd)
  10800. }
  10801. }
  10802. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10803. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10804. fed.AdmDeptName = department.Name
  10805. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10806. fed.DscgDeptName = department.Name
  10807. fed.MedType = order.MedType
  10808. //处方医嘱信息
  10809. var orders []*models.FsiOrderDtos
  10810. //for _, item := range prescriptions {
  10811. // for _, subItem := range item.HisDoctorAdviceInfo {
  10812. // var order models.FsiOrderDtos
  10813. // order.RxID = strconv.FormatInt(item.ID, 10)
  10814. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10815. // order.LongDrordFlag = "0"
  10816. // order.HilistType = "1"
  10817. // order.ChrgType = "1"
  10818. // order.DrordBhvr = "-"
  10819. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10820. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10821. // order.HilistLv = "1"
  10822. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10823. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10824. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10825. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10826. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10827. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10828. // order.OwnpayAmt = ""
  10829. // order.SelfpayAmt = ""
  10830. // order.Spec = ""
  10831. // order.SpecUnt = ""
  10832. // order.DrordBegnDate = s_tm
  10833. // order.DrordStopDate = ""
  10834. // order.DrordDrCodg = "1"
  10835. // order.DrordDeptName = department.Name
  10836. // order.DrordDrCodg = "1"
  10837. // order.DrordDrName = doctor_info.UserName
  10838. // order.DrordDrProfttl = ""
  10839. // order.CurrDrordFlag = "1"
  10840. // orders = append(orders, &order)
  10841. // }
  10842. // for _, subItem := range item.HisPrescriptionProject {
  10843. // if subItem.Type == 2 {
  10844. // var order models.FsiOrderDtos
  10845. // order.RxID = strconv.FormatInt(item.ID, 10)
  10846. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10847. // order.LongDrordFlag = "0"
  10848. // order.HilistType = "1"
  10849. // order.ChrgType = "1"
  10850. // order.DrordBhvr = "-"
  10851. // order.HilistCode = subItem.HisProject.MedicalCode
  10852. // order.HosplistName = subItem.HisProject.ProjectName
  10853. // order.HilistLv = "1"
  10854. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10855. // order.HosplistCode = subItem.HisProject.MedicalCode
  10856. // order.HosplistName = subItem.HisProject.ProjectName
  10857. // order.Cnt = subItem.Count
  10858. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10859. //
  10860. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10861. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10862. // order.OwnpayAmt = ""
  10863. // order.SelfpayAmt = ""
  10864. // order.Spec = ""
  10865. // order.SpecUnt = ""
  10866. // order.DrordBegnDate = s_tm
  10867. // order.DrordStopDate = ""
  10868. // order.DrordDrCodg = "1"
  10869. // order.DrordDeptName = department.Name
  10870. // order.DrordDrCodg = "1"
  10871. // order.DrordDrName = doctor_info.UserName
  10872. // order.DrordDrProfttl = ""
  10873. // order.CurrDrordFlag = "1"
  10874. // orders = append(orders, &order)
  10875. //
  10876. // }
  10877. // if subItem.Type == 3 {
  10878. //
  10879. // var order models.FsiOrderDtos
  10880. // order.RxID = strconv.FormatInt(item.ID, 10)
  10881. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10882. // order.LongDrordFlag = "0"
  10883. // order.HilistType = "1"
  10884. // order.ChrgType = "1"
  10885. // order.DrordBhvr = "-"
  10886. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10887. // order.HosplistName = subItem.GoodInfo.GoodName
  10888. // order.HilistLv = "1"
  10889. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10890. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10891. // order.HosplistName = subItem.GoodInfo.GoodName
  10892. // order.Cnt = subItem.Count
  10893. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10894. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10895. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10896. // order.OwnpayAmt = ""
  10897. // order.SelfpayAmt = ""
  10898. // order.Spec = ""
  10899. // order.SpecUnt = ""
  10900. // order.DrordBegnDate = s_tm
  10901. // order.DrordStopDate = ""
  10902. // order.DrordDrCodg = "1"
  10903. // order.DrordDeptName = department.Name
  10904. // order.DrordDrCodg = "1"
  10905. // order.DrordDrName = doctor_info.UserName
  10906. // order.DrordDrProfttl = ""
  10907. // order.CurrDrordFlag = "1"
  10908. // orders = append(orders, &order)
  10909. //
  10910. // }
  10911. // }
  10912. //}
  10913. for _, item := range prescriptions {
  10914. for _, subItem := range item.HisDoctorAdviceInfo {
  10915. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10916. var order models.FsiOrderDtos
  10917. order.RxID = strconv.FormatInt(item.ID, 10)
  10918. order.Rxno = strconv.FormatInt(item.ID, 10)
  10919. order.LongDrordFlag = "0"
  10920. order.HilistType = "1"
  10921. order.ChrgType = "1"
  10922. order.DrordBhvr = "-"
  10923. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10924. order.HosplistName = subItem.BaseDrugLib.DrugName
  10925. order.HilistLv = "1"
  10926. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10927. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10928. order.HosplistName = subItem.BaseDrugLib.DrugName
  10929. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10930. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10931. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10932. order.OwnpayAmt = ""
  10933. order.SelfpayAmt = ""
  10934. order.Spec = ""
  10935. order.SpecUnt = ""
  10936. order.DrordBegnDate = s_tm
  10937. order.DrordStopDate = ""
  10938. order.DrordDrCodg = doctor_info.DoctorNumber
  10939. order.DrordDeptName = department.Name
  10940. order.DrordDeptCodg = department.Number
  10941. order.DrordDrName = doctor_info.UserName
  10942. order.DrordDrProfttl = "234"
  10943. order.CurrDrordFlag = "1"
  10944. orders = append(orders, &order)
  10945. }
  10946. }
  10947. for _, subItem := range item.HisPrescriptionProject {
  10948. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10949. var order models.FsiOrderDtos
  10950. order.RxID = strconv.FormatInt(item.ID, 10)
  10951. order.Rxno = strconv.FormatInt(item.ID, 10)
  10952. order.LongDrordFlag = "0"
  10953. order.HilistType = "1"
  10954. order.ChrgType = "1"
  10955. order.DrordBhvr = "-"
  10956. order.HilistCode = subItem.HisProject.MedicalCode
  10957. order.HosplistName = subItem.HisProject.ProjectName
  10958. order.HilistLv = "1"
  10959. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10960. order.HosplistCode = subItem.HisProject.MedicalCode
  10961. order.HosplistName = subItem.HisProject.ProjectName
  10962. order.Cnt = subItem.Count
  10963. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10964. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10965. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10966. order.OwnpayAmt = ""
  10967. order.SelfpayAmt = ""
  10968. order.Spec = ""
  10969. order.SpecUnt = ""
  10970. order.DrordBegnDate = s_tm
  10971. order.DrordStopDate = ""
  10972. order.DrordDrCodg = doctor_info.DoctorNumber
  10973. order.DrordDeptName = department.Name
  10974. order.DrordDeptCodg = department.Number
  10975. order.DrordDrName = doctor_info.UserName
  10976. order.DrordDrProfttl = "234"
  10977. order.CurrDrordFlag = "1"
  10978. orders = append(orders, &order)
  10979. }
  10980. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10981. var order models.FsiOrderDtos
  10982. order.RxID = strconv.FormatInt(item.ID, 10)
  10983. order.Rxno = strconv.FormatInt(item.ID, 10)
  10984. order.LongDrordFlag = "0"
  10985. order.HilistType = "1"
  10986. order.ChrgType = "1"
  10987. order.DrordBhvr = "0"
  10988. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10989. order.HosplistName = subItem.GoodInfo.GoodName
  10990. order.HilistLv = "1"
  10991. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10992. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10993. order.HosplistName = subItem.GoodInfo.GoodName
  10994. order.Cnt = subItem.Count
  10995. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10996. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10997. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10998. order.OwnpayAmt = ""
  10999. order.SelfpayAmt = ""
  11000. order.Spec = ""
  11001. order.SpecUnt = ""
  11002. order.DrordBegnDate = s_tm
  11003. order.DrordStopDate = ""
  11004. order.DrordDrCodg = doctor_info.DoctorNumber
  11005. order.DrordDeptName = department.Name
  11006. order.DrordDeptCodg = department.Number
  11007. order.DrordDrName = doctor_info.UserName
  11008. order.DrordDrProfttl = "234"
  11009. order.CurrDrordFlag = "1"
  11010. orders = append(orders, &order)
  11011. }
  11012. }
  11013. }
  11014. //处方医嘱信息
  11015. fed.MatnStas = "0"
  11016. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11017. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11018. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11019. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11020. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11021. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11022. fed.SetlTotlnum = "1"
  11023. fed.Insutype = his.Insutype
  11024. fed.ReimFlag = "0"
  11025. fed.OutSetlFlag = "0"
  11026. var fopd []*models.FsiOperationDtosData
  11027. data := make(map[string]interface{})
  11028. data["fed"] = fed
  11029. data["fdd"] = fdds
  11030. data["fod"] = orders
  11031. data["pd"] = pd
  11032. data["pp"] = pp
  11033. data["fopd"] = fopd
  11034. data["trig_scen"] = trig_scen
  11035. client := &http.Client{}
  11036. bytesData, _ := json.Marshal(data)
  11037. var req *http.Request
  11038. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11039. if miConfig.MdtrtareaAdmvs == "320921" {
  11040. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11041. } else {
  11042. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11043. }
  11044. resp, _ := client.Do(req)
  11045. defer resp.Body.Close()
  11046. body, ioErr := ioutil.ReadAll(resp.Body)
  11047. if ioErr != nil {
  11048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11050. return res
  11051. }
  11052. var respJSON map[string]interface{}
  11053. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11056. return res
  11057. }
  11058. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11059. result, _ := json.Marshal(respJSON)
  11060. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11061. utils.ErrorLog("解析失败:%v", err)
  11062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11063. return res
  11064. }
  11065. return res
  11066. } else {
  11067. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11068. saveLog(output, input, "3102", "事中")
  11069. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11070. utils.ErrorLog("解析失败:%v", err)
  11071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11072. return
  11073. }
  11074. return res
  11075. }
  11076. return res
  11077. }
  11078. 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) {
  11079. var res Resultgd3101
  11080. adminUser := c.GetAdminUserInfo()
  11081. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11082. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11083. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11084. //record_time := c.GetString("record_time")
  11085. //trig_scen := c.GetString("trig_scen")
  11086. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11087. //psn_info, _ := service.GetPatientId(patient_id)
  11088. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11089. timeLayout := "2006-01-02"
  11090. loc, _ := time.LoadLocation("Local")
  11091. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11092. if err != nil {
  11093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11094. return res
  11095. }
  11096. recordDateTime := theTime.Unix()
  11097. var patientPrescription models.HisPrescriptionInfo
  11098. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11099. //if patientPrescription.ID == 0 {
  11100. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11101. //}
  11102. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11103. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11104. //
  11105. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11106. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11107. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11108. var pp models.PublicParams
  11109. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11110. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11111. pp.FixmedinsName = miConfig.OrgName
  11112. pp.FixmedinsCode = miConfig.Code
  11113. pp.RequestUrl = miConfig.Url
  11114. pp.Cainfo = miConfig.Cainfo
  11115. pp.SecretKey = miConfig.SecretKey
  11116. pp.AccessKey = miConfig.AccessKey
  11117. pp.OpterName = roles.UserName
  11118. var config []*models.HisXtDiagnoseConfig
  11119. for _, item := range diagnosis_ids {
  11120. id, _ := strconv.ParseInt(item, 10, 64)
  11121. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11122. config = append(config, &diagnosisConfig)
  11123. }
  11124. var pd models.PatientDtos
  11125. pd.PatnID = his.PsnNo
  11126. pd.PatnName = his.Name
  11127. pd.Gend = his.Gend
  11128. pd.Brdy = str
  11129. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11130. pd.CurrMdtrtID = his.Number
  11131. var fed models.FsiEncounterDtos
  11132. fed.MdtrtID = his.Number
  11133. fed.MedinsID = miConfig.Code
  11134. fed.MedinsName = miConfig.OrgName
  11135. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11136. fed.MedMdtrtType = "1"
  11137. fed.MedinsType = "1"
  11138. fed.MedinsLv = "11"
  11139. tm := time.Unix(his.RecordDate, 0)
  11140. s_tm := tm.Format("2006-01-02 15:04:05")
  11141. fed.AdmDate = s_tm
  11142. fed.DscgDate = s_tm
  11143. fed.DscgMainDiseCodg = config[0].CountryCode
  11144. fed.DscgMainDiseName = config[0].CountryContentName
  11145. //诊断信息
  11146. var fdds []*models.FsiDiagnoseDtos
  11147. for index, item := range config {
  11148. if index == 0 {
  11149. var fdd models.FsiDiagnoseDtos
  11150. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11151. fdd.InoutDiseType = "1"
  11152. fdd.MaindiseFlag = "1"
  11153. fdd.DiseDate = s_tm
  11154. fdd.DiasSrtNo = "1"
  11155. fdd.DiseName = item.CountryContentName
  11156. fdd.DiseCodg = item.CountryCode
  11157. fdds = append(fdds, &fdd)
  11158. } else {
  11159. var fdd models.FsiDiagnoseDtos
  11160. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11161. fdd.InoutDiseType = "1"
  11162. fdd.MaindiseFlag = "1"
  11163. fdd.DiseDate = s_tm
  11164. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11165. fdd.DiseName = item.CountryContentName
  11166. fdd.DiseCodg = item.CountryCode
  11167. fdds = append(fdds, &fdd)
  11168. }
  11169. }
  11170. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11171. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11172. fed.AdmDeptName = de.Name
  11173. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11174. fed.DscgDeptName = de.Name
  11175. fed.MedMdtrtType = "1"
  11176. fed.MedType = "11"
  11177. //if his.Insutype == "390" {
  11178. // fed.MedType = "1402"
  11179. //} else {
  11180. // fed.MedType = "9933"
  11181. //}
  11182. var orders []*models.FsiOrderDtos
  11183. if trig_scen == "2" {
  11184. //处方医嘱信息
  11185. for _, item := range prescriptions {
  11186. for _, subItem := range item.HisDoctorAdviceInfo {
  11187. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11188. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11189. var order models.FsiOrderDtos
  11190. order.RxID = strconv.FormatInt(item.ID, 10)
  11191. order.Rxno = strconv.FormatInt(item.ID, 10)
  11192. order.LongDrordFlag = "0"
  11193. order.HilistType = "1"
  11194. order.ChrgType = "1"
  11195. order.DrordBhvr = "0"
  11196. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11197. order.HosplistName = subItem.BaseDrugLib.DrugName
  11198. order.HilistLv = "1"
  11199. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11200. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11201. order.HosplistName = subItem.BaseDrugLib.DrugName
  11202. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11203. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11204. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11205. order.OwnpayAmt = ""
  11206. order.SelfpayAmt = ""
  11207. order.Spec = spec
  11208. order.SpecUnt = subItem.PrescribingNumberUnit
  11209. order.DrordBegnDate = s_tm
  11210. order.DrordStopDate = ""
  11211. order.DrordDrCodg = doctor_info.DoctorNumber
  11212. order.DrordDeptName = department.Name
  11213. order.DrordDeptCodg = department.Number
  11214. order.DrordDrName = doctor_info.UserName
  11215. order.DrordDrProfttl = "234"
  11216. order.CurrDrordFlag = "1"
  11217. orders = append(orders, &order)
  11218. }
  11219. }
  11220. for _, subItem := range item.HisPrescriptionProject {
  11221. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11222. var order models.FsiOrderDtos
  11223. order.RxID = strconv.FormatInt(item.ID, 10)
  11224. order.Rxno = strconv.FormatInt(item.ID, 10)
  11225. order.LongDrordFlag = "0"
  11226. order.HilistType = "1"
  11227. order.ChrgType = "1"
  11228. order.DrordBhvr = "0"
  11229. order.HilistCode = subItem.HisProject.MedicalCode
  11230. order.HosplistName = subItem.HisProject.ProjectName
  11231. order.HilistLv = "1"
  11232. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11233. order.HosplistCode = subItem.HisProject.MedicalCode
  11234. order.HosplistName = subItem.HisProject.ProjectName
  11235. order.Cnt = subItem.Count
  11236. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11237. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11238. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11239. order.OwnpayAmt = ""
  11240. order.SelfpayAmt = ""
  11241. order.Spec = subItem.Unit
  11242. order.SpecUnt = subItem.Unit
  11243. order.DrordBegnDate = s_tm
  11244. order.DrordStopDate = ""
  11245. order.DrordDrCodg = doctor_info.DoctorNumber
  11246. order.DrordDeptName = department.Name
  11247. order.DrordDeptCodg = department.Number
  11248. order.DrordDrName = doctor_info.UserName
  11249. order.DrordDrProfttl = "234"
  11250. order.CurrDrordFlag = "1"
  11251. orders = append(orders, &order)
  11252. }
  11253. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11254. var order models.FsiOrderDtos
  11255. order.RxID = strconv.FormatInt(item.ID, 10)
  11256. order.Rxno = strconv.FormatInt(item.ID, 10)
  11257. order.LongDrordFlag = "0"
  11258. order.HilistType = "1"
  11259. order.ChrgType = "1"
  11260. order.DrordBhvr = "0"
  11261. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11262. order.HosplistName = subItem.GoodInfo.GoodName
  11263. order.HilistLv = "1"
  11264. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11265. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11266. order.HosplistName = subItem.GoodInfo.GoodName
  11267. order.Cnt = subItem.Count
  11268. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11269. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11270. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11271. order.OwnpayAmt = ""
  11272. order.SelfpayAmt = ""
  11273. order.Spec = subItem.GoodInfo.SpecificationName
  11274. order.SpecUnt = subItem.Unit
  11275. order.DrordBegnDate = s_tm
  11276. order.DrordStopDate = ""
  11277. order.DrordDrCodg = doctor_info.DoctorNumber
  11278. order.DrordDeptName = department.Name
  11279. order.DrordDeptCodg = department.Number
  11280. order.DrordDrName = doctor_info.UserName
  11281. order.DrordDrProfttl = "234"
  11282. order.CurrDrordFlag = "1"
  11283. orders = append(orders, &order)
  11284. }
  11285. }
  11286. }
  11287. //处方医嘱信息
  11288. }
  11289. fed.MatnStas = "0"
  11290. fed.MedfeeSumamt = "0"
  11291. fed.OwnpayAmt = "0"
  11292. fed.SelfpayAmt = "0"
  11293. fed.AcctPayamt = "0"
  11294. fed.MaAmt = "0"
  11295. fed.HifpPayamt = "0"
  11296. fed.SetlTotlnum = "1"
  11297. fed.Insutype = his.Insutype
  11298. fed.ReimFlag = "0"
  11299. fed.OutSetlFlag = "0"
  11300. var fopd []*models.FsiOperationDtosData
  11301. data := make(map[string]interface{})
  11302. data["fed"] = fed
  11303. data["fdd"] = fdds
  11304. data["fod"] = orders
  11305. data["pd"] = pd
  11306. data["pp"] = pp
  11307. data["fopd"] = fopd
  11308. data["trig_scen"] = trig_scen
  11309. fmt.Println(data)
  11310. fmt.Println(fed)
  11311. fmt.Println(fdds)
  11312. fmt.Println(orders)
  11313. fmt.Println(pd)
  11314. fmt.Println(pp)
  11315. fmt.Println(fopd)
  11316. client := &http.Client{}
  11317. bytesData, _ := json.Marshal(data)
  11318. var req *http.Request
  11319. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11320. if miConfig.MdtrtareaAdmvs == "320921" {
  11321. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11322. } else {
  11323. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11324. }
  11325. resp, _ := client.Do(req)
  11326. defer resp.Body.Close()
  11327. body, ioErr := ioutil.ReadAll(resp.Body)
  11328. if ioErr != nil {
  11329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11331. return res
  11332. }
  11333. var respJSON map[string]interface{}
  11334. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11337. return res
  11338. }
  11339. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11340. fmt.Println(respJSON)
  11341. result, _ := json.Marshal(respJSON)
  11342. fmt.Println(result)
  11343. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11344. utils.ErrorLog("解析失败:%v", err)
  11345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11346. return res
  11347. }
  11348. return res
  11349. } else {
  11350. //if miConfig.MdtrtareaAdmvs == "441202" {
  11351. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11352. saveLog(output, input, "3101", "事前")
  11353. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11354. utils.ErrorLog("解析失败:%v", err)
  11355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11356. return
  11357. }
  11358. return res
  11359. //}
  11360. }
  11361. }
  11362. 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) {
  11363. adminUser := c.GetAdminUserInfo()
  11364. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11365. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11366. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11367. //record_time := c.GetString("record_time")
  11368. //trig_scen := c.GetString("trig_scen")
  11369. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11370. timeLayout := "2006-01-02"
  11371. loc, _ := time.LoadLocation("Local")
  11372. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11373. if err != nil {
  11374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11375. return res
  11376. }
  11377. recordDateTime := theTime.Unix()
  11378. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11379. var patientPrescription models.HisPrescriptionInfo
  11380. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11381. if patientPrescription.ID == 0 {
  11382. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11383. }
  11384. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11385. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11386. //
  11387. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11388. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11389. var pp models.PublicParams
  11390. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11391. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11392. pp.FixmedinsName = miConfig.OrgName
  11393. pp.FixmedinsCode = miConfig.Code
  11394. pp.RequestUrl = miConfig.Url
  11395. pp.Cainfo = miConfig.Cainfo
  11396. pp.SecretKey = miConfig.SecretKey
  11397. pp.AccessKey = miConfig.AccessKey
  11398. pp.OpterName = roles.UserName
  11399. var config []*models.HisXtDiagnoseConfig
  11400. for _, item := range diagnosis_ids {
  11401. id, _ := strconv.ParseInt(item, 10, 64)
  11402. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11403. config = append(config, &diagnosisConfig)
  11404. }
  11405. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11406. var pd models.PatientDtos
  11407. pd.PatnID = his.PsnNo
  11408. pd.PatnName = his.Name
  11409. pd.Gend = his.Gend
  11410. pd.Brdy = str
  11411. pd.Poolarea = his.InsuplcAdmdvs
  11412. pd.CurrMdtrtID = his.Number
  11413. var fed models.FsiEncounterDtos
  11414. fed.MdtrtID = his.Number
  11415. fed.MedinsID = miConfig.Code
  11416. fed.MedinsName = miConfig.OrgName
  11417. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11418. fed.MedMdtrtType = "1"
  11419. fed.MedinsType = "1"
  11420. fed.MedinsLv = "11"
  11421. tm := time.Unix(his.RecordDate, 0)
  11422. s_tm := tm.Format("2006-01-02 15:04:05")
  11423. fed.AdmDate = s_tm
  11424. fed.DscgDate = s_tm
  11425. fed.DscgMainDiseCodg = config[0].CountryCode
  11426. fed.DscgMainDiseName = config[0].CountryContentName
  11427. //诊断信息
  11428. var fdds []*models.FsiDiagnoseDtos
  11429. for index, item := range config {
  11430. if index == 0 {
  11431. var fdd models.FsiDiagnoseDtos
  11432. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11433. fdd.InoutDiseType = "1"
  11434. fdd.MaindiseFlag = "1"
  11435. fdd.DiseDate = s_tm
  11436. fdd.DiasSrtNo = "1"
  11437. fdd.DiseName = item.CountryContentName
  11438. fdd.DiseCodg = item.CountryCode
  11439. fdds = append(fdds, &fdd)
  11440. } else {
  11441. var fdd models.FsiDiagnoseDtos
  11442. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11443. fdd.InoutDiseType = "1"
  11444. fdd.MaindiseFlag = "1"
  11445. fdd.DiseDate = s_tm
  11446. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11447. fdd.DiseName = item.CountryContentName
  11448. fdd.DiseCodg = item.CountryCode
  11449. fdds = append(fdds, &fdd)
  11450. }
  11451. }
  11452. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11453. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11454. fed.AdmDeptName = department.Name
  11455. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11456. fed.DscgDeptName = department.Name
  11457. fed.MedMdtrtType = "1"
  11458. fed.MedType = "11"
  11459. //if his.Insutype == "390" {
  11460. // fed.MedType = "1402"
  11461. //} else {
  11462. // fed.MedType = "9933"
  11463. //}
  11464. var orders []*models.FsiOrderDtos
  11465. if trig_scen == "2" {
  11466. //处方医嘱信息
  11467. for _, item := range prescriptions {
  11468. for _, subItem := range item.HisDoctorAdviceInfo {
  11469. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11470. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11471. var order models.FsiOrderDtos
  11472. order.RxID = strconv.FormatInt(item.ID, 10)
  11473. order.Rxno = strconv.FormatInt(item.ID, 10)
  11474. order.LongDrordFlag = "0"
  11475. order.HilistType = "1"
  11476. order.ChrgType = "1"
  11477. order.DrordBhvr = "0"
  11478. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11479. order.HosplistName = subItem.BaseDrugLib.DrugName
  11480. order.HilistLv = "1"
  11481. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11482. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11483. order.HosplistName = subItem.BaseDrugLib.DrugName
  11484. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11485. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11486. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11487. order.OwnpayAmt = ""
  11488. order.SelfpayAmt = ""
  11489. order.Spec = spec
  11490. order.SpecUnt = subItem.PrescribingNumberUnit
  11491. order.DrordBegnDate = s_tm
  11492. order.DrordStopDate = ""
  11493. order.DrordDrCodg = doctor_info.DoctorNumber
  11494. order.DrordDeptName = department.Name
  11495. order.DrordDeptCodg = department.Number
  11496. order.DrordDrName = doctor_info.UserName
  11497. order.DrordDrProfttl = "234"
  11498. order.CurrDrordFlag = "1"
  11499. orders = append(orders, &order)
  11500. }
  11501. }
  11502. for _, subItem := range item.HisPrescriptionProject {
  11503. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11504. var order models.FsiOrderDtos
  11505. order.RxID = strconv.FormatInt(item.ID, 10)
  11506. order.Rxno = strconv.FormatInt(item.ID, 10)
  11507. order.LongDrordFlag = "0"
  11508. order.HilistType = "1"
  11509. order.ChrgType = "1"
  11510. order.DrordBhvr = "0"
  11511. order.HilistCode = subItem.HisProject.MedicalCode
  11512. order.HosplistName = subItem.HisProject.ProjectName
  11513. order.HilistLv = "1"
  11514. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11515. order.HosplistCode = subItem.HisProject.MedicalCode
  11516. order.HosplistName = subItem.HisProject.ProjectName
  11517. order.Cnt = subItem.Count
  11518. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11519. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11520. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11521. order.OwnpayAmt = ""
  11522. order.SelfpayAmt = ""
  11523. order.Spec = subItem.Unit
  11524. order.SpecUnt = subItem.Unit
  11525. order.DrordBegnDate = s_tm
  11526. order.DrordStopDate = ""
  11527. order.DrordDrCodg = doctor_info.DoctorNumber
  11528. order.DrordDeptName = department.Name
  11529. order.DrordDeptCodg = department.Number
  11530. order.DrordDrName = doctor_info.UserName
  11531. order.DrordDrProfttl = "234"
  11532. order.CurrDrordFlag = "1"
  11533. orders = append(orders, &order)
  11534. }
  11535. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11536. var order models.FsiOrderDtos
  11537. order.RxID = strconv.FormatInt(item.ID, 10)
  11538. order.Rxno = strconv.FormatInt(item.ID, 10)
  11539. order.LongDrordFlag = "0"
  11540. order.HilistType = "1"
  11541. order.ChrgType = "1"
  11542. order.DrordBhvr = "0"
  11543. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11544. order.HosplistName = subItem.GoodInfo.GoodName
  11545. order.HilistLv = "1"
  11546. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11547. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11548. order.HosplistName = subItem.GoodInfo.GoodName
  11549. order.Cnt = subItem.Count
  11550. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11551. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11552. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11553. order.OwnpayAmt = ""
  11554. order.SelfpayAmt = ""
  11555. order.Spec = subItem.GoodInfo.SpecificationName
  11556. order.SpecUnt = subItem.Unit
  11557. order.DrordBegnDate = s_tm
  11558. order.DrordStopDate = ""
  11559. order.DrordDrCodg = doctor_info.DoctorNumber
  11560. order.DrordDeptName = department.Name
  11561. order.DrordDeptCodg = department.Number
  11562. order.DrordDrName = doctor_info.UserName
  11563. order.DrordDrProfttl = "234"
  11564. order.CurrDrordFlag = "1"
  11565. orders = append(orders, &order)
  11566. }
  11567. }
  11568. }
  11569. //处方医嘱信息
  11570. }
  11571. fed.MatnStas = "0"
  11572. fed.MedfeeSumamt = "0"
  11573. fed.OwnpayAmt = "0"
  11574. fed.SelfpayAmt = "0"
  11575. fed.AcctPayamt = "0"
  11576. fed.MaAmt = "0"
  11577. fed.HifpPayamt = "0"
  11578. fed.SetlTotlnum = "1"
  11579. fed.Insutype = his.Insutype
  11580. fed.ReimFlag = "0"
  11581. fed.OutSetlFlag = "0"
  11582. var fopd []*models.FsiOperationDtosData
  11583. data := make(map[string]interface{})
  11584. data["fed"] = fed
  11585. data["fdd"] = fdds
  11586. data["fod"] = orders
  11587. data["pd"] = pd
  11588. data["pp"] = pp
  11589. data["fopd"] = fopd
  11590. data["trig_scen"] = trig_scen
  11591. fmt.Println(data)
  11592. fmt.Println(fed)
  11593. fmt.Println(fdds)
  11594. fmt.Println(orders)
  11595. fmt.Println(pd)
  11596. fmt.Println(pp)
  11597. fmt.Println(fopd)
  11598. client := &http.Client{}
  11599. bytesData, _ := json.Marshal(data)
  11600. var req *http.Request
  11601. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11602. if miConfig.MdtrtareaAdmvs == "320921" {
  11603. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11604. } else {
  11605. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11606. }
  11607. resp, _ := client.Do(req)
  11608. defer resp.Body.Close()
  11609. body, ioErr := ioutil.ReadAll(resp.Body)
  11610. if ioErr != nil {
  11611. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11613. return res
  11614. }
  11615. var respJSON map[string]interface{}
  11616. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11619. return res
  11620. }
  11621. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11622. fmt.Println(respJSON)
  11623. result, _ := json.Marshal(respJSON)
  11624. fmt.Println(result)
  11625. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11626. utils.ErrorLog("解析失败:%v", err)
  11627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11628. return res
  11629. }
  11630. return res
  11631. } else {
  11632. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11633. saveLog(output, input, "3101", "事前")
  11634. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11635. utils.ErrorLog("解析失败:%v", err)
  11636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11637. return
  11638. }
  11639. return res
  11640. }
  11641. return res
  11642. }
  11643. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11644. ////patient_id, _ := c.GetInt64("patient_id")
  11645. //order_id, _ := c.GetInt64("order_id")
  11646. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11647. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11648. //trig_scen := c.GetString("trig_scen")
  11649. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11650. //utils.ErrorLog("解析失败:%v", psn_info)
  11651. adminUser := c.GetAdminUserInfo()
  11652. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11653. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11654. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11655. record_time := c.GetString("record_time")
  11656. order, _ := service.GetHisOrderByID(order_id)
  11657. timeLayout := "2006-01-02"
  11658. loc, _ := time.LoadLocation("Local")
  11659. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11660. if err != nil {
  11661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11662. return
  11663. }
  11664. recordDateTime := theTime.Unix()
  11665. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11666. var patientPrescription models.HisPrescriptionInfo
  11667. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11668. if patientPrescription.ID == 0 {
  11669. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11670. }
  11671. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11672. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11673. //
  11674. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11675. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11676. var pp models.PublicParams
  11677. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11678. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11679. pp.FixmedinsName = miConfig.OrgName
  11680. pp.FixmedinsCode = miConfig.Code
  11681. pp.RequestUrl = miConfig.Url
  11682. pp.Cainfo = miConfig.Cainfo
  11683. pp.SecretKey = miConfig.SecretKey
  11684. pp.AccessKey = miConfig.AccessKey
  11685. pp.OpterName = roles.UserName
  11686. var config []*models.HisXtDiagnoseConfig
  11687. for _, item := range diagnosis_ids {
  11688. id, _ := strconv.ParseInt(item, 10, 64)
  11689. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11690. config = append(config, &diagnosisConfig)
  11691. }
  11692. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11693. var pd models.PatientDtos
  11694. pd.PatnID = his.PsnNo
  11695. pd.PatnName = his.Name
  11696. pd.Gend = his.Gend
  11697. pd.Brdy = str
  11698. pd.Poolarea = his.InsuplcAdmdvs
  11699. pd.CurrMdtrtID = his.Number
  11700. var fed models.FsiEncounterDtos
  11701. fed.MdtrtID = his.Number
  11702. fed.MedinsID = miConfig.Code
  11703. fed.MedinsName = miConfig.OrgName
  11704. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11705. fed.MedMdtrtType = "1"
  11706. fed.MedinsType = "1"
  11707. fed.MedinsLv = "11"
  11708. tm := time.Unix(his.RecordDate, 0)
  11709. s_tm := tm.Format("2006-01-02 15:04:05")
  11710. fed.AdmDate = s_tm
  11711. fed.DscgDate = s_tm
  11712. fed.DscgMainDiseCodg = config[0].CountryCode
  11713. fed.DscgMainDiseName = config[0].CountryContentName
  11714. //诊断信息
  11715. var fdds []*models.FsiDiagnoseDtos
  11716. for index, item := range config {
  11717. if index == 0 {
  11718. var fdd models.FsiDiagnoseDtos
  11719. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11720. fdd.InoutDiseType = "1"
  11721. fdd.MaindiseFlag = "1"
  11722. fdd.DiseDate = s_tm
  11723. fdd.DiasSrtNo = "1"
  11724. fdd.DiseName = item.CountryContentName
  11725. fdd.DiseCodg = item.CountryCode
  11726. fdds = append(fdds, &fdd)
  11727. } else {
  11728. var fdd models.FsiDiagnoseDtos
  11729. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11730. fdd.InoutDiseType = "1"
  11731. fdd.MaindiseFlag = "1"
  11732. fdd.DiseDate = s_tm
  11733. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11734. fdd.DiseName = item.CountryContentName
  11735. fdd.DiseCodg = item.CountryCode
  11736. fdds = append(fdds, &fdd)
  11737. }
  11738. }
  11739. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11740. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11741. fed.AdmDeptName = department.Name
  11742. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11743. fed.DscgDeptName = department.Name
  11744. fed.MedType = order.MedType
  11745. //处方医嘱信息
  11746. var orders []*models.FsiOrderDtos
  11747. //for _, item := range prescriptions {
  11748. // for _, subItem := range item.HisDoctorAdviceInfo {
  11749. // var order models.FsiOrderDtos
  11750. // order.RxID = strconv.FormatInt(item.ID, 10)
  11751. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11752. // order.LongDrordFlag = "0"
  11753. // order.HilistType = "1"
  11754. // order.ChrgType = "1"
  11755. // order.DrordBhvr = "-"
  11756. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11757. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11758. // order.HilistLv = "1"
  11759. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11760. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11761. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11762. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11763. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11764. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11765. // order.OwnpayAmt = ""
  11766. // order.SelfpayAmt = ""
  11767. // order.Spec = ""
  11768. // order.SpecUnt = ""
  11769. // order.DrordBegnDate = s_tm
  11770. // order.DrordStopDate = ""
  11771. // order.DrordDrCodg = "1"
  11772. // order.DrordDeptName = department.Name
  11773. // order.DrordDrCodg = "1"
  11774. // order.DrordDrName = doctor_info.UserName
  11775. // order.DrordDrProfttl = ""
  11776. // order.CurrDrordFlag = "1"
  11777. // orders = append(orders, &order)
  11778. // }
  11779. // for _, subItem := range item.HisPrescriptionProject {
  11780. // if subItem.Type == 2 {
  11781. // var order models.FsiOrderDtos
  11782. // order.RxID = strconv.FormatInt(item.ID, 10)
  11783. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11784. // order.LongDrordFlag = "0"
  11785. // order.HilistType = "1"
  11786. // order.ChrgType = "1"
  11787. // order.DrordBhvr = "-"
  11788. // order.HilistCode = subItem.HisProject.MedicalCode
  11789. // order.HosplistName = subItem.HisProject.ProjectName
  11790. // order.HilistLv = "1"
  11791. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11792. // order.HosplistCode = subItem.HisProject.MedicalCode
  11793. // order.HosplistName = subItem.HisProject.ProjectName
  11794. // order.Cnt = subItem.Count
  11795. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11796. //
  11797. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11798. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11799. // order.OwnpayAmt = ""
  11800. // order.SelfpayAmt = ""
  11801. // order.Spec = ""
  11802. // order.SpecUnt = ""
  11803. // order.DrordBegnDate = s_tm
  11804. // order.DrordStopDate = ""
  11805. // order.DrordDrCodg = "1"
  11806. // order.DrordDeptName = department.Name
  11807. // order.DrordDrCodg = "1"
  11808. // order.DrordDrName = doctor_info.UserName
  11809. // order.DrordDrProfttl = ""
  11810. // order.CurrDrordFlag = "1"
  11811. // orders = append(orders, &order)
  11812. //
  11813. // }
  11814. // if subItem.Type == 3 {
  11815. //
  11816. // var order models.FsiOrderDtos
  11817. // order.RxID = strconv.FormatInt(item.ID, 10)
  11818. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11819. // order.LongDrordFlag = "0"
  11820. // order.HilistType = "1"
  11821. // order.ChrgType = "1"
  11822. // order.DrordBhvr = "-"
  11823. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11824. // order.HosplistName = subItem.GoodInfo.GoodName
  11825. // order.HilistLv = "1"
  11826. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11827. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11828. // order.HosplistName = subItem.GoodInfo.GoodName
  11829. // order.Cnt = subItem.Count
  11830. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11831. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11832. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11833. // order.OwnpayAmt = ""
  11834. // order.SelfpayAmt = ""
  11835. // order.Spec = ""
  11836. // order.SpecUnt = ""
  11837. // order.DrordBegnDate = s_tm
  11838. // order.DrordStopDate = ""
  11839. // order.DrordDrCodg = "1"
  11840. // order.DrordDeptName = department.Name
  11841. // order.DrordDrCodg = "1"
  11842. // order.DrordDrName = doctor_info.UserName
  11843. // order.DrordDrProfttl = ""
  11844. // order.CurrDrordFlag = "1"
  11845. // orders = append(orders, &order)
  11846. //
  11847. // }
  11848. // }
  11849. //}
  11850. for _, item := range prescriptions {
  11851. for _, subItem := range item.HisDoctorAdviceInfo {
  11852. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11853. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11854. var order models.FsiOrderDtos
  11855. order.RxID = strconv.FormatInt(item.ID, 10)
  11856. order.Rxno = strconv.FormatInt(item.ID, 10)
  11857. order.LongDrordFlag = "0"
  11858. order.HilistType = "1"
  11859. order.ChrgType = "1"
  11860. order.DrordBhvr = "0"
  11861. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11862. order.HosplistName = subItem.BaseDrugLib.DrugName
  11863. order.HilistLv = "1"
  11864. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11865. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11866. order.HosplistName = subItem.BaseDrugLib.DrugName
  11867. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11868. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11869. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11870. order.OwnpayAmt = ""
  11871. order.SelfpayAmt = ""
  11872. order.Spec = spec
  11873. order.SpecUnt = subItem.PrescribingNumberUnit
  11874. order.DrordBegnDate = s_tm
  11875. order.DrordStopDate = ""
  11876. order.DrordDrCodg = doctor_info.DoctorNumber
  11877. order.DrordDeptName = department.Name
  11878. order.DrordDeptCodg = department.Number
  11879. order.DrordDrName = doctor_info.UserName
  11880. order.DrordDrProfttl = "234"
  11881. order.CurrDrordFlag = "1"
  11882. orders = append(orders, &order)
  11883. }
  11884. }
  11885. for _, subItem := range item.HisPrescriptionProject {
  11886. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11887. var order models.FsiOrderDtos
  11888. order.RxID = strconv.FormatInt(item.ID, 10)
  11889. order.Rxno = strconv.FormatInt(item.ID, 10)
  11890. order.LongDrordFlag = "0"
  11891. order.HilistType = "1"
  11892. order.ChrgType = "1"
  11893. order.DrordBhvr = "0"
  11894. order.HilistCode = subItem.HisProject.MedicalCode
  11895. order.HosplistName = subItem.HisProject.ProjectName
  11896. order.HilistLv = "1"
  11897. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11898. order.HosplistCode = subItem.HisProject.MedicalCode
  11899. order.HosplistName = subItem.HisProject.ProjectName
  11900. order.Cnt = subItem.Count
  11901. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11902. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11903. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11904. order.OwnpayAmt = ""
  11905. order.SelfpayAmt = ""
  11906. order.Spec = subItem.Unit
  11907. order.SpecUnt = subItem.Unit
  11908. order.DrordBegnDate = s_tm
  11909. order.DrordStopDate = ""
  11910. order.DrordDrCodg = doctor_info.DoctorNumber
  11911. order.DrordDeptName = department.Name
  11912. order.DrordDeptCodg = department.Number
  11913. order.DrordDrName = doctor_info.UserName
  11914. order.DrordDrProfttl = "234"
  11915. order.CurrDrordFlag = "1"
  11916. orders = append(orders, &order)
  11917. }
  11918. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11919. var order models.FsiOrderDtos
  11920. order.RxID = strconv.FormatInt(item.ID, 10)
  11921. order.Rxno = strconv.FormatInt(item.ID, 10)
  11922. order.LongDrordFlag = "0"
  11923. order.HilistType = "1"
  11924. order.ChrgType = "1"
  11925. order.DrordBhvr = "0"
  11926. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11927. order.HosplistName = subItem.GoodInfo.GoodName
  11928. order.HilistLv = "1"
  11929. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11930. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11931. order.HosplistName = subItem.GoodInfo.GoodName
  11932. order.Cnt = subItem.Count
  11933. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11934. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11935. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11936. order.OwnpayAmt = ""
  11937. order.SelfpayAmt = ""
  11938. order.Spec = subItem.GoodInfo.SpecificationName
  11939. order.SpecUnt = subItem.Unit
  11940. order.DrordBegnDate = s_tm
  11941. order.DrordStopDate = ""
  11942. order.DrordDrCodg = doctor_info.DoctorNumber
  11943. order.DrordDeptName = department.Name
  11944. order.DrordDeptCodg = department.Number
  11945. order.DrordDrName = doctor_info.UserName
  11946. order.DrordDrProfttl = "234"
  11947. order.CurrDrordFlag = "1"
  11948. orders = append(orders, &order)
  11949. }
  11950. }
  11951. }
  11952. //处方医嘱信息
  11953. fed.MatnStas = "0"
  11954. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11955. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11956. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11957. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11958. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11959. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11960. fed.SetlTotlnum = "1"
  11961. fed.Insutype = his.Insutype
  11962. fed.ReimFlag = "0"
  11963. fed.OutSetlFlag = "0"
  11964. var fopd []*models.FsiOperationDtosData
  11965. data := make(map[string]interface{})
  11966. data["fed"] = fed
  11967. data["fdd"] = fdds
  11968. data["fod"] = orders
  11969. data["pd"] = pd
  11970. data["pp"] = pp
  11971. data["fopd"] = fopd
  11972. data["trig_scen"] = trig_scen
  11973. client := &http.Client{}
  11974. bytesData, _ := json.Marshal(data)
  11975. var req *http.Request
  11976. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11977. if miConfig.MdtrtareaAdmvs == "320921" {
  11978. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11979. } else {
  11980. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11981. }
  11982. resp, _ := client.Do(req)
  11983. defer resp.Body.Close()
  11984. body, ioErr := ioutil.ReadAll(resp.Body)
  11985. if ioErr != nil {
  11986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11988. return res
  11989. }
  11990. var respJSON map[string]interface{}
  11991. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11994. return res
  11995. }
  11996. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(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 res
  12002. }
  12003. return res
  12004. } else {
  12005. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12006. saveLog(output, input, "3102", "事中")
  12007. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12008. utils.ErrorLog("解析失败:%v", err)
  12009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12010. return
  12011. }
  12012. return res
  12013. }
  12014. return res
  12015. }
  12016. func (c *HisApiController) Check() {
  12017. psn_no := c.GetString("psn_no")
  12018. in := c.GetString("in")
  12019. mt := c.GetString("mt")
  12020. baseParams := models.BaseParams{
  12021. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12022. FixmedinsCode: "H15049901371",
  12023. InsuplcAdmdvs: "150499",
  12024. MdtrtareaAdmvs: "150499",
  12025. OrgName: "赤峰费森血液透析中心",
  12026. Doctor: "1111",
  12027. }
  12028. service.Gdyb2001(baseParams, psn_no, in, mt)
  12029. }
  12030. func (c *HisApiController) GetPsnNcdsInfo() {
  12031. admin_user_id, _ := c.GetInt64("admin_user_id")
  12032. patient_id, _ := c.GetInt64("patient_id")
  12033. //id, _ := c.GetInt64("id")
  12034. adminUser := c.GetAdminUserInfo()
  12035. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12036. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12037. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12038. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12039. //psn_record, _ := service.GetP(id)
  12040. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12041. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12042. //
  12043. //if psn_record.ID == 0 {
  12044. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12045. // return
  12046. //}
  12047. var res Result5301
  12048. var res10265 Result5301For10265
  12049. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12050. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12051. var api string
  12052. if miConfig.MdtrtareaAdmvs == "320921" {
  12053. 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 +
  12054. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12055. } else {
  12056. 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 +
  12057. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12058. }
  12059. resp, requestErr := http.Get(api)
  12060. if requestErr != nil {
  12061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12062. return
  12063. }
  12064. body, ioErr := ioutil.ReadAll(resp.Body)
  12065. if ioErr != nil {
  12066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12068. return
  12069. }
  12070. var respJSON map[string]interface{}
  12071. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12074. return
  12075. }
  12076. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12077. result, _ := json.Marshal(respJSON)
  12078. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12079. utils.ErrorLog("解析失败:%v", err)
  12080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12081. return
  12082. }
  12083. res.ErrMsg = res10265.ErrMsg
  12084. res.Output = res10265.Output
  12085. res.InfRefmsgid = res10265.InfRefmsgid
  12086. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12087. res.Infcode = infocode
  12088. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12089. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12090. var api string
  12091. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12092. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12093. resp, requestErr := http.Get(api)
  12094. if requestErr != nil {
  12095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12096. return
  12097. }
  12098. body, ioErr := ioutil.ReadAll(resp.Body)
  12099. if ioErr != nil {
  12100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12102. return
  12103. }
  12104. var respJSON map[string]interface{}
  12105. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12108. return
  12109. }
  12110. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12111. if status == "0" {
  12112. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12113. c.ServeSuccessJSON(map[string]interface{}{
  12114. "failed_code": -10,
  12115. "msg": err_msg,
  12116. })
  12117. return
  12118. }
  12119. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12120. result, _ := json.Marshal(respJSON)
  12121. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12122. utils.ErrorLog("解析失败:%v", err)
  12123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12124. return
  12125. }
  12126. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12127. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12128. var api string
  12129. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12130. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12131. resp, requestErr := http.Get(api)
  12132. if requestErr != nil {
  12133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12134. return
  12135. }
  12136. body, ioErr := ioutil.ReadAll(resp.Body)
  12137. if ioErr != nil {
  12138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12140. return
  12141. }
  12142. var respJSON map[string]interface{}
  12143. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12146. return
  12147. }
  12148. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12149. if status == "0" {
  12150. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12151. c.ServeSuccessJSON(map[string]interface{}{
  12152. "failed_code": -10,
  12153. "msg": err_msg,
  12154. })
  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 == "360302" {
  12165. p, _ := service.GetHisPatientById(patient_id)
  12166. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12167. var dat map[string]interface{}
  12168. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12169. fmt.Println(dat)
  12170. } else {
  12171. fmt.Println(err)
  12172. }
  12173. userJSONBytes, _ := json.Marshal(dat)
  12174. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12175. utils.ErrorLog("解析失败:%v", err)
  12176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12177. return
  12178. }
  12179. } else if miConfig.MdtrtareaAdmvs == "361025" {
  12180. p, _ := service.GetHisPatientById(patient_id)
  12181. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12182. var dat map[string]interface{}
  12183. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12184. fmt.Println(dat)
  12185. } else {
  12186. fmt.Println(err)
  12187. }
  12188. userJSONBytes, _ := json.Marshal(dat)
  12189. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12190. utils.ErrorLog("解析失败:%v", err)
  12191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12192. return
  12193. }
  12194. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12195. p, _ := service.GetHisPatientById(patient_id)
  12196. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12197. var dat map[string]interface{}
  12198. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12199. fmt.Println(dat)
  12200. } else {
  12201. fmt.Println(err)
  12202. }
  12203. userJSONBytes, _ := json.Marshal(dat)
  12204. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12205. utils.ErrorLog("解析失败:%v", err)
  12206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12207. return
  12208. }
  12209. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12210. p, _ := service.GetHisPatientById(patient_id)
  12211. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12212. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12213. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12214. resp, requestErr := http.Get(api)
  12215. if requestErr != nil {
  12216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12217. return
  12218. }
  12219. body, ioErr := ioutil.ReadAll(resp.Body)
  12220. if ioErr != nil {
  12221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12223. return
  12224. }
  12225. var respJSON map[string]interface{}
  12226. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12229. return
  12230. }
  12231. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12232. result, _ := json.Marshal(respJSON)
  12233. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12234. utils.ErrorLog("解析失败:%v", err)
  12235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12236. return
  12237. }
  12238. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12239. p, _ := service.GetHisPatientById(patient_id)
  12240. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12241. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12242. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12243. resp, requestErr := http.Get(api)
  12244. if requestErr != nil {
  12245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12246. return
  12247. }
  12248. body, ioErr := ioutil.ReadAll(resp.Body)
  12249. if ioErr != nil {
  12250. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12252. return
  12253. }
  12254. var respJSON map[string]interface{}
  12255. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12258. return
  12259. }
  12260. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12261. result, _ := json.Marshal(respJSON)
  12262. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12263. utils.ErrorLog("解析失败:%v", err)
  12264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12265. return
  12266. }
  12267. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12268. p, _ := service.GetHisPatientById(patient_id)
  12269. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12270. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12271. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12272. resp, requestErr := http.Get(api)
  12273. if requestErr != nil {
  12274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12275. return
  12276. }
  12277. body, ioErr := ioutil.ReadAll(resp.Body)
  12278. if ioErr != nil {
  12279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12281. return
  12282. }
  12283. var respJSON map[string]interface{}
  12284. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12287. return
  12288. }
  12289. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12290. result, _ := json.Marshal(respJSON)
  12291. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12292. utils.ErrorLog("解析失败:%v", err)
  12293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12294. return
  12295. }
  12296. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12297. p, _ := service.GetHisPatientById(patient_id)
  12298. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12299. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12300. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12301. resp, requestErr := http.Get(api)
  12302. if requestErr != nil {
  12303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12304. return
  12305. }
  12306. body, ioErr := ioutil.ReadAll(resp.Body)
  12307. if ioErr != nil {
  12308. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12310. return
  12311. }
  12312. var respJSON map[string]interface{}
  12313. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12314. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12316. return
  12317. }
  12318. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12319. result, _ := json.Marshal(respJSON)
  12320. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12321. utils.ErrorLog("解析失败:%v", err)
  12322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12323. return
  12324. }
  12325. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12326. p, _ := service.GetHisPatientById(patient_id)
  12327. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12328. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12329. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12330. resp, requestErr := http.Get(api)
  12331. if requestErr != nil {
  12332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12333. return
  12334. }
  12335. body, ioErr := ioutil.ReadAll(resp.Body)
  12336. if ioErr != nil {
  12337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12339. return
  12340. }
  12341. var respJSON map[string]interface{}
  12342. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12345. return
  12346. }
  12347. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12348. result, _ := json.Marshal(respJSON)
  12349. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12350. utils.ErrorLog("解析失败:%v", err)
  12351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12352. return
  12353. }
  12354. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12355. p, _ := service.GetHisPatientById(patient_id)
  12356. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12357. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12358. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12359. resp, requestErr := http.Get(api)
  12360. if requestErr != nil {
  12361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12362. return
  12363. }
  12364. body, ioErr := ioutil.ReadAll(resp.Body)
  12365. if ioErr != nil {
  12366. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12368. return
  12369. }
  12370. var respJSON map[string]interface{}
  12371. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12374. return
  12375. }
  12376. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12377. result, _ := json.Marshal(respJSON)
  12378. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12379. utils.ErrorLog("解析失败:%v", err)
  12380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12381. return
  12382. }
  12383. } else {
  12384. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12385. var dat map[string]interface{}
  12386. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12387. fmt.Println(dat)
  12388. } else {
  12389. fmt.Println(err)
  12390. }
  12391. userJSONBytes, _ := json.Marshal(dat)
  12392. if miConfig.Code == "H15049901371" {
  12393. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12394. utils.ErrorLog("解析失败:%v", err)
  12395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12396. return
  12397. }
  12398. res.InfRefmsgid = res10265.InfRefmsgid
  12399. res.Output = res10265.Output
  12400. res.ErrMsg = res10265.ErrMsg
  12401. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12402. res.Infcode = infocode
  12403. } else {
  12404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12405. utils.ErrorLog("解析失败:%v", err)
  12406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12407. return
  12408. }
  12409. }
  12410. }
  12411. if res.Infcode == 0 {
  12412. c.ServeSuccessJSON(map[string]interface{}{
  12413. "result": res.Output.Result,
  12414. })
  12415. }
  12416. }
  12417. func (c *HisApiController) CheckInsutype() {
  12418. his_patient_id, _ := c.GetInt64("his_patient_id")
  12419. admin_user_id, _ := c.GetInt64("admin_user_id")
  12420. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12421. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12422. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12423. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12424. var dat map[string]interface{}
  12425. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12426. fmt.Println(dat)
  12427. } else {
  12428. fmt.Println(err)
  12429. }
  12430. userJSONBytes, _ := json.Marshal(dat)
  12431. var res Result90100
  12432. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12433. utils.ErrorLog("解析失败:%v", err)
  12434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12435. return
  12436. }
  12437. if res.Infcode != 0 {
  12438. c.ServeSuccessJSON(map[string]interface{}{
  12439. "failed_code": -10,
  12440. "msg": res.ErrMsg,
  12441. })
  12442. return
  12443. } else {
  12444. fmt.Println(res)
  12445. }
  12446. }
  12447. func (c *HisApiController) CheckCardPWD() {
  12448. card_pwd := c.GetString("card_pwd")
  12449. his_patient_id, _ := c.GetInt64("his_patient_id")
  12450. admin_user_id, _ := c.GetInt64("admin_user_id")
  12451. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12452. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12453. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12454. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12455. bas := strings.Split(psn.CardInfo, "|")
  12456. basNumber := bas[2]
  12457. if psn.InsuplcAdmdvs[:4] == "4403" {
  12458. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12459. var dat map[string]interface{}
  12460. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12461. fmt.Println(dat)
  12462. } else {
  12463. fmt.Println(err)
  12464. }
  12465. userJSONBytes, _ := json.Marshal(dat)
  12466. var res Result90991
  12467. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12468. utils.ErrorLog("解析失败:%v", err)
  12469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12470. return
  12471. }
  12472. if res.Infcode != 0 {
  12473. c.ServeSuccessJSON(map[string]interface{}{
  12474. "failed_code": -10,
  12475. "msg": res.ErrMsg,
  12476. })
  12477. return
  12478. } else {
  12479. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12480. var msg string
  12481. switch res.Output.Result.CardStat {
  12482. case "00":
  12483. msg = "未激活"
  12484. break
  12485. case "10":
  12486. msg = "激活"
  12487. break
  12488. case "20":
  12489. msg = "窗口挂失"
  12490. break
  12491. case "21":
  12492. msg = "电话挂失"
  12493. break
  12494. case "22":
  12495. msg = "单位网上申报挂失"
  12496. break
  12497. case "23":
  12498. msg = "保健办挂失"
  12499. break
  12500. case "24":
  12501. msg = "个人网上挂失"
  12502. break
  12503. case "25":
  12504. msg = "网上服务大厅挂失"
  12505. break
  12506. case "30":
  12507. msg = "注销"
  12508. break
  12509. case "40":
  12510. msg = "回收"
  12511. break
  12512. case "99":
  12513. msg = "制卡中(无效卡)"
  12514. break
  12515. }
  12516. c.ServeSuccessJSON(map[string]interface{}{
  12517. "failed_code": -10,
  12518. "msg": msg,
  12519. })
  12520. return
  12521. } else {
  12522. c.ServeSuccessJSON(map[string]interface{}{
  12523. "msg": "校验成功",
  12524. })
  12525. return
  12526. }
  12527. }
  12528. } else {
  12529. c.ServeSuccessJSON(map[string]interface{}{
  12530. "msg": "校验成功",
  12531. })
  12532. return
  12533. }
  12534. }
  12535. func (c *HisApiController) CheckCardPWDTwo() {
  12536. //card_pwd := c.GetString("card_pwd")
  12537. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12538. admin_user_id, _ := c.GetInt64("admin_user_id")
  12539. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12540. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12541. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12542. var dat map[string]interface{}
  12543. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12544. fmt.Println(dat)
  12545. } else {
  12546. fmt.Println(err)
  12547. }
  12548. userJSONBytes, _ := json.Marshal(dat)
  12549. var res Result90991
  12550. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12551. utils.ErrorLog("解析失败:%v", err)
  12552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12553. return
  12554. }
  12555. if res.Infcode != 0 {
  12556. c.ServeSuccessJSON(map[string]interface{}{
  12557. "failed_code": -10,
  12558. "msg": res.ErrMsg,
  12559. })
  12560. return
  12561. } else {
  12562. if res.Output.Result.SscnoCheckStat == "0" {
  12563. var msg string
  12564. switch res.Output.Result.CardStat {
  12565. case "00":
  12566. msg = "未激活"
  12567. break
  12568. case "10":
  12569. msg = "激活"
  12570. break
  12571. case "20":
  12572. msg = "窗口挂失"
  12573. break
  12574. case "21":
  12575. msg = "电话挂失"
  12576. break
  12577. case "22":
  12578. msg = "单位网上申报挂失"
  12579. break
  12580. case "23":
  12581. msg = "保健办挂失"
  12582. break
  12583. case "24":
  12584. msg = "个人网上挂失"
  12585. break
  12586. case "25":
  12587. msg = "网上服务大厅挂失"
  12588. break
  12589. case "30":
  12590. msg = "注销"
  12591. break
  12592. case "40":
  12593. msg = "回收"
  12594. break
  12595. case "99":
  12596. msg = "制卡中(无效卡)"
  12597. break
  12598. }
  12599. c.ServeSuccessJSON(map[string]interface{}{
  12600. "failed_code": -10,
  12601. "msg": msg,
  12602. })
  12603. return
  12604. } else {
  12605. c.ServeSuccessJSON(map[string]interface{}{
  12606. "msg": "校验成功",
  12607. })
  12608. return
  12609. }
  12610. }
  12611. }
  12612. type ELeCertData struct {
  12613. Data struct {
  12614. Extra string `json:"extra"`
  12615. IDNo string `json:"idNo"`
  12616. IDType string `json:"idType"`
  12617. EcToken string `json:"ecToken"`
  12618. InsuOrg string `json:"insuOrg"`
  12619. UserName string `json:"userName"`
  12620. EcIndexNo string `json:"ecIndexNo"`
  12621. Gender string `json:"gender"`
  12622. Birthday string `json:"birthday"`
  12623. Nationality string `json:"nationality"`
  12624. Email string `json:"email"`
  12625. } `json:"OutData"`
  12626. }
  12627. func (c *HisApiController) ReadCard() {
  12628. id_card_type, _ := c.GetInt64("id_card_type")
  12629. admin_user_id, _ := c.GetInt64("admin_user_id")
  12630. certificates, _ := c.GetInt64("certificates")
  12631. //
  12632. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12633. id_card_no := c.GetString("id_card_no")
  12634. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12635. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12636. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12637. switch id_card_type {
  12638. case 1:
  12639. if miConfig.MdtrtareaAdmvs == "421300" {
  12640. var res ResultTwo
  12641. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12642. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12643. "&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)
  12644. resp, requestErr := http.Get(api)
  12645. if requestErr != nil {
  12646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12647. return
  12648. }
  12649. body, ioErr := ioutil.ReadAll(resp.Body)
  12650. if ioErr != nil {
  12651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12653. return
  12654. }
  12655. var respJSON map[string]interface{}
  12656. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12659. return
  12660. }
  12661. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12662. result, _ := json.Marshal(respJSON)
  12663. fmt.Println("log")
  12664. fmt.Println(string(result))
  12665. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12666. utils.ErrorLog("解析失败:%v", err)
  12667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12668. return
  12669. }
  12670. if res.Infcode == 0 {
  12671. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12672. if err == gorm.ErrRecordNotFound {
  12673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12674. return
  12675. } else if err != nil {
  12676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12677. return
  12678. } else {
  12679. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12680. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12681. infoStr := string(Iinfos)
  12682. idetinfoStr := string(Idetinfos)
  12683. var rf []*ResultFive
  12684. json.Unmarshal([]byte(infoStr), &rf)
  12685. var insutypes []*ResultFive
  12686. var insutype string
  12687. var is390 int = 0
  12688. var is310 int = 0
  12689. for _, item := range rf {
  12690. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12691. insutypes = append(insutypes, item)
  12692. }
  12693. }
  12694. if len(insutypes) == 1 {
  12695. insutype = insutypes[0].Insutype
  12696. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12697. } else {
  12698. for _, i := range insutypes {
  12699. if i.Insutype == "390" {
  12700. is390 = 1
  12701. }
  12702. if i.Insutype == "310" {
  12703. is310 = 1
  12704. }
  12705. }
  12706. }
  12707. if is390 == 1 {
  12708. insutype = "390"
  12709. }
  12710. if is310 == 1 {
  12711. insutype = "310"
  12712. }
  12713. if len(insutypes) == 0 {
  12714. insutype = "390"
  12715. }
  12716. var insuplc_admdvs string
  12717. for _, item := range rf {
  12718. if item.Insutype == insutype {
  12719. insuplc_admdvs = item.InsuplcAdmdvs
  12720. }
  12721. }
  12722. if strings.Contains(insuplc_admdvs, "4213") {
  12723. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12724. }
  12725. psn := &models.HisPsn{
  12726. PsnNo: res.Output.Baseinfo.PsnNo,
  12727. PatientId: patient.ID,
  12728. Certno: res.Output.Baseinfo.Certno,
  12729. Gend: res.Output.Baseinfo.Gend,
  12730. Naty: res.Output.Baseinfo.Naty,
  12731. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12732. PsnName: res.Output.Baseinfo.PsnName,
  12733. Idetinfo: idetinfoStr,
  12734. Insuinfo: infoStr,
  12735. InsuplcAdmdvs: insuplc_admdvs,
  12736. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12737. }
  12738. service.CreateHisPsn(psn)
  12739. c.ServeSuccessJSON(map[string]interface{}{
  12740. "patient": patient,
  12741. "number": res.Output.Baseinfo.Certno,
  12742. })
  12743. }
  12744. } else {
  12745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12746. return
  12747. }
  12748. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12749. var res ResultTwo
  12750. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12751. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12752. "&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)
  12753. resp, requestErr := http.Get(api)
  12754. if requestErr != nil {
  12755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12756. return
  12757. }
  12758. body, ioErr := ioutil.ReadAll(resp.Body)
  12759. if ioErr != nil {
  12760. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12762. return
  12763. }
  12764. var respJSON map[string]interface{}
  12765. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12768. return
  12769. }
  12770. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12771. result, _ := json.Marshal(respJSON)
  12772. fmt.Println("log")
  12773. fmt.Println(string(result))
  12774. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12775. utils.ErrorLog("解析失败:%v", err)
  12776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12777. return
  12778. }
  12779. if res.Infcode == 0 {
  12780. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12781. if err == gorm.ErrRecordNotFound {
  12782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12783. return
  12784. } else if err != nil {
  12785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12786. return
  12787. } else {
  12788. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12789. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12790. infoStr := string(Iinfos)
  12791. idetinfoStr := string(Idetinfos)
  12792. psn := &models.HisPsn{
  12793. PsnNo: res.Output.Baseinfo.PsnNo,
  12794. PatientId: patient.ID,
  12795. Certno: res.Output.Baseinfo.Certno,
  12796. Gend: res.Output.Baseinfo.Gend,
  12797. Naty: res.Output.Baseinfo.Naty,
  12798. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12799. PsnName: res.Output.Baseinfo.PsnName,
  12800. Idetinfo: idetinfoStr,
  12801. Insuinfo: infoStr,
  12802. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12803. }
  12804. service.CreateHisPsn(psn)
  12805. var rf []*ResultFive
  12806. json.Unmarshal([]byte(infoStr), &rf)
  12807. var insutypes []*ResultFive
  12808. var insutype string
  12809. var is390 int = 0
  12810. var is310 int = 0
  12811. for _, item := range rf {
  12812. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12813. insutypes = append(insutypes, item)
  12814. }
  12815. }
  12816. if len(insutypes) == 1 {
  12817. insutype = insutypes[0].Insutype
  12818. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12819. } else {
  12820. for _, i := range insutypes {
  12821. if i.Insutype == "390" {
  12822. is390 = 1
  12823. }
  12824. if i.Insutype == "310" {
  12825. is310 = 1
  12826. }
  12827. }
  12828. }
  12829. if is390 == 1 {
  12830. insutype = "390"
  12831. }
  12832. if is310 == 1 {
  12833. insutype = "310"
  12834. }
  12835. if len(insutypes) == 0 {
  12836. insutype = "310"
  12837. }
  12838. c.ServeSuccessJSON(map[string]interface{}{
  12839. "patient": patient,
  12840. "number": res.Output.Baseinfo.Certno,
  12841. "insutype": insutype,
  12842. })
  12843. }
  12844. } else {
  12845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12846. return
  12847. }
  12848. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12849. var res ResultTwo
  12850. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12851. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12852. "&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)
  12853. resp, requestErr := http.Get(api)
  12854. if requestErr != nil {
  12855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12856. return
  12857. }
  12858. body, ioErr := ioutil.ReadAll(resp.Body)
  12859. if ioErr != nil {
  12860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12862. return
  12863. }
  12864. var respJSON map[string]interface{}
  12865. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12868. return
  12869. }
  12870. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12871. result, _ := json.Marshal(respJSON)
  12872. fmt.Println("log")
  12873. fmt.Println(string(result))
  12874. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12875. utils.ErrorLog("解析失败:%v", err)
  12876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12877. return
  12878. }
  12879. if res.Infcode == 0 {
  12880. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12881. if err == gorm.ErrRecordNotFound {
  12882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12883. return
  12884. } else if err != nil {
  12885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12886. return
  12887. } else {
  12888. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12889. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12890. infoStr := string(Iinfos)
  12891. idetinfoStr := string(Idetinfos)
  12892. var rf []*ResultFive
  12893. json.Unmarshal([]byte(infoStr), &rf)
  12894. var insutypes []*ResultFive
  12895. var insutype string
  12896. var is390 int = 0
  12897. var is310 int = 0
  12898. for _, item := range rf {
  12899. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12900. insutypes = append(insutypes, item)
  12901. }
  12902. }
  12903. if len(insutypes) == 1 {
  12904. insutype = insutypes[0].Insutype
  12905. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12906. } else {
  12907. for _, i := range insutypes {
  12908. if i.Insutype == "390" {
  12909. is390 = 1
  12910. }
  12911. if i.Insutype == "310" {
  12912. is310 = 1
  12913. }
  12914. }
  12915. }
  12916. if is390 == 1 {
  12917. insutype = "390"
  12918. }
  12919. if is310 == 1 {
  12920. insutype = "310"
  12921. }
  12922. if len(insutypes) == 0 {
  12923. insutype = "390"
  12924. }
  12925. var insuplc_admdvs string
  12926. for _, item := range rf {
  12927. if item.Insutype == insutype {
  12928. insuplc_admdvs = item.InsuplcAdmdvs
  12929. }
  12930. }
  12931. psn := &models.HisPsn{
  12932. PsnNo: res.Output.Baseinfo.PsnNo,
  12933. PatientId: patient.ID,
  12934. Certno: res.Output.Baseinfo.Certno,
  12935. Gend: res.Output.Baseinfo.Gend,
  12936. Naty: res.Output.Baseinfo.Naty,
  12937. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12938. PsnName: res.Output.Baseinfo.PsnName,
  12939. Idetinfo: idetinfoStr,
  12940. Insuinfo: infoStr,
  12941. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12942. InsuplcAdmdvs: insuplc_admdvs,
  12943. }
  12944. service.CreateHisPsn(psn)
  12945. for _, item := range rf {
  12946. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12947. insutypes = append(insutypes, item)
  12948. }
  12949. }
  12950. if len(insutypes) == 1 {
  12951. insutype = insutypes[0].Insutype
  12952. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12953. } else {
  12954. for _, i := range insutypes {
  12955. if i.Insutype == "390" {
  12956. is390 = 1
  12957. }
  12958. if i.Insutype == "310" {
  12959. is310 = 1
  12960. }
  12961. }
  12962. }
  12963. if is390 == 1 {
  12964. insutype = "390"
  12965. }
  12966. if is310 == 1 {
  12967. insutype = "310"
  12968. }
  12969. if len(insutypes) == 0 {
  12970. insutype = "310"
  12971. }
  12972. c.ServeSuccessJSON(map[string]interface{}{
  12973. "patient": patient,
  12974. "number": res.Output.Baseinfo.Certno,
  12975. "insutype": insutype,
  12976. })
  12977. }
  12978. } else {
  12979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12980. return
  12981. }
  12982. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12983. var res ResultTwo
  12984. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  12985. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12986. "&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)
  12987. resp, requestErr := http.Get(api)
  12988. if requestErr != nil {
  12989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12990. return
  12991. }
  12992. body, ioErr := ioutil.ReadAll(resp.Body)
  12993. if ioErr != nil {
  12994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12996. return
  12997. }
  12998. var respJSON map[string]interface{}
  12999. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13002. return
  13003. }
  13004. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13005. result, _ := json.Marshal(respJSON)
  13006. fmt.Println("log")
  13007. fmt.Println(string(result))
  13008. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13009. utils.ErrorLog("解析失败:%v", err)
  13010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13011. return
  13012. }
  13013. if res.Infcode == 0 {
  13014. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13015. if err == gorm.ErrRecordNotFound {
  13016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13017. return
  13018. } else if err != nil {
  13019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13020. return
  13021. } else {
  13022. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13023. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13024. infoStr := string(Iinfos)
  13025. idetinfoStr := string(Idetinfos)
  13026. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13027. psn := &models.HisPsn{
  13028. PsnNo: res.Output.Baseinfo.PsnNo,
  13029. PatientId: patient.ID,
  13030. Certno: res.Output.Baseinfo.Certno,
  13031. Brdy: b,
  13032. Age: float64(age),
  13033. Gend: res.Output.Baseinfo.Gend,
  13034. Naty: res.Output.Baseinfo.Naty,
  13035. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13036. PsnName: res.Output.Baseinfo.PsnName,
  13037. Idetinfo: idetinfoStr,
  13038. Insuinfo: infoStr,
  13039. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13040. }
  13041. service.CreateHisPsn(psn)
  13042. var rf []*ResultFive
  13043. json.Unmarshal([]byte(infoStr), &rf)
  13044. var insutypes []*ResultFive
  13045. var insutype string
  13046. var is390 int = 0
  13047. var is310 int = 0
  13048. for _, item := range rf {
  13049. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13050. insutypes = append(insutypes, item)
  13051. }
  13052. }
  13053. if len(insutypes) == 1 {
  13054. insutype = insutypes[0].Insutype
  13055. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13056. } else {
  13057. for _, i := range insutypes {
  13058. if i.Insutype == "390" {
  13059. is390 = 1
  13060. }
  13061. if i.Insutype == "310" {
  13062. is310 = 1
  13063. }
  13064. }
  13065. }
  13066. if is390 == 1 {
  13067. insutype = "390"
  13068. }
  13069. if is310 == 1 {
  13070. insutype = "310"
  13071. }
  13072. if len(insutypes) == 0 {
  13073. insutype = "310"
  13074. }
  13075. c.ServeSuccessJSON(map[string]interface{}{
  13076. "patient": patient,
  13077. "number": res.Output.Baseinfo.Certno,
  13078. "insutype": insutype,
  13079. })
  13080. }
  13081. } else {
  13082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13083. return
  13084. }
  13085. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13086. var api string
  13087. if miConfig.MdtrtareaAdmvs == "320921" {
  13088. 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 +
  13089. "&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
  13090. fmt.Println(api)
  13091. } else {
  13092. 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 +
  13093. "&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)
  13094. }
  13095. resp, requestErr := http.Get(api)
  13096. if requestErr != nil {
  13097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13098. return
  13099. }
  13100. body, ioErr := ioutil.ReadAll(resp.Body)
  13101. if ioErr != nil {
  13102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13104. return
  13105. }
  13106. var respJSON map[string]interface{}
  13107. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13110. return
  13111. }
  13112. var status string
  13113. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13114. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13115. //console.log()
  13116. fmt.Println("type===")
  13117. fmt.Println(card_type)
  13118. var token string
  13119. var res ResultTwo //1101结果
  13120. var res10265 ResultTwo10265 //1101结果
  13121. var card_info string //卡信息
  13122. var busi_card_info string
  13123. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13124. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13125. if status == "0" { //读卡成功
  13126. if card_type == "1" {
  13127. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13128. result, _ := json.Marshal(respJSON)
  13129. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13130. utils.ErrorLog("解析失败:%v", err)
  13131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13132. return
  13133. }
  13134. res.ErrMsg = res10265.ErrMsg
  13135. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13136. res.Infcode = infocode
  13137. res.Output = res10265.Output
  13138. res.InfRefmsgid = res10265.InfRefmsgid
  13139. } else {
  13140. //var card_info string //卡信息
  13141. //var busi_card_info string
  13142. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13143. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13144. //fmt.Println(card_info)
  13145. //fmt.Println(busi_card_info)
  13146. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13147. result, _ := json.Marshal(respJSON)
  13148. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13149. utils.ErrorLog("解析失败:%v", err)
  13150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13151. return
  13152. }
  13153. res.ErrMsg = res10265.ErrMsg
  13154. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13155. res.Infcode = infocode
  13156. res.Output = res10265.Output
  13157. res.InfRefmsgid = res10265.InfRefmsgid
  13158. }
  13159. if res.Infcode == 0 {
  13160. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13161. if err == gorm.ErrRecordNotFound {
  13162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13163. return
  13164. } else if err != nil {
  13165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13166. return
  13167. } else {
  13168. if card_type == "1" {
  13169. bas := strings.Split(card_info, "|")
  13170. basNumber := bas[2]
  13171. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13172. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13173. infoStr := string(Iinfos)
  13174. idetinfoStr := string(Idetinfos)
  13175. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13176. psn := &models.HisPsn{
  13177. PsnNo: res.Output.Baseinfo.PsnNo,
  13178. PatientId: patient.ID,
  13179. Certno: res.Output.Baseinfo.Certno,
  13180. Brdy: b,
  13181. Age: float64(age),
  13182. Gend: res.Output.Baseinfo.Gend,
  13183. Naty: res.Output.Baseinfo.Naty,
  13184. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13185. PsnName: res.Output.Baseinfo.PsnName,
  13186. Idetinfo: idetinfoStr,
  13187. Insuinfo: infoStr,
  13188. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13189. CardInfo: card_info,
  13190. VerifyNumber: busi_card_info,
  13191. }
  13192. service.CreateHisPsn(psn)
  13193. var rf []*ResultFive
  13194. json.Unmarshal([]byte(infoStr), &rf)
  13195. var insutypes []*ResultFive
  13196. var insutype string
  13197. var is390 int = 0
  13198. var is310 int = 0
  13199. for _, item := range rf {
  13200. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13201. insutypes = append(insutypes, item)
  13202. }
  13203. }
  13204. if len(insutypes) == 1 {
  13205. insutype = insutypes[0].Insutype
  13206. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13207. } else {
  13208. for _, i := range insutypes {
  13209. if i.Insutype == "390" {
  13210. is390 = 1
  13211. }
  13212. if i.Insutype == "310" {
  13213. is310 = 1
  13214. }
  13215. }
  13216. }
  13217. if is390 == 1 {
  13218. insutype = "390"
  13219. }
  13220. if is310 == 1 {
  13221. insutype = "310"
  13222. }
  13223. if len(insutypes) == 0 {
  13224. insutype = "310"
  13225. }
  13226. c.ServeSuccessJSON(map[string]interface{}{
  13227. "patient": patient,
  13228. "number": basNumber,
  13229. "insutype": insutype,
  13230. })
  13231. } else {
  13232. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13233. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13234. infoStr := string(Iinfos)
  13235. idetinfoStr := string(Idetinfos)
  13236. psn := &models.HisPsn{
  13237. PsnNo: res.Output.Baseinfo.PsnNo,
  13238. PatientId: patient.ID,
  13239. Certno: res.Output.Baseinfo.Certno,
  13240. Gend: res.Output.Baseinfo.Gend,
  13241. Naty: res.Output.Baseinfo.Naty,
  13242. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13243. PsnName: res.Output.Baseinfo.PsnName,
  13244. Idetinfo: idetinfoStr,
  13245. Insuinfo: infoStr,
  13246. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13247. CardInfo: card_info,
  13248. VerifyNumber: token,
  13249. }
  13250. service.CreateHisPsn(psn)
  13251. c.ServeSuccessJSON(map[string]interface{}{
  13252. "patient": patient,
  13253. "number": token,
  13254. })
  13255. }
  13256. }
  13257. } else {
  13258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13259. return
  13260. }
  13261. } else { //读卡失败
  13262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13263. return
  13264. }
  13265. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13266. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13267. cardnum = DeleteExtraSpaceTwo(cardnum)
  13268. cardCode = DeleteExtraSpaceTwo(cardCode)
  13269. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13270. name = DeleteExtraSpaceTwo(name)
  13271. errmsg = DeleteExtraSpaceTwo(errmsg)
  13272. cardnum = Remove0000(cardnum)
  13273. cardCode = Remove0000(cardCode)
  13274. id_card_no = Remove0000(id_card_no)
  13275. name = Remove0000(name)
  13276. errmsg = Remove0000(errmsg)
  13277. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13278. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13279. //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)
  13280. //fmt.Println(result2)
  13281. //fmt.Println(requestLog2)
  13282. //fmt.Println(errMsgLog2)
  13283. 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)
  13284. saveLog(result, requestLog, "1101", "获取人员信息")
  13285. fmt.Println(errMsgLog)
  13286. if len(errMsgLog) > 0 {
  13287. } else {
  13288. var dat map[string]interface{}
  13289. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13290. fmt.Println(dat)
  13291. } else {
  13292. fmt.Println(err)
  13293. }
  13294. userJSONBytes, _ := json.Marshal(dat)
  13295. var res ResultTwo
  13296. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13297. utils.ErrorLog("解析失败:%v", err)
  13298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13299. return
  13300. }
  13301. res.ErrMsg = errMsgLog
  13302. if res.Infcode == 0 {
  13303. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13304. if err == gorm.ErrRecordNotFound {
  13305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13306. return
  13307. } else if err != nil {
  13308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13309. return
  13310. } else {
  13311. fmt.Println(res)
  13312. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13313. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13314. infoStr := string(Iinfos)
  13315. idetinfoStr := string(Idetinfos)
  13316. var rf []*ResultFive
  13317. json.Unmarshal([]byte(infoStr), &rf)
  13318. var insutypes []*ResultFive
  13319. var insutype string
  13320. var is390 int = 0
  13321. var is310 int = 0
  13322. for _, item := range rf {
  13323. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13324. insutypes = append(insutypes, item)
  13325. }
  13326. }
  13327. if len(insutypes) == 1 {
  13328. insutype = insutypes[0].Insutype
  13329. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13330. } else {
  13331. for _, i := range insutypes {
  13332. if i.Insutype == "390" {
  13333. is390 = 1
  13334. }
  13335. if i.Insutype == "310" {
  13336. is310 = 1
  13337. }
  13338. }
  13339. }
  13340. if is390 == 1 {
  13341. insutype = "390"
  13342. }
  13343. if is310 == 1 {
  13344. insutype = "310"
  13345. }
  13346. if len(insutypes) == 0 {
  13347. insutype = "390"
  13348. }
  13349. var insuplc_admdvs string
  13350. for _, item := range rf {
  13351. if item.Insutype == insutype {
  13352. insuplc_admdvs = item.InsuplcAdmdvs
  13353. }
  13354. }
  13355. psn := &models.HisPsn{
  13356. PsnNo: res.Output.Baseinfo.PsnNo,
  13357. PatientId: patient.ID,
  13358. Certno: res.Output.Baseinfo.Certno,
  13359. Gend: res.Output.Baseinfo.Gend,
  13360. Naty: res.Output.Baseinfo.Naty,
  13361. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13362. PsnName: res.Output.Baseinfo.PsnName,
  13363. Idetinfo: idetinfoStr,
  13364. Insuinfo: infoStr,
  13365. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13366. CardInfo: basStr,
  13367. VerifyNumber: "",
  13368. InsuplcAdmdvs: insuplc_admdvs,
  13369. }
  13370. service.CreateHisPsn(psn)
  13371. c.ServeSuccessJSON(map[string]interface{}{
  13372. "patient": patient,
  13373. "number": cardnum,
  13374. "insutype": insutype,
  13375. })
  13376. }
  13377. } else {
  13378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13379. return
  13380. }
  13381. }
  13382. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13383. fmt.Println(initFlag)
  13384. fmt.Println("initFlag")
  13385. if initFlag == 0 {
  13386. c.TestGetJiangXiBasBaseInit()
  13387. }
  13388. basStr := c.GetBasBaseInfo()
  13389. if len(basStr) == 0 {
  13390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13391. return
  13392. }
  13393. fmt.Println(basStr)
  13394. bas := strings.Split(basStr, "|")
  13395. basNumber := bas[1]
  13396. fmt.Println(basNumber)
  13397. card_sn := bas[3]
  13398. fmt.Println(card_sn)
  13399. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13400. 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)
  13401. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13402. var dat map[string]interface{}
  13403. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13404. fmt.Println(dat)
  13405. } else {
  13406. fmt.Println(err)
  13407. }
  13408. userJSONBytes, _ := json.Marshal(dat)
  13409. var res ResultTwo
  13410. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13411. utils.ErrorLog("解析失败:%v", err)
  13412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13413. return
  13414. }
  13415. if res.Infcode == 0 {
  13416. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13417. if err == gorm.ErrRecordNotFound {
  13418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13419. return
  13420. } else if err != nil {
  13421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13422. return
  13423. } else {
  13424. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13425. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13426. infoStr := string(Iinfos)
  13427. idetinfoStr := string(Idetinfos)
  13428. var rf []*ResultFive
  13429. json.Unmarshal([]byte(infoStr), &rf)
  13430. var insutypes []*ResultFive
  13431. var insutype string
  13432. var is390 int = 0
  13433. var is310 int = 0
  13434. var insuplc_admdvs string
  13435. for _, item := range rf {
  13436. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13437. insutypes = append(insutypes, item)
  13438. }
  13439. }
  13440. if len(insutypes) == 1 {
  13441. insutype = insutypes[0].Insutype
  13442. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13443. } else {
  13444. for _, i := range insutypes {
  13445. if i.Insutype == "390" {
  13446. is390 = 1
  13447. }
  13448. if i.Insutype == "310" {
  13449. is310 = 1
  13450. }
  13451. }
  13452. }
  13453. if is390 == 1 {
  13454. insutype = "390"
  13455. }
  13456. if is310 == 1 {
  13457. insutype = "310"
  13458. }
  13459. if len(insutypes) == 0 {
  13460. insutype = "310"
  13461. }
  13462. for _, item := range rf {
  13463. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13464. insuplc_admdvs = item.InsuplcAdmdvs
  13465. }
  13466. }
  13467. psn := &models.HisPsn{
  13468. PsnNo: res.Output.Baseinfo.PsnNo,
  13469. PatientId: patient.ID,
  13470. Certno: res.Output.Baseinfo.Certno,
  13471. Gend: res.Output.Baseinfo.Gend,
  13472. Naty: res.Output.Baseinfo.Naty,
  13473. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13474. PsnName: res.Output.Baseinfo.PsnName,
  13475. Idetinfo: idetinfoStr,
  13476. Insuinfo: infoStr,
  13477. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13478. CardInfo: basStr,
  13479. InsuplcAdmdvs: insuplc_admdvs,
  13480. VerifyNumber: "",
  13481. }
  13482. service.CreateHisPsn(psn)
  13483. c.ServeSuccessJSON(map[string]interface{}{
  13484. "patient": patient,
  13485. "number": basNumber,
  13486. "insutype": insutype,
  13487. })
  13488. }
  13489. } else {
  13490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13491. return
  13492. }
  13493. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13494. basStr := c.GetBasBaseInfo22222()
  13495. fmt.Println(basStr)
  13496. if len(basStr) == 0 {
  13497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13498. return
  13499. }
  13500. fmt.Println(basStr)
  13501. bas := strings.Split(basStr, "|")
  13502. basNumber := bas[2] //卡号
  13503. card_sn := bas[3] //
  13504. id_card_No := bas[1] //卡号
  13505. fmt.Println(basNumber)
  13506. fmt.Println(card_sn)
  13507. fmt.Println(id_card_No)
  13508. var patient service.Patients
  13509. if len(id_card_No) == 0 {
  13510. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13511. } else {
  13512. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13513. }
  13514. result, _ := service.Jxyb1101bycard(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, patient.Name, patient.IdCardNo)
  13515. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13516. var dat map[string]interface{}
  13517. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13518. fmt.Println(dat)
  13519. } else {
  13520. fmt.Println(err)
  13521. }
  13522. userJSONBytes, _ := json.Marshal(dat)
  13523. var res ResultTwo
  13524. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13525. utils.ErrorLog("解析失败:%v", err)
  13526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13527. return
  13528. }
  13529. if res.Infcode == 0 {
  13530. var pateint2 service.Patients
  13531. var err error
  13532. if len(id_card_No) == 0 {
  13533. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13534. } else {
  13535. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13536. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13537. }
  13538. if err == gorm.ErrRecordNotFound {
  13539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13540. return
  13541. } else if err != nil {
  13542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13543. return
  13544. } else {
  13545. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13546. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13547. infoStr := string(Iinfos)
  13548. idetinfoStr := string(Idetinfos)
  13549. var rf []*ResultFive
  13550. json.Unmarshal([]byte(infoStr), &rf)
  13551. var insutypes []*ResultFive
  13552. var insutype string
  13553. var is390 int = 0
  13554. var is310 int = 0
  13555. var insuplc_admdvs string
  13556. for _, item := range rf {
  13557. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13558. insutypes = append(insutypes, item)
  13559. }
  13560. }
  13561. if len(insutypes) == 1 {
  13562. insutype = insutypes[0].Insutype
  13563. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13564. } else {
  13565. for _, i := range insutypes {
  13566. if i.Insutype == "390" {
  13567. is390 = 1
  13568. }
  13569. if i.Insutype == "310" {
  13570. is310 = 1
  13571. }
  13572. }
  13573. }
  13574. if is390 == 1 {
  13575. insutype = "390"
  13576. }
  13577. if is310 == 1 {
  13578. insutype = "310"
  13579. }
  13580. if len(insutypes) == 0 {
  13581. insutype = "310"
  13582. }
  13583. for _, item := range rf {
  13584. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13585. insuplc_admdvs = item.InsuplcAdmdvs
  13586. }
  13587. }
  13588. psn := &models.HisPsn{
  13589. PsnNo: res.Output.Baseinfo.PsnNo,
  13590. PatientId: pateint2.ID,
  13591. Certno: res.Output.Baseinfo.Certno,
  13592. Gend: res.Output.Baseinfo.Gend,
  13593. Naty: res.Output.Baseinfo.Naty,
  13594. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13595. PsnName: res.Output.Baseinfo.PsnName,
  13596. Idetinfo: idetinfoStr,
  13597. Insuinfo: infoStr,
  13598. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13599. CardInfo: basStr,
  13600. InsuplcAdmdvs: insuplc_admdvs,
  13601. VerifyNumber: "",
  13602. }
  13603. service.CreateHisPsn(psn)
  13604. c.ServeSuccessJSON(map[string]interface{}{
  13605. "patient": patient,
  13606. "number": basNumber,
  13607. "insutype": insutype,
  13608. })
  13609. }
  13610. } else {
  13611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13612. return
  13613. }
  13614. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13615. fmt.Println(initFlag)
  13616. fmt.Println("initFlag")
  13617. if initFlag == 0 {
  13618. c.TestGetHnBasBaseInit()
  13619. }
  13620. basStr := c.GetBasBaseInfo()
  13621. if len(basStr) == 0 {
  13622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13623. return
  13624. }
  13625. fmt.Println(basStr)
  13626. bas := strings.Split(basStr, "|")
  13627. basNumber := bas[1]
  13628. fmt.Println(basNumber)
  13629. card_sn := bas[3]
  13630. card_no := bas[2]
  13631. fmt.Println(card_sn)
  13632. name := bas[4]
  13633. name = ConvertToString(name, "gbk", "utf-8")
  13634. 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)
  13635. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13636. var dat map[string]interface{}
  13637. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13638. fmt.Println(dat)
  13639. } else {
  13640. fmt.Println(err)
  13641. }
  13642. userJSONBytes, _ := json.Marshal(dat)
  13643. var res ResultTwo
  13644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13645. utils.ErrorLog("解析失败:%v", err)
  13646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13647. return
  13648. }
  13649. if res.Infcode == 0 {
  13650. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13651. if err == gorm.ErrRecordNotFound {
  13652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13653. return
  13654. } else if err != nil {
  13655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13656. return
  13657. } else {
  13658. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13659. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13660. infoStr := string(Iinfos)
  13661. idetinfoStr := string(Idetinfos)
  13662. psn := &models.HisPsn{
  13663. PsnNo: res.Output.Baseinfo.PsnNo,
  13664. PatientId: patient.ID,
  13665. Certno: res.Output.Baseinfo.Certno,
  13666. Gend: res.Output.Baseinfo.Gend,
  13667. Naty: res.Output.Baseinfo.Naty,
  13668. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13669. PsnName: res.Output.Baseinfo.PsnName,
  13670. Idetinfo: idetinfoStr,
  13671. Insuinfo: infoStr,
  13672. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13673. CardInfo: basStr,
  13674. VerifyNumber: "",
  13675. }
  13676. service.CreateHisPsn(psn)
  13677. var rf []*ResultFive
  13678. json.Unmarshal([]byte(infoStr), &rf)
  13679. var insutypes []*ResultFive
  13680. var insutype string
  13681. var is390 int = 0
  13682. var is310 int = 0
  13683. for _, item := range rf {
  13684. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13685. insutypes = append(insutypes, item)
  13686. }
  13687. }
  13688. if len(insutypes) == 1 {
  13689. insutype = insutypes[0].Insutype
  13690. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13691. } else {
  13692. for _, i := range insutypes {
  13693. if i.Insutype == "390" {
  13694. is390 = 1
  13695. }
  13696. if i.Insutype == "310" {
  13697. is310 = 1
  13698. }
  13699. }
  13700. }
  13701. if is390 == 1 {
  13702. insutype = "390"
  13703. }
  13704. if is310 == 1 {
  13705. insutype = "310"
  13706. }
  13707. if len(insutypes) == 0 {
  13708. insutype = "310"
  13709. }
  13710. c.ServeSuccessJSON(map[string]interface{}{
  13711. "patient": patient,
  13712. "number": basNumber,
  13713. "insutype": insutype,
  13714. })
  13715. }
  13716. } else {
  13717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13718. return
  13719. }
  13720. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13721. var api string
  13722. 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 +
  13723. "&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
  13724. fmt.Println(api)
  13725. resp, requestErr := http.Get(api)
  13726. if requestErr != nil {
  13727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13728. return
  13729. }
  13730. body, ioErr := ioutil.ReadAll(resp.Body)
  13731. if ioErr != nil {
  13732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13734. return
  13735. }
  13736. var respJSON map[string]interface{}
  13737. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13740. return
  13741. }
  13742. var res ResultTwo //1101结果
  13743. var res10265 ResultTwo10265 //1101结果
  13744. var card_info string //卡信息
  13745. token := respJSON["data"].(map[string]interface{})["token"].(string)
  13746. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13747. result, _ := json.Marshal(respJSON)
  13748. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13749. utils.ErrorLog("解析失败:%v", err)
  13750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13751. return
  13752. }
  13753. res.ErrMsg = res10265.ErrMsg
  13754. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13755. res.Infcode = infocode
  13756. res.Output = res10265.Output
  13757. res.InfRefmsgid = res10265.InfRefmsgid
  13758. if res.Infcode == 0 {
  13759. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13760. if err == gorm.ErrRecordNotFound {
  13761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13762. return
  13763. } else if err != nil {
  13764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13765. return
  13766. } else {
  13767. bas := strings.Split(card_info, "|")
  13768. basNumber := bas[2]
  13769. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13770. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13771. infoStr := string(Iinfos)
  13772. idetinfoStr := string(Idetinfos)
  13773. psn := &models.HisPsn{
  13774. PsnNo: res.Output.Baseinfo.PsnNo,
  13775. PatientId: patient.ID,
  13776. Certno: res.Output.Baseinfo.Certno,
  13777. Gend: res.Output.Baseinfo.Gend,
  13778. Naty: res.Output.Baseinfo.Naty,
  13779. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13780. PsnName: res.Output.Baseinfo.PsnName,
  13781. Idetinfo: idetinfoStr,
  13782. Insuinfo: infoStr,
  13783. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13784. CardInfo: card_info,
  13785. VerifyNumber: token,
  13786. }
  13787. service.CreateHisPsn(psn)
  13788. var rf []*ResultFive
  13789. json.Unmarshal([]byte(infoStr), &rf)
  13790. var insutypes []*ResultFive
  13791. var insutype string
  13792. var is390 int = 0
  13793. var is310 int = 0
  13794. for _, item := range rf {
  13795. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13796. insutypes = append(insutypes, item)
  13797. }
  13798. }
  13799. if len(insutypes) == 1 {
  13800. insutype = insutypes[0].Insutype
  13801. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13802. } else {
  13803. for _, i := range insutypes {
  13804. if i.Insutype == "390" {
  13805. is390 = 1
  13806. }
  13807. if i.Insutype == "310" {
  13808. is310 = 1
  13809. }
  13810. }
  13811. }
  13812. if is390 == 1 {
  13813. insutype = "390"
  13814. }
  13815. if is310 == 1 {
  13816. insutype = "310"
  13817. }
  13818. if len(insutypes) == 0 {
  13819. insutype = "310"
  13820. }
  13821. c.ServeSuccessJSON(map[string]interface{}{
  13822. "patient": patient,
  13823. "number": basNumber,
  13824. "insutype": insutype,
  13825. })
  13826. }
  13827. } else {
  13828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13829. return
  13830. }
  13831. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13832. res := c.GetoleInfo()
  13833. if res.Infcode == 0 {
  13834. var result string
  13835. if res.Output.MdtrtCertType == "01" {
  13836. 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)
  13837. } else if res.Output.MdtrtCertType == "02" {
  13838. 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)
  13839. } else if res.Output.MdtrtCertType == "03" {
  13840. 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)
  13841. }
  13842. var dat map[string]interface{}
  13843. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13844. fmt.Println(dat)
  13845. } else {
  13846. fmt.Println(err)
  13847. }
  13848. userJSONBytes, _ := json.Marshal(dat)
  13849. var res2 ResultTwo
  13850. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13851. utils.ErrorLog("解析失败:%v", err)
  13852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13853. return
  13854. }
  13855. if res2.Infcode == 0 {
  13856. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13857. if err == gorm.ErrRecordNotFound {
  13858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13859. return
  13860. } else if err != nil {
  13861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13862. return
  13863. } else {
  13864. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13865. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13866. infoStr := string(Iinfos)
  13867. idetinfoStr := string(Idetinfos)
  13868. var rf []*ResultFive
  13869. json.Unmarshal([]byte(infoStr), &rf)
  13870. var insutypes []*ResultFive
  13871. var insutype string
  13872. var is390 int = 0
  13873. var is310 int = 0
  13874. //var insuplc_admdvs string
  13875. for _, item := range rf {
  13876. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13877. insutypes = append(insutypes, item)
  13878. }
  13879. }
  13880. if len(insutypes) == 1 {
  13881. insutype = insutypes[0].Insutype
  13882. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13883. } else {
  13884. for _, i := range insutypes {
  13885. if i.Insutype == "390" {
  13886. is390 = 1
  13887. }
  13888. if i.Insutype == "310" {
  13889. is310 = 1
  13890. }
  13891. }
  13892. }
  13893. if is390 == 1 {
  13894. insutype = "390"
  13895. }
  13896. if is310 == 1 {
  13897. insutype = "310"
  13898. }
  13899. if len(insutypes) == 0 {
  13900. insutype = "310"
  13901. }
  13902. psn := &models.HisPsn{
  13903. PsnNo: res2.Output.Baseinfo.PsnNo,
  13904. PatientId: patient.ID,
  13905. Certno: res2.Output.Baseinfo.Certno,
  13906. Gend: res2.Output.Baseinfo.Gend,
  13907. Naty: res2.Output.Baseinfo.Naty,
  13908. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  13909. PsnName: res2.Output.Baseinfo.PsnName,
  13910. Idetinfo: idetinfoStr,
  13911. Insuinfo: infoStr,
  13912. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13913. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  13914. VerifyNumber: res.Output.EcToken,
  13915. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  13916. }
  13917. if res.Output.MdtrtCertType == "01" {
  13918. psn.VerifyNumber = res.Output.EcToken
  13919. //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)
  13920. } else if res.Output.MdtrtCertType == "02" {
  13921. psn.VerifyNumber = res.Output.MdtrtCertNo
  13922. //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)
  13923. } else if res.Output.MdtrtCertType == "03" {
  13924. psn.VerifyNumber = res.Output.MdtrtCertNo
  13925. //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)
  13926. }
  13927. var balc float64
  13928. for _, item := range rf {
  13929. if item.Insutype == insutype {
  13930. balc = item.Balc
  13931. }
  13932. }
  13933. service.CreateHisPsn(psn)
  13934. c.ServeSuccessJSON(map[string]interface{}{
  13935. "patient": patient,
  13936. "number": res.Output.CardNo,
  13937. "insutype": insutype,
  13938. "blac": balc,
  13939. "desc": idetinfoStr,
  13940. })
  13941. }
  13942. } else {
  13943. c.ServeSuccessJSON(map[string]interface{}{
  13944. "failed_code": -10,
  13945. "msg": res2.ErrMsg,
  13946. })
  13947. }
  13948. } else {
  13949. c.ServeSuccessJSON(map[string]interface{}{
  13950. "failed_code": -10,
  13951. "msg": res.ErrMsg,
  13952. })
  13953. }
  13954. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13955. var api string
  13956. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13957. "&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
  13958. fmt.Println(api)
  13959. resp, requestErr := http.Get(api)
  13960. if requestErr != nil {
  13961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13962. return
  13963. }
  13964. body, ioErr := ioutil.ReadAll(resp.Body)
  13965. if ioErr != nil {
  13966. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13968. return
  13969. }
  13970. var respJSON map[string]interface{}
  13971. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13974. return
  13975. }
  13976. var status string
  13977. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13978. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13979. //console.log()
  13980. fmt.Println("type===")
  13981. fmt.Println(card_type)
  13982. var token string
  13983. var res ResultTwo //1101结果
  13984. //var res10265 ResultTwoesultTwo10265 //1101结果
  13985. var card_info string //卡信息
  13986. var busi_card_info string
  13987. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13988. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13989. if status == "0" { //读卡成功
  13990. if card_type == "1" {
  13991. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13992. result, _ := json.Marshal(respJSON)
  13993. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13994. utils.ErrorLog("解析失败:%v", err)
  13995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13996. return
  13997. }
  13998. } else {
  13999. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14000. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14001. result, _ := json.Marshal(respJSON)
  14002. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14003. utils.ErrorLog("解析失败:%v", err)
  14004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14005. return
  14006. }
  14007. }
  14008. if res.Infcode == 0 {
  14009. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14010. if err == gorm.ErrRecordNotFound {
  14011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14012. return
  14013. } else if err != nil {
  14014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14015. return
  14016. } else {
  14017. if card_type == "1" {
  14018. bas := strings.Split(card_info, "|")
  14019. basNumber := bas[2]
  14020. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14021. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14022. infoStr := string(Iinfos)
  14023. idetinfoStr := string(Idetinfos)
  14024. psn := &models.HisPsn{
  14025. PsnNo: res.Output.Baseinfo.PsnNo,
  14026. PatientId: patient.ID,
  14027. Certno: res.Output.Baseinfo.Certno,
  14028. Gend: res.Output.Baseinfo.Gend,
  14029. Naty: res.Output.Baseinfo.Naty,
  14030. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14031. PsnName: res.Output.Baseinfo.PsnName,
  14032. Idetinfo: idetinfoStr,
  14033. Insuinfo: infoStr,
  14034. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14035. CardInfo: card_info,
  14036. VerifyNumber: busi_card_info,
  14037. }
  14038. service.CreateHisPsn(psn)
  14039. var rf []*ResultFive
  14040. json.Unmarshal([]byte(infoStr), &rf)
  14041. var insutypes []*ResultFive
  14042. var insutype string
  14043. var is390 int = 0
  14044. var is310 int = 0
  14045. for _, item := range rf {
  14046. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14047. insutypes = append(insutypes, item)
  14048. }
  14049. }
  14050. if len(insutypes) == 1 {
  14051. insutype = insutypes[0].Insutype
  14052. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14053. } else {
  14054. for _, i := range insutypes {
  14055. if i.Insutype == "390" {
  14056. is390 = 1
  14057. }
  14058. if i.Insutype == "310" {
  14059. is310 = 1
  14060. }
  14061. }
  14062. }
  14063. if is390 == 1 {
  14064. insutype = "390"
  14065. }
  14066. if is310 == 1 {
  14067. insutype = "310"
  14068. }
  14069. if len(insutypes) == 0 {
  14070. insutype = "310"
  14071. }
  14072. c.ServeSuccessJSON(map[string]interface{}{
  14073. "patient": patient,
  14074. "number": basNumber,
  14075. "insutype": insutype,
  14076. })
  14077. } else {
  14078. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14079. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14080. infoStr := string(Iinfos)
  14081. idetinfoStr := string(Idetinfos)
  14082. psn := &models.HisPsn{
  14083. PsnNo: res.Output.Baseinfo.PsnNo,
  14084. PatientId: patient.ID,
  14085. Certno: res.Output.Baseinfo.Certno,
  14086. Gend: res.Output.Baseinfo.Gend,
  14087. Naty: res.Output.Baseinfo.Naty,
  14088. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14089. PsnName: res.Output.Baseinfo.PsnName,
  14090. Idetinfo: idetinfoStr,
  14091. Insuinfo: infoStr,
  14092. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14093. CardInfo: card_info,
  14094. VerifyNumber: token,
  14095. }
  14096. service.CreateHisPsn(psn)
  14097. c.ServeSuccessJSON(map[string]interface{}{
  14098. "patient": patient,
  14099. "number": token,
  14100. })
  14101. }
  14102. }
  14103. } else {
  14104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14105. return
  14106. }
  14107. } else { //读卡失败
  14108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14109. return
  14110. }
  14111. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14112. var api string
  14113. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14114. "&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
  14115. fmt.Println(api)
  14116. resp, requestErr := http.Get(api)
  14117. if requestErr != nil {
  14118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14119. return
  14120. }
  14121. body, ioErr := ioutil.ReadAll(resp.Body)
  14122. if ioErr != nil {
  14123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14125. return
  14126. }
  14127. var respJSON map[string]interface{}
  14128. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14131. return
  14132. }
  14133. var status string
  14134. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14135. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14136. //console.log()
  14137. fmt.Println("type===")
  14138. fmt.Println(card_type)
  14139. var token string
  14140. var res ResultTwo //1101结果
  14141. //var res10265 ResultTwoesultTwo10265 //1101结果
  14142. var card_info string //卡信息
  14143. //var busi_card_info string
  14144. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14145. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14146. if status == "0" { //读卡成功
  14147. if card_type == "1" {
  14148. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14149. result, _ := json.Marshal(respJSON)
  14150. fmt.Println(result)
  14151. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14152. utils.ErrorLog("解析失败:%v", err)
  14153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14154. return
  14155. }
  14156. fmt.Println(res)
  14157. } else {
  14158. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14159. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14160. result, _ := json.Marshal(respJSON)
  14161. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14162. utils.ErrorLog("解析失败:%v", err)
  14163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14164. return
  14165. }
  14166. }
  14167. if res.Infcode == 0 {
  14168. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14169. if err == gorm.ErrRecordNotFound {
  14170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14171. return
  14172. } else if err != nil {
  14173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14174. return
  14175. } else {
  14176. if card_type == "1" {
  14177. bas := strings.Split(card_info, "|")
  14178. basNumber := bas[2]
  14179. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14180. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14181. infoStr := string(Iinfos)
  14182. idetinfoStr := string(Idetinfos)
  14183. psn := &models.HisPsn{
  14184. PsnNo: res.Output.Baseinfo.PsnNo,
  14185. PatientId: patient.ID,
  14186. Certno: res.Output.Baseinfo.Certno,
  14187. Gend: res.Output.Baseinfo.Gend,
  14188. Naty: res.Output.Baseinfo.Naty,
  14189. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14190. PsnName: res.Output.Baseinfo.PsnName,
  14191. Idetinfo: idetinfoStr,
  14192. Insuinfo: infoStr,
  14193. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14194. CardInfo: card_info,
  14195. //VerifyNumber: busi_card_info,
  14196. }
  14197. service.CreateHisPsn(psn)
  14198. var rf []*ResultFive
  14199. json.Unmarshal([]byte(infoStr), &rf)
  14200. var insutypes []*ResultFive
  14201. var insutype string
  14202. var is390 int = 0
  14203. var is310 int = 0
  14204. for _, item := range rf {
  14205. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14206. insutypes = append(insutypes, item)
  14207. }
  14208. }
  14209. if len(insutypes) == 1 {
  14210. insutype = insutypes[0].Insutype
  14211. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14212. } else {
  14213. for _, i := range insutypes {
  14214. if i.Insutype == "390" {
  14215. is390 = 1
  14216. }
  14217. if i.Insutype == "310" {
  14218. is310 = 1
  14219. }
  14220. }
  14221. }
  14222. if is390 == 1 {
  14223. insutype = "390"
  14224. }
  14225. if is310 == 1 {
  14226. insutype = "310"
  14227. }
  14228. if len(insutypes) == 0 {
  14229. insutype = "310"
  14230. }
  14231. c.ServeSuccessJSON(map[string]interface{}{
  14232. "patient": patient,
  14233. "number": basNumber,
  14234. "insutype": insutype,
  14235. })
  14236. } else {
  14237. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14238. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14239. infoStr := string(Iinfos)
  14240. idetinfoStr := string(Idetinfos)
  14241. psn := &models.HisPsn{
  14242. PsnNo: res.Output.Baseinfo.PsnNo,
  14243. PatientId: patient.ID,
  14244. Certno: res.Output.Baseinfo.Certno,
  14245. Gend: res.Output.Baseinfo.Gend,
  14246. Naty: res.Output.Baseinfo.Naty,
  14247. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14248. PsnName: res.Output.Baseinfo.PsnName,
  14249. Idetinfo: idetinfoStr,
  14250. Insuinfo: infoStr,
  14251. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14252. CardInfo: card_info,
  14253. VerifyNumber: token,
  14254. }
  14255. service.CreateHisPsn(psn)
  14256. c.ServeSuccessJSON(map[string]interface{}{
  14257. "patient": patient,
  14258. "number": token,
  14259. })
  14260. }
  14261. }
  14262. } else {
  14263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14264. return
  14265. }
  14266. } else { //读卡失败
  14267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14268. return
  14269. }
  14270. } else {
  14271. if initFlag == 0 {
  14272. c.TestGetBasBaseInit()
  14273. }
  14274. basStr := c.GetBasBaseInfo()
  14275. if len(basStr) == 0 {
  14276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14277. return
  14278. }
  14279. fmt.Println(basStr)
  14280. bas := strings.Split(basStr, "|")
  14281. basNumber := bas[1]
  14282. fmt.Println(basNumber)
  14283. card_sn := bas[3]
  14284. fmt.Println(card_sn)
  14285. cardNumber := bas[2]
  14286. fmt.Println(cardNumber)
  14287. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14288. var result string
  14289. if bas[0][:2] == "44" {
  14290. 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)
  14291. } else {
  14292. 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)
  14293. }
  14294. var dat map[string]interface{}
  14295. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14296. fmt.Println(dat)
  14297. } else {
  14298. fmt.Println(err)
  14299. }
  14300. userJSONBytes, _ := json.Marshal(dat)
  14301. var res ResultTwo
  14302. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14303. utils.ErrorLog("解析失败:%v", err)
  14304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14305. return
  14306. }
  14307. if res.Infcode == 0 {
  14308. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14309. if err == gorm.ErrRecordNotFound {
  14310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14311. return
  14312. } else if err != nil {
  14313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14314. return
  14315. } else {
  14316. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14317. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14318. infoStr := string(Iinfos)
  14319. idetinfoStr := string(Idetinfos)
  14320. var rf []*ResultFive
  14321. json.Unmarshal([]byte(infoStr), &rf)
  14322. var insutypes []*ResultFive
  14323. var insutype string
  14324. var is390 int = 0
  14325. var is310 int = 0
  14326. var insuplc_admdvs string
  14327. for _, item := range rf {
  14328. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14329. insutypes = append(insutypes, item)
  14330. }
  14331. }
  14332. if len(insutypes) == 1 {
  14333. insutype = insutypes[0].Insutype
  14334. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14335. } else {
  14336. for _, i := range insutypes {
  14337. if i.Insutype == "390" {
  14338. is390 = 1
  14339. }
  14340. if i.Insutype == "310" {
  14341. is310 = 1
  14342. }
  14343. }
  14344. }
  14345. if is390 == 1 {
  14346. insutype = "390"
  14347. }
  14348. if is310 == 1 {
  14349. insutype = "310"
  14350. }
  14351. if len(insutypes) == 0 {
  14352. insutype = "310"
  14353. }
  14354. for _, item := range rf {
  14355. if item.Insutype == insutype {
  14356. insuplc_admdvs = item.InsuplcAdmdvs
  14357. }
  14358. }
  14359. psn := &models.HisPsn{
  14360. PsnNo: res.Output.Baseinfo.PsnNo,
  14361. PatientId: patient.ID,
  14362. Certno: res.Output.Baseinfo.Certno,
  14363. Gend: res.Output.Baseinfo.Gend,
  14364. Naty: res.Output.Baseinfo.Naty,
  14365. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14366. PsnName: res.Output.Baseinfo.PsnName,
  14367. Idetinfo: idetinfoStr,
  14368. Insuinfo: infoStr,
  14369. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14370. CardInfo: basStr,
  14371. VerifyNumber: "",
  14372. InsuplcAdmdvs: insuplc_admdvs,
  14373. }
  14374. service.CreateHisPsn(psn)
  14375. c.ServeSuccessJSON(map[string]interface{}{
  14376. "patient": patient,
  14377. "number": basNumber,
  14378. })
  14379. }
  14380. } else {
  14381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14382. return
  14383. }
  14384. break
  14385. }
  14386. case 2:
  14387. if miConfig.MdtrtareaAdmvs == "430800" {
  14388. if initFlag == 0 {
  14389. c.TestGetHnBasBaseInit()
  14390. }
  14391. SFZStr := c.GetSFZBaseInfo()
  14392. if len(SFZStr) == 0 {
  14393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14394. return
  14395. }
  14396. fmt.Println(SFZStr)
  14397. id_card_str := strings.Split(SFZStr, "^")
  14398. card_no := id_card_str[0]
  14399. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14400. //name := id_card_str[1]
  14401. //name = ConvertToString(name, "gbk", "utf-8")
  14402. 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)
  14403. var dat map[string]interface{}
  14404. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14405. fmt.Println(dat)
  14406. } else {
  14407. fmt.Println(err)
  14408. }
  14409. userJSONBytes, _ := json.Marshal(dat)
  14410. var res ResultTwo
  14411. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14412. utils.ErrorLog("解析失败:%v", err)
  14413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14414. return
  14415. }
  14416. if res.Infcode == 0 {
  14417. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14418. if err == gorm.ErrRecordNotFound {
  14419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14420. return
  14421. } else if err != nil {
  14422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14423. return
  14424. } else {
  14425. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14426. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14427. infoStr := string(Iinfos)
  14428. idetinfoStr := string(Idetinfos)
  14429. var rf []*ResultFive
  14430. json.Unmarshal([]byte(infoStr), &rf)
  14431. var insutypes []*ResultFive
  14432. var insutype string
  14433. var is390 int = 0
  14434. var is310 int = 0
  14435. for _, item := range rf {
  14436. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14437. insutypes = append(insutypes, item)
  14438. }
  14439. }
  14440. if len(insutypes) == 1 {
  14441. insutype = insutypes[0].Insutype
  14442. } else {
  14443. for _, i := range insutypes {
  14444. if i.Insutype == "390" {
  14445. is390 = 1
  14446. }
  14447. if i.Insutype == "310" {
  14448. is310 = 1
  14449. }
  14450. }
  14451. }
  14452. if is390 == 1 {
  14453. insutype = "390"
  14454. }
  14455. if is310 == 1 {
  14456. insutype = "310"
  14457. }
  14458. if len(insutypes) == 0 {
  14459. insutype = "310"
  14460. }
  14461. var InsuplcAdmdvs string
  14462. for _, item := range rf {
  14463. if item.Insutype == insutype {
  14464. InsuplcAdmdvs = item.InsuplcAdmdvs
  14465. }
  14466. }
  14467. psn := &models.HisPsn{
  14468. PsnNo: res.Output.Baseinfo.PsnNo,
  14469. PatientId: patient.ID,
  14470. Certno: res.Output.Baseinfo.Certno,
  14471. Gend: res.Output.Baseinfo.Gend,
  14472. Naty: res.Output.Baseinfo.Naty,
  14473. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14474. PsnName: res.Output.Baseinfo.PsnName,
  14475. Idetinfo: idetinfoStr,
  14476. Insuinfo: infoStr,
  14477. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14478. CardInfo: SFZStr,
  14479. VerifyNumber: "",
  14480. InsuplcAdmdvs: InsuplcAdmdvs,
  14481. }
  14482. service.CreateHisPsn(psn)
  14483. c.ServeSuccessJSON(map[string]interface{}{
  14484. "patient": patient,
  14485. "number": card_no,
  14486. "insutype": insutype,
  14487. })
  14488. }
  14489. } else {
  14490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14491. return
  14492. }
  14493. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14494. var res ResultTwo
  14495. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14496. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14497. "&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)
  14498. resp, requestErr := http.Get(api)
  14499. if requestErr != nil {
  14500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14501. return
  14502. }
  14503. body, ioErr := ioutil.ReadAll(resp.Body)
  14504. if ioErr != nil {
  14505. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14507. return
  14508. }
  14509. var respJSON map[string]interface{}
  14510. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14511. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14513. return
  14514. }
  14515. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14516. result, _ := json.Marshal(respJSON)
  14517. fmt.Println("log")
  14518. fmt.Println(string(result))
  14519. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14520. utils.ErrorLog("解析失败:%v", err)
  14521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14522. return
  14523. }
  14524. if res.Infcode == 0 {
  14525. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14526. if err == gorm.ErrRecordNotFound {
  14527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14528. return
  14529. } else if err != nil {
  14530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14531. return
  14532. } else {
  14533. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14534. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14535. infoStr := string(Iinfos)
  14536. idetinfoStr := string(Idetinfos)
  14537. psn := &models.HisPsn{
  14538. PsnNo: res.Output.Baseinfo.PsnNo,
  14539. PatientId: patient.ID,
  14540. Certno: res.Output.Baseinfo.Certno,
  14541. Gend: res.Output.Baseinfo.Gend,
  14542. Naty: res.Output.Baseinfo.Naty,
  14543. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14544. PsnName: res.Output.Baseinfo.PsnName,
  14545. Idetinfo: idetinfoStr,
  14546. Insuinfo: infoStr,
  14547. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14548. }
  14549. service.CreateHisPsn(psn)
  14550. c.ServeSuccessJSON(map[string]interface{}{
  14551. "patient": patient,
  14552. "number": res.Output.Baseinfo.Certno,
  14553. })
  14554. }
  14555. } else {
  14556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14557. return
  14558. }
  14559. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14560. var res ResultTwo
  14561. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14562. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14563. "&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)
  14564. resp, requestErr := http.Get(api)
  14565. if requestErr != nil {
  14566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14567. return
  14568. }
  14569. body, ioErr := ioutil.ReadAll(resp.Body)
  14570. if ioErr != nil {
  14571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14573. return
  14574. }
  14575. var respJSON map[string]interface{}
  14576. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14579. return
  14580. }
  14581. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14582. result, _ := json.Marshal(respJSON)
  14583. fmt.Println("log")
  14584. fmt.Println(string(result))
  14585. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14586. utils.ErrorLog("解析失败:%v", err)
  14587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14588. return
  14589. }
  14590. if res.Infcode == 0 {
  14591. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14592. if err == gorm.ErrRecordNotFound {
  14593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14594. return
  14595. } else if err != nil {
  14596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14597. return
  14598. } else {
  14599. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14600. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14601. infoStr := string(Iinfos)
  14602. idetinfoStr := string(Idetinfos)
  14603. psn := &models.HisPsn{
  14604. PsnNo: res.Output.Baseinfo.PsnNo,
  14605. PatientId: patient.ID,
  14606. Certno: res.Output.Baseinfo.Certno,
  14607. Gend: res.Output.Baseinfo.Gend,
  14608. Naty: res.Output.Baseinfo.Naty,
  14609. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14610. PsnName: res.Output.Baseinfo.PsnName,
  14611. Idetinfo: idetinfoStr,
  14612. Insuinfo: infoStr,
  14613. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14614. }
  14615. service.CreateHisPsn(psn)
  14616. c.ServeSuccessJSON(map[string]interface{}{
  14617. "patient": patient,
  14618. "number": res.Output.Baseinfo.Certno,
  14619. })
  14620. }
  14621. } else {
  14622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14623. return
  14624. }
  14625. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14626. var res ResultTwo
  14627. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14628. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14629. "&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)
  14630. resp, requestErr := http.Get(api)
  14631. if requestErr != nil {
  14632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14633. return
  14634. }
  14635. body, ioErr := ioutil.ReadAll(resp.Body)
  14636. if ioErr != nil {
  14637. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14639. return
  14640. }
  14641. var respJSON map[string]interface{}
  14642. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14645. return
  14646. }
  14647. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14648. result, _ := json.Marshal(respJSON)
  14649. fmt.Println("log")
  14650. fmt.Println(string(result))
  14651. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14652. utils.ErrorLog("解析失败:%v", err)
  14653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14654. return
  14655. }
  14656. if res.Infcode == 0 {
  14657. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14658. if err == gorm.ErrRecordNotFound {
  14659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14660. return
  14661. } else if err != nil {
  14662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14663. return
  14664. } else {
  14665. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14666. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14667. infoStr := string(Iinfos)
  14668. idetinfoStr := string(Idetinfos)
  14669. var rf []*ResultFive
  14670. json.Unmarshal([]byte(infoStr), &rf)
  14671. var insutypes []*ResultFive
  14672. var insutype string
  14673. var is390 int = 0
  14674. var is310 int = 0
  14675. for _, item := range rf {
  14676. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14677. insutypes = append(insutypes, item)
  14678. }
  14679. }
  14680. if len(insutypes) == 1 {
  14681. insutype = insutypes[0].Insutype
  14682. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14683. } else {
  14684. for _, i := range insutypes {
  14685. if i.Insutype == "390" {
  14686. is390 = 1
  14687. }
  14688. if i.Insutype == "310" {
  14689. is310 = 1
  14690. }
  14691. }
  14692. }
  14693. if is390 == 1 {
  14694. insutype = "390"
  14695. }
  14696. if is310 == 1 {
  14697. insutype = "310"
  14698. }
  14699. if len(insutypes) == 0 {
  14700. insutype = "390"
  14701. }
  14702. var insuplc_admdvs string
  14703. for _, item := range rf {
  14704. if item.Insutype == insutype {
  14705. insuplc_admdvs = item.InsuplcAdmdvs
  14706. }
  14707. }
  14708. psn := &models.HisPsn{
  14709. PsnNo: res.Output.Baseinfo.PsnNo,
  14710. PatientId: patient.ID,
  14711. Certno: res.Output.Baseinfo.Certno,
  14712. Gend: res.Output.Baseinfo.Gend,
  14713. Naty: res.Output.Baseinfo.Naty,
  14714. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14715. PsnName: res.Output.Baseinfo.PsnName,
  14716. Idetinfo: idetinfoStr,
  14717. Insuinfo: infoStr,
  14718. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14719. InsuplcAdmdvs: insuplc_admdvs,
  14720. }
  14721. service.CreateHisPsn(psn)
  14722. c.ServeSuccessJSON(map[string]interface{}{
  14723. "patient": patient,
  14724. "number": res.Output.Baseinfo.Certno,
  14725. })
  14726. }
  14727. } else {
  14728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14729. return
  14730. }
  14731. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14732. res := c.GetoleInfo()
  14733. if res.Infcode == 0 {
  14734. var result string
  14735. if res.Output.MdtrtCertType == "01" {
  14736. 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)
  14737. } else if res.Output.MdtrtCertType == "02" {
  14738. 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)
  14739. } else if res.Output.MdtrtCertType == "03" {
  14740. 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)
  14741. }
  14742. var dat map[string]interface{}
  14743. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14744. fmt.Println(dat)
  14745. } else {
  14746. fmt.Println(err)
  14747. }
  14748. userJSONBytes, _ := json.Marshal(dat)
  14749. var res2 ResultTwo
  14750. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14751. utils.ErrorLog("解析失败:%v", err)
  14752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14753. return
  14754. }
  14755. if res2.Infcode == 0 {
  14756. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14757. if err == gorm.ErrRecordNotFound {
  14758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14759. return
  14760. } else if err != nil {
  14761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14762. return
  14763. } else {
  14764. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14765. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14766. infoStr := string(Iinfos)
  14767. idetinfoStr := string(Idetinfos)
  14768. var rf []*ResultFive
  14769. json.Unmarshal([]byte(infoStr), &rf)
  14770. var insutypes []*ResultFive
  14771. var insutype string
  14772. var is390 int = 0
  14773. var is310 int = 0
  14774. //var insuplc_admdvs string
  14775. for _, item := range rf {
  14776. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14777. insutypes = append(insutypes, item)
  14778. }
  14779. }
  14780. if len(insutypes) == 1 {
  14781. insutype = insutypes[0].Insutype
  14782. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14783. } else {
  14784. for _, i := range insutypes {
  14785. if i.Insutype == "390" {
  14786. is390 = 1
  14787. }
  14788. if i.Insutype == "310" {
  14789. is310 = 1
  14790. }
  14791. }
  14792. }
  14793. if is390 == 1 {
  14794. insutype = "390"
  14795. }
  14796. if is310 == 1 {
  14797. insutype = "310"
  14798. }
  14799. if len(insutypes) == 0 {
  14800. insutype = "310"
  14801. }
  14802. psn := &models.HisPsn{
  14803. PsnNo: res2.Output.Baseinfo.PsnNo,
  14804. PatientId: patient.ID,
  14805. //Brdy: res2.Output.Baseinfo.Brdy,
  14806. Certno: res2.Output.Baseinfo.Certno,
  14807. Gend: res2.Output.Baseinfo.Gend,
  14808. Naty: res2.Output.Baseinfo.Naty,
  14809. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14810. PsnName: res2.Output.Baseinfo.PsnName,
  14811. Idetinfo: idetinfoStr,
  14812. Insuinfo: infoStr,
  14813. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14814. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14815. VerifyNumber: res.Output.EcToken,
  14816. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14817. }
  14818. service.CreateHisPsn(psn)
  14819. var balc float64
  14820. for _, item := range rf {
  14821. if item.Insutype == insutype {
  14822. balc = item.Balc
  14823. }
  14824. }
  14825. c.ServeSuccessJSON(map[string]interface{}{
  14826. "patient": patient,
  14827. "number": res.Output.CardNo,
  14828. "insutype": insutype,
  14829. "blac": balc,
  14830. "desc": idetinfoStr,
  14831. })
  14832. }
  14833. } else {
  14834. c.ServeSuccessJSON(map[string]interface{}{
  14835. "failed_code": -10,
  14836. "msg": res2.ErrMsg,
  14837. })
  14838. }
  14839. } else {
  14840. c.ServeSuccessJSON(map[string]interface{}{
  14841. "failed_code": -10,
  14842. "msg": res.ErrMsg,
  14843. })
  14844. }
  14845. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14846. var insuplc_admdvs string
  14847. if len(patient.InsuplcAdmdvs) > 0 {
  14848. insuplc_admdvs = patient.InsuplcAdmdvs
  14849. } else {
  14850. if len(insuplc_admdvs_str) > 0 {
  14851. insuplc_admdvs = insuplc_admdvs_str
  14852. } else {
  14853. insuplc_admdvs = miConfig.InsuplcAdmdvs
  14854. }
  14855. }
  14856. //请求内网数据
  14857. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  14858. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14859. "&insuplc_admdvs=" + insuplc_admdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&name=" + patient.Name + "&token=" + ""
  14860. resp, requestErr := http.Get(api)
  14861. if requestErr != nil {
  14862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14863. return
  14864. }
  14865. body, ioErr := ioutil.ReadAll(resp.Body)
  14866. if ioErr != nil {
  14867. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14869. return
  14870. }
  14871. var respJSON map[string]interface{}
  14872. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14875. return
  14876. }
  14877. status := respJSON["data"].(map[string]interface{})["status"].(string)
  14878. if status == "0" {
  14879. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  14880. c.ServeSuccessJSON(map[string]interface{}{
  14881. "failed_code": -10,
  14882. "msg": err_msg,
  14883. })
  14884. return
  14885. }
  14886. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14887. var res ResultTwo
  14888. result, _ := json.Marshal(respJSON)
  14889. fmt.Println("log")
  14890. fmt.Println(string(result))
  14891. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14892. utils.ErrorLog("解析失败:%v", err)
  14893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14894. return
  14895. }
  14896. if res.Infcode == 0 {
  14897. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14898. if err == gorm.ErrRecordNotFound {
  14899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14900. return
  14901. } else if err != nil {
  14902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14903. return
  14904. } else {
  14905. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14906. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14907. infoStr := string(Iinfos)
  14908. idetinfoStr := string(Idetinfos)
  14909. psn := &models.HisPsn{
  14910. PsnNo: res.Output.Baseinfo.PsnNo,
  14911. PatientId: patient.ID,
  14912. Certno: res.Output.Baseinfo.Certno,
  14913. Gend: res.Output.Baseinfo.Gend,
  14914. Naty: res.Output.Baseinfo.Naty,
  14915. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14916. PsnName: res.Output.Baseinfo.PsnName,
  14917. Idetinfo: idetinfoStr,
  14918. Insuinfo: infoStr,
  14919. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14920. }
  14921. service.CreateHisPsn(psn)
  14922. var rf []*ResultFive
  14923. json.Unmarshal([]byte(infoStr), &rf)
  14924. var insutypes []*ResultFive
  14925. var is390 int = 0
  14926. var is310 int = 0
  14927. var insutype string
  14928. for _, item := range rf {
  14929. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14930. insutypes = append(insutypes, item)
  14931. }
  14932. }
  14933. if len(insutypes) == 1 {
  14934. insutype = insutypes[0].Insutype
  14935. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14936. } else {
  14937. for _, i := range insutypes {
  14938. if i.Insutype == "390" {
  14939. is390 = 1
  14940. }
  14941. if i.Insutype == "310" {
  14942. is310 = 1
  14943. }
  14944. }
  14945. }
  14946. if is390 == 1 {
  14947. insutype = "390"
  14948. }
  14949. if is310 == 1 {
  14950. insutype = "310"
  14951. }
  14952. if len(insutypes) == 0 {
  14953. insutype = "390"
  14954. }
  14955. c.ServeSuccessJSON(map[string]interface{}{
  14956. "patient": patient,
  14957. "insutype": insutype,
  14958. "number": res.Output.Baseinfo.Certno,
  14959. "info": res,
  14960. })
  14961. }
  14962. } else {
  14963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14964. return
  14965. }
  14966. } else {
  14967. SFZStr := c.GetSFZBaseInfo()
  14968. id_card_str := strings.Split(SFZStr, "^")
  14969. id_card_number := id_card_str[0]
  14970. card_sn := ""
  14971. 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)
  14972. var dat map[string]interface{}
  14973. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14974. fmt.Println(dat)
  14975. } else {
  14976. fmt.Println(err)
  14977. }
  14978. userJSONBytes, _ := json.Marshal(dat)
  14979. var res ResultTwo
  14980. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14981. utils.ErrorLog("解析失败:%v", err)
  14982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14983. return
  14984. }
  14985. if res.Infcode == 0 {
  14986. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  14987. if err == gorm.ErrRecordNotFound {
  14988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14989. return
  14990. } else if err != nil {
  14991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14992. return
  14993. } else {
  14994. c.ServeSuccessJSON(map[string]interface{}{
  14995. "patient": patient,
  14996. "number": id_card_number,
  14997. })
  14998. }
  14999. } else {
  15000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15001. return
  15002. }
  15003. }
  15004. break
  15005. case 3:
  15006. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15007. var api string
  15008. if miConfig.MdtrtareaAdmvs == "320921" {
  15009. 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 +
  15010. "&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
  15011. fmt.Println(api)
  15012. } else {
  15013. 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 +
  15014. "&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)
  15015. }
  15016. resp, requestErr := http.Get(api)
  15017. if requestErr != nil {
  15018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15019. return
  15020. }
  15021. body, ioErr := ioutil.ReadAll(resp.Body)
  15022. if ioErr != nil {
  15023. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15025. return
  15026. }
  15027. var respJSON map[string]interface{}
  15028. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15031. return
  15032. }
  15033. var status string
  15034. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15035. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15036. var token string
  15037. var res ResultTwo //1101结果
  15038. var res10265 ResultTwo10265 //1101结果
  15039. var card_info string //卡信息
  15040. var busi_card_info string
  15041. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15042. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15043. if status == "0" { //读卡成功
  15044. if card_type == "1" {
  15045. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15046. result, _ := json.Marshal(respJSON)
  15047. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15048. utils.ErrorLog("解析失败:%v", err)
  15049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15050. return
  15051. }
  15052. res.ErrMsg = res10265.ErrMsg
  15053. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15054. res.Infcode = infocode
  15055. res.Output = res10265.Output
  15056. res.InfRefmsgid = res10265.InfRefmsgid
  15057. } else {
  15058. //var card_info string //卡信息
  15059. //var busi_card_info string
  15060. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15061. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15062. //fmt.Println(card_info)
  15063. //fmt.Println(busi_card_info)
  15064. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15065. result, _ := json.Marshal(respJSON)
  15066. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15067. utils.ErrorLog("解析失败:%v", err)
  15068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15069. return
  15070. }
  15071. res.ErrMsg = res10265.ErrMsg
  15072. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15073. res.Infcode = infocode
  15074. res.Output = res10265.Output
  15075. res.InfRefmsgid = res10265.InfRefmsgid
  15076. }
  15077. if res.Infcode == 0 {
  15078. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15079. if err == gorm.ErrRecordNotFound {
  15080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15081. return
  15082. } else if err != nil {
  15083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15084. return
  15085. } else {
  15086. if card_type == "1" {
  15087. bas := strings.Split(card_info, "|")
  15088. basNumber := bas[2]
  15089. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15090. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15091. infoStr := string(Iinfos)
  15092. idetinfoStr := string(Idetinfos)
  15093. psn := &models.HisPsn{
  15094. PsnNo: res.Output.Baseinfo.PsnNo,
  15095. PatientId: patient.ID,
  15096. Certno: res.Output.Baseinfo.Certno,
  15097. //Brdy: res.Output.Baseinfo.Brdy,
  15098. Gend: res.Output.Baseinfo.Gend,
  15099. Naty: res.Output.Baseinfo.Naty,
  15100. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15101. PsnName: res.Output.Baseinfo.PsnName,
  15102. Idetinfo: idetinfoStr,
  15103. Insuinfo: infoStr,
  15104. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15105. CardInfo: card_info,
  15106. VerifyNumber: busi_card_info,
  15107. }
  15108. service.CreateHisPsn(psn)
  15109. c.ServeSuccessJSON(map[string]interface{}{
  15110. "patient": patient,
  15111. "number": basNumber,
  15112. })
  15113. } else {
  15114. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15115. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15116. infoStr := string(Iinfos)
  15117. idetinfoStr := string(Idetinfos)
  15118. psn := &models.HisPsn{
  15119. PsnNo: res.Output.Baseinfo.PsnNo,
  15120. PatientId: patient.ID,
  15121. Certno: res.Output.Baseinfo.Certno,
  15122. Gend: res.Output.Baseinfo.Gend,
  15123. Naty: res.Output.Baseinfo.Naty,
  15124. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15125. PsnName: res.Output.Baseinfo.PsnName,
  15126. Idetinfo: idetinfoStr,
  15127. Insuinfo: infoStr,
  15128. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15129. CardInfo: card_info,
  15130. VerifyNumber: token,
  15131. }
  15132. service.CreateHisPsn(psn)
  15133. var rf []*ResultFive
  15134. json.Unmarshal([]byte(infoStr), &rf)
  15135. var insutypes []*ResultFive
  15136. var insutype string
  15137. var is390 int = 0
  15138. var is310 int = 0
  15139. for _, item := range rf {
  15140. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15141. insutypes = append(insutypes, item)
  15142. }
  15143. }
  15144. if len(insutypes) == 1 {
  15145. insutype = insutypes[0].Insutype
  15146. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15147. } else {
  15148. for _, i := range insutypes {
  15149. if i.Insutype == "390" {
  15150. is390 = 1
  15151. }
  15152. if i.Insutype == "310" {
  15153. is310 = 1
  15154. }
  15155. }
  15156. }
  15157. if is390 == 1 {
  15158. insutype = "390"
  15159. }
  15160. if is310 == 1 {
  15161. insutype = "310"
  15162. }
  15163. if len(insutypes) == 0 {
  15164. insutype = "310"
  15165. }
  15166. c.ServeSuccessJSON(map[string]interface{}{
  15167. "patient": patient,
  15168. "number": token,
  15169. "insutype": insutype,
  15170. })
  15171. }
  15172. }
  15173. } else {
  15174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15175. return
  15176. }
  15177. } else { //读卡失败
  15178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15179. return
  15180. }
  15181. }
  15182. break
  15183. case 4:
  15184. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15185. var api string
  15186. if miConfig.MdtrtareaAdmvs == "320921" {
  15187. 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 +
  15188. "&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
  15189. fmt.Println(api)
  15190. } else {
  15191. 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 +
  15192. "&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)
  15193. }
  15194. resp, requestErr := http.Get(api)
  15195. if requestErr != nil {
  15196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15197. return
  15198. }
  15199. body, ioErr := ioutil.ReadAll(resp.Body)
  15200. if ioErr != nil {
  15201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15203. return
  15204. }
  15205. var respJSON map[string]interface{}
  15206. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15209. return
  15210. }
  15211. var status string
  15212. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15213. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15214. var token string
  15215. var res ResultTwo //1101结果
  15216. var res10265 ResultTwo10265 //1101结果
  15217. if status == "0" { //读卡成功
  15218. var card_info string //卡信息
  15219. var busi_card_info string
  15220. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15221. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15222. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15223. fmt.Println(card_info)
  15224. fmt.Println(busi_card_info)
  15225. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15226. result, _ := json.Marshal(respJSON)
  15227. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15228. utils.ErrorLog("解析失败:%v", err)
  15229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15230. return
  15231. }
  15232. res.ErrMsg = res10265.ErrMsg
  15233. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15234. res.Infcode = infocode
  15235. res.Output = res10265.Output
  15236. res.InfRefmsgid = res10265.InfRefmsgid
  15237. if res.Infcode == 0 {
  15238. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15239. if err == gorm.ErrRecordNotFound {
  15240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15241. return
  15242. } else if err != nil {
  15243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15244. return
  15245. } else {
  15246. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15247. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15248. infoStr := string(Iinfos)
  15249. idetinfoStr := string(Idetinfos)
  15250. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15251. psn := &models.HisPsn{
  15252. PsnNo: res.Output.Baseinfo.PsnNo,
  15253. PatientId: patient.ID,
  15254. Certno: res.Output.Baseinfo.Certno,
  15255. Brdy: b,
  15256. Age: float64(age),
  15257. //Brdy: res.Output.Baseinfo.Brdy,
  15258. Gend: res.Output.Baseinfo.Gend,
  15259. Naty: res.Output.Baseinfo.Naty,
  15260. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15261. PsnName: res.Output.Baseinfo.PsnName,
  15262. Idetinfo: idetinfoStr,
  15263. Insuinfo: infoStr,
  15264. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15265. CardInfo: card_info,
  15266. VerifyNumber: token,
  15267. }
  15268. var rf []*ResultFive
  15269. json.Unmarshal([]byte(infoStr), &rf)
  15270. var insutypes []*ResultFive
  15271. var insutype string
  15272. var is390 int = 0
  15273. var is310 int = 0
  15274. for _, item := range rf {
  15275. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15276. insutypes = append(insutypes, item)
  15277. }
  15278. }
  15279. if len(insutypes) == 1 {
  15280. insutype = insutypes[0].Insutype
  15281. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15282. } else {
  15283. for _, i := range insutypes {
  15284. if i.Insutype == "390" {
  15285. is390 = 1
  15286. }
  15287. if i.Insutype == "310" {
  15288. is310 = 1
  15289. }
  15290. }
  15291. }
  15292. if is390 == 1 {
  15293. insutype = "390"
  15294. }
  15295. if is310 == 1 {
  15296. insutype = "310"
  15297. }
  15298. if len(insutypes) == 0 {
  15299. insutype = "310"
  15300. }
  15301. service.CreateHisPsn(psn)
  15302. c.ServeSuccessJSON(map[string]interface{}{
  15303. "patient": patient,
  15304. "number": token,
  15305. "insutype": insutype,
  15306. })
  15307. }
  15308. } else {
  15309. c.ServeSuccessJSON(map[string]interface{}{
  15310. "failed_code": -10,
  15311. "msg": res.ErrMsg,
  15312. })
  15313. }
  15314. } else { //读卡失败
  15315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15316. return
  15317. }
  15318. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15319. var api string
  15320. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15321. "&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
  15322. resp, requestErr := http.Get(api)
  15323. if requestErr != nil {
  15324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15325. return
  15326. }
  15327. body, ioErr := ioutil.ReadAll(resp.Body)
  15328. if ioErr != nil {
  15329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15331. return
  15332. }
  15333. var respJSON map[string]interface{}
  15334. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15337. return
  15338. }
  15339. var status string
  15340. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15341. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15342. var token string
  15343. var res ResultTwo //1101结果
  15344. if status == "1" { //读卡成功
  15345. var card_info string //卡信息
  15346. var busi_card_info string
  15347. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15348. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15349. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15350. fmt.Println(card_info)
  15351. fmt.Println(busi_card_info)
  15352. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15353. result, _ := json.Marshal(respJSON)
  15354. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15355. utils.ErrorLog("解析失败:%v", err)
  15356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15357. return
  15358. }
  15359. if res.Infcode == 0 {
  15360. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15361. if err == gorm.ErrRecordNotFound {
  15362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15363. return
  15364. } else if err != nil {
  15365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15366. return
  15367. } else {
  15368. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15369. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15370. infoStr := string(Iinfos)
  15371. idetinfoStr := string(Idetinfos)
  15372. psn := &models.HisPsn{
  15373. PsnNo: res.Output.Baseinfo.PsnNo,
  15374. PatientId: patient.ID,
  15375. Certno: res.Output.Baseinfo.Certno,
  15376. Gend: res.Output.Baseinfo.Gend,
  15377. Naty: res.Output.Baseinfo.Naty,
  15378. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15379. PsnName: res.Output.Baseinfo.PsnName,
  15380. Idetinfo: idetinfoStr,
  15381. Insuinfo: infoStr,
  15382. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15383. CardInfo: card_info,
  15384. VerifyNumber: token,
  15385. }
  15386. var rf []*ResultFive
  15387. json.Unmarshal([]byte(infoStr), &rf)
  15388. var insutypes []*ResultFive
  15389. var insutype string
  15390. var is390 int = 0
  15391. var is310 int = 0
  15392. for _, item := range rf {
  15393. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15394. insutypes = append(insutypes, item)
  15395. }
  15396. }
  15397. if len(insutypes) == 1 {
  15398. insutype = insutypes[0].Insutype
  15399. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15400. } else {
  15401. for _, i := range insutypes {
  15402. if i.Insutype == "390" {
  15403. is390 = 1
  15404. }
  15405. if i.Insutype == "310" {
  15406. is310 = 1
  15407. }
  15408. }
  15409. }
  15410. if is390 == 1 {
  15411. insutype = "390"
  15412. }
  15413. if is310 == 1 {
  15414. insutype = "310"
  15415. }
  15416. if len(insutypes) == 0 {
  15417. insutype = "310"
  15418. }
  15419. service.CreateHisPsn(psn)
  15420. c.ServeSuccessJSON(map[string]interface{}{
  15421. "patient": patient,
  15422. "number": token,
  15423. "insutype": insutype,
  15424. })
  15425. }
  15426. } else {
  15427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15428. return
  15429. }
  15430. } else { //读卡失败
  15431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15432. return
  15433. }
  15434. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15435. var api string
  15436. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15437. "&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
  15438. resp, requestErr := http.Get(api)
  15439. if requestErr != nil {
  15440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15441. return
  15442. }
  15443. body, ioErr := ioutil.ReadAll(resp.Body)
  15444. if ioErr != nil {
  15445. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15447. return
  15448. }
  15449. var respJSON map[string]interface{}
  15450. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15451. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15453. return
  15454. }
  15455. var status string
  15456. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15457. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15458. var token string
  15459. var res ResultTwo //1101结果
  15460. if status == "1" { //读卡成功
  15461. var card_info string //卡信息
  15462. var busi_card_info string
  15463. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15464. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15465. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15466. fmt.Println(card_info)
  15467. fmt.Println(busi_card_info)
  15468. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15469. result, _ := json.Marshal(respJSON)
  15470. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15471. utils.ErrorLog("解析失败:%v", err)
  15472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15473. return
  15474. }
  15475. if res.Infcode == 0 {
  15476. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15477. if err == gorm.ErrRecordNotFound {
  15478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15479. return
  15480. } else if err != nil {
  15481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15482. return
  15483. } else {
  15484. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15485. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15486. infoStr := string(Iinfos)
  15487. idetinfoStr := string(Idetinfos)
  15488. psn := &models.HisPsn{
  15489. PsnNo: res.Output.Baseinfo.PsnNo,
  15490. PatientId: patient.ID,
  15491. Certno: res.Output.Baseinfo.Certno,
  15492. Gend: res.Output.Baseinfo.Gend,
  15493. Naty: res.Output.Baseinfo.Naty,
  15494. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15495. PsnName: res.Output.Baseinfo.PsnName,
  15496. Idetinfo: idetinfoStr,
  15497. Insuinfo: infoStr,
  15498. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15499. CardInfo: card_info,
  15500. VerifyNumber: token,
  15501. }
  15502. var rf []*ResultFive
  15503. json.Unmarshal([]byte(infoStr), &rf)
  15504. var insutypes []*ResultFive
  15505. var insutype string
  15506. var is390 int = 0
  15507. var is310 int = 0
  15508. for _, item := range rf {
  15509. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15510. insutypes = append(insutypes, item)
  15511. }
  15512. }
  15513. if len(insutypes) == 1 {
  15514. insutype = insutypes[0].Insutype
  15515. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15516. } else {
  15517. for _, i := range insutypes {
  15518. if i.Insutype == "390" {
  15519. is390 = 1
  15520. }
  15521. if i.Insutype == "310" {
  15522. is310 = 1
  15523. }
  15524. }
  15525. }
  15526. if is390 == 1 {
  15527. insutype = "390"
  15528. }
  15529. if is310 == 1 {
  15530. insutype = "310"
  15531. }
  15532. if len(insutypes) == 0 {
  15533. insutype = "310"
  15534. }
  15535. service.CreateHisPsn(psn)
  15536. c.ServeSuccessJSON(map[string]interface{}{
  15537. "patient": patient,
  15538. "number": token,
  15539. "insutype": insutype,
  15540. })
  15541. }
  15542. } else {
  15543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15544. return
  15545. }
  15546. } else { //读卡失败
  15547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15548. return
  15549. }
  15550. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15551. //idNo := c.GetString("idNo")
  15552. //userName := c.GetString("userName")
  15553. //ecToken := c.GetString("ecToken")
  15554. //insuOrg := c.GetString("insuOrg")
  15555. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15556. utils.ErrorLog("解析失败:%v", json_result)
  15557. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15558. type ELeData struct {
  15559. Data struct {
  15560. IdNo string `json:"idNo"`
  15561. IdType string `json:"idType"`
  15562. UserName string `json:"userName"`
  15563. EcToken string `json:"ecToken"`
  15564. InsuOrg string `json:"insuOrg"`
  15565. Gender string `json:"gender"`
  15566. Birthday string `json:"birthday"`
  15567. Nationality string `json:"nationality"`
  15568. Email string `json:"email"`
  15569. Extra string `json:"extra"`
  15570. } `json:"data"`
  15571. Code int `json:"code"`
  15572. Message string `json:"message"`
  15573. }
  15574. var ele ELeData
  15575. err := json.Unmarshal([]byte(json_result), &ele)
  15576. if err != nil {
  15577. utils.ErrorLog("解析失败:%v", err)
  15578. }
  15579. token := ele.Data.EcToken
  15580. token = Remove0000(token)
  15581. 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)
  15582. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15583. var res ResultTwo
  15584. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15585. utils.ErrorLog("解析失败:%v", err)
  15586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15587. return
  15588. }
  15589. if res.Infcode == 0 {
  15590. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15591. if err == gorm.ErrRecordNotFound {
  15592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15593. return
  15594. } else if err != nil {
  15595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15596. return
  15597. } else {
  15598. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15599. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15600. infoStr := string(Iinfos)
  15601. idetinfoStr := string(Idetinfos)
  15602. psn := &models.HisPsn{
  15603. PsnNo: res.Output.Baseinfo.PsnNo,
  15604. PatientId: patient.ID,
  15605. Certno: res.Output.Baseinfo.Certno,
  15606. Gend: res.Output.Baseinfo.Gend,
  15607. Naty: res.Output.Baseinfo.Naty,
  15608. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15609. PsnName: res.Output.Baseinfo.PsnName,
  15610. Idetinfo: idetinfoStr,
  15611. Insuinfo: infoStr,
  15612. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15613. CardInfo: "",
  15614. Stage: "1",
  15615. VerifyNumber: token,
  15616. InsuplcAdmdvs: ele.Data.InsuOrg,
  15617. }
  15618. service.CreateHisPsn(psn)
  15619. var rf []*ResultFive
  15620. json.Unmarshal([]byte(infoStr), &rf)
  15621. var insutypes []*ResultFive
  15622. var insutype string
  15623. var is390 int = 0
  15624. var is310 int = 0
  15625. for _, item := range rf {
  15626. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15627. insutypes = append(insutypes, item)
  15628. }
  15629. }
  15630. if len(insutypes) == 1 {
  15631. insutype = insutypes[0].Insutype
  15632. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15633. } else {
  15634. for _, i := range insutypes {
  15635. if i.Insutype == "390" {
  15636. is390 = 1
  15637. }
  15638. if i.Insutype == "310" {
  15639. is310 = 1
  15640. }
  15641. }
  15642. }
  15643. if is390 == 1 {
  15644. insutype = "390"
  15645. }
  15646. if is310 == 1 {
  15647. insutype = "310"
  15648. }
  15649. if len(insutypes) == 0 {
  15650. insutype = "310"
  15651. }
  15652. c.ServeSuccessJSON(map[string]interface{}{
  15653. "patient": patient,
  15654. "number": token,
  15655. "insutype": insutype,
  15656. })
  15657. }
  15658. } else {
  15659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15660. return
  15661. }
  15662. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15663. //if initFlag == 0 {
  15664. //c.TestGetJiangXiBasBaseInit()
  15665. //}
  15666. //if initEleFlag == 0 {
  15667. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15668. //}
  15669. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15670. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15671. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15672. type ELeData struct {
  15673. Data struct {
  15674. IdNo string `json:"idNo"`
  15675. IdType string `json:"idType"`
  15676. UserName string `json:"userName"`
  15677. EcToken string `json:"ecToken"`
  15678. InsuOrg string `json:"insuOrg"`
  15679. Gender string `json:"gender"`
  15680. Birthday string `json:"birthday"`
  15681. Nationality string `json:"nationality"`
  15682. Email string `json:"email"`
  15683. Extra string `json:"extra"`
  15684. } `json:"data"`
  15685. Code int `json:"code"`
  15686. Message string `json:"message"`
  15687. }
  15688. var ele ELeData
  15689. err := json.Unmarshal([]byte(result), &ele)
  15690. if err != nil {
  15691. utils.ErrorLog("解析失败:%v", err)
  15692. }
  15693. token := ele.Data.EcToken
  15694. token = Remove0000(token)
  15695. 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)
  15696. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15697. var res ResultTwo
  15698. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15699. utils.ErrorLog("解析失败:%v", err)
  15700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15701. return
  15702. }
  15703. if res.Infcode == 0 {
  15704. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15705. if err == gorm.ErrRecordNotFound {
  15706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15707. return
  15708. } else if err != nil {
  15709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15710. return
  15711. } else {
  15712. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15713. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15714. infoStr := string(Iinfos)
  15715. idetinfoStr := string(Idetinfos)
  15716. psn := &models.HisPsn{
  15717. PsnNo: res.Output.Baseinfo.PsnNo,
  15718. PatientId: patient.ID,
  15719. Certno: res.Output.Baseinfo.Certno,
  15720. Gend: res.Output.Baseinfo.Gend,
  15721. Naty: res.Output.Baseinfo.Naty,
  15722. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15723. PsnName: res.Output.Baseinfo.PsnName,
  15724. Idetinfo: idetinfoStr,
  15725. Insuinfo: infoStr,
  15726. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15727. CardInfo: "",
  15728. VerifyNumber: token,
  15729. InsuplcAdmdvs: ele.Data.InsuOrg,
  15730. }
  15731. service.CreateHisPsn(psn)
  15732. var rf []*ResultFive
  15733. json.Unmarshal([]byte(infoStr), &rf)
  15734. var insutypes []*ResultFive
  15735. var insutype string
  15736. var is390 int = 0
  15737. var is310 int = 0
  15738. for _, item := range rf {
  15739. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15740. insutypes = append(insutypes, item)
  15741. }
  15742. }
  15743. if len(insutypes) == 1 {
  15744. insutype = insutypes[0].Insutype
  15745. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15746. } else {
  15747. for _, i := range insutypes {
  15748. if i.Insutype == "390" {
  15749. is390 = 1
  15750. }
  15751. if i.Insutype == "310" {
  15752. is310 = 1
  15753. }
  15754. }
  15755. }
  15756. if is390 == 1 {
  15757. insutype = "390"
  15758. }
  15759. if is310 == 1 {
  15760. insutype = "310"
  15761. }
  15762. if len(insutypes) == 0 {
  15763. insutype = "310"
  15764. }
  15765. c.ServeSuccessJSON(map[string]interface{}{
  15766. "patient": patient,
  15767. "number": token,
  15768. "insutype": insutype,
  15769. })
  15770. }
  15771. } else {
  15772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15773. return
  15774. }
  15775. } else if miConfig.MdtrtareaAdmvs == "361025" {
  15776. //if initFlag == 0 {
  15777. //c.TestGetJiangXiBasBaseInit()
  15778. //}
  15779. //if initEleFlag == 0 {
  15780. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15781. //}
  15782. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15783. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15784. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15785. type ELeData struct {
  15786. Data struct {
  15787. IdNo string `json:"idNo"`
  15788. IdType string `json:"idType"`
  15789. UserName string `json:"userName"`
  15790. EcToken string `json:"ecToken"`
  15791. InsuOrg string `json:"insuOrg"`
  15792. Gender string `json:"gender"`
  15793. Birthday string `json:"birthday"`
  15794. Nationality string `json:"nationality"`
  15795. Email string `json:"email"`
  15796. Extra string `json:"extra"`
  15797. } `json:"data"`
  15798. Code int `json:"code"`
  15799. Message string `json:"message"`
  15800. }
  15801. var ele ELeData
  15802. err := json.Unmarshal([]byte(result), &ele)
  15803. if err != nil {
  15804. utils.ErrorLog("解析失败:%v", err)
  15805. }
  15806. token := ele.Data.EcToken
  15807. token = Remove0000(token)
  15808. 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)
  15809. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15810. var res ResultTwo
  15811. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15812. utils.ErrorLog("解析失败:%v", err)
  15813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15814. return
  15815. }
  15816. if res.Infcode == 0 {
  15817. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15818. if err == gorm.ErrRecordNotFound {
  15819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15820. return
  15821. } else if err != nil {
  15822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15823. return
  15824. } else {
  15825. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15826. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15827. infoStr := string(Iinfos)
  15828. idetinfoStr := string(Idetinfos)
  15829. psn := &models.HisPsn{
  15830. PsnNo: res.Output.Baseinfo.PsnNo,
  15831. PatientId: patient.ID,
  15832. Certno: res.Output.Baseinfo.Certno,
  15833. Gend: res.Output.Baseinfo.Gend,
  15834. Naty: res.Output.Baseinfo.Naty,
  15835. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15836. PsnName: res.Output.Baseinfo.PsnName,
  15837. Idetinfo: idetinfoStr,
  15838. Insuinfo: infoStr,
  15839. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15840. CardInfo: "",
  15841. VerifyNumber: token,
  15842. InsuplcAdmdvs: ele.Data.InsuOrg,
  15843. }
  15844. service.CreateHisPsn(psn)
  15845. var rf []*ResultFive
  15846. json.Unmarshal([]byte(infoStr), &rf)
  15847. var insutypes []*ResultFive
  15848. var insutype string
  15849. var is390 int = 0
  15850. var is310 int = 0
  15851. for _, item := range rf {
  15852. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15853. insutypes = append(insutypes, item)
  15854. }
  15855. }
  15856. if len(insutypes) == 1 {
  15857. insutype = insutypes[0].Insutype
  15858. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15859. } else {
  15860. for _, i := range insutypes {
  15861. if i.Insutype == "390" {
  15862. is390 = 1
  15863. }
  15864. if i.Insutype == "310" {
  15865. is310 = 1
  15866. }
  15867. }
  15868. }
  15869. if is390 == 1 {
  15870. insutype = "390"
  15871. }
  15872. if is310 == 1 {
  15873. insutype = "310"
  15874. }
  15875. if len(insutypes) == 0 {
  15876. insutype = "310"
  15877. }
  15878. c.ServeSuccessJSON(map[string]interface{}{
  15879. "patient": patient,
  15880. "number": token,
  15881. "insutype": insutype,
  15882. })
  15883. }
  15884. } else {
  15885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15886. return
  15887. }
  15888. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15889. //if initFlag == 0 {
  15890. c.TestGetJiangXiBasBaseInit()
  15891. //}
  15892. //if initEleFlag == 0 {
  15893. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15894. //}
  15895. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15896. type ELeData struct {
  15897. Data struct {
  15898. IdNo string `json:"idNo"`
  15899. IdType string `json:"idType"`
  15900. UserName string `json:"userName"`
  15901. EcToken string `json:"ecToken"`
  15902. InsuOrg string `json:"insuOrg"`
  15903. Gender string `json:"gender"`
  15904. Birthday string `json:"birthday"`
  15905. Nationality string `json:"nationality"`
  15906. Email string `json:"email"`
  15907. Extra string `json:"extra"`
  15908. } `json:"data"`
  15909. Code int `json:"code"`
  15910. Message string `json:"message"`
  15911. }
  15912. var ele ELeData
  15913. err := json.Unmarshal([]byte(json_result), &ele)
  15914. if err != nil {
  15915. utils.ErrorLog("解析失败:%v", err)
  15916. }
  15917. token := ele.Data.EcToken
  15918. token = Remove0000(token)
  15919. 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)
  15920. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15921. var res ResultTwo
  15922. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15923. utils.ErrorLog("解析失败:%v", err)
  15924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15925. return
  15926. }
  15927. if res.Infcode == 0 {
  15928. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15929. if err == gorm.ErrRecordNotFound {
  15930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15931. return
  15932. } else if err != nil {
  15933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15934. return
  15935. } else {
  15936. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15937. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15938. infoStr := string(Iinfos)
  15939. idetinfoStr := string(Idetinfos)
  15940. psn := &models.HisPsn{
  15941. PsnNo: res.Output.Baseinfo.PsnNo,
  15942. PatientId: patient.ID,
  15943. Certno: res.Output.Baseinfo.Certno,
  15944. Gend: res.Output.Baseinfo.Gend,
  15945. Naty: res.Output.Baseinfo.Naty,
  15946. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15947. PsnName: res.Output.Baseinfo.PsnName,
  15948. Idetinfo: idetinfoStr,
  15949. Insuinfo: infoStr,
  15950. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15951. CardInfo: "",
  15952. VerifyNumber: token,
  15953. }
  15954. service.CreateHisPsn(psn)
  15955. var rf []*ResultFive
  15956. json.Unmarshal([]byte(infoStr), &rf)
  15957. var insutypes []*ResultFive
  15958. var insutype string
  15959. var is390 int = 0
  15960. var is310 int = 0
  15961. for _, item := range rf {
  15962. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15963. insutypes = append(insutypes, item)
  15964. }
  15965. }
  15966. if len(insutypes) == 1 {
  15967. insutype = insutypes[0].Insutype
  15968. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15969. } else {
  15970. for _, i := range insutypes {
  15971. if i.Insutype == "390" {
  15972. is390 = 1
  15973. }
  15974. if i.Insutype == "310" {
  15975. is310 = 1
  15976. }
  15977. }
  15978. }
  15979. if is390 == 1 {
  15980. insutype = "390"
  15981. }
  15982. if is310 == 1 {
  15983. insutype = "310"
  15984. }
  15985. if len(insutypes) == 0 {
  15986. insutype = "310"
  15987. }
  15988. c.ServeSuccessJSON(map[string]interface{}{
  15989. "patient": patient,
  15990. "number": token,
  15991. "insutype": insutype,
  15992. })
  15993. }
  15994. } else {
  15995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15996. return
  15997. }
  15998. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15999. type ELeData struct {
  16000. Code string `json:"code"`
  16001. Data struct {
  16002. Aac002 string `json:"aac002"`
  16003. Aaz500 string `json:"aaz500"`
  16004. ActCardNo string `json:"actCardNo"`
  16005. Bab520 string `json:"bab520"`
  16006. Bkz543 string `json:"bkz543"`
  16007. BusinessType string `json:"businessType"`
  16008. CertfCodg string `json:"certfCodg"`
  16009. EcIndexNo string `json:"ecIndexNo"`
  16010. EcToken string `json:"ecToken"`
  16011. ID0000 string `json:"id0000"`
  16012. IDNo string `json:"idNo"`
  16013. IDType string `json:"idType"`
  16014. Idcode string `json:"idcode"`
  16015. IdentityToken string `json:"identity_token"`
  16016. InsuOrg string `json:"insuOrg"`
  16017. OfficeID string `json:"officeId"`
  16018. OfficeName string `json:"officeName"`
  16019. OperatorID string `json:"operatorId"`
  16020. OperatorName string `json:"operatorName"`
  16021. OrgID string `json:"orgId"`
  16022. UserName string `json:"userName"`
  16023. } `json:"data"`
  16024. Infno interface{} `json:"infno"`
  16025. Message string `json:"message"`
  16026. OrgID string `json:"orgId"`
  16027. TransType string `json:"transType"`
  16028. }
  16029. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  16030. outPutInfo = Remove0000(outPutInfo)
  16031. if len(outPutInfo) > 0 {
  16032. var ele ELeData
  16033. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16034. if err != nil {
  16035. utils.ErrorLog("解析失败:%v", err)
  16036. }
  16037. token := ele.Data.EcToken
  16038. fmt.Println(inputInfo)
  16039. fmt.Println(outPutInfo)
  16040. 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)
  16041. saveLog(result, requestLog, "1101", "获取人员信息")
  16042. var dat map[string]interface{}
  16043. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16044. fmt.Println(dat)
  16045. } else {
  16046. fmt.Println(err)
  16047. }
  16048. userJSONBytes, _ := json.Marshal(dat)
  16049. var res ResultTwo
  16050. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16051. utils.ErrorLog("解析失败:%v", err)
  16052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16053. return
  16054. }
  16055. res.ErrMsg = errMsgLog
  16056. if res.Infcode == 0 {
  16057. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16058. if err == gorm.ErrRecordNotFound {
  16059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16060. return
  16061. } else if err != nil {
  16062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16063. return
  16064. } else {
  16065. fmt.Println(res)
  16066. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16067. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16068. infoStr := string(Iinfos)
  16069. idetinfoStr := string(Idetinfos)
  16070. psn := &models.HisPsn{
  16071. PsnNo: res.Output.Baseinfo.PsnNo,
  16072. PatientId: patient.ID,
  16073. Certno: res.Output.Baseinfo.Certno,
  16074. Gend: res.Output.Baseinfo.Gend,
  16075. Naty: res.Output.Baseinfo.Naty,
  16076. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16077. PsnName: res.Output.Baseinfo.PsnName,
  16078. Idetinfo: idetinfoStr,
  16079. Insuinfo: infoStr,
  16080. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16081. CardInfo: outPutInfo,
  16082. VerifyNumber: token,
  16083. InsuplcAdmdvs: ele.Data.InsuOrg,
  16084. }
  16085. service.CreateHisPsn(psn)
  16086. var rf []*ResultFive
  16087. json.Unmarshal([]byte(infoStr), &rf)
  16088. var insutypes []*ResultFive
  16089. var insutype string
  16090. var is390 int = 0
  16091. var is310 int = 0
  16092. for _, item := range rf {
  16093. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16094. insutypes = append(insutypes, item)
  16095. }
  16096. }
  16097. if len(insutypes) == 1 {
  16098. insutype = insutypes[0].Insutype
  16099. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16100. } else {
  16101. for _, i := range insutypes {
  16102. if i.Insutype == "390" {
  16103. is390 = 1
  16104. }
  16105. if i.Insutype == "310" {
  16106. is310 = 1
  16107. }
  16108. }
  16109. }
  16110. if is390 == 1 {
  16111. insutype = "390"
  16112. }
  16113. if is310 == 1 {
  16114. insutype = "310"
  16115. }
  16116. if len(insutypes) == 0 {
  16117. insutype = "310"
  16118. }
  16119. c.ServeSuccessJSON(map[string]interface{}{
  16120. "patient": patient,
  16121. "number": token,
  16122. "insutype": insutype,
  16123. })
  16124. }
  16125. } else {
  16126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16127. return
  16128. }
  16129. }
  16130. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16131. var api string
  16132. 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 +
  16133. "&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
  16134. resp, requestErr := http.Get(api)
  16135. if requestErr != nil {
  16136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16137. return
  16138. }
  16139. body, ioErr := ioutil.ReadAll(resp.Body)
  16140. if ioErr != nil {
  16141. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16143. return
  16144. }
  16145. var respJSON map[string]interface{}
  16146. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16149. return
  16150. }
  16151. var status string
  16152. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16153. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16154. var token string
  16155. var res ResultTwo //1101结果
  16156. var res10265 ResultTwo10265 //1101结果
  16157. if status == "0" { //读卡成功
  16158. var card_info string //卡信息
  16159. var busi_card_info string
  16160. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16161. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16162. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16163. fmt.Println(card_info)
  16164. fmt.Println(busi_card_info)
  16165. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16166. result, _ := json.Marshal(respJSON)
  16167. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16168. utils.ErrorLog("解析失败:%v", err)
  16169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16170. return
  16171. }
  16172. res.ErrMsg = res10265.ErrMsg
  16173. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16174. res.Infcode = infocode
  16175. res.Output = res10265.Output
  16176. res.InfRefmsgid = res10265.InfRefmsgid
  16177. if res.Infcode == 0 {
  16178. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16179. if err == gorm.ErrRecordNotFound {
  16180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16181. return
  16182. } else if err != nil {
  16183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16184. return
  16185. } else {
  16186. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16187. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16188. infoStr := string(Iinfos)
  16189. idetinfoStr := string(Idetinfos)
  16190. psn := &models.HisPsn{
  16191. PsnNo: res.Output.Baseinfo.PsnNo,
  16192. PatientId: patient.ID,
  16193. Certno: res.Output.Baseinfo.Certno,
  16194. Gend: res.Output.Baseinfo.Gend,
  16195. Naty: res.Output.Baseinfo.Naty,
  16196. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16197. PsnName: res.Output.Baseinfo.PsnName,
  16198. Idetinfo: idetinfoStr,
  16199. Insuinfo: infoStr,
  16200. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16201. CardInfo: card_info,
  16202. VerifyNumber: token,
  16203. }
  16204. var rf []*ResultFive
  16205. json.Unmarshal([]byte(infoStr), &rf)
  16206. var insutypes []*ResultFive
  16207. var insutype string
  16208. var is390 int = 0
  16209. var is310 int = 0
  16210. for _, item := range rf {
  16211. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16212. insutypes = append(insutypes, item)
  16213. }
  16214. }
  16215. if len(insutypes) == 1 {
  16216. insutype = insutypes[0].Insutype
  16217. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16218. } else {
  16219. for _, i := range insutypes {
  16220. if i.Insutype == "390" {
  16221. is390 = 1
  16222. }
  16223. if i.Insutype == "310" {
  16224. is310 = 1
  16225. }
  16226. }
  16227. }
  16228. if is390 == 1 {
  16229. insutype = "390"
  16230. }
  16231. if is310 == 1 {
  16232. insutype = "310"
  16233. }
  16234. if len(insutypes) == 0 {
  16235. insutype = "310"
  16236. }
  16237. service.CreateHisPsn(psn)
  16238. c.ServeSuccessJSON(map[string]interface{}{
  16239. "patient": patient,
  16240. "number": token,
  16241. "insutype": insutype,
  16242. })
  16243. }
  16244. } else {
  16245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16246. return
  16247. }
  16248. } else { //读卡失败
  16249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16250. return
  16251. }
  16252. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16253. res := c.GetoleInfo()
  16254. if res.Infcode == 0 {
  16255. var result string
  16256. if res.Output.MdtrtCertType == "01" {
  16257. 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)
  16258. } else if res.Output.MdtrtCertType == "02" {
  16259. 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)
  16260. } else if res.Output.MdtrtCertType == "03" {
  16261. 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)
  16262. }
  16263. var dat map[string]interface{}
  16264. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16265. fmt.Println(dat)
  16266. } else {
  16267. fmt.Println(err)
  16268. }
  16269. userJSONBytes, _ := json.Marshal(dat)
  16270. var res2 ResultTwo
  16271. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16272. utils.ErrorLog("解析失败:%v", err)
  16273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16274. return
  16275. }
  16276. if res2.Infcode == 0 {
  16277. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  16278. if err == gorm.ErrRecordNotFound {
  16279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16280. return
  16281. } else if err != nil {
  16282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16283. return
  16284. } else {
  16285. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  16286. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16287. infoStr := string(Iinfos)
  16288. idetinfoStr := string(Idetinfos)
  16289. var rf []*ResultFive
  16290. json.Unmarshal([]byte(infoStr), &rf)
  16291. var insutypes []*ResultFive
  16292. var insutype string
  16293. var is390 int = 0
  16294. var is310 int = 0
  16295. //var insuplc_admdvs string
  16296. for _, item := range rf {
  16297. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16298. insutypes = append(insutypes, item)
  16299. }
  16300. }
  16301. if len(insutypes) == 1 {
  16302. insutype = insutypes[0].Insutype
  16303. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16304. } else {
  16305. for _, i := range insutypes {
  16306. if i.Insutype == "390" {
  16307. is390 = 1
  16308. }
  16309. if i.Insutype == "310" {
  16310. is310 = 1
  16311. }
  16312. }
  16313. }
  16314. if is390 == 1 {
  16315. insutype = "390"
  16316. }
  16317. if is310 == 1 {
  16318. insutype = "310"
  16319. }
  16320. if len(insutypes) == 0 {
  16321. insutype = "310"
  16322. }
  16323. psn := &models.HisPsn{
  16324. PsnNo: res2.Output.Baseinfo.PsnNo,
  16325. PatientId: patient.ID,
  16326. Certno: res2.Output.Baseinfo.Certno,
  16327. Gend: res2.Output.Baseinfo.Gend,
  16328. Naty: res2.Output.Baseinfo.Naty,
  16329. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16330. PsnName: res2.Output.Baseinfo.PsnName,
  16331. Idetinfo: idetinfoStr,
  16332. Insuinfo: infoStr,
  16333. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16334. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16335. VerifyNumber: res.Output.EcToken,
  16336. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16337. }
  16338. if res.Output.MdtrtCertType == "01" {
  16339. psn.VerifyNumber = res.Output.EcToken
  16340. //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)
  16341. } else if res.Output.MdtrtCertType == "02" {
  16342. psn.VerifyNumber = res.Output.CardNo
  16343. //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)
  16344. } else if res.Output.MdtrtCertType == "03" {
  16345. psn.VerifyNumber = res.Output.MdtrtCertNo
  16346. //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)
  16347. }
  16348. service.CreateHisPsn(psn)
  16349. var balc float64
  16350. for _, item := range rf {
  16351. if item.Insutype == insutype {
  16352. balc = item.Balc
  16353. }
  16354. }
  16355. c.ServeSuccessJSON(map[string]interface{}{
  16356. "patient": patient,
  16357. "number": res.Output.CardNo,
  16358. "insutype": insutype,
  16359. "blac": balc,
  16360. "desc": idetinfoStr,
  16361. })
  16362. }
  16363. } else {
  16364. c.ServeSuccessJSON(map[string]interface{}{
  16365. "failed_code": -10,
  16366. "msg": res2.ErrMsg,
  16367. })
  16368. }
  16369. } else {
  16370. c.ServeSuccessJSON(map[string]interface{}{
  16371. "failed_code": -10,
  16372. "msg": res.ErrMsg,
  16373. })
  16374. }
  16375. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16376. var res ResultTwo
  16377. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16378. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16379. "&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)
  16380. resp, requestErr := http.Get(api)
  16381. if requestErr != nil {
  16382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16383. return
  16384. }
  16385. body, ioErr := ioutil.ReadAll(resp.Body)
  16386. if ioErr != nil {
  16387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16389. return
  16390. }
  16391. var respJSON map[string]interface{}
  16392. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16395. return
  16396. }
  16397. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16398. result, _ := json.Marshal(respJSON)
  16399. fmt.Println("log")
  16400. fmt.Println(string(result))
  16401. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16402. utils.ErrorLog("解析失败:%v", err)
  16403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16404. return
  16405. }
  16406. if res.Infcode == 0 {
  16407. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16408. if err == gorm.ErrRecordNotFound {
  16409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16410. return
  16411. } else if err != nil {
  16412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16413. return
  16414. } else {
  16415. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16416. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16417. infoStr := string(Iinfos)
  16418. idetinfoStr := string(Idetinfos)
  16419. var rf []*ResultFive
  16420. json.Unmarshal([]byte(infoStr), &rf)
  16421. var insutypes []*ResultFive
  16422. var insutype string
  16423. var is390 int = 0
  16424. var is310 int = 0
  16425. for _, item := range rf {
  16426. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16427. insutypes = append(insutypes, item)
  16428. }
  16429. }
  16430. if len(insutypes) == 1 {
  16431. insutype = insutypes[0].Insutype
  16432. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16433. } else {
  16434. for _, i := range insutypes {
  16435. if i.Insutype == "390" {
  16436. is390 = 1
  16437. }
  16438. if i.Insutype == "310" {
  16439. is310 = 1
  16440. }
  16441. }
  16442. }
  16443. if is390 == 1 {
  16444. insutype = "390"
  16445. }
  16446. if is310 == 1 {
  16447. insutype = "310"
  16448. }
  16449. if len(insutypes) == 0 {
  16450. insutype = "390"
  16451. }
  16452. var insuplc_admdvs string
  16453. for _, item := range rf {
  16454. if item.Insutype == insutype {
  16455. insuplc_admdvs = item.InsuplcAdmdvs
  16456. }
  16457. }
  16458. psn := &models.HisPsn{
  16459. PsnNo: res.Output.Baseinfo.PsnNo,
  16460. PatientId: patient.ID,
  16461. Certno: res.Output.Baseinfo.Certno,
  16462. Gend: res.Output.Baseinfo.Gend,
  16463. Naty: res.Output.Baseinfo.Naty,
  16464. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16465. PsnName: res.Output.Baseinfo.PsnName,
  16466. Idetinfo: idetinfoStr,
  16467. Insuinfo: infoStr,
  16468. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16469. InsuplcAdmdvs: insuplc_admdvs,
  16470. }
  16471. service.CreateHisPsn(psn)
  16472. c.ServeSuccessJSON(map[string]interface{}{
  16473. "patient": patient,
  16474. "number": res.Output.Baseinfo.Certno,
  16475. })
  16476. }
  16477. } else {
  16478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16479. return
  16480. }
  16481. } else {
  16482. type ELeData struct {
  16483. Code string `json:"code"`
  16484. Data struct {
  16485. Aac002 string `json:"aac002"`
  16486. Aaz500 string `json:"aaz500"`
  16487. ActCardNo string `json:"actCardNo"`
  16488. Bab520 string `json:"bab520"`
  16489. Bkz543 string `json:"bkz543"`
  16490. BusinessType string `json:"businessType"`
  16491. CertfCodg string `json:"certfCodg"`
  16492. EcIndexNo string `json:"ecIndexNo"`
  16493. EcToken string `json:"ecToken"`
  16494. ID0000 string `json:"id0000"`
  16495. IDNo string `json:"idNo"`
  16496. IDType string `json:"idType"`
  16497. Idcode string `json:"idcode"`
  16498. IdentityToken string `json:"identity_token"`
  16499. InsuOrg string `json:"insuOrg"`
  16500. OfficeID string `json:"officeId"`
  16501. OfficeName string `json:"officeName"`
  16502. OperatorID string `json:"operatorId"`
  16503. OperatorName string `json:"operatorName"`
  16504. OrgID string `json:"orgId"`
  16505. UserName string `json:"userName"`
  16506. } `json:"data"`
  16507. Infno interface{} `json:"infno"`
  16508. Message string `json:"message"`
  16509. OrgID string `json:"orgId"`
  16510. TransType string `json:"transType"`
  16511. }
  16512. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16513. fmt.Println(result)
  16514. outPutInfo := Remove0000(result)
  16515. fmt.Println(outPutInfo)
  16516. if len(outPutInfo) > 0 {
  16517. var ele ELeData
  16518. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16519. if err != nil {
  16520. utils.ErrorLog("解析失败:%v", err)
  16521. }
  16522. token := ele.Data.EcToken
  16523. fmt.Println(outPutInfo)
  16524. 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)
  16525. saveLog(result, requestLog, "1101", "获取人员信息")
  16526. var dat map[string]interface{}
  16527. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16528. fmt.Println(dat)
  16529. } else {
  16530. fmt.Println(err)
  16531. }
  16532. userJSONBytes, _ := json.Marshal(dat)
  16533. var res ResultTwo
  16534. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16535. utils.ErrorLog("解析失败:%v", err)
  16536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16537. return
  16538. }
  16539. if res.Infcode == 0 {
  16540. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16541. if err == gorm.ErrRecordNotFound {
  16542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16543. return
  16544. } else if err != nil {
  16545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16546. return
  16547. } else {
  16548. fmt.Println(res)
  16549. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16550. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16551. infoStr := string(Iinfos)
  16552. idetinfoStr := string(Idetinfos)
  16553. psn := &models.HisPsn{
  16554. PsnNo: res.Output.Baseinfo.PsnNo,
  16555. PatientId: patient.ID,
  16556. Certno: res.Output.Baseinfo.Certno,
  16557. Gend: res.Output.Baseinfo.Gend,
  16558. Naty: res.Output.Baseinfo.Naty,
  16559. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16560. PsnName: res.Output.Baseinfo.PsnName,
  16561. Idetinfo: idetinfoStr,
  16562. Insuinfo: infoStr,
  16563. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16564. CardInfo: outPutInfo,
  16565. VerifyNumber: token,
  16566. InsuplcAdmdvs: ele.Data.InsuOrg,
  16567. }
  16568. service.CreateHisPsn(psn)
  16569. var rf []*ResultFive
  16570. json.Unmarshal([]byte(infoStr), &rf)
  16571. var insutypes []*ResultFive
  16572. var insutype string
  16573. var is390 int = 0
  16574. var is310 int = 0
  16575. for _, item := range rf {
  16576. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16577. insutypes = append(insutypes, item)
  16578. }
  16579. }
  16580. if len(insutypes) == 1 {
  16581. insutype = insutypes[0].Insutype
  16582. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16583. } else {
  16584. for _, i := range insutypes {
  16585. if i.Insutype == "390" {
  16586. is390 = 1
  16587. }
  16588. if i.Insutype == "310" {
  16589. is310 = 1
  16590. }
  16591. }
  16592. }
  16593. if is390 == 1 {
  16594. insutype = "390"
  16595. }
  16596. if is310 == 1 {
  16597. insutype = "310"
  16598. }
  16599. if len(insutypes) == 0 {
  16600. insutype = "310"
  16601. }
  16602. c.ServeSuccessJSON(map[string]interface{}{
  16603. "patient": patient,
  16604. "number": token,
  16605. "insutype": insutype,
  16606. })
  16607. }
  16608. } else {
  16609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16610. return
  16611. }
  16612. }
  16613. //fmt.Println(result)
  16614. //
  16615. //if initFlag == 0 {
  16616. // c.TestGetBasBaseInit()
  16617. //}
  16618. //token := c.GetEleBaseInfo()
  16619. //
  16620. //token = Remove0000(token)
  16621. //
  16622. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  16623. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  16624. ////
  16625. //var res ResultTwo
  16626. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16627. // utils.ErrorLog("解析失败:%v", err)
  16628. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16629. // return
  16630. //}
  16631. //
  16632. //if res.Infcode == 0 {
  16633. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16634. // if err == gorm.ErrRecordNotFound {
  16635. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16636. // return
  16637. // } else if err != nil {
  16638. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16639. // return
  16640. //
  16641. // } else {
  16642. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16643. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16644. // infoStr := string(Iinfos)
  16645. // idetinfoStr := string(Idetinfos)
  16646. //
  16647. //
  16648. //
  16649. //
  16650. // var rf []*ResultFive
  16651. // json.Unmarshal([]byte(infoStr), &rf)
  16652. //
  16653. // var insutypes []*ResultFive
  16654. // var insutype string
  16655. // var is390 int = 0
  16656. // var is310 int = 0
  16657. // var insuplc_admdvs string
  16658. //
  16659. // for _, item := range rf {
  16660. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16661. // insutypes = append(insutypes, item)
  16662. // }
  16663. // }
  16664. //
  16665. // if len(insutypes) == 1 {
  16666. // insutype = insutypes[0].Insutype
  16667. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16668. // } else {
  16669. // for _, i := range insutypes {
  16670. // if i.Insutype == "390" {
  16671. // is390 = 1
  16672. // }
  16673. //
  16674. // if i.Insutype == "310" {
  16675. // is310 = 1
  16676. // }
  16677. // }
  16678. // }
  16679. // if is390 == 1 {
  16680. // insutype = "390"
  16681. // }
  16682. //
  16683. // if is310 == 1 {
  16684. // insutype = "310"
  16685. // }
  16686. // if len(insutypes) == 0 {
  16687. // insutype = "310"
  16688. // }
  16689. // for _, item := range rf {
  16690. // if item.Insutype == insutype {
  16691. // insuplc_admdvs = item.InsuplcAdmdvs
  16692. // }
  16693. // }
  16694. // psn := &models.HisPsn{
  16695. // PsnNo: res.Output.Baseinfo.PsnNo,
  16696. // Age: res.Output.Baseinfo.Age,
  16697. // PatientId: patient.ID,
  16698. // Certno: res.Output.Baseinfo.Certno,
  16699. // Brdy: res.Output.Baseinfo.Brdy,
  16700. // Gend: res.Output.Baseinfo.Gend,
  16701. // Naty: res.Output.Baseinfo.Naty,
  16702. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  16703. // PsnName: res.Output.Baseinfo.PsnName,
  16704. // Idetinfo: idetinfoStr,
  16705. // Insuinfo: infoStr,
  16706. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16707. // CardInfo: "",
  16708. // VerifyNumber: token,
  16709. // InsuplcAdmdvs: insuplc_admdvs,
  16710. // }
  16711. // service.CreateHisPsn(psn)
  16712. //
  16713. // c.ServeSuccessJSON(map[string]interface{}{
  16714. // "patient": patient,
  16715. // "number": token,
  16716. // })
  16717. // }
  16718. //} else {
  16719. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16720. // return
  16721. //}
  16722. }
  16723. break
  16724. case 5:
  16725. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16726. var api string
  16727. if miConfig.MdtrtareaAdmvs == "320921" {
  16728. 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 +
  16729. "&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
  16730. fmt.Println(api)
  16731. } else {
  16732. 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 +
  16733. "&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)
  16734. }
  16735. resp, requestErr := http.Get(api)
  16736. if requestErr != nil {
  16737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16738. return
  16739. }
  16740. body, ioErr := ioutil.ReadAll(resp.Body)
  16741. if ioErr != nil {
  16742. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16744. return
  16745. }
  16746. var respJSON map[string]interface{}
  16747. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16750. return
  16751. }
  16752. var status string
  16753. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16754. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16755. var token string
  16756. var res ResultTwo //1101结果
  16757. var res10265 ResultTwo10265 //1101结果
  16758. if status == "0" { //读卡成功
  16759. var card_info string //卡信息
  16760. //var busi_card_info string
  16761. var auth_info string
  16762. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16763. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16764. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16765. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  16766. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16767. result, _ := json.Marshal(respJSON)
  16768. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16769. utils.ErrorLog("解析失败:%v", err)
  16770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16771. return
  16772. }
  16773. res.ErrMsg = res10265.ErrMsg
  16774. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16775. res.Infcode = infocode
  16776. res.Output = res10265.Output
  16777. res.InfRefmsgid = res10265.InfRefmsgid
  16778. if res.Infcode == 0 {
  16779. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16780. if err == gorm.ErrRecordNotFound {
  16781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16782. return
  16783. } else if err != nil {
  16784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16785. return
  16786. } else {
  16787. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16788. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16789. infoStr := string(Iinfos)
  16790. idetinfoStr := string(Idetinfos)
  16791. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16792. psn := &models.HisPsn{
  16793. PsnNo: res.Output.Baseinfo.PsnNo,
  16794. PatientId: patient.ID,
  16795. Certno: res.Output.Baseinfo.Certno,
  16796. Gend: res.Output.Baseinfo.Gend,
  16797. Brdy: b,
  16798. Age: float64(age),
  16799. Naty: res.Output.Baseinfo.Naty,
  16800. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16801. PsnName: res.Output.Baseinfo.PsnName,
  16802. Idetinfo: idetinfoStr,
  16803. Insuinfo: infoStr,
  16804. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16805. CardInfo: card_info,
  16806. VerifyNumber: token,
  16807. AuthInfo: auth_info,
  16808. }
  16809. var rf []*ResultFive
  16810. json.Unmarshal([]byte(infoStr), &rf)
  16811. var insutypes []*ResultFive
  16812. var insutype string
  16813. var is390 int = 0
  16814. var is310 int = 0
  16815. for _, item := range rf {
  16816. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16817. insutypes = append(insutypes, item)
  16818. }
  16819. }
  16820. if len(insutypes) == 1 {
  16821. insutype = insutypes[0].Insutype
  16822. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16823. } else {
  16824. for _, i := range insutypes {
  16825. if i.Insutype == "390" {
  16826. is390 = 1
  16827. }
  16828. if i.Insutype == "310" {
  16829. is310 = 1
  16830. }
  16831. }
  16832. }
  16833. if is390 == 1 {
  16834. insutype = "390"
  16835. }
  16836. if is310 == 1 {
  16837. insutype = "310"
  16838. }
  16839. if len(insutypes) == 0 {
  16840. insutype = "310"
  16841. }
  16842. service.CreateHisPsn(psn)
  16843. c.ServeSuccessJSON(map[string]interface{}{
  16844. "patient": patient,
  16845. "number": token,
  16846. "insutype": insutype,
  16847. })
  16848. }
  16849. } else {
  16850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16851. return
  16852. }
  16853. } else { //读卡失败
  16854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16855. return
  16856. }
  16857. }
  16858. break
  16859. }
  16860. }
  16861. var initFlag int64 = 0
  16862. var initEleFlag int64 = 0
  16863. func (c *HisApiController) TestGetBasBaseInit() {
  16864. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16865. Iinit := DllDef.MustFindProc("Init")
  16866. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16867. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  16868. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  16869. if ret != 0 {
  16870. fmt.Println("SSCard的报错原因:", err)
  16871. fmt.Println("SSCard的运算结果为:", ret)
  16872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16873. return
  16874. }
  16875. result := int(ret)
  16876. fmt.Println("SSCard的运算结果为1:", result)
  16877. initFlag = 1
  16878. return
  16879. }
  16880. func (c *HisApiController) HandleJiangXiReadCard() {
  16881. fmt.Println("~~~~~~")
  16882. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16883. admin_user_id, _ := c.GetInt64("admin_user_id")
  16884. id_card_type, _ := c.GetInt64("id_card_type")
  16885. //certificates, _ := c.GetInt64("certificates")
  16886. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16887. if initFlag == 0 {
  16888. c.TestGetJiangXiBasBaseInit()
  16889. }
  16890. basStr := c.GetBasBaseInfo()
  16891. if len(basStr) == 0 {
  16892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16893. return
  16894. }
  16895. fmt.Println(basStr)
  16896. bas := strings.Split(basStr, "|")
  16897. basNumber := bas[1]
  16898. fmt.Println(basNumber)
  16899. card_sn := bas[3]
  16900. fmt.Println(card_sn)
  16901. 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, "")
  16902. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  16903. var dat map[string]interface{}
  16904. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16905. fmt.Println(dat)
  16906. } else {
  16907. fmt.Println(err)
  16908. }
  16909. userJSONBytes, _ := json.Marshal(dat)
  16910. var res ResultTwo
  16911. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16912. utils.ErrorLog("解析失败:%v", err)
  16913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16914. return
  16915. }
  16916. if res.Infcode == 0 {
  16917. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  16918. if err == gorm.ErrRecordNotFound {
  16919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16920. return
  16921. } else if err != nil {
  16922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16923. return
  16924. } else {
  16925. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16926. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16927. infoStr := string(Iinfos)
  16928. idetinfoStr := string(Idetinfos)
  16929. psn := &models.HisPsn{
  16930. PsnNo: res.Output.Baseinfo.PsnNo,
  16931. PatientId: patient.ID,
  16932. Certno: res.Output.Baseinfo.Certno,
  16933. Gend: res.Output.Baseinfo.Gend,
  16934. Naty: res.Output.Baseinfo.Naty,
  16935. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16936. PsnName: res.Output.Baseinfo.PsnName,
  16937. Idetinfo: idetinfoStr,
  16938. Insuinfo: infoStr,
  16939. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16940. CardInfo: basStr,
  16941. VerifyNumber: "",
  16942. }
  16943. service.CreateHisPsn(psn)
  16944. c.ServeSuccessJSON(map[string]interface{}{
  16945. "patient": patient,
  16946. "number": basNumber,
  16947. })
  16948. }
  16949. } else {
  16950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16951. return
  16952. }
  16953. }
  16954. func (c *HisApiController) TestGetHnBasBaseInit() {
  16955. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16956. Iinit := DllDef.MustFindProc("Init")
  16957. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16958. //http://10.77.211.236/CSB/hsa-fsi-1303
  16959. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  16960. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  16961. // 调用 Init 函数
  16962. 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"))))
  16963. //if ret != 0 {
  16964. fmt.Println("SSCard的报错原因:", err)
  16965. fmt.Println("SSCard的运算结果为:", ret)
  16966. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16967. // return
  16968. //}
  16969. result := int(ret)
  16970. fmt.Println("SSCard的运算结果为1:", result)
  16971. initFlag = 1
  16972. return
  16973. }
  16974. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  16975. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16976. Iinit := DllDef.MustFindProc("Init")
  16977. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16978. //http://10.77.211.236/CSB/hsa-fsi-1303
  16979. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  16980. if ret != 0 {
  16981. fmt.Println("SSCard的报错原因:", err)
  16982. fmt.Println("SSCard的运算结果为:", ret)
  16983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16984. return
  16985. }
  16986. result := int(ret)
  16987. fmt.Println("SSCard的运算结果为1:", result)
  16988. initFlag = 1
  16989. return
  16990. }
  16991. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  16992. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16993. Iinit := DllDef.MustFindProc("Init")
  16994. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16995. //http://10.77.211.236/CSB/hsa-fsi-1303
  16996. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  16997. if ret != 0 {
  16998. fmt.Println("SSCard的报错原因:", err)
  16999. fmt.Println("SSCard的运算结果为:", ret)
  17000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17001. return
  17002. }
  17003. result := int(ret)
  17004. fmt.Println("SSCard的运算结果为1:", result)
  17005. initFlag = 1
  17006. return
  17007. }
  17008. func (c *HisApiController) GetSFZBaseInfo() string {
  17009. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17010. readCard := DllDef.MustFindProc("ReadSFZ")
  17011. if readCard == nil {
  17012. fmt.Println("readcard is nil")
  17013. readCard = DllDef.MustFindProc("ReadSFZ")
  17014. }
  17015. str := make([]byte, 8096)
  17016. str1 := make([]byte, 8096)
  17017. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  17018. fmt.Println(r)
  17019. return Remove0000(string(str))
  17020. }
  17021. func (c *HisApiController) GetEleBaseInfo() string {
  17022. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17023. readCard := DllDef.MustFindProc("GetQRBase")
  17024. fmt.Println(readCard)
  17025. if readCard == nil {
  17026. fmt.Println("readcard is nil")
  17027. readCard = DllDef.MustFindProc("GetQRBase")
  17028. }
  17029. str := make([]byte, 1024)
  17030. str1 := make([]byte, 1024)
  17031. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17032. fmt.Println(ret2)
  17033. fmt.Println(string(str1))
  17034. fmt.Println(string(str))
  17035. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17036. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17037. if ret2 != 0 {
  17038. return ""
  17039. }
  17040. return string(str)
  17041. }
  17042. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17043. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17044. readCard := DllDef.MustFindProc("NationEcTrans")
  17045. fmt.Println(readCard)
  17046. fmt.Println("!!!!!")
  17047. pBusiCardInfo := make([]byte, 2048)
  17048. input := make(map[string]interface{})
  17049. inputData := make(map[string]interface{})
  17050. inputData["orgId"] = code
  17051. inputData["businessType"] = "01101"
  17052. inputData["operatorId"] = "1"
  17053. inputData["operatorName"] = "admin"
  17054. inputData["officeId"] = "001"
  17055. inputData["officeName"] = "血透室"
  17056. inputData["deviceType"] = ""
  17057. input["data"] = inputData
  17058. input["orgId"] = code
  17059. input["transType"] = "ec.query"
  17060. bytesData, _ := json.Marshal(input)
  17061. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17062. fmt.Println(ret2)
  17063. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17064. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17065. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  17066. }
  17067. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17068. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17069. readCard := DllDef.MustFindProc("NationEcTrans")
  17070. fmt.Println(readCard)
  17071. fmt.Println("!!!!!")
  17072. pBusiCardInfo := make([]byte, 2048)
  17073. input := make(map[string]interface{})
  17074. inputData := make(map[string]interface{})
  17075. inputData["orgId"] = code
  17076. inputData["businessType"] = "01101"
  17077. inputData["operatorId"] = "9"
  17078. inputData["operatorName"] = "admin"
  17079. inputData["officeId"] = "001"
  17080. inputData["officeName"] = "血透室"
  17081. inputData["deviceType"] = ""
  17082. input["data"] = inputData
  17083. input["orgId"] = code
  17084. input["transType"] = "ec.query"
  17085. bytesData, _ := json.Marshal(input)
  17086. 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])))
  17087. fmt.Println(ret2)
  17088. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17089. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17090. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17091. }
  17092. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  17093. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17094. readCard := DllDef.MustFindProc("NationEcTrans")
  17095. fmt.Println(readCard)
  17096. fmt.Println("!!!!!")
  17097. pBusiCardInfo := make([]byte, 2048)
  17098. input := make(map[string]interface{})
  17099. inputData := make(map[string]interface{})
  17100. inputData["orgId"] = code
  17101. inputData["businessType"] = "01301"
  17102. inputData["operatorId"] = "9"
  17103. inputData["operatorName"] = "admin"
  17104. inputData["officeId"] = "001"
  17105. inputData["officeName"] = "血透室"
  17106. inputData["deviceType"] = ""
  17107. input["data"] = inputData
  17108. input["orgId"] = code
  17109. input["transType"] = "ec.query"
  17110. bytesData, _ := json.Marshal(input)
  17111. 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])))
  17112. fmt.Println(ret2)
  17113. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17114. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17115. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17116. }
  17117. func GetJxEleBaseInfo(org_id int64) string {
  17118. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17119. readCard := DllDef.MustFindProc("NationEcTrans")
  17120. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17121. if readCard == nil {
  17122. fmt.Println("readcard is nil")
  17123. readCard = DllDef.MustFindProc("NationEcTrans")
  17124. }
  17125. str1 := make([]byte, 1024)
  17126. data := make(map[string]interface{})
  17127. inputData := make(map[string]interface{})
  17128. inputData["orgId"] = miConfig.Code
  17129. inputData["businessType"] = "01101"
  17130. inputData["operatorId"] = "test001"
  17131. inputData["operatorName"] = "cn"
  17132. inputData["officeId"] = "32760"
  17133. inputData["officeName"] = "waike"
  17134. inputData["deviceType"] = ""
  17135. data["data"] = inputData
  17136. data["transType"] = "ec.query"
  17137. data["extra "] = ""
  17138. data["orgId"] = miConfig.Code
  17139. bytesData, _ := json.Marshal(data)
  17140. //bytesData, _ := json.Marshal(data)
  17141. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17142. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17143. fmt.Println(ret2)
  17144. fmt.Println(string(str1))
  17145. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17146. if ret2 != 0 {
  17147. return ""
  17148. }
  17149. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17150. }
  17151. //func GetJxEleBaseInfoTWO(org_id int64) string {
  17152. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  17153. // readCard := DllDef.MustFindProc("NationEcTrans")
  17154. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17155. //
  17156. // if readCard == nil {
  17157. // fmt.Println("readcard is nil")
  17158. // readCard = DllDef.MustFindProc("NationEcTrans")
  17159. // }
  17160. // str1 := make([]byte, 1024)
  17161. //
  17162. // data := make(map[string]interface{})
  17163. //
  17164. // inputData := make(map[string]interface{})
  17165. // inputData["orgId"] = miConfig.Code
  17166. // inputData["businessType"] = "01101"
  17167. // inputData["operatorId"] = "test001"
  17168. // inputData["operatorName"] = "cn"
  17169. // inputData["officeId"] = "32760"
  17170. // inputData["officeName"] = "waike"
  17171. // inputData["deviceType"] = ""
  17172. //
  17173. // data["data"] = inputData
  17174. // data["transType"] = "ec.query"
  17175. // data["extra "] = ""
  17176. // data["orgId"] = miConfig.Code
  17177. // bytesData, _ := json.Marshal(data)
  17178. // //bytesData, _ := json.Marshal(data)
  17179. //
  17180. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17181. //
  17182. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17183. // fmt.Println(ret2)
  17184. // fmt.Println(string(str1))
  17185. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17186. //
  17187. // if ret2 != 0 {
  17188. // return ""
  17189. // }
  17190. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17191. //}
  17192. func GetJxEleBaseInitInfo(org_id int64) string {
  17193. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17194. readCard := DllDef.MustFindProc("NationEcTrans")
  17195. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17196. if readCard == nil {
  17197. fmt.Println("readcard is nil")
  17198. readCard = DllDef.MustFindProc("NationEcTrans")
  17199. }
  17200. str1 := make([]byte, 2048)
  17201. data := make(map[string]interface{})
  17202. inputData := make(map[string]interface{})
  17203. inputData["orgId"] = miConfig.Code
  17204. inputData["businessType"] = "01101"
  17205. inputData["operatorId"] = "1"
  17206. inputData["operatorName"] = "huangchuang"
  17207. inputData["officeId"] = "101"
  17208. inputData["officeName"] = "xuetou"
  17209. inputData["deviceType"] = ""
  17210. data["data"] = inputData
  17211. data["transType"] = "ec.query"
  17212. data["orgId"] = miConfig.Code
  17213. bytesData, _ := json.Marshal(data)
  17214. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17215. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17216. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  17217. fmt.Println(ret2)
  17218. fmt.Println(string(str1))
  17219. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17220. if ret2 != 0 {
  17221. return ""
  17222. }
  17223. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  17224. initEleFlag = 1
  17225. }
  17226. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17227. }
  17228. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  17229. // // 构建命令
  17230. // cmd := exec.Command("python", "b.py")
  17231. //
  17232. // // 执行命令并等待完成
  17233. // output, err := cmd.CombinedOutput()
  17234. // if err != nil {
  17235. // fmt.Println("Error executing Python script:", err)
  17236. // return
  17237. // }
  17238. //
  17239. // // 打印Python脚本的输出
  17240. // fmt.Println(string(output))
  17241. //}
  17242. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  17243. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  17244. readCard := DllDef.MustFindProc("gxyb_call")
  17245. if readCard == nil {
  17246. fmt.Println("readcard is nil")
  17247. readCard = DllDef.MustFindProc("gxyb_call")
  17248. }
  17249. str := make([]byte, 1024)
  17250. str1 := make([]byte, 1024)
  17251. //data := make(map[string]interface{})
  17252. currentTime := time.Now()
  17253. // 格式化时间为 "YYYYMMDDHH24MISS"
  17254. formattedTime := currentTime.Format("20060102150405")
  17255. inputData := make(map[string]interface{})
  17256. inputData2 := make(map[string]interface{})
  17257. inputData["transNo"] = "1401"
  17258. inputData["transType"] = "passwordCheck"
  17259. inputData["timestamp"] = formattedTime
  17260. inputData2["fixmedinsCode"] = code
  17261. inputData2["psnNo"] = ""
  17262. inputData["data"] = inputData2
  17263. jsonBytes, err := json.Marshal(inputData)
  17264. if err != nil {
  17265. fmt.Println("Error encoding map to JSON:", err)
  17266. }
  17267. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17268. fmt.Println(string(str1))
  17269. fmt.Println(string(str))
  17270. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17271. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17272. if ret2 != 0 {
  17273. return ""
  17274. }
  17275. return string(str)
  17276. }
  17277. func (c *HisApiController) GetoleInfo() Response {
  17278. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17279. defer ole.CoUninitialize()
  17280. // Replace with the ProgID or CLSID of your COM object
  17281. progID := "YinHai.XJ.Actual.Interface.New"
  17282. // Create COM object
  17283. unknown, err := oleutil.CreateObject(progID)
  17284. if err != nil {
  17285. fmt.Println("Unable to create COM object:", err)
  17286. }
  17287. defer unknown.Release()
  17288. // Query for the IDispatch interface
  17289. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17290. if err != nil {
  17291. fmt.Println("Unable to get IDispatch interface:", err)
  17292. }
  17293. defer dispatch.Release()
  17294. // Prepare parameters
  17295. transNo := "1401"
  17296. transType := "passwordCheck"
  17297. timestamp := time.Now().Unix()
  17298. fixmedinsCode := "H45072101171"
  17299. psnNo := ""
  17300. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17301. result2 := ""
  17302. // Call COM object's method using the IDispatch interface
  17303. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17304. fmt.Println(resulr)
  17305. fmt.Println(result2)
  17306. if err != nil {
  17307. fmt.Println("调用COM对象方法失败:", err)
  17308. }
  17309. var response Response
  17310. err2 := json.Unmarshal([]byte(result2), &response)
  17311. if err2 != nil {
  17312. fmt.Println("解析JSON失败:", err)
  17313. }
  17314. return response
  17315. }
  17316. func (c *HisApiController) GetBasBaseInfo() string {
  17317. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17318. readCard := DllDef.MustFindProc("ReadCardBas")
  17319. if readCard == nil {
  17320. fmt.Println("readcard is nil")
  17321. readCard = DllDef.MustFindProc("ReadCardBas")
  17322. }
  17323. str := make([]byte, 1024)
  17324. str1 := make([]byte, 1024)
  17325. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17326. fmt.Println(string(str1))
  17327. fmt.Println(string(str))
  17328. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17329. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17330. if ret2 != 0 {
  17331. return ""
  17332. }
  17333. return string(str)
  17334. }
  17335. type Program struct {
  17336. FunctionID string `xml:"function_id"`
  17337. CardInfo string `xml:"cardinfo"`
  17338. User string `xml:"user"`
  17339. }
  17340. func (c *HisApiController) GetBasBaseInfo1111() string {
  17341. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17342. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17343. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17344. if readCard == nil {
  17345. fmt.Println("readcard is nil")
  17346. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17347. }
  17348. if readCard2 == nil {
  17349. fmt.Println("readcard is nil")
  17350. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17351. }
  17352. str := make([]byte, 1024)
  17353. str1 := make([]byte, 1024)
  17354. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17355. str3 := make([]byte, 1024)
  17356. str4 := make([]byte, 1024)
  17357. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17358. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17359. //if err != nil {
  17360. // fmt.Println("Error opening file:", err)
  17361. //}
  17362. //defer file.Close()
  17363. //
  17364. //var lastProgram Program
  17365. //scanner := bufio.NewScanner(file)
  17366. //inProgram := false
  17367. //
  17368. //for scanner.Scan() {
  17369. // line := scanner.Text()
  17370. // if strings.Contains(line, "<program>") {
  17371. // inProgram = true
  17372. // programXML := "<program>"
  17373. // for scanner.Scan() {
  17374. // line = scanner.Text()
  17375. // programXML += line
  17376. // if strings.Contains(line, "</program>") {
  17377. // programXML += "</program>"
  17378. // break
  17379. // }
  17380. // }
  17381. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17382. // // 解析成功,更新最后的 Program
  17383. // }
  17384. // inProgram = false
  17385. // }
  17386. //}
  17387. //
  17388. // fmt.Println("Error reading file:", inProgram)
  17389. //
  17390. //if err := scanner.Err(); err != nil {
  17391. // fmt.Println("Error reading file:", err)
  17392. //}
  17393. // 输出最后一次的 Program
  17394. //fmt.Printf("最后一次的 <program>:\n")
  17395. //fmt.Printf("<program>\n")
  17396. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17397. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17398. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17399. //fmt.Printf("</program>\n")
  17400. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17401. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17402. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17403. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17404. return ConvertToString(string(str), "gbk", "utf-8")
  17405. }
  17406. func (c *HisApiController) GetBasBaseInfo22222() string {
  17407. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17408. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17409. if readCard == nil {
  17410. fmt.Println("readcard is nil")
  17411. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17412. }
  17413. str := make([]byte, 1024)
  17414. str1 := make([]byte, 1024)
  17415. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17416. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17417. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17418. //if err != nil {
  17419. // fmt.Println("Error opening file:", err)
  17420. //}
  17421. //defer file.Close()
  17422. //
  17423. //var lastProgram Program
  17424. //scanner := bufio.NewScanner(file)
  17425. //inProgram := false
  17426. //
  17427. //for scanner.Scan() {
  17428. // line := scanner.Text()
  17429. // if strings.Contains(line, "<program>") {
  17430. // inProgram = true
  17431. // programXML := "<program>"
  17432. // for scanner.Scan() {
  17433. // line = scanner.Text()
  17434. // programXML += line
  17435. // if strings.Contains(line, "</program>") {
  17436. // programXML += "</program>"
  17437. // break
  17438. // }
  17439. // }
  17440. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17441. // // 解析成功,更新最后的 Program
  17442. // }
  17443. // inProgram = false
  17444. // }
  17445. //}
  17446. //
  17447. // fmt.Println("Error reading file:", inProgram)
  17448. //
  17449. //if err := scanner.Err(); err != nil {
  17450. // fmt.Println("Error reading file:", err)
  17451. //}
  17452. // 输出最后一次的 Program
  17453. //fmt.Printf("最后一次的 <program>:\n")
  17454. //fmt.Printf("<program>\n")
  17455. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17456. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17457. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17458. //fmt.Printf("</program>\n")
  17459. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17460. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17461. return ConvertToString(string(str1), "gbk", "utf-8")
  17462. }
  17463. func (c *HisApiController) GetahBasBaseInfo() string {
  17464. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17465. readCard := DllDef.MustFindProc("iReadCardBas")
  17466. if readCard == nil {
  17467. fmt.Println("readcard is nil")
  17468. readCard = DllDef.MustFindProc("iReadCardBas")
  17469. }
  17470. //str := make([]byte, 1024)
  17471. str1 := make([]byte, 1024)
  17472. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17473. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17474. //if err != nil {
  17475. // fmt.Println("Error opening file:", err)
  17476. //}
  17477. //defer file.Close()
  17478. //
  17479. //var lastProgram Program
  17480. //scanner := bufio.NewScanner(file)
  17481. //inProgram := false
  17482. //
  17483. //for scanner.Scan() {
  17484. // line := scanner.Text()
  17485. // if strings.Contains(line, "<program>") {
  17486. // inProgram = true
  17487. // programXML := "<program>"
  17488. // for scanner.Scan() {
  17489. // line = scanner.Text()
  17490. // programXML += line
  17491. // if strings.Contains(line, "</program>") {
  17492. // programXML += "</program>"
  17493. // break
  17494. // }
  17495. // }
  17496. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17497. // // 解析成功,更新最后的 Program
  17498. // }
  17499. // inProgram = false
  17500. // }
  17501. //}
  17502. //
  17503. // fmt.Println("Error reading file:", inProgram)
  17504. //
  17505. //if err := scanner.Err(); err != nil {
  17506. // fmt.Println("Error reading file:", err)
  17507. //}
  17508. // 输出最后一次的 Program
  17509. //fmt.Printf("最后一次的 <program>:\n")
  17510. //fmt.Printf("<program>\n")
  17511. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17512. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17513. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17514. //fmt.Printf("</program>\n")
  17515. fmt.Println(string(str1))
  17516. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17517. if ret2 != 0 {
  17518. return ""
  17519. }
  17520. return string(str1)
  17521. }
  17522. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17523. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17524. readCard := DllDef.MustFindProc("read_cardinfo")
  17525. if readCard == nil {
  17526. fmt.Println("readcard is nil")
  17527. readCard = DllDef.MustFindProc("read_cardinfo")
  17528. }
  17529. str := make([]byte, 1024) //卡号
  17530. str1 := make([]byte, 1024) //卡识别码
  17531. str2 := make([]byte, 1024) //身份证号
  17532. str3 := make([]byte, 1024) //姓名
  17533. str4 := make([]byte, 1024) //错误信息
  17534. 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])))
  17535. fmt.Println(string(str1))
  17536. fmt.Println(string(str))
  17537. fmt.Println(string(str2))
  17538. fmt.Println(string(str3))
  17539. fmt.Println(string(str4))
  17540. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17541. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17542. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17543. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17544. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17545. if ret2 != 0 {
  17546. return "", "", "", "", ""
  17547. }
  17548. return string(str), string(str1), string(str2), string(str3), string(str4)
  17549. }
  17550. type CustomFundPay struct {
  17551. FundPayType string `json:"fund_pay_type"`
  17552. FundPayamt float64 `json:"fund_payamt"`
  17553. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17554. }
  17555. //func (c *HisApiController) GetBatchSettleList() {
  17556. // start_time_str := c.GetString("start_time")
  17557. // //end_time_str := c.GetString("end_time")
  17558. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17559. //
  17560. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17561. //
  17562. // for _, item := range orders {
  17563. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17564. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17565. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17566. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17567. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17568. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17569. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17570. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17571. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17572. //
  17573. // if order.ID == 0 {
  17574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17575. // return
  17576. // }
  17577. //
  17578. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17579. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17580. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17581. // //fmt.Println(count)
  17582. // //var zero string
  17583. // //number := count + 1
  17584. // //if number >= 1000 {
  17585. // // zero = "0000" + strconv.FormatInt(number, 10)
  17586. // //} else if number >= 10000 {
  17587. // // zero = "000" + strconv.FormatInt(number, 10)
  17588. // //} else if number >= 100000 {
  17589. // // zero = "00" + strconv.FormatInt(number, 10)
  17590. // //} else if number >= 1000000 {
  17591. // // zero = "0" + strconv.FormatInt(number, 10)
  17592. // //} else {
  17593. // // zero = strconv.FormatInt(number, 10)
  17594. // //}
  17595. // //fmt.Println(zero)
  17596. //
  17597. // struct4101 := service.Struct4101{
  17598. // PsnNo: order.PsnNo,
  17599. // MdtrtId: order.MdtrtId,
  17600. // SetlId: order.SetlId,
  17601. // PsnName: order.PsnName,
  17602. // Gend: order.Gend,
  17603. // Brdy: his.Brdy,
  17604. // Age: his.Age,
  17605. // Naty: order.Naty,
  17606. // PatnCertType: "01",
  17607. // Certno: order.Certno,
  17608. // Prfs: "90",
  17609. // ConerName: roles[0].UserName,
  17610. // PatnRlts: "99",
  17611. // ConerAddr: miConfig.OrgName,
  17612. // ConerTel: admin.Mobile,
  17613. // HiType: order.Insutype,
  17614. // Insuplc: miConfig.InsuplcAdmdvs,
  17615. // MaindiagFlag: "1",
  17616. // BillCode: order.SetlId,
  17617. // BillNo: order.SetlId,
  17618. // BizSn: order.Number,
  17619. // PsnSelfPay: order.PsnPartAmt,
  17620. // PsnOwnPay: order.PsnPartAmt,
  17621. // AcctPay: order.AcctPay,
  17622. // PsnCashpay: order.PsnCashPay,
  17623. // HiPaymtd: "1",
  17624. // Hsorg: miConfig.InsuplcAdmdvs,
  17625. // HsorgOpter: miConfig.InsuplcAdmdvs,
  17626. // MedinsFillPsn: curRoles.UserName,
  17627. // MedinsFillDept: miConfig.OrgName,
  17628. // IptMedType: "2",
  17629. // }
  17630. // struct4101.SetlBegnDate = order.SetlTime
  17631. // struct4101.SetlEndDate = order.SetlTime
  17632. // time_arr := strings.Split(order.SetlTime, " ")
  17633. // struct4101.AdmTime = time_arr[0]
  17634. // struct4101.AdmEndTime = time_arr[0]
  17635. //
  17636. // var rf []CustomFundPay
  17637. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  17638. //
  17639. // var tempFunPays []service.CustomStruct
  17640. // for _, item := range rf {
  17641. // var tempFunPay service.CustomStruct
  17642. // tempFunPay.FundPayamt = item.FundPayamt
  17643. // tempFunPay.FundPayType = item.FundPayType
  17644. // tempFunPays = append(tempFunPays, tempFunPay)
  17645. // }
  17646. // struct4101.CustomStruct = tempFunPays
  17647. //
  17648. // var tempDiaginfos []service.DiaginfoStructTwo
  17649. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17650. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17651. //
  17652. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17653. // var config []*models.HisXtDiagnoseConfig
  17654. // for _, item := range diagnosis_ids {
  17655. // id, _ := strconv.ParseInt(item, 10, 64)
  17656. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  17657. // config = append(config, &diagnosisConfig)
  17658. // }
  17659. //
  17660. // for index, item := range config {
  17661. // if index == 0 {
  17662. // var tempDiaginfo service.DiaginfoStructTwo
  17663. // tempDiaginfo.DiagCode = item.CountryCode
  17664. // tempDiaginfo.DiagName = item.CountryContentName
  17665. // tempDiaginfo.DiagType = "1"
  17666. // tempDiaginfo.MaindiagFlag = "1"
  17667. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17668. // } else {
  17669. // var tempDiaginfo service.DiaginfoStructTwo
  17670. // tempDiaginfo.DiagCode = item.CountryCode
  17671. // tempDiaginfo.DiagName = item.CountryContentName
  17672. // tempDiaginfo.DiagType = "1"
  17673. // tempDiaginfo.MaindiagFlag = "0"
  17674. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17675. // }
  17676. // }
  17677. // struct4101.Diseinfo = tempDiaginfos
  17678. //
  17679. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  17680. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17681. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17682. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17683. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17684. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17685. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17686. //
  17687. // var iteminfo service.IteminfoStruct
  17688. //
  17689. // var bedCostTotal float64 = 0 //床位总费
  17690. // var bedCostSelfTotal float64 = 0 //床位自费
  17691. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17692. //
  17693. // var operationCostTotal float64 = 0 //手术费
  17694. // var operationCostSelfTotal float64 = 0 //手术费
  17695. // var operationCostPartSelfTotal float64 = 0 //手术费
  17696. //
  17697. // var otherCostTotal float64 = 0 //其他费用
  17698. // var otherCostSelfTotal float64 = 0 //其他费用
  17699. // var otherCostPartSelfTotal float64 = 0 //其他费用
  17700. //
  17701. // var materialCostTotal float64 = 0 //材料费
  17702. // var materialCostSelfTotal float64 = 0 //材料费
  17703. // var materialCostPartSelfTotal float64 = 0 //材料费
  17704. //
  17705. // var westernMedicineCostTotal float64 = 0 //西药费
  17706. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  17707. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17708. //
  17709. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17710. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17711. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17712. //
  17713. // var checkCostTotal float64 = 0 //检查费
  17714. // var checkCostSelfTotal float64 = 0 //检查费
  17715. // var checkCostPartSelfTotal float64 = 0 //检查费
  17716. //
  17717. // var laboratoryCostTotal float64 = 0 //化验费
  17718. // var laboratoryCostSelfTotal float64 = 0 //化验费
  17719. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17720. //
  17721. // var treatCostTotal float64 = 0 //治疗费用
  17722. // var treatCostSelfTotal float64 = 0 //治疗费用
  17723. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  17724. //
  17725. // decimal.DivisionPrecision = 2
  17726. //
  17727. // var bed_fulamt_ownpay_amt float64 = 0
  17728. // var operation_fulamt_ownpay_amt float64 = 0
  17729. // var other_fulamt_ownpay_amt float64 = 0
  17730. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  17731. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17732. // var check_fulamt_ownpay_amt float64 = 0
  17733. // var material_fulamt_ownpay_amt float64 = 0
  17734. // var laboratory_fulamt_ownpay_amt float64 = 0
  17735. // var treat_fulamt_ownpay_amt float64 = 0
  17736. //
  17737. // var bed_claa_sunmfee float64 = 0
  17738. // var bed_clab_amt float64 = 0
  17739. // var bed_other_amt float64 = 0
  17740. //
  17741. // var operation_claa_sunmfee float64 = 0
  17742. // var operation_clab_amt float64 = 0
  17743. // var operation_other_amt float64 = 0
  17744. //
  17745. // var other_claa_sunmfee float64 = 0
  17746. // var other_clab_amt float64 = 0
  17747. // var other_other_amt float64 = 0
  17748. //
  17749. // var westernMedicine_claa_sunmfee float64 = 0
  17750. // var westernMedicine_clab_amt float64 = 0
  17751. // var westernMedicine_other_amt float64 = 0
  17752. //
  17753. // var chineseTraditional_claa_sunmfee float64 = 0
  17754. // var chineseTraditional_clab_amt float64 = 0
  17755. // var chineseTraditional_other_amt float64 = 0
  17756. //
  17757. // var check_claa_sunmfee float64 = 0
  17758. // var check_clab_amt float64 = 0
  17759. // var check_other_amt float64 = 0
  17760. //
  17761. // var material_claa_sunmfee float64 = 0
  17762. // var material_clab_amt float64 = 0
  17763. // var material_other_amt float64 = 0
  17764. //
  17765. // var laboratory_claa_sunmfee float64 = 0
  17766. // var laboratory_clab_amt float64 = 0
  17767. // var laboratory_other_amt float64 = 0
  17768. //
  17769. // var treat_claa_sunmfee float64 = 0
  17770. // var treat_clab_amt float64 = 0
  17771. // var treat_other_amt float64 = 0
  17772. //
  17773. // for _, item := range order.HisOrderInfo {
  17774. // if item.MedChrgitmType == "01" { //床位费
  17775. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17776. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17777. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17778. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17779. // if item.ChrgitmLv == "1" {
  17780. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17781. // }
  17782. // if item.ChrgitmLv == "2" {
  17783. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17784. //
  17785. // }
  17786. // if item.ChrgitmLv == "3" {
  17787. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17788. // }
  17789. //
  17790. // }
  17791. //
  17792. // if item.MedChrgitmType == "03" { //检查费
  17793. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17794. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17795. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17796. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17797. // if item.ChrgitmLv == "1" {
  17798. //
  17799. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17800. //
  17801. // }
  17802. // if item.ChrgitmLv == "2" {
  17803. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17804. //
  17805. // }
  17806. // if item.ChrgitmLv == "3" {
  17807. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17808. // }
  17809. // }
  17810. //
  17811. // if item.MedChrgitmType == "04" { //化验费
  17812. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17813. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17814. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17815. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17816. // if item.ChrgitmLv == "1" {
  17817. //
  17818. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17819. //
  17820. // }
  17821. // if item.ChrgitmLv == "2" {
  17822. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17823. //
  17824. // }
  17825. // if item.ChrgitmLv == "3" {
  17826. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17827. // }
  17828. // }
  17829. //
  17830. // if item.MedChrgitmType == "05" { //治疗费
  17831. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17832. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17833. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17834. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17835. // if item.ChrgitmLv == "1" {
  17836. //
  17837. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17838. //
  17839. // }
  17840. // if item.ChrgitmLv == "2" {
  17841. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17842. //
  17843. // }
  17844. // if item.ChrgitmLv == "3" {
  17845. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17846. // }
  17847. // }
  17848. //
  17849. // if item.MedChrgitmType == "06" { //手术费
  17850. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17851. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17852. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17853. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17854. //
  17855. // if item.ChrgitmLv == "1" {
  17856. //
  17857. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17858. //
  17859. // }
  17860. // if item.ChrgitmLv == "2" {
  17861. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17862. //
  17863. // }
  17864. // if item.ChrgitmLv == "3" {
  17865. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17866. // }
  17867. // }
  17868. //
  17869. // if item.MedChrgitmType == "08" { //材料费
  17870. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17871. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17872. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17873. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17874. // if item.ChrgitmLv == "1" {
  17875. //
  17876. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17877. //
  17878. // }
  17879. // if item.ChrgitmLv == "2" {
  17880. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17881. //
  17882. // }
  17883. // if item.ChrgitmLv == "3" {
  17884. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17885. // }
  17886. // }
  17887. //
  17888. // if item.MedChrgitmType == "09" { //西药费
  17889. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17890. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17891. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17892. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17893. // if item.ChrgitmLv == "1" {
  17894. //
  17895. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17896. //
  17897. // }
  17898. // if item.ChrgitmLv == "2" {
  17899. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17900. //
  17901. // }
  17902. // if item.ChrgitmLv == "3" {
  17903. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17904. // }
  17905. // }
  17906. //
  17907. // if item.MedChrgitmType == "11" { //中成费
  17908. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17909. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17910. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17911. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17912. // if item.ChrgitmLv == "1" {
  17913. //
  17914. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17915. //
  17916. // }
  17917. // if item.ChrgitmLv == "2" {
  17918. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17919. //
  17920. // }
  17921. // if item.ChrgitmLv == "3" {
  17922. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17923. // }
  17924. // }
  17925. //
  17926. // if item.MedChrgitmType == "14" { //其他费
  17927. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17928. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17929. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17930. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17931. // if item.ChrgitmLv == "1" {
  17932. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17933. //
  17934. // }
  17935. // if item.ChrgitmLv == "2" {
  17936. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17937. //
  17938. // }
  17939. // if item.ChrgitmLv == "3" {
  17940. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17941. // }
  17942. // }
  17943. //
  17944. // }
  17945. //
  17946. // var iteminfoStructs []service.IteminfoStruct
  17947. //
  17948. // if bedCostTotal != 0 {
  17949. // iteminfo.MedChrgitm = "01"
  17950. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17951. // iteminfo.Amt = bedCostTotal
  17952. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  17953. // iteminfo.ClabAmt = bed_clab_amt
  17954. // iteminfo.OthAmt = bed_other_amt
  17955. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17956. // }
  17957. //
  17958. // if checkCostTotal != 0 {
  17959. // iteminfo.MedChrgitm = "03"
  17960. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  17961. // iteminfo.Amt = checkCostTotal
  17962. // iteminfo.ClaaSumfee = check_claa_sunmfee
  17963. // iteminfo.ClabAmt = check_clab_amt
  17964. // iteminfo.OthAmt = check_other_amt
  17965. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17966. //
  17967. // }
  17968. //
  17969. // if laboratoryCostTotal != 0 {
  17970. // iteminfo.MedChrgitm = "04"
  17971. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  17972. // iteminfo.Amt = laboratoryCostTotal
  17973. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  17974. // iteminfo.ClabAmt = laboratory_clab_amt
  17975. // iteminfo.OthAmt = laboratory_other_amt
  17976. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17977. //
  17978. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17979. //
  17980. // }
  17981. //
  17982. // if treatCostTotal != 0 {
  17983. // iteminfo.MedChrgitm = "05"
  17984. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  17985. // iteminfo.Amt = treatCostTotal
  17986. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  17987. // iteminfo.ClabAmt = treat_clab_amt
  17988. // iteminfo.OthAmt = treat_other_amt
  17989. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17990. // //(struct4101.IteminfoStruct, iteminfo)
  17991. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17992. // }
  17993. //
  17994. // if operationCostTotal != 0 {
  17995. // iteminfo.MedChrgitm = "06"
  17996. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17997. // iteminfo.Amt = operationCostTotal
  17998. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  17999. // iteminfo.ClabAmt = operation_clab_amt
  18000. // iteminfo.OthAmt = operation_other_amt
  18001. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18002. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18003. // }
  18004. //
  18005. // if materialCostTotal != 0 {
  18006. // iteminfo.MedChrgitm = "08"
  18007. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18008. // iteminfo.Amt = materialCostTotal
  18009. // iteminfo.ClaaSumfee = material_claa_sunmfee
  18010. // iteminfo.ClabAmt = material_clab_amt
  18011. // iteminfo.OthAmt = material_other_amt
  18012. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18013. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18014. // }
  18015. //
  18016. // if westernMedicineCostTotal != 0 {
  18017. // iteminfo.MedChrgitm = "09"
  18018. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18019. // iteminfo.Amt = westernMedicineCostTotal
  18020. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18021. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18022. // iteminfo.OthAmt = westernMedicine_other_amt
  18023. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18024. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18025. //
  18026. // }
  18027. // if chineseTraditionalMedicineCostTotal != 0 {
  18028. // iteminfo.MedChrgitm = "11"
  18029. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18030. // iteminfo.Amt = westernMedicineCostTotal
  18031. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18032. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18033. // iteminfo.OthAmt = westernMedicine_other_amt
  18034. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18035. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18036. //
  18037. // }
  18038. // if otherCostTotal != 0 {
  18039. // iteminfo.MedChrgitm = "14"
  18040. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18041. // iteminfo.Amt = otherCostTotal
  18042. // iteminfo.ClaaSumfee = other_claa_sunmfee
  18043. // iteminfo.ClabAmt = other_clab_amt
  18044. // iteminfo.OthAmt = other_other_amt
  18045. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18046. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18047. //
  18048. // }
  18049. // struct4101.IteminfoStruct = iteminfoStructs
  18050. // struct4101.Ntly = "中国"
  18051. // struct4101.AdmCaty = "A03.06"
  18052. //
  18053. // struct4101.DoctorName = doctor.UserName
  18054. // struct4101.DoctorCode = doctor.DoctorNumber
  18055. //
  18056. // var res ResultSeventeen
  18057. //
  18058. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18059. // struct4101.BillCode = order.Number
  18060. // struct4101.BillNo = order.SetlId
  18061. // var resOther ResultSeventeenOther
  18062. // var pp models.PublicParams
  18063. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18064. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18065. // pp.FixmedinsName = miConfig.OrgName
  18066. // pp.FixmedinsCode = miConfig.Code
  18067. // pp.RequestUrl = miConfig.Url
  18068. // pp.Cainfo = miConfig.Cainfo
  18069. // pp.SecretKey = miConfig.SecretKey
  18070. // pp.AccessKey = miConfig.AccessKey
  18071. // pp.OpterName = curRoles.UserName
  18072. //
  18073. // client := &http.Client{}
  18074. // var req *http.Request
  18075. // data := make(map[string]interface{})
  18076. // data["struct4101"] = struct4101
  18077. // data["pp"] = pp
  18078. // bytesData, _ := json.Marshal(data)
  18079. // if miConfig.MdtrtareaAdmvs == "320921" {
  18080. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18081. // } else {
  18082. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18083. // }
  18084. // resp, _ := client.Do(req)
  18085. // defer resp.Body.Close()
  18086. // body, ioErr := ioutil.ReadAll(resp.Body)
  18087. // if ioErr != nil {
  18088. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18090. // return
  18091. // }
  18092. // var respJSON map[string]interface{}
  18093. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18094. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18095. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18096. // return
  18097. // }
  18098. //
  18099. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18100. // userJSONBytes, _ := json.Marshal(respJSON)
  18101. // fmt.Println("log")
  18102. // fmt.Println(string(userJSONBytes))
  18103. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18104. // utils.ErrorLog("解析失败:%v", err)
  18105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18106. // return
  18107. // }
  18108. // res.InfRefmsgid = resOther.InfRefmsgid
  18109. // res.Output = resOther.Output
  18110. // res.ErrMsg = resOther.ErrMsg
  18111. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18112. // res.Infcode = infocode
  18113. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  18114. //
  18115. // var pp models.PublicParams
  18116. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18117. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18118. // pp.FixmedinsName = miConfig.OrgName
  18119. // pp.FixmedinsCode = miConfig.Code
  18120. // pp.RequestUrl = miConfig.Url
  18121. // pp.Cainfo = miConfig.Cainfo
  18122. // pp.SecretKey = miConfig.SecretKey
  18123. // pp.AccessKey = miConfig.AccessKey
  18124. // pp.OpterName = curRoles.UserName
  18125. // result, _ := service.Jxyb4101(struct4101, pp)
  18126. // var dat map[string]interface{}
  18127. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18128. // fmt.Println(dat)
  18129. // } else {
  18130. // fmt.Println(err)
  18131. // }
  18132. // userJSONBytes, _ := json.Marshal(dat)
  18133. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18134. // utils.ErrorLog("解析失败:%v", err)
  18135. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18136. // return
  18137. // }
  18138. //
  18139. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  18140. // var pp models.PublicParams
  18141. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18142. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18143. // pp.FixmedinsName = miConfig.OrgName
  18144. // pp.FixmedinsCode = miConfig.Code
  18145. // pp.RequestUrl = miConfig.Url
  18146. // pp.Cainfo = miConfig.Cainfo
  18147. // pp.SecretKey = miConfig.SecretKey
  18148. // pp.AccessKey = miConfig.AccessKey
  18149. // pp.OpterName = curRoles.UserName
  18150. // result, _ := service.Hnyb4101(struct4101, pp)
  18151. // var dat map[string]interface{}
  18152. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18153. // fmt.Println(dat)
  18154. // } else {
  18155. // fmt.Println(err)
  18156. // }
  18157. // userJSONBytes, _ := json.Marshal(dat)
  18158. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18159. // utils.ErrorLog("解析失败:%v", err)
  18160. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18161. // return
  18162. // }
  18163. //
  18164. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  18165. // var resOther ResultSeventeenOther
  18166. //
  18167. // var pp models.PublicParams
  18168. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18169. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18170. // pp.FixmedinsName = miConfig.OrgName
  18171. // pp.FixmedinsCode = miConfig.Code
  18172. // pp.RequestUrl = miConfig.Url
  18173. // pp.Cainfo = miConfig.Cainfo
  18174. // pp.SecretKey = miConfig.SecretKey
  18175. // pp.AccessKey = miConfig.AccessKey
  18176. // pp.OpterName = curRoles.UserName
  18177. // client := &http.Client{}
  18178. // var req *http.Request
  18179. // data := make(map[string]interface{})
  18180. // data["struct4101"] = struct4101
  18181. // data["pp"] = pp
  18182. // bytesData, _ := json.Marshal(data)
  18183. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18184. // resp, _ := client.Do(req)
  18185. // defer resp.Body.Close()
  18186. // body, ioErr := ioutil.ReadAll(resp.Body)
  18187. // if ioErr != nil {
  18188. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18189. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18190. // return
  18191. // }
  18192. // var respJSON map[string]interface{}
  18193. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18194. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18196. // return
  18197. // }
  18198. //
  18199. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18200. // userJSONBytes, _ := json.Marshal(respJSON)
  18201. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18202. // utils.ErrorLog("解析失败:%v", err)
  18203. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18204. // return
  18205. // }
  18206. // res.InfRefmsgid = resOther.InfRefmsgid
  18207. // res.Output = resOther.Output
  18208. // res.ErrMsg = resOther.ErrMsg
  18209. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18210. // res.Infcode = infocode
  18211. //
  18212. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  18213. // var pp models.PublicParams
  18214. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18215. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18216. // pp.FixmedinsName = miConfig.OrgName
  18217. // pp.FixmedinsCode = miConfig.Code
  18218. // pp.RequestUrl = miConfig.Url
  18219. // pp.Cainfo = miConfig.Cainfo
  18220. // pp.SecretKey = miConfig.SecretKey
  18221. // pp.AccessKey = miConfig.AccessKey
  18222. // pp.OpterName = curRoles.UserName
  18223. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18224. // fmt.Println(requestLog)
  18225. // fmt.Println(errMsgLog)
  18226. //
  18227. // saveLog(result, requestLog, "4101a", "上传清单")
  18228. //
  18229. // var dat map[string]interface{}
  18230. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18231. // fmt.Println(dat)
  18232. // } else {
  18233. // fmt.Println(err)
  18234. // }
  18235. // userJSONBytes, _ := json.Marshal(dat)
  18236. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18237. // utils.ErrorLog("解析失败:%v", err)
  18238. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18239. // return
  18240. // }
  18241. //
  18242. // } else {
  18243. //
  18244. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  18245. // var dat map[string]interface{}
  18246. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18247. // fmt.Println(dat)
  18248. // } else {
  18249. // fmt.Println(err)
  18250. // }
  18251. // userJSONBytes, _ := json.Marshal(dat)
  18252. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18253. // utils.ErrorLog("解析失败:%v", err)
  18254. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18255. // return
  18256. // }
  18257. // }
  18258. //
  18259. // if res.Infcode != 0 {
  18260. // adminUser := c.GetAdminUserInfo()
  18261. // errlog := &models.HisOrderError{
  18262. // UserOrgId: adminUser.CurrentOrgId,
  18263. // Ctime: time.Now().Unix(),
  18264. // Mtime: time.Now().Unix(),
  18265. // ErrMsg: res.ErrMsg,
  18266. // Status: 1,
  18267. // PatientId: order.ID,
  18268. // Stage: 10265,
  18269. // }
  18270. // service.CreateErrMsgLog(errlog)
  18271. // continue
  18272. // } else {
  18273. // //order.FaPiaoNumber = zero
  18274. // //order.FaPiaoCode = last_order.FaPiaoCode
  18275. // //service.UpdateOrder(order)
  18276. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18277. // Number: res.Output.SetlListId,
  18278. // Status: 1,
  18279. // Ctime: time.Now().Unix(),
  18280. // Mtime: time.Now().Unix(),
  18281. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18282. // IsUpload: 1,
  18283. // OrderId: order.ID,
  18284. // }
  18285. // service.CreateUploadRecord(hisFundSettleListResult)
  18286. // c.ServeSuccessJSON(map[string]interface{}{
  18287. // "msg": "上传成功",
  18288. // "result": hisFundSettleListResult,
  18289. // })
  18290. // continue
  18291. // }
  18292. // }
  18293. //}
  18294. func (c *HisApiController) GetbatchSettleList() {
  18295. //order_id, _ := c.GetInt64("order_id")
  18296. admin_user_id, _ := c.GetInt64("admin_user_id")
  18297. orders, _ := service.GetAllHisOrderTwo10485()
  18298. for _, item := range orders {
  18299. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18300. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18301. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18302. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18303. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18304. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18305. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18306. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18307. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18308. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18309. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18310. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18311. //fmt.Println(count)
  18312. //var zero string
  18313. //number := count + 1
  18314. //if number >= 1000 {
  18315. // zero = "0000" + strconv.FormatInt(number, 10)
  18316. //} else if number >= 10000 {
  18317. // zero = "000" + strconv.FormatInt(number, 10)
  18318. //} else if number >= 100000 {
  18319. // zero = "00" + strconv.FormatInt(number, 10)
  18320. //} else if number >= 1000000 {
  18321. // zero = "0" + strconv.FormatInt(number, 10)
  18322. //} else {
  18323. // zero = strconv.FormatInt(number, 10)
  18324. //}
  18325. //fmt.Println(zero)
  18326. struct4101 := service.Struct4101{
  18327. PsnNo: order.PsnNo,
  18328. MdtrtId: order.MdtrtId,
  18329. SetlId: order.SetlId,
  18330. PsnName: order.PsnName,
  18331. Gend: order.Gend,
  18332. Brdy: his.Brdy,
  18333. Age: his.Age,
  18334. Naty: order.Naty,
  18335. PatnCertType: "01",
  18336. Certno: order.Certno,
  18337. Prfs: "90",
  18338. ConerName: roles[0].UserName,
  18339. PatnRlts: "99",
  18340. ConerAddr: miConfig.OrgName,
  18341. ConerTel: admin.Mobile,
  18342. HiType: order.Insutype,
  18343. Insuplc: miConfig.InsuplcAdmdvs,
  18344. MaindiagFlag: "1",
  18345. BillCode: order.SetlId,
  18346. BillNo: order.SetlId,
  18347. BizSn: order.Number,
  18348. PsnSelfPay: order.PsnPartAmt,
  18349. PsnOwnPay: order.PsnPartAmt,
  18350. AcctPay: order.AcctPay,
  18351. PsnCashpay: order.PsnCashPay,
  18352. HiPaymtd: "1",
  18353. Hsorg: miConfig.InsuplcAdmdvs,
  18354. HsorgOpter: miConfig.InsuplcAdmdvs,
  18355. MedinsFillPsn: curRoles.UserName,
  18356. MedinsFillDept: miConfig.OrgName,
  18357. IptMedType: "2",
  18358. }
  18359. struct4101.SetlBegnDate = order.SetlTime
  18360. struct4101.SetlEndDate = order.SetlTime
  18361. time_arr := strings.Split(order.SetlTime, " ")
  18362. struct4101.AdmTime = time_arr[0]
  18363. struct4101.AdmEndTime = time_arr[0]
  18364. //var rf []CustomFundPay
  18365. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18366. //
  18367. //var tempFunPays []service.CustomStruct
  18368. //for _, item := range rf {
  18369. // var tempFunPay service.CustomStruct
  18370. // tempFunPay.FundPayamt = item.FundPayamt
  18371. // tempFunPay.FundPayType = item.FundPayType
  18372. // tempFunPays = append(tempFunPays, tempFunPay)
  18373. //}
  18374. //struct4101.CustomStruct = tempFunPays
  18375. var tempDiaginfos []service.DiaginfoStructTwo
  18376. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18377. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18378. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18379. var config []*models.HisXtDiagnoseConfig
  18380. for _, item := range diagnosis_ids {
  18381. id, _ := strconv.ParseInt(item, 10, 64)
  18382. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18383. config = append(config, &diagnosisConfig)
  18384. }
  18385. for index, item := range config {
  18386. if index == 0 {
  18387. var tempDiaginfo service.DiaginfoStructTwo
  18388. tempDiaginfo.DiagCode = item.CountryCode
  18389. tempDiaginfo.DiagName = item.CountryContentName
  18390. tempDiaginfo.DiagType = "1"
  18391. tempDiaginfo.MaindiagFlag = "1"
  18392. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18393. } else {
  18394. var tempDiaginfo service.DiaginfoStructTwo
  18395. tempDiaginfo.DiagCode = item.CountryCode
  18396. tempDiaginfo.DiagName = item.CountryContentName
  18397. tempDiaginfo.DiagType = "1"
  18398. tempDiaginfo.MaindiagFlag = "0"
  18399. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18400. }
  18401. }
  18402. struct4101.Diseinfo = tempDiaginfos
  18403. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18404. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18405. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18406. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18407. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18408. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18409. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18410. var iteminfo service.IteminfoStruct
  18411. var bedCostTotal float64 = 0 //床位总费
  18412. var bedCostSelfTotal float64 = 0 //床位自费
  18413. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18414. var operationCostTotal float64 = 0 //手术费
  18415. var operationCostSelfTotal float64 = 0 //手术费
  18416. var operationCostPartSelfTotal float64 = 0 //手术费
  18417. var otherCostTotal float64 = 0 //其他费用
  18418. var otherCostSelfTotal float64 = 0 //其他费用
  18419. var otherCostPartSelfTotal float64 = 0 //其他费用
  18420. var materialCostTotal float64 = 0 //材料费
  18421. var materialCostSelfTotal float64 = 0 //材料费
  18422. var materialCostPartSelfTotal float64 = 0 //材料费
  18423. var westernMedicineCostTotal float64 = 0 //西药费
  18424. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18425. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18426. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18427. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18428. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18429. var checkCostTotal float64 = 0 //检查费
  18430. var checkCostSelfTotal float64 = 0 //检查费
  18431. var checkCostPartSelfTotal float64 = 0 //检查费
  18432. var laboratoryCostTotal float64 = 0 //化验费
  18433. var laboratoryCostSelfTotal float64 = 0 //化验费
  18434. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18435. var treatCostTotal float64 = 0 //治疗费用
  18436. var treatCostSelfTotal float64 = 0 //治疗费用
  18437. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18438. decimal.DivisionPrecision = 2
  18439. var bed_fulamt_ownpay_amt float64 = 0
  18440. var operation_fulamt_ownpay_amt float64 = 0
  18441. var other_fulamt_ownpay_amt float64 = 0
  18442. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18443. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18444. var check_fulamt_ownpay_amt float64 = 0
  18445. var material_fulamt_ownpay_amt float64 = 0
  18446. var laboratory_fulamt_ownpay_amt float64 = 0
  18447. var treat_fulamt_ownpay_amt float64 = 0
  18448. var bed_claa_sunmfee float64 = 0
  18449. var bed_clab_amt float64 = 0
  18450. var bed_other_amt float64 = 0
  18451. var operation_claa_sunmfee float64 = 0
  18452. var operation_clab_amt float64 = 0
  18453. var operation_other_amt float64 = 0
  18454. var other_claa_sunmfee float64 = 0
  18455. var other_clab_amt float64 = 0
  18456. var other_other_amt float64 = 0
  18457. var westernMedicine_claa_sunmfee float64 = 0
  18458. var westernMedicine_clab_amt float64 = 0
  18459. var westernMedicine_other_amt float64 = 0
  18460. var chineseTraditional_claa_sunmfee float64 = 0
  18461. var chineseTraditional_clab_amt float64 = 0
  18462. var chineseTraditional_other_amt float64 = 0
  18463. var check_claa_sunmfee float64 = 0
  18464. var check_clab_amt float64 = 0
  18465. var check_other_amt float64 = 0
  18466. var material_claa_sunmfee float64 = 0
  18467. var material_clab_amt float64 = 0
  18468. var material_other_amt float64 = 0
  18469. var laboratory_claa_sunmfee float64 = 0
  18470. var laboratory_clab_amt float64 = 0
  18471. var laboratory_other_amt float64 = 0
  18472. var treat_claa_sunmfee float64 = 0
  18473. var treat_clab_amt float64 = 0
  18474. var treat_other_amt float64 = 0
  18475. for _, item := range order.HisOrderInfo {
  18476. if item.MedChrgitmType == "01" { //床位费
  18477. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18478. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18479. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18480. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18481. if item.ChrgitmLv == "1" {
  18482. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18483. }
  18484. if item.ChrgitmLv == "2" {
  18485. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18486. }
  18487. if item.ChrgitmLv == "3" {
  18488. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18489. }
  18490. }
  18491. if item.MedChrgitmType == "03" { //检查费
  18492. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18493. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18494. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18495. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18496. if item.ChrgitmLv == "1" {
  18497. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18498. }
  18499. if item.ChrgitmLv == "2" {
  18500. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18501. }
  18502. if item.ChrgitmLv == "3" {
  18503. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18504. }
  18505. }
  18506. if item.MedChrgitmType == "04" { //化验费
  18507. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18508. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18509. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18510. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18511. if item.ChrgitmLv == "1" {
  18512. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18513. }
  18514. if item.ChrgitmLv == "2" {
  18515. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18516. }
  18517. if item.ChrgitmLv == "3" {
  18518. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18519. }
  18520. }
  18521. if item.MedChrgitmType == "05" { //治疗费
  18522. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18523. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18524. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18525. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18526. if item.ChrgitmLv == "1" {
  18527. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18528. }
  18529. if item.ChrgitmLv == "2" {
  18530. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18531. }
  18532. if item.ChrgitmLv == "3" {
  18533. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18534. }
  18535. }
  18536. if item.MedChrgitmType == "06" { //手术费
  18537. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18538. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18539. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18540. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18541. if item.ChrgitmLv == "1" {
  18542. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18543. }
  18544. if item.ChrgitmLv == "2" {
  18545. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18546. }
  18547. if item.ChrgitmLv == "3" {
  18548. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18549. }
  18550. }
  18551. if item.MedChrgitmType == "08" { //材料费
  18552. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18553. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18554. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18555. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18556. if item.ChrgitmLv == "1" {
  18557. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18558. }
  18559. if item.ChrgitmLv == "2" {
  18560. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18561. }
  18562. if item.ChrgitmLv == "3" {
  18563. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18564. }
  18565. }
  18566. if item.MedChrgitmType == "09" { //西药费
  18567. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18568. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18569. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18570. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18571. if item.ChrgitmLv == "1" {
  18572. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18573. }
  18574. if item.ChrgitmLv == "2" {
  18575. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18576. }
  18577. if item.ChrgitmLv == "3" {
  18578. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18579. }
  18580. }
  18581. if item.MedChrgitmType == "11" { //中成费
  18582. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18583. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18584. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18585. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18586. if item.ChrgitmLv == "1" {
  18587. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18588. }
  18589. if item.ChrgitmLv == "2" {
  18590. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18591. }
  18592. if item.ChrgitmLv == "3" {
  18593. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18594. }
  18595. }
  18596. if item.MedChrgitmType == "14" { //其他费
  18597. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18598. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18599. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18600. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18601. if item.ChrgitmLv == "1" {
  18602. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18603. }
  18604. if item.ChrgitmLv == "2" {
  18605. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18606. }
  18607. if item.ChrgitmLv == "3" {
  18608. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18609. }
  18610. }
  18611. }
  18612. var iteminfoStructs []service.IteminfoStruct
  18613. if bedCostTotal != 0 {
  18614. iteminfo.MedChrgitm = "01"
  18615. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18616. iteminfo.Amt = bedCostTotal
  18617. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18618. iteminfo.ClabAmt = bed_clab_amt
  18619. iteminfo.OthAmt = bed_other_amt
  18620. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18621. }
  18622. if checkCostTotal != 0 {
  18623. iteminfo.MedChrgitm = "03"
  18624. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18625. iteminfo.Amt = checkCostTotal
  18626. iteminfo.ClaaSumfee = check_claa_sunmfee
  18627. iteminfo.ClabAmt = check_clab_amt
  18628. iteminfo.OthAmt = check_other_amt
  18629. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18630. }
  18631. if laboratoryCostTotal != 0 {
  18632. iteminfo.MedChrgitm = "04"
  18633. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18634. iteminfo.Amt = laboratoryCostTotal
  18635. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18636. iteminfo.ClabAmt = laboratory_clab_amt
  18637. iteminfo.OthAmt = laboratory_other_amt
  18638. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18639. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18640. }
  18641. if treatCostTotal != 0 {
  18642. iteminfo.MedChrgitm = "05"
  18643. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18644. iteminfo.Amt = treatCostTotal
  18645. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18646. iteminfo.ClabAmt = treat_clab_amt
  18647. iteminfo.OthAmt = treat_other_amt
  18648. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18649. //(struct4101.IteminfoStruct, iteminfo)
  18650. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18651. }
  18652. if operationCostTotal != 0 {
  18653. iteminfo.MedChrgitm = "06"
  18654. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18655. iteminfo.Amt = operationCostTotal
  18656. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18657. iteminfo.ClabAmt = operation_clab_amt
  18658. iteminfo.OthAmt = operation_other_amt
  18659. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18660. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18661. }
  18662. if materialCostTotal != 0 {
  18663. iteminfo.MedChrgitm = "08"
  18664. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18665. iteminfo.Amt = materialCostTotal
  18666. iteminfo.ClaaSumfee = material_claa_sunmfee
  18667. iteminfo.ClabAmt = material_clab_amt
  18668. iteminfo.OthAmt = material_other_amt
  18669. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18670. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18671. }
  18672. if westernMedicineCostTotal != 0 {
  18673. iteminfo.MedChrgitm = "09"
  18674. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18675. iteminfo.Amt = westernMedicineCostTotal
  18676. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18677. iteminfo.ClabAmt = westernMedicine_clab_amt
  18678. iteminfo.OthAmt = westernMedicine_other_amt
  18679. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18680. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18681. }
  18682. if chineseTraditionalMedicineCostTotal != 0 {
  18683. iteminfo.MedChrgitm = "11"
  18684. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18685. iteminfo.Amt = westernMedicineCostTotal
  18686. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18687. iteminfo.ClabAmt = westernMedicine_clab_amt
  18688. iteminfo.OthAmt = westernMedicine_other_amt
  18689. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18690. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18691. }
  18692. if otherCostTotal != 0 {
  18693. iteminfo.MedChrgitm = "14"
  18694. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18695. iteminfo.Amt = otherCostTotal
  18696. iteminfo.ClaaSumfee = other_claa_sunmfee
  18697. iteminfo.ClabAmt = other_clab_amt
  18698. iteminfo.OthAmt = other_other_amt
  18699. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18700. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18701. }
  18702. struct4101.IteminfoStruct = iteminfoStructs
  18703. struct4101.Ntly = "中国"
  18704. struct4101.AdmCaty = "A03.06"
  18705. struct4101.DoctorName = doctor.UserName
  18706. struct4101.DoctorCode = doctor.DoctorNumber
  18707. var res ResultSeventeen
  18708. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18709. struct4101.BillCode = order.Number
  18710. struct4101.BillNo = order.SetlId
  18711. var resOther ResultSeventeenOther
  18712. var pp models.PublicParams
  18713. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18714. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18715. pp.FixmedinsName = miConfig.OrgName
  18716. pp.FixmedinsCode = miConfig.Code
  18717. pp.RequestUrl = miConfig.Url
  18718. pp.Cainfo = miConfig.Cainfo
  18719. pp.SecretKey = miConfig.SecretKey
  18720. pp.AccessKey = miConfig.AccessKey
  18721. pp.OpterName = curRoles.UserName
  18722. client := &http.Client{}
  18723. var req *http.Request
  18724. data := make(map[string]interface{})
  18725. data["struct4101"] = struct4101
  18726. data["pp"] = pp
  18727. bytesData, _ := json.Marshal(data)
  18728. if miConfig.MdtrtareaAdmvs == "320921" {
  18729. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18730. } else {
  18731. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18732. }
  18733. resp, _ := client.Do(req)
  18734. defer resp.Body.Close()
  18735. body, ioErr := ioutil.ReadAll(resp.Body)
  18736. if ioErr != nil {
  18737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18739. return
  18740. }
  18741. var respJSON map[string]interface{}
  18742. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18745. return
  18746. }
  18747. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18748. userJSONBytes, _ := json.Marshal(respJSON)
  18749. fmt.Println("log")
  18750. fmt.Println(string(userJSONBytes))
  18751. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18752. utils.ErrorLog("解析失败:%v", err)
  18753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18754. return
  18755. }
  18756. res.InfRefmsgid = resOther.InfRefmsgid
  18757. res.Output = resOther.Output
  18758. res.ErrMsg = resOther.ErrMsg
  18759. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18760. res.Infcode = infocode
  18761. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18762. var pp models.PublicParams
  18763. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18764. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18765. pp.FixmedinsName = miConfig.OrgName
  18766. pp.FixmedinsCode = miConfig.Code
  18767. pp.RequestUrl = miConfig.Url
  18768. pp.Cainfo = miConfig.Cainfo
  18769. pp.SecretKey = miConfig.SecretKey
  18770. pp.AccessKey = miConfig.AccessKey
  18771. pp.OpterName = curRoles.UserName
  18772. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18773. result, _ := service.Jxyb4101(struct4101, pp)
  18774. var dat map[string]interface{}
  18775. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18776. fmt.Println(dat)
  18777. } else {
  18778. fmt.Println(err)
  18779. }
  18780. userJSONBytes, _ := json.Marshal(dat)
  18781. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18782. utils.ErrorLog("解析失败:%v", err)
  18783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18784. return
  18785. }
  18786. } else if miConfig.MdtrtareaAdmvs == "361025" {
  18787. var pp models.PublicParams
  18788. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18789. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18790. pp.FixmedinsName = miConfig.OrgName
  18791. pp.FixmedinsCode = miConfig.Code
  18792. pp.RequestUrl = miConfig.Url
  18793. pp.Cainfo = miConfig.Cainfo
  18794. pp.SecretKey = miConfig.SecretKey
  18795. pp.AccessKey = miConfig.AccessKey
  18796. pp.OpterName = curRoles.UserName
  18797. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18798. result, _ := service.Jxyb4101(struct4101, pp)
  18799. var dat map[string]interface{}
  18800. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18801. fmt.Println(dat)
  18802. } else {
  18803. fmt.Println(err)
  18804. }
  18805. userJSONBytes, _ := json.Marshal(dat)
  18806. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18807. utils.ErrorLog("解析失败:%v", err)
  18808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18809. return
  18810. }
  18811. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18812. var pp models.PublicParams
  18813. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18814. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18815. pp.FixmedinsName = miConfig.OrgName
  18816. pp.FixmedinsCode = miConfig.Code
  18817. pp.RequestUrl = miConfig.Url
  18818. pp.Cainfo = miConfig.Cainfo
  18819. pp.SecretKey = miConfig.SecretKey
  18820. pp.AccessKey = miConfig.AccessKey
  18821. pp.OpterName = curRoles.UserName
  18822. result, _ := service.Hnyb4101(struct4101, pp)
  18823. var dat map[string]interface{}
  18824. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18825. fmt.Println(dat)
  18826. } else {
  18827. fmt.Println(err)
  18828. }
  18829. userJSONBytes, _ := json.Marshal(dat)
  18830. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18831. utils.ErrorLog("解析失败:%v", err)
  18832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18833. return
  18834. }
  18835. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18836. var resOther ResultSeventeenOther
  18837. var pp models.PublicParams
  18838. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18839. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18840. pp.FixmedinsName = miConfig.OrgName
  18841. pp.FixmedinsCode = miConfig.Code
  18842. pp.RequestUrl = miConfig.Url
  18843. pp.Cainfo = miConfig.Cainfo
  18844. pp.SecretKey = miConfig.SecretKey
  18845. pp.AccessKey = miConfig.AccessKey
  18846. pp.OpterName = curRoles.UserName
  18847. client := &http.Client{}
  18848. var req *http.Request
  18849. data := make(map[string]interface{})
  18850. data["struct4101"] = struct4101
  18851. data["pp"] = pp
  18852. bytesData, _ := json.Marshal(data)
  18853. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18854. resp, _ := client.Do(req)
  18855. defer resp.Body.Close()
  18856. body, ioErr := ioutil.ReadAll(resp.Body)
  18857. if ioErr != nil {
  18858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18860. return
  18861. }
  18862. var respJSON map[string]interface{}
  18863. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18866. return
  18867. }
  18868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18869. userJSONBytes, _ := json.Marshal(respJSON)
  18870. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18871. utils.ErrorLog("解析失败:%v", err)
  18872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18873. return
  18874. }
  18875. res.InfRefmsgid = resOther.InfRefmsgid
  18876. res.Output = resOther.Output
  18877. res.ErrMsg = resOther.ErrMsg
  18878. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18879. res.Infcode = infocode
  18880. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18881. var pp models.PublicParams
  18882. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18883. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18884. pp.FixmedinsName = miConfig.OrgName
  18885. pp.FixmedinsCode = miConfig.Code
  18886. pp.RequestUrl = miConfig.Url
  18887. pp.Cainfo = miConfig.Cainfo
  18888. pp.SecretKey = miConfig.SecretKey
  18889. pp.AccessKey = miConfig.AccessKey
  18890. pp.OpterName = curRoles.UserName
  18891. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18892. fmt.Println(requestLog)
  18893. fmt.Println(errMsgLog)
  18894. saveLog(result, requestLog, "4101a", "上传清单")
  18895. var dat map[string]interface{}
  18896. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18897. fmt.Println(dat)
  18898. } else {
  18899. fmt.Println(err)
  18900. }
  18901. userJSONBytes, _ := json.Marshal(dat)
  18902. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18903. utils.ErrorLog("解析失败:%v", err)
  18904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18905. return
  18906. }
  18907. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18908. var pp models.PublicParams
  18909. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18910. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18911. pp.FixmedinsName = miConfig.OrgName
  18912. pp.FixmedinsCode = miConfig.Code
  18913. pp.RequestUrl = miConfig.Url
  18914. pp.Cainfo = miConfig.Cainfo
  18915. pp.SecretKey = miConfig.SecretKey
  18916. pp.AccessKey = miConfig.AccessKey
  18917. pp.OpterName = curRoles.UserName
  18918. client := &http.Client{}
  18919. var req *http.Request
  18920. data := make(map[string]interface{})
  18921. data["struct4101"] = struct4101
  18922. data["pp"] = pp
  18923. bytesData, _ := json.Marshal(data)
  18924. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  18925. resp, _ := client.Do(req)
  18926. defer resp.Body.Close()
  18927. body, ioErr := ioutil.ReadAll(resp.Body)
  18928. if ioErr != nil {
  18929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18931. return
  18932. }
  18933. var respJSON map[string]interface{}
  18934. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18937. return
  18938. }
  18939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18940. userJSONBytes, _ := json.Marshal(respJSON)
  18941. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18942. utils.ErrorLog("解析失败:%v", err)
  18943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18944. return
  18945. }
  18946. } else {
  18947. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  18948. var dat map[string]interface{}
  18949. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18950. fmt.Println(dat)
  18951. } else {
  18952. fmt.Println(err)
  18953. }
  18954. userJSONBytes, _ := json.Marshal(dat)
  18955. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18956. utils.ErrorLog("解析失败:%v", err)
  18957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18958. return
  18959. }
  18960. }
  18961. if res.Infcode != 0 {
  18962. errlog := &models.HisOrderError{
  18963. UserOrgId: order.UserOrgId,
  18964. Ctime: time.Now().Unix(),
  18965. Mtime: time.Now().Unix(),
  18966. ErrMsg: res.ErrMsg + "解析失败",
  18967. Status: 1,
  18968. PatientId: order.ID,
  18969. Stage: 10485,
  18970. }
  18971. service.CreateErrMsgLog(errlog)
  18972. continue
  18973. //c.ServeSuccessJSON(map[string]interface{}{
  18974. // "failed_code": -10,
  18975. // "msg": res.ErrMsg,
  18976. //})
  18977. } else {
  18978. //order.FaPiaoNumber = zero
  18979. //order.FaPiaoCode = last_order.FaPiaoCode
  18980. //service.UpdateOrder(order)
  18981. hisFundSettleListResult := &models.HisFundSettleListResult{
  18982. Number: res.Output.SetlListId,
  18983. Status: 1,
  18984. Ctime: time.Now().Unix(),
  18985. Mtime: time.Now().Unix(),
  18986. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18987. IsUpload: 1,
  18988. OrderId: order.ID,
  18989. }
  18990. service.CreateUploadRecord(hisFundSettleListResult)
  18991. continue
  18992. }
  18993. }
  18994. }
  18995. func (c *HisApiController) GetSettleList() {
  18996. order_id, _ := c.GetInt64("order_id")
  18997. admin_user_id, _ := c.GetInt64("admin_user_id")
  18998. order, _ := service.GetHisOrderByIDTwo(order_id)
  18999. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19000. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19001. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19002. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19003. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19004. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19005. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19006. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19007. if order.ID == 0 {
  19008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19009. return
  19010. }
  19011. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19012. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19013. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19014. //fmt.Println(count)
  19015. //var zero string
  19016. //number := count + 1
  19017. //if number >= 1000 {
  19018. // zero = "0000" + strconv.FormatInt(number, 10)
  19019. //} else if number >= 10000 {
  19020. // zero = "000" + strconv.FormatInt(number, 10)
  19021. //} else if number >= 100000 {
  19022. // zero = "00" + strconv.FormatInt(number, 10)
  19023. //} else if number >= 1000000 {
  19024. // zero = "0" + strconv.FormatInt(number, 10)
  19025. //} else {
  19026. // zero = strconv.FormatInt(number, 10)
  19027. //}
  19028. //fmt.Println(zero)
  19029. struct4101 := service.Struct4101{
  19030. PsnNo: order.PsnNo,
  19031. MdtrtId: order.MdtrtId,
  19032. SetlId: order.SetlId,
  19033. PsnName: order.PsnName,
  19034. Gend: order.Gend,
  19035. Brdy: his.Brdy,
  19036. Age: his.Age,
  19037. Naty: order.Naty,
  19038. PatnCertType: "01",
  19039. Certno: order.Certno,
  19040. Prfs: "90",
  19041. ConerName: roles[0].UserName,
  19042. PatnRlts: "99",
  19043. ConerAddr: miConfig.OrgName,
  19044. ConerTel: admin.Mobile,
  19045. HiType: order.Insutype,
  19046. Insuplc: miConfig.InsuplcAdmdvs,
  19047. MaindiagFlag: "1",
  19048. BillCode: order.SetlId,
  19049. BillNo: order.SetlId,
  19050. BizSn: order.Number,
  19051. PsnSelfPay: order.PsnPartAmt,
  19052. PsnOwnPay: order.PsnPartAmt,
  19053. AcctPay: order.AcctPay,
  19054. PsnCashpay: order.PsnCashPay,
  19055. HiPaymtd: "1",
  19056. Hsorg: miConfig.InsuplcAdmdvs,
  19057. HsorgOpter: miConfig.InsuplcAdmdvs,
  19058. MedinsFillPsn: curRoles.UserName,
  19059. MedinsFillDept: miConfig.OrgName,
  19060. IptMedType: "2",
  19061. }
  19062. struct4101.SetlBegnDate = order.SetlTime
  19063. struct4101.SetlEndDate = order.SetlTime
  19064. time_arr := strings.Split(order.SetlTime, " ")
  19065. struct4101.AdmTime = time_arr[0]
  19066. struct4101.AdmEndTime = time_arr[0]
  19067. //
  19068. //var rf []CustomFundPay
  19069. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19070. //
  19071. //var tempFunPays []service.CustomStruct
  19072. //for _, item := range rf {
  19073. // var tempFunPay service.CustomStruct
  19074. // tempFunPay.FundPayamt = item.FundPayamt
  19075. // tempFunPay.FundPayType = item.FundPayType
  19076. // tempFunPays = append(tempFunPays, tempFunPay)
  19077. //}
  19078. //struct4101.CustomStruct = tempFunPays
  19079. var tempDiaginfos []service.DiaginfoStructTwo
  19080. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19081. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19082. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  19083. var config []*models.HisXtDiagnoseConfig
  19084. for _, item := range diagnosis_ids {
  19085. id, _ := strconv.ParseInt(item, 10, 64)
  19086. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19087. config = append(config, &diagnosisConfig)
  19088. }
  19089. if miConfig.Code == "H15049901371" {
  19090. //for _, item := range config {
  19091. // if item.ID == 138 {
  19092. diagnosisConfig, _ := service.FindDiagnoseById(138)
  19093. var tempDiaginfo service.DiaginfoStructTwo
  19094. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  19095. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  19096. tempDiaginfo.DiagType = "1"
  19097. tempDiaginfo.MaindiagFlag = "1"
  19098. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19099. //}
  19100. //}
  19101. for _, item := range config {
  19102. if item.ID != 138 {
  19103. var tempDiaginfo service.DiaginfoStructTwo
  19104. tempDiaginfo.DiagCode = item.CountryCode
  19105. tempDiaginfo.DiagName = item.CountryContentName
  19106. tempDiaginfo.DiagType = "1"
  19107. tempDiaginfo.MaindiagFlag = "0"
  19108. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19109. }
  19110. }
  19111. } else {
  19112. for index, item := range config {
  19113. if index == 0 {
  19114. var tempDiaginfo service.DiaginfoStructTwo
  19115. tempDiaginfo.DiagCode = item.CountryCode
  19116. tempDiaginfo.DiagName = item.CountryContentName
  19117. tempDiaginfo.DiagType = "1"
  19118. tempDiaginfo.MaindiagFlag = "1"
  19119. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19120. } else {
  19121. var tempDiaginfo service.DiaginfoStructTwo
  19122. tempDiaginfo.DiagCode = item.CountryCode
  19123. tempDiaginfo.DiagName = item.CountryContentName
  19124. tempDiaginfo.DiagType = "1"
  19125. tempDiaginfo.MaindiagFlag = "0"
  19126. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19127. }
  19128. }
  19129. }
  19130. struct4101.Diseinfo = tempDiaginfos
  19131. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19132. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19133. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19134. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19135. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19136. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19137. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19138. var iteminfo service.IteminfoStruct
  19139. var bedCostTotal float64 = 0 //床位总费
  19140. var bedCostSelfTotal float64 = 0 //床位自费
  19141. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19142. var operationCostTotal float64 = 0 //手术费
  19143. var operationCostSelfTotal float64 = 0 //手术费
  19144. var operationCostPartSelfTotal float64 = 0 //手术费
  19145. var otherCostTotal float64 = 0 //其他费用
  19146. var otherCostSelfTotal float64 = 0 //其他费用
  19147. var otherCostPartSelfTotal float64 = 0 //其他费用
  19148. var materialCostTotal float64 = 0 //材料费
  19149. var materialCostSelfTotal float64 = 0 //材料费
  19150. var materialCostPartSelfTotal float64 = 0 //材料费
  19151. var westernMedicineCostTotal float64 = 0 //西药费
  19152. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19153. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19154. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19155. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19156. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19157. var checkCostTotal float64 = 0 //检查费
  19158. var checkCostSelfTotal float64 = 0 //检查费
  19159. var checkCostPartSelfTotal float64 = 0 //检查费
  19160. var laboratoryCostTotal float64 = 0 //化验费
  19161. var laboratoryCostSelfTotal float64 = 0 //化验费
  19162. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19163. var treatCostTotal float64 = 0 //治疗费用
  19164. var treatCostSelfTotal float64 = 0 //治疗费用
  19165. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19166. decimal.DivisionPrecision = 2
  19167. var bed_fulamt_ownpay_amt float64 = 0
  19168. var operation_fulamt_ownpay_amt float64 = 0
  19169. var other_fulamt_ownpay_amt float64 = 0
  19170. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19171. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19172. var check_fulamt_ownpay_amt float64 = 0
  19173. var material_fulamt_ownpay_amt float64 = 0
  19174. var laboratory_fulamt_ownpay_amt float64 = 0
  19175. var treat_fulamt_ownpay_amt float64 = 0
  19176. var bed_claa_sunmfee float64 = 0
  19177. var bed_clab_amt float64 = 0
  19178. var bed_other_amt float64 = 0
  19179. var operation_claa_sunmfee float64 = 0
  19180. var operation_clab_amt float64 = 0
  19181. var operation_other_amt float64 = 0
  19182. var other_claa_sunmfee float64 = 0
  19183. var other_clab_amt float64 = 0
  19184. var other_other_amt float64 = 0
  19185. var westernMedicine_claa_sunmfee float64 = 0
  19186. var westernMedicine_clab_amt float64 = 0
  19187. var westernMedicine_other_amt float64 = 0
  19188. var chineseTraditional_claa_sunmfee float64 = 0
  19189. var chineseTraditional_clab_amt float64 = 0
  19190. var chineseTraditional_other_amt float64 = 0
  19191. var check_claa_sunmfee float64 = 0
  19192. var check_clab_amt float64 = 0
  19193. var check_other_amt float64 = 0
  19194. var material_claa_sunmfee float64 = 0
  19195. var material_clab_amt float64 = 0
  19196. var material_other_amt float64 = 0
  19197. var laboratory_claa_sunmfee float64 = 0
  19198. var laboratory_clab_amt float64 = 0
  19199. var laboratory_other_amt float64 = 0
  19200. var treat_claa_sunmfee float64 = 0
  19201. var treat_clab_amt float64 = 0
  19202. var treat_other_amt float64 = 0
  19203. for _, item := range order.HisOrderInfo {
  19204. if item.MedChrgitmType == "01" { //床位费
  19205. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19206. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19207. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19208. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19209. if item.ChrgitmLv == "1" {
  19210. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19211. }
  19212. if item.ChrgitmLv == "2" {
  19213. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19214. }
  19215. if item.ChrgitmLv == "3" {
  19216. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19217. }
  19218. }
  19219. if item.MedChrgitmType == "03" { //检查费
  19220. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19221. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19222. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19223. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19224. if item.ChrgitmLv == "1" {
  19225. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19226. }
  19227. if item.ChrgitmLv == "2" {
  19228. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19229. }
  19230. if item.ChrgitmLv == "3" {
  19231. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19232. }
  19233. }
  19234. if item.MedChrgitmType == "04" { //化验费
  19235. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19236. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19237. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19238. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19239. if item.ChrgitmLv == "1" {
  19240. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19241. }
  19242. if item.ChrgitmLv == "2" {
  19243. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19244. }
  19245. if item.ChrgitmLv == "3" {
  19246. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19247. }
  19248. }
  19249. if item.MedChrgitmType == "05" { //治疗费
  19250. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19251. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19252. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19253. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19254. if item.ChrgitmLv == "1" {
  19255. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19256. }
  19257. if item.ChrgitmLv == "2" {
  19258. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19259. }
  19260. if item.ChrgitmLv == "3" {
  19261. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19262. }
  19263. }
  19264. if item.MedChrgitmType == "06" { //手术费
  19265. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19266. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19267. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19268. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19269. if item.ChrgitmLv == "1" {
  19270. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19271. }
  19272. if item.ChrgitmLv == "2" {
  19273. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19274. }
  19275. if item.ChrgitmLv == "3" {
  19276. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19277. }
  19278. }
  19279. if item.MedChrgitmType == "08" { //材料费
  19280. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19281. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19282. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19283. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19284. if item.ChrgitmLv == "1" {
  19285. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19286. }
  19287. if item.ChrgitmLv == "2" {
  19288. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19289. }
  19290. if item.ChrgitmLv == "3" {
  19291. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19292. }
  19293. }
  19294. if item.MedChrgitmType == "09" { //西药费
  19295. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19296. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19297. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19298. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19299. if item.ChrgitmLv == "1" {
  19300. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19301. }
  19302. if item.ChrgitmLv == "2" {
  19303. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19304. }
  19305. if item.ChrgitmLv == "3" {
  19306. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19307. }
  19308. }
  19309. if item.MedChrgitmType == "11" { //中成费
  19310. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19311. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19312. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19313. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19314. if item.ChrgitmLv == "1" {
  19315. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19316. }
  19317. if item.ChrgitmLv == "2" {
  19318. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19319. }
  19320. if item.ChrgitmLv == "3" {
  19321. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19322. }
  19323. }
  19324. if item.MedChrgitmType == "14" { //其他费
  19325. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19326. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19327. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19328. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19329. if item.ChrgitmLv == "1" {
  19330. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19331. }
  19332. if item.ChrgitmLv == "2" {
  19333. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19334. }
  19335. if item.ChrgitmLv == "3" {
  19336. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19337. }
  19338. }
  19339. }
  19340. var iteminfoStructs []service.IteminfoStruct
  19341. if bedCostTotal != 0 {
  19342. iteminfo.MedChrgitm = "01"
  19343. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19344. iteminfo.Amt = bedCostTotal
  19345. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19346. iteminfo.ClabAmt = bed_clab_amt
  19347. iteminfo.OthAmt = bed_other_amt
  19348. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19349. }
  19350. if checkCostTotal != 0 {
  19351. iteminfo.MedChrgitm = "03"
  19352. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19353. iteminfo.Amt = checkCostTotal
  19354. iteminfo.ClaaSumfee = check_claa_sunmfee
  19355. iteminfo.ClabAmt = check_clab_amt
  19356. iteminfo.OthAmt = check_other_amt
  19357. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19358. }
  19359. if laboratoryCostTotal != 0 {
  19360. iteminfo.MedChrgitm = "04"
  19361. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19362. iteminfo.Amt = laboratoryCostTotal
  19363. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19364. iteminfo.ClabAmt = laboratory_clab_amt
  19365. iteminfo.OthAmt = laboratory_other_amt
  19366. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19367. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19368. }
  19369. if treatCostTotal != 0 {
  19370. iteminfo.MedChrgitm = "05"
  19371. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19372. iteminfo.Amt = treatCostTotal
  19373. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19374. iteminfo.ClabAmt = treat_clab_amt
  19375. iteminfo.OthAmt = treat_other_amt
  19376. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19377. //(struct4101.IteminfoStruct, iteminfo)
  19378. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19379. }
  19380. if operationCostTotal != 0 {
  19381. iteminfo.MedChrgitm = "06"
  19382. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19383. iteminfo.Amt = operationCostTotal
  19384. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19385. iteminfo.ClabAmt = operation_clab_amt
  19386. iteminfo.OthAmt = operation_other_amt
  19387. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19388. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19389. }
  19390. if materialCostTotal != 0 {
  19391. iteminfo.MedChrgitm = "08"
  19392. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19393. iteminfo.Amt = materialCostTotal
  19394. iteminfo.ClaaSumfee = material_claa_sunmfee
  19395. iteminfo.ClabAmt = material_clab_amt
  19396. iteminfo.OthAmt = material_other_amt
  19397. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19398. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19399. }
  19400. if westernMedicineCostTotal != 0 {
  19401. iteminfo.MedChrgitm = "09"
  19402. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19403. iteminfo.Amt = westernMedicineCostTotal
  19404. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19405. iteminfo.ClabAmt = westernMedicine_clab_amt
  19406. iteminfo.OthAmt = westernMedicine_other_amt
  19407. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19408. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19409. }
  19410. if chineseTraditionalMedicineCostTotal != 0 {
  19411. iteminfo.MedChrgitm = "11"
  19412. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19413. iteminfo.Amt = westernMedicineCostTotal
  19414. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19415. iteminfo.ClabAmt = westernMedicine_clab_amt
  19416. iteminfo.OthAmt = westernMedicine_other_amt
  19417. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19418. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19419. }
  19420. if otherCostTotal != 0 {
  19421. iteminfo.MedChrgitm = "14"
  19422. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19423. iteminfo.Amt = otherCostTotal
  19424. iteminfo.ClaaSumfee = other_claa_sunmfee
  19425. iteminfo.ClabAmt = other_clab_amt
  19426. iteminfo.OthAmt = other_other_amt
  19427. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19428. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19429. }
  19430. struct4101.IteminfoStruct = iteminfoStructs
  19431. struct4101.Ntly = "中国"
  19432. struct4101.AdmCaty = "A03.06"
  19433. struct4101.DoctorName = doctor.UserName
  19434. struct4101.DoctorCode = doctor.DoctorNumber
  19435. var res ResultSeventeen
  19436. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19437. struct4101.BillCode = order.Number
  19438. struct4101.BillNo = order.SetlId
  19439. var resOther ResultSeventeenOther
  19440. var pp models.PublicParams
  19441. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19442. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19443. pp.FixmedinsName = miConfig.OrgName
  19444. pp.FixmedinsCode = miConfig.Code
  19445. pp.RequestUrl = miConfig.Url
  19446. pp.Cainfo = miConfig.Cainfo
  19447. pp.SecretKey = miConfig.SecretKey
  19448. pp.AccessKey = miConfig.AccessKey
  19449. pp.OpterName = curRoles.UserName
  19450. client := &http.Client{}
  19451. var req *http.Request
  19452. data := make(map[string]interface{})
  19453. data["struct4101"] = struct4101
  19454. data["pp"] = pp
  19455. bytesData, _ := json.Marshal(data)
  19456. if miConfig.MdtrtareaAdmvs == "320921" {
  19457. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19458. } else {
  19459. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19460. }
  19461. resp, _ := client.Do(req)
  19462. defer resp.Body.Close()
  19463. body, ioErr := ioutil.ReadAll(resp.Body)
  19464. if ioErr != nil {
  19465. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19467. return
  19468. }
  19469. var respJSON map[string]interface{}
  19470. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19473. return
  19474. }
  19475. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19476. userJSONBytes, _ := json.Marshal(respJSON)
  19477. fmt.Println("log")
  19478. fmt.Println(string(userJSONBytes))
  19479. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19480. utils.ErrorLog("解析失败:%v", err)
  19481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19482. return
  19483. }
  19484. res.InfRefmsgid = resOther.InfRefmsgid
  19485. res.Output = resOther.Output
  19486. res.ErrMsg = resOther.ErrMsg
  19487. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19488. res.Infcode = infocode
  19489. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19490. var pp models.PublicParams
  19491. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19492. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19493. pp.FixmedinsName = miConfig.OrgName
  19494. pp.FixmedinsCode = miConfig.Code
  19495. pp.RequestUrl = miConfig.Url
  19496. pp.Cainfo = miConfig.Cainfo
  19497. pp.SecretKey = miConfig.SecretKey
  19498. pp.AccessKey = miConfig.AccessKey
  19499. pp.OpterName = curRoles.UserName
  19500. result, _ := service.Jxyb4101(struct4101, pp)
  19501. var dat map[string]interface{}
  19502. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19503. fmt.Println(dat)
  19504. } else {
  19505. fmt.Println(err)
  19506. }
  19507. userJSONBytes, _ := json.Marshal(dat)
  19508. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19509. utils.ErrorLog("解析失败:%v", err)
  19510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19511. return
  19512. }
  19513. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19514. var pp models.PublicParams
  19515. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19516. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19517. pp.FixmedinsName = miConfig.OrgName
  19518. pp.FixmedinsCode = miConfig.Code
  19519. pp.RequestUrl = miConfig.Url
  19520. pp.Cainfo = miConfig.Cainfo
  19521. pp.SecretKey = miConfig.SecretKey
  19522. pp.AccessKey = miConfig.AccessKey
  19523. pp.OpterName = curRoles.UserName
  19524. result, _ := service.Jxyb4101(struct4101, pp)
  19525. var dat map[string]interface{}
  19526. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19527. fmt.Println(dat)
  19528. } else {
  19529. fmt.Println(err)
  19530. }
  19531. userJSONBytes, _ := json.Marshal(dat)
  19532. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19533. utils.ErrorLog("解析失败:%v", err)
  19534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19535. return
  19536. }
  19537. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19538. var pp models.PublicParams
  19539. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19540. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19541. pp.FixmedinsName = miConfig.OrgName
  19542. pp.FixmedinsCode = miConfig.Code
  19543. pp.RequestUrl = miConfig.Url
  19544. pp.Cainfo = miConfig.Cainfo
  19545. pp.SecretKey = miConfig.SecretKey
  19546. pp.AccessKey = miConfig.AccessKey
  19547. pp.OpterName = curRoles.UserName
  19548. result, _ := service.Hnyb4101(struct4101, pp)
  19549. var dat map[string]interface{}
  19550. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19551. fmt.Println(dat)
  19552. } else {
  19553. fmt.Println(err)
  19554. }
  19555. userJSONBytes, _ := json.Marshal(dat)
  19556. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19557. utils.ErrorLog("解析失败:%v", err)
  19558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19559. return
  19560. }
  19561. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19562. var resOther ResultSeventeenOther
  19563. var pp models.PublicParams
  19564. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19565. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19566. pp.FixmedinsName = miConfig.OrgName
  19567. pp.FixmedinsCode = miConfig.Code
  19568. pp.RequestUrl = miConfig.Url
  19569. pp.Cainfo = miConfig.Cainfo
  19570. pp.SecretKey = miConfig.SecretKey
  19571. pp.AccessKey = miConfig.AccessKey
  19572. pp.OpterName = curRoles.UserName
  19573. client := &http.Client{}
  19574. var req *http.Request
  19575. data := make(map[string]interface{})
  19576. data["struct4101"] = struct4101
  19577. data["pp"] = pp
  19578. bytesData, _ := json.Marshal(data)
  19579. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19580. resp, _ := client.Do(req)
  19581. defer resp.Body.Close()
  19582. body, ioErr := ioutil.ReadAll(resp.Body)
  19583. if ioErr != nil {
  19584. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19586. return
  19587. }
  19588. var respJSON map[string]interface{}
  19589. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19592. return
  19593. }
  19594. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19595. userJSONBytes, _ := json.Marshal(respJSON)
  19596. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19597. utils.ErrorLog("解析失败:%v", err)
  19598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19599. return
  19600. }
  19601. res.InfRefmsgid = resOther.InfRefmsgid
  19602. res.Output = resOther.Output
  19603. res.ErrMsg = resOther.ErrMsg
  19604. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19605. res.Infcode = infocode
  19606. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19607. var pp models.PublicParams
  19608. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19609. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19610. pp.FixmedinsName = miConfig.OrgName
  19611. pp.FixmedinsCode = miConfig.Code
  19612. pp.RequestUrl = miConfig.Url
  19613. pp.Cainfo = miConfig.Cainfo
  19614. pp.SecretKey = miConfig.SecretKey
  19615. pp.AccessKey = miConfig.AccessKey
  19616. pp.OpterName = curRoles.UserName
  19617. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19618. fmt.Println(requestLog)
  19619. fmt.Println(errMsgLog)
  19620. saveLog(result, requestLog, "4101a", "上传清单")
  19621. var dat map[string]interface{}
  19622. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19623. fmt.Println(dat)
  19624. } else {
  19625. fmt.Println(err)
  19626. }
  19627. userJSONBytes, _ := json.Marshal(dat)
  19628. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19629. utils.ErrorLog("解析失败:%v", err)
  19630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19631. return
  19632. }
  19633. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19634. var pp models.PublicParams
  19635. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19636. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19637. pp.FixmedinsName = miConfig.OrgName
  19638. pp.FixmedinsCode = miConfig.Code
  19639. pp.RequestUrl = miConfig.Url
  19640. pp.Cainfo = miConfig.Cainfo
  19641. pp.SecretKey = miConfig.SecretKey
  19642. pp.AccessKey = miConfig.AccessKey
  19643. pp.OpterName = curRoles.UserName
  19644. client := &http.Client{}
  19645. var req *http.Request
  19646. data := make(map[string]interface{})
  19647. data["struct4101"] = struct4101
  19648. data["pp"] = pp
  19649. bytesData, _ := json.Marshal(data)
  19650. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19651. resp, _ := client.Do(req)
  19652. defer resp.Body.Close()
  19653. body, ioErr := ioutil.ReadAll(resp.Body)
  19654. if ioErr != nil {
  19655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19657. return
  19658. }
  19659. var respJSON map[string]interface{}
  19660. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19663. return
  19664. }
  19665. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19666. userJSONBytes, _ := json.Marshal(respJSON)
  19667. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19668. utils.ErrorLog("解析失败:%v", err)
  19669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19670. return
  19671. }
  19672. } else {
  19673. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19674. var dat map[string]interface{}
  19675. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19676. fmt.Println(dat)
  19677. } else {
  19678. fmt.Println(err)
  19679. }
  19680. userJSONBytes, _ := json.Marshal(dat)
  19681. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19682. utils.ErrorLog("解析失败:%v", err)
  19683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19684. return
  19685. }
  19686. }
  19687. if res.Infcode != 0 {
  19688. c.ServeSuccessJSON(map[string]interface{}{
  19689. "failed_code": -10,
  19690. "msg": res.ErrMsg,
  19691. })
  19692. return
  19693. } else {
  19694. //order.FaPiaoNumber = zero
  19695. //order.FaPiaoCode = last_order.FaPiaoCode
  19696. //service.UpdateOrder(order)
  19697. hisFundSettleListResult := &models.HisFundSettleListResult{
  19698. Number: res.Output.SetlListId,
  19699. Status: 1,
  19700. Ctime: time.Now().Unix(),
  19701. Mtime: time.Now().Unix(),
  19702. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19703. IsUpload: 1,
  19704. OrderId: order_id,
  19705. }
  19706. service.CreateUploadRecord(hisFundSettleListResult)
  19707. c.ServeSuccessJSON(map[string]interface{}{
  19708. "msg": "上传成功",
  19709. "result": hisFundSettleListResult,
  19710. })
  19711. return
  19712. }
  19713. }
  19714. func (c *HisApiController) GetSettleListHospital() {
  19715. order_id, _ := c.GetInt64("order_id")
  19716. admin_user_id, _ := c.GetInt64("admin_user_id")
  19717. order, _ := service.GetHisOrderByIDTwo(order_id)
  19718. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19719. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  19720. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19721. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19722. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19723. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19724. if order.ID == 0 {
  19725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19726. return
  19727. }
  19728. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19729. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19730. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19731. fmt.Println(count)
  19732. var zero string
  19733. number := count + 1
  19734. if number >= 1000 {
  19735. zero = "0000" + strconv.FormatInt(number, 10)
  19736. } else if number >= 10000 {
  19737. zero = "000" + strconv.FormatInt(number, 10)
  19738. } else if number >= 100000 {
  19739. zero = "00" + strconv.FormatInt(number, 10)
  19740. } else if number >= 1000000 {
  19741. zero = "0" + strconv.FormatInt(number, 10)
  19742. } else {
  19743. zero = strconv.FormatInt(number, 10)
  19744. }
  19745. fmt.Println(zero)
  19746. struct4101 := service.Struct4101{
  19747. PsnNo: order.PsnNo,
  19748. MdtrtId: order.MdtrtId,
  19749. SetlId: order.SetlId,
  19750. PsnName: order.PsnName,
  19751. Gend: order.Gend,
  19752. Brdy: his.Brdy,
  19753. Age: int64(order.Age),
  19754. Naty: order.Naty,
  19755. PatnCertType: "01",
  19756. Certno: order.Certno,
  19757. Prfs: "90",
  19758. ConerName: roles[0].UserName,
  19759. PatnRlts: "99",
  19760. ConerAddr: miConfig.OrgName,
  19761. ConerTel: admin.Mobile,
  19762. HiType: order.Insutype,
  19763. Insuplc: miConfig.InsuplcAdmdvs,
  19764. MaindiagFlag: "1",
  19765. BillCode: order.SetlId,
  19766. BillNo: order.SetlId,
  19767. BizSn: order.Number,
  19768. PsnSelfPay: order.PsnPartAmt,
  19769. PsnOwnPay: order.PsnPartAmt,
  19770. AcctPay: order.AcctPay,
  19771. PsnCashpay: order.PsnCashPay,
  19772. HiPaymtd: "1",
  19773. Hsorg: miConfig.InsuplcAdmdvs,
  19774. HsorgOpter: miConfig.InsuplcAdmdvs,
  19775. MedinsFillPsn: curRoles.UserName,
  19776. MedinsFillDept: depart.Name,
  19777. IptMedType: "2",
  19778. AdmTime: his.InHosptialTime,
  19779. AdmEndTime: his.OutHosptialTime,
  19780. }
  19781. struct4101.SetlBegnDate = order.SetlTime
  19782. struct4101.SetlEndDate = order.SetlTime
  19783. //var rf []CustomFundPay
  19784. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19785. //
  19786. //var tempFunPays []service.CustomStruct
  19787. //for _, item := range rf {
  19788. // var tempFunPay service.CustomStruct
  19789. // tempFunPay.FundPayamt = item.FundPayamt
  19790. // tempFunPay.FundPayType = item.FundPayType
  19791. // tempFunPays = append(tempFunPays, tempFunPay)
  19792. //}
  19793. //struct4101.CustomStruct = tempFunPays
  19794. var tempDiaginfos []service.DiaginfoStructTwo
  19795. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19796. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19797. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  19798. //for _, item := range infos {
  19799. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  19800. //}
  19801. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  19802. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  19803. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19804. fmt.Println(diagnosis_ids_arr)
  19805. if order.UserOrgId == 10210 {
  19806. var diagnosis_ids_arr_two []int64
  19807. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  19808. var config []*models.HisXtDiagnoseConfig
  19809. for _, id := range diagnosis_ids_arr_two {
  19810. //id, _ := strconv.ParseInt(item, 10, 64)
  19811. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19812. if diagnosisConfig.ID > 0 {
  19813. config = append(config, &diagnosisConfig)
  19814. }
  19815. }
  19816. for index, item := range config {
  19817. if item.ID > 0 {
  19818. if index == 0 {
  19819. var tempDiaginfo service.DiaginfoStructTwo
  19820. tempDiaginfo.DiagCode = item.CountryCode
  19821. tempDiaginfo.DiagName = item.CountryContentName
  19822. tempDiaginfo.DiagType = "1"
  19823. tempDiaginfo.MaindiagFlag = "1"
  19824. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19825. } else {
  19826. var tempDiaginfo service.DiaginfoStructTwo
  19827. tempDiaginfo.DiagCode = item.CountryCode
  19828. tempDiaginfo.DiagName = item.CountryContentName
  19829. tempDiaginfo.DiagType = "1"
  19830. tempDiaginfo.MaindiagFlag = "0"
  19831. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19832. }
  19833. }
  19834. }
  19835. struct4101.Diseinfo = tempDiaginfos
  19836. } else {
  19837. var config []*models.HisXtDiagnoseConfig
  19838. for _, item := range diagnosis_ids_arr {
  19839. id, _ := strconv.ParseInt(item, 10, 64)
  19840. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19841. if diagnosisConfig.ID > 0 {
  19842. config = append(config, &diagnosisConfig)
  19843. }
  19844. }
  19845. for index, item := range config {
  19846. if item.ID > 0 {
  19847. if index == 0 {
  19848. var tempDiaginfo service.DiaginfoStructTwo
  19849. tempDiaginfo.DiagCode = item.CountryCode
  19850. tempDiaginfo.DiagName = item.CountryContentName
  19851. tempDiaginfo.DiagType = "1"
  19852. tempDiaginfo.MaindiagFlag = "1"
  19853. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19854. } else {
  19855. var tempDiaginfo service.DiaginfoStructTwo
  19856. tempDiaginfo.DiagCode = item.CountryCode
  19857. tempDiaginfo.DiagName = item.CountryContentName
  19858. tempDiaginfo.DiagType = "1"
  19859. tempDiaginfo.MaindiagFlag = "0"
  19860. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19861. }
  19862. }
  19863. }
  19864. struct4101.Diseinfo = tempDiaginfos
  19865. }
  19866. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19867. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19868. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19869. tempOpspdiseinfo2.OprnOprtCode = ""
  19870. tempOpspdiseinfo2.OprnOprtName = ""
  19871. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19872. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19873. var iteminfo service.IteminfoStruct
  19874. var bedCostTotal float64 = 0 //床位总费
  19875. var bedCostSelfTotal float64 = 0 //床位自费
  19876. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19877. var operationCostTotal float64 = 0 //手术费
  19878. var operationCostSelfTotal float64 = 0 //手术费
  19879. var operationCostPartSelfTotal float64 = 0 //手术费
  19880. var otherCostTotal float64 = 0 //其他费用
  19881. var otherCostSelfTotal float64 = 0 //其他费用
  19882. var otherCostPartSelfTotal float64 = 0 //其他费用
  19883. var materialCostTotal float64 = 0 //材料费
  19884. var materialCostSelfTotal float64 = 0 //材料费
  19885. var materialCostPartSelfTotal float64 = 0 //材料费
  19886. var westernMedicineCostTotal float64 = 0 //西药费
  19887. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19888. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19889. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19890. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19891. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19892. var checkCostTotal float64 = 0 //检查费
  19893. var checkCostSelfTotal float64 = 0 //检查费
  19894. var checkCostPartSelfTotal float64 = 0 //检查费
  19895. var laboratoryCostTotal float64 = 0 //化验费
  19896. var laboratoryCostSelfTotal float64 = 0 //化验费
  19897. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19898. var treatCostTotal float64 = 0 //治疗费用
  19899. var treatCostSelfTotal float64 = 0 //治疗费用
  19900. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19901. decimal.DivisionPrecision = 2
  19902. var bed_fulamt_ownpay_amt float64 = 0
  19903. var operation_fulamt_ownpay_amt float64 = 0
  19904. var other_fulamt_ownpay_amt float64 = 0
  19905. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19906. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19907. var check_fulamt_ownpay_amt float64 = 0
  19908. var material_fulamt_ownpay_amt float64 = 0
  19909. var laboratory_fulamt_ownpay_amt float64 = 0
  19910. var treat_fulamt_ownpay_amt float64 = 0
  19911. var bed_claa_sunmfee float64 = 0
  19912. var bed_clab_amt float64 = 0
  19913. var bed_other_amt float64 = 0
  19914. var operation_claa_sunmfee float64 = 0
  19915. var operation_clab_amt float64 = 0
  19916. var operation_other_amt float64 = 0
  19917. var other_claa_sunmfee float64 = 0
  19918. var other_clab_amt float64 = 0
  19919. var other_other_amt float64 = 0
  19920. var westernMedicine_claa_sunmfee float64 = 0
  19921. var westernMedicine_clab_amt float64 = 0
  19922. var westernMedicine_other_amt float64 = 0
  19923. var chineseTraditional_claa_sunmfee float64 = 0
  19924. var chineseTraditional_clab_amt float64 = 0
  19925. var chineseTraditional_other_amt float64 = 0
  19926. var check_claa_sunmfee float64 = 0
  19927. var check_clab_amt float64 = 0
  19928. var check_other_amt float64 = 0
  19929. var material_claa_sunmfee float64 = 0
  19930. var material_clab_amt float64 = 0
  19931. var material_other_amt float64 = 0
  19932. var laboratory_claa_sunmfee float64 = 0
  19933. var laboratory_clab_amt float64 = 0
  19934. var laboratory_other_amt float64 = 0
  19935. var treat_claa_sunmfee float64 = 0
  19936. var treat_clab_amt float64 = 0
  19937. var treat_other_amt float64 = 0
  19938. for _, item := range order.HisOrderInfo {
  19939. if item.MedChrgitmType == "01" { //床位费
  19940. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19941. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19942. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19943. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19944. if item.ChrgitmLv == "1" {
  19945. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19946. }
  19947. if item.ChrgitmLv == "2" {
  19948. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19949. }
  19950. if item.ChrgitmLv == "3" {
  19951. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19952. }
  19953. }
  19954. if item.MedChrgitmType == "03" { //检查费
  19955. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19956. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19957. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19958. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19959. if item.ChrgitmLv == "1" {
  19960. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19961. }
  19962. if item.ChrgitmLv == "2" {
  19963. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19964. }
  19965. if item.ChrgitmLv == "3" {
  19966. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19967. }
  19968. }
  19969. if item.MedChrgitmType == "04" { //化验费
  19970. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19971. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19972. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19973. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19974. if item.ChrgitmLv == "1" {
  19975. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19976. }
  19977. if item.ChrgitmLv == "2" {
  19978. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19979. }
  19980. if item.ChrgitmLv == "3" {
  19981. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19982. }
  19983. }
  19984. if item.MedChrgitmType == "05" { //治疗费
  19985. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19986. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19987. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19988. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19989. if item.ChrgitmLv == "1" {
  19990. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19991. }
  19992. if item.ChrgitmLv == "2" {
  19993. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19994. }
  19995. if item.ChrgitmLv == "3" {
  19996. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19997. }
  19998. }
  19999. if item.MedChrgitmType == "06" { //手术费
  20000. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20001. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20002. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20003. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20004. if item.ChrgitmLv == "1" {
  20005. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20006. }
  20007. if item.ChrgitmLv == "2" {
  20008. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20009. }
  20010. if item.ChrgitmLv == "3" {
  20011. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20012. }
  20013. }
  20014. if item.MedChrgitmType == "08" { //材料费
  20015. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20016. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20017. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20018. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20019. if item.ChrgitmLv == "1" {
  20020. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20021. }
  20022. if item.ChrgitmLv == "2" {
  20023. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20024. }
  20025. if item.ChrgitmLv == "3" {
  20026. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20027. }
  20028. }
  20029. if item.MedChrgitmType == "09" { //西药费
  20030. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20031. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20032. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20033. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20034. if item.ChrgitmLv == "1" {
  20035. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20036. }
  20037. if item.ChrgitmLv == "2" {
  20038. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20039. }
  20040. if item.ChrgitmLv == "3" {
  20041. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20042. }
  20043. }
  20044. if item.MedChrgitmType == "11" { //中成费
  20045. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20046. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20047. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20048. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20049. if item.ChrgitmLv == "1" {
  20050. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20051. }
  20052. if item.ChrgitmLv == "2" {
  20053. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20054. }
  20055. if item.ChrgitmLv == "3" {
  20056. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20057. }
  20058. }
  20059. if item.MedChrgitmType == "14" { //其他费
  20060. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20061. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20062. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20063. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20064. if item.ChrgitmLv == "1" {
  20065. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20066. }
  20067. if item.ChrgitmLv == "2" {
  20068. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20069. }
  20070. if item.ChrgitmLv == "3" {
  20071. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20072. }
  20073. }
  20074. }
  20075. var iteminfoStructs []service.IteminfoStruct
  20076. if bedCostTotal != 0 {
  20077. iteminfo.MedChrgitm = "01"
  20078. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20079. iteminfo.Amt = bedCostTotal
  20080. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20081. iteminfo.ClabAmt = bed_clab_amt
  20082. iteminfo.OthAmt = bed_other_amt
  20083. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20084. }
  20085. if checkCostTotal != 0 {
  20086. iteminfo.MedChrgitm = "03"
  20087. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20088. iteminfo.Amt = checkCostTotal
  20089. iteminfo.ClaaSumfee = check_claa_sunmfee
  20090. iteminfo.ClabAmt = check_clab_amt
  20091. iteminfo.OthAmt = check_other_amt
  20092. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20093. }
  20094. if laboratoryCostTotal != 0 {
  20095. iteminfo.MedChrgitm = "04"
  20096. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20097. iteminfo.Amt = laboratoryCostTotal
  20098. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20099. iteminfo.ClabAmt = laboratory_clab_amt
  20100. iteminfo.OthAmt = laboratory_other_amt
  20101. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20102. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20103. }
  20104. if treatCostTotal != 0 {
  20105. iteminfo.MedChrgitm = "05"
  20106. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20107. iteminfo.Amt = treatCostTotal
  20108. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20109. iteminfo.ClabAmt = treat_clab_amt
  20110. iteminfo.OthAmt = treat_other_amt
  20111. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20112. //(struct4101.IteminfoStruct, iteminfo)
  20113. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20114. }
  20115. if operationCostTotal != 0 {
  20116. iteminfo.MedChrgitm = "06"
  20117. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20118. iteminfo.Amt = operationCostTotal
  20119. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20120. iteminfo.ClabAmt = operation_clab_amt
  20121. iteminfo.OthAmt = operation_other_amt
  20122. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20123. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20124. }
  20125. if materialCostTotal != 0 {
  20126. iteminfo.MedChrgitm = "08"
  20127. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20128. iteminfo.Amt = materialCostTotal
  20129. iteminfo.ClaaSumfee = material_claa_sunmfee
  20130. iteminfo.ClabAmt = material_clab_amt
  20131. iteminfo.OthAmt = material_other_amt
  20132. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20133. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20134. }
  20135. if westernMedicineCostTotal != 0 {
  20136. iteminfo.MedChrgitm = "09"
  20137. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20138. iteminfo.Amt = westernMedicineCostTotal
  20139. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20140. iteminfo.ClabAmt = westernMedicine_clab_amt
  20141. iteminfo.OthAmt = westernMedicine_other_amt
  20142. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20143. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20144. }
  20145. if chineseTraditionalMedicineCostTotal != 0 {
  20146. iteminfo.MedChrgitm = "11"
  20147. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20148. iteminfo.Amt = westernMedicineCostTotal
  20149. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20150. iteminfo.ClabAmt = westernMedicine_clab_amt
  20151. iteminfo.OthAmt = westernMedicine_other_amt
  20152. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20153. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20154. }
  20155. if otherCostTotal != 0 {
  20156. iteminfo.MedChrgitm = "14"
  20157. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20158. iteminfo.Amt = otherCostTotal
  20159. iteminfo.ClaaSumfee = other_claa_sunmfee
  20160. iteminfo.ClabAmt = other_clab_amt
  20161. iteminfo.OthAmt = other_other_amt
  20162. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20163. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20164. }
  20165. struct4101.IteminfoStruct = iteminfoStructs
  20166. struct4101.Ntly = "中国"
  20167. struct4101.AdmCaty = "A03.06"
  20168. var resOther ResultSeventeenOther
  20169. var res ResultSeventeen
  20170. if miConfig.MdtrtareaAdmvs == "150499" {
  20171. var pp models.PublicParams
  20172. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20173. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20174. pp.FixmedinsName = miConfig.OrgName
  20175. pp.FixmedinsCode = miConfig.Code
  20176. pp.RequestUrl = miConfig.Url
  20177. pp.Cainfo = miConfig.Cainfo
  20178. pp.SecretKey = miConfig.SecretKey
  20179. pp.AccessKey = miConfig.AccessKey
  20180. pp.OpterName = curRoles.UserName
  20181. client := &http.Client{}
  20182. var req *http.Request
  20183. data := make(map[string]interface{})
  20184. data["struct4101"] = struct4101
  20185. data["pp"] = pp
  20186. bytesData, _ := json.Marshal(data)
  20187. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20188. resp, _ := client.Do(req)
  20189. defer resp.Body.Close()
  20190. body, ioErr := ioutil.ReadAll(resp.Body)
  20191. if ioErr != nil {
  20192. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20194. return
  20195. }
  20196. var respJSON map[string]interface{}
  20197. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20200. return
  20201. }
  20202. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20203. userJSONBytes, _ := json.Marshal(respJSON)
  20204. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20205. utils.ErrorLog("解析失败:%v", err)
  20206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20207. return
  20208. }
  20209. res.InfRefmsgid = resOther.InfRefmsgid
  20210. res.Output = resOther.Output
  20211. res.ErrMsg = resOther.ErrMsg
  20212. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20213. res.Infcode = infocode
  20214. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20215. var pp models.PublicParams
  20216. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20217. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20218. pp.FixmedinsName = miConfig.OrgName
  20219. pp.FixmedinsCode = miConfig.Code
  20220. pp.RequestUrl = miConfig.Url
  20221. pp.Cainfo = miConfig.Cainfo
  20222. pp.SecretKey = miConfig.SecretKey
  20223. pp.AccessKey = miConfig.AccessKey
  20224. pp.OpterName = curRoles.UserName
  20225. result, _ := service.Jxyb4101(struct4101, pp)
  20226. var dat map[string]interface{}
  20227. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20228. fmt.Println(dat)
  20229. } else {
  20230. fmt.Println(err)
  20231. }
  20232. userJSONBytes, _ := json.Marshal(dat)
  20233. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20234. utils.ErrorLog("解析失败:%v", err)
  20235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20236. return
  20237. }
  20238. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20239. var pp models.PublicParams
  20240. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20241. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20242. pp.FixmedinsName = miConfig.OrgName
  20243. pp.FixmedinsCode = miConfig.Code
  20244. pp.RequestUrl = miConfig.Url
  20245. pp.Cainfo = miConfig.Cainfo
  20246. pp.SecretKey = miConfig.SecretKey
  20247. pp.AccessKey = miConfig.AccessKey
  20248. pp.OpterName = curRoles.UserName
  20249. result, _ := service.Jxyb4101(struct4101, pp)
  20250. var dat map[string]interface{}
  20251. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20252. fmt.Println(dat)
  20253. } else {
  20254. fmt.Println(err)
  20255. }
  20256. userJSONBytes, _ := json.Marshal(dat)
  20257. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20258. utils.ErrorLog("解析失败:%v", err)
  20259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20260. return
  20261. }
  20262. } else {
  20263. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20264. var dat map[string]interface{}
  20265. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20266. fmt.Println(dat)
  20267. } else {
  20268. fmt.Println(err)
  20269. }
  20270. userJSONBytes, _ := json.Marshal(dat)
  20271. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20272. utils.ErrorLog("解析失败:%v", err)
  20273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20274. return
  20275. }
  20276. }
  20277. if res.Infcode != 0 {
  20278. c.ServeSuccessJSON(map[string]interface{}{
  20279. "failed_code": -10,
  20280. "msg": res.ErrMsg,
  20281. })
  20282. return
  20283. } else {
  20284. if miConfig.MdtrtareaAdmvs != "150499" {
  20285. order.FaPiaoNumber = zero
  20286. order.FaPiaoCode = last_order.FaPiaoCode
  20287. service.UpdateOrder(order)
  20288. }
  20289. hisFundSettleListResult := &models.HisFundSettleListResult{
  20290. Number: res.Output.SetlListId,
  20291. Status: 1,
  20292. Ctime: time.Now().Unix(),
  20293. Mtime: time.Now().Unix(),
  20294. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20295. IsUpload: 1,
  20296. OrderId: order_id,
  20297. }
  20298. service.CreateUploadRecord(hisFundSettleListResult)
  20299. c.ServeSuccessJSON(map[string]interface{}{
  20300. "msg": "上传成功",
  20301. "result": hisFundSettleListResult,
  20302. })
  20303. return
  20304. }
  20305. }
  20306. //func (c *HisApiController) GetBatchSettleList() {
  20307. // orders, _ := service.GetAllHisOrder(10106)
  20308. // for _, item := range orders {
  20309. // order_id := item.ID
  20310. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20311. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20312. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20313. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20314. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20315. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20316. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20317. //
  20318. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20319. //
  20320. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20321. //
  20322. // if order.ID == 0 {
  20323. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20324. // return
  20325. // }
  20326. // if his.BalanceAccountsType == 2 {
  20327. // continue
  20328. // }
  20329. // struct4101 := service.Struct4101{
  20330. // PsnNo: order.PsnNo,
  20331. // MdtrtId: order.MdtrtId,
  20332. // SetlId: order.SetlId,
  20333. // PsnName: order.PsnName,
  20334. // Gend: order.Gend,
  20335. // Brdy: his.Brdy,
  20336. // Age: his.Age,
  20337. // Naty: order.Naty,
  20338. // PatnCertType: "01",
  20339. // Certno: order.Certno,
  20340. // Prfs: "90",
  20341. // ConerName: roles[0].UserName,
  20342. // PatnRlts: "99",
  20343. // ConerAddr: miConfig.OrgName,
  20344. // ConerTel: admin.Mobile,
  20345. // HiType: order.Insutype,
  20346. // Insuplc: his.InsuplcAdmdvs,
  20347. // MaindiagFlag: "1",
  20348. // BillCode: order.SetlId,
  20349. // BillNo: order.SetlId,
  20350. // BizSn: order.Number,
  20351. // PsnSelfPay: order.PsnPartAmt,
  20352. // PsnOwnPay: order.PsnPartAmt,
  20353. // AcctPay: order.AcctPay,
  20354. // PsnCashpay: order.PsnCashPay,
  20355. // HiPaymtd: "1",
  20356. // Hsorg: his.InsuplcAdmdvs,
  20357. // HsorgOpter: his.InsuplcAdmdvs,
  20358. // MedinsFillPsn: curRoles.UserName,
  20359. // MedinsFillDept: depart.Name,
  20360. // IptMedType: "2",
  20361. // }
  20362. // struct4101.SetlBegnDate = order.SetlTime
  20363. // struct4101.SetlEndDate = order.SetlTime
  20364. // //if order.SettleType == 1 {
  20365. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20366. // // dateStr := t.Format("2006-01-02")
  20367. // // struct4101.SetlBegnDate = dateStr
  20368. // // struct4101.SetlEndDate = dateStr
  20369. // //} else {
  20370. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20371. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20372. // // dateStartStr := t.Format("2006-01-02")
  20373. // // dateEndStr := t2.Format("2006-01-02")
  20374. // // struct4101.SetlBegnDate = dateStartStr
  20375. // // struct4101.SetlEndDate = dateEndStr
  20376. // //}
  20377. //
  20378. // var rf []CustomFundPay
  20379. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20380. //
  20381. // var tempFunPays []service.CustomStruct
  20382. // var tempFunPay610100 service.CustomStruct
  20383. //
  20384. // for _, item := range rf {
  20385. // if item.FundPayType == "610100" {
  20386. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20387. // tempFunPay610100.FundPayType = item.FundPayType
  20388. // } else {
  20389. // var tempFunPay service.CustomStruct
  20390. // tempFunPay.FundPayamt = item.FundPayamt
  20391. // tempFunPay.FundPayType = item.FundPayType
  20392. // tempFunPays = append(tempFunPays, tempFunPay)
  20393. // }
  20394. // }
  20395. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20396. // struct4101.CustomStruct = tempFunPays
  20397. //
  20398. // var tempDiaginfos []service.DiaginfoStructTwo
  20399. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20400. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20401. //
  20402. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20403. // var config []*models.HisXtDiagnoseConfig
  20404. // for _, item := range diagnosis_ids {
  20405. // id, _ := strconv.ParseInt(item, 10, 64)
  20406. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20407. // config = append(config, &diagnosisConfig)
  20408. // }
  20409. //
  20410. // for index, item := range config {
  20411. // if index == 0 {
  20412. // var tempDiaginfo service.DiaginfoStructTwo
  20413. // tempDiaginfo.DiagCode = item.CountryCode
  20414. // tempDiaginfo.DiagName = item.CountryContentName
  20415. // tempDiaginfo.DiagType = "1"
  20416. // tempDiaginfo.MaindiagFlag = "1"
  20417. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20418. // } else {
  20419. //
  20420. // var tempDiaginfo service.DiaginfoStructTwo
  20421. // tempDiaginfo.DiagCode = item.CountryCode
  20422. // tempDiaginfo.DiagName = item.CountryContentName
  20423. // tempDiaginfo.DiagType = "2"
  20424. // tempDiaginfo.MaindiagFlag = "0"
  20425. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20426. // }
  20427. // }
  20428. // struct4101.Diseinfo = tempDiaginfos
  20429. //
  20430. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20431. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20432. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20433. // tempOpspdiseinfo2.OprnOprtCode = ""
  20434. // tempOpspdiseinfo2.OprnOprtName = ""
  20435. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20436. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20437. //
  20438. // var iteminfo service.IteminfoStruct
  20439. //
  20440. // var bedCostTotal float64 = 0 //床位总费
  20441. // var bedCostSelfTotal float64 = 0 //床位自费
  20442. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20443. //
  20444. // var examineCostTotal float64 = 0 //诊查总费
  20445. // var examineCostSelfTotal float64 = 0 //诊查自费
  20446. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  20447. //
  20448. // var nursingCostTotal float64 = 0 //护理总费
  20449. // var nursingCostSelfTotal float64 = 0 //护理自费
  20450. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  20451. //
  20452. // var chineseMedicineCostTotal float64 = 0 //中成药
  20453. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  20454. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  20455. //
  20456. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  20457. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  20458. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  20459. //
  20460. // var registerCostTotal float64 = 0 //一般诊疗费
  20461. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  20462. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  20463. //
  20464. // var operationCostTotal float64 = 0 //手术费
  20465. // var operationCostSelfTotal float64 = 0 //手术费
  20466. // var operationCostPartSelfTotal float64 = 0 //手术费
  20467. //
  20468. // var otherCostTotal float64 = 0 //其他费用
  20469. // var otherCostSelfTotal float64 = 0 //其他费用
  20470. // var otherCostPartSelfTotal float64 = 0 //其他费用
  20471. //
  20472. // var materialCostTotal float64 = 0 //材料费
  20473. // var materialCostSelfTotal float64 = 0 //材料费
  20474. // var materialCostPartSelfTotal float64 = 0 //材料费
  20475. //
  20476. // var westernMedicineCostTotal float64 = 0 //西药费
  20477. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  20478. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20479. //
  20480. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20481. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20482. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20483. //
  20484. // var checkCostTotal float64 = 0 //检查费
  20485. // var checkCostSelfTotal float64 = 0 //检查费
  20486. // var checkCostPartSelfTotal float64 = 0 //检查费
  20487. //
  20488. // var laboratoryCostTotal float64 = 0 //化验费
  20489. // var laboratoryCostSelfTotal float64 = 0 //化验费
  20490. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20491. //
  20492. // var treatCostTotal float64 = 0 //治疗费用
  20493. // var treatCostSelfTotal float64 = 0 //治疗费用
  20494. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  20495. //
  20496. // decimal.DivisionPrecision = 2
  20497. //
  20498. // var bed_fulamt_ownpay_amt float64 = 0
  20499. //
  20500. // var examine_fulamt_ownpay_amt float64 = 0
  20501. //
  20502. // var nursing_fulamt_ownpay_amt float64 = 0
  20503. //
  20504. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  20505. //
  20506. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  20507. //
  20508. // var register_fulamt_ownpay_amt float64 = 0
  20509. //
  20510. // var operation_fulamt_ownpay_amt float64 = 0
  20511. // var other_fulamt_ownpay_amt float64 = 0
  20512. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  20513. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20514. // var check_fulamt_ownpay_amt float64 = 0
  20515. // var material_fulamt_ownpay_amt float64 = 0
  20516. // var laboratory_fulamt_ownpay_amt float64 = 0
  20517. // var treat_fulamt_ownpay_amt float64 = 0
  20518. //
  20519. // var bed_claa_sunmfee float64 = 0
  20520. // var bed_clab_amt float64 = 0
  20521. // var bed_other_amt float64 = 0
  20522. //
  20523. // var examine_claa_sunmfee float64 = 0
  20524. // var examine_clab_amt float64 = 0
  20525. // var examine_other_amt float64 = 0
  20526. //
  20527. // var nursing_claa_sunmfee float64 = 0
  20528. // var nursing_clab_amt float64 = 0
  20529. // var nursing_other_amt float64 = 0
  20530. //
  20531. // var chinese_medicine_claa_sunmfee float64 = 0
  20532. // var chinese_medicine_clab_amt float64 = 0
  20533. // var chinese_medicine_other_amt float64 = 0
  20534. //
  20535. // var commonly_treatment_claa_sunmfee float64 = 0
  20536. // var commonly_treatment_clab_amt float64 = 0
  20537. // var commonly_treatment_other_amt float64 = 0
  20538. //
  20539. // var operation_claa_sunmfee float64 = 0
  20540. // var operation_clab_amt float64 = 0
  20541. // var operation_other_amt float64 = 0
  20542. //
  20543. // var other_claa_sunmfee float64 = 0
  20544. // var other_clab_amt float64 = 0
  20545. // var other_other_amt float64 = 0
  20546. //
  20547. // var westernMedicine_claa_sunmfee float64 = 0
  20548. // var westernMedicine_clab_amt float64 = 0
  20549. // var westernMedicine_other_amt float64 = 0
  20550. //
  20551. // var chineseTraditional_claa_sunmfee float64 = 0
  20552. // var chineseTraditional_clab_amt float64 = 0
  20553. // var chineseTraditional_other_amt float64 = 0
  20554. //
  20555. // var check_claa_sunmfee float64 = 0
  20556. // var check_clab_amt float64 = 0
  20557. // var check_other_amt float64 = 0
  20558. //
  20559. // var material_claa_sunmfee float64 = 0
  20560. // var material_clab_amt float64 = 0
  20561. // var material_other_amt float64 = 0
  20562. //
  20563. // var laboratory_claa_sunmfee float64 = 0
  20564. // var laboratory_clab_amt float64 = 0
  20565. // var laboratory_other_amt float64 = 0
  20566. //
  20567. // var treat_claa_sunmfee float64 = 0
  20568. // var treat_clab_amt float64 = 0
  20569. // var treat_other_amt float64 = 0
  20570. //
  20571. // var register_claa_sunmfee float64 = 0
  20572. // var register_clab_amt float64 = 0
  20573. // var register_other_amt float64 = 0
  20574. //
  20575. // for _, item := range order.HisOrderInfo {
  20576. // if item.MedChrgitmType == "01" { //床位费
  20577. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20578. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20579. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20580. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20581. // if item.ChrgitmLv == "1" {
  20582. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20583. // }
  20584. // if item.ChrgitmLv == "2" {
  20585. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20586. //
  20587. // }
  20588. // if item.ChrgitmLv == "3" {
  20589. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20590. // }
  20591. //
  20592. // }
  20593. //
  20594. // if item.MedChrgitmType == "02" { //诊查
  20595. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20596. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20597. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20598. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20599. // if item.ChrgitmLv == "1" {
  20600. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20601. // }
  20602. // if item.ChrgitmLv == "2" {
  20603. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20604. //
  20605. // }
  20606. // if item.ChrgitmLv == "3" {
  20607. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20608. // }
  20609. //
  20610. // }
  20611. //
  20612. // if item.MedChrgitmType == "03" { //检查费
  20613. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20614. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20615. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20616. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20617. // if item.ChrgitmLv == "1" {
  20618. //
  20619. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20620. //
  20621. // }
  20622. // if item.ChrgitmLv == "2" {
  20623. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20624. //
  20625. // }
  20626. // if item.ChrgitmLv == "3" {
  20627. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20628. // }
  20629. // }
  20630. //
  20631. // if item.MedChrgitmType == "04" { //化验费
  20632. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20633. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20634. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20635. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20636. // if item.ChrgitmLv == "1" {
  20637. //
  20638. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20639. //
  20640. // }
  20641. // if item.ChrgitmLv == "2" {
  20642. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20643. //
  20644. // }
  20645. // if item.ChrgitmLv == "3" {
  20646. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20647. // }
  20648. // }
  20649. //
  20650. // if item.MedChrgitmType == "05" { //治疗费
  20651. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20652. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20653. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20654. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20655. // if item.ChrgitmLv == "1" {
  20656. //
  20657. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20658. //
  20659. // }
  20660. // if item.ChrgitmLv == "2" {
  20661. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20662. //
  20663. // }
  20664. // if item.ChrgitmLv == "3" {
  20665. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20666. // }
  20667. // }
  20668. //
  20669. // if item.MedChrgitmType == "06" { //手术费
  20670. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20671. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20672. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20673. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20674. //
  20675. // if item.ChrgitmLv == "1" {
  20676. //
  20677. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20678. //
  20679. // }
  20680. // if item.ChrgitmLv == "2" {
  20681. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20682. //
  20683. // }
  20684. // if item.ChrgitmLv == "3" {
  20685. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20686. // }
  20687. // }
  20688. //
  20689. // if item.MedChrgitmType == "07" { //手术费
  20690. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20691. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20692. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20693. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20694. //
  20695. // if item.ChrgitmLv == "1" {
  20696. //
  20697. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20698. //
  20699. // }
  20700. // if item.ChrgitmLv == "2" {
  20701. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20702. //
  20703. // }
  20704. // if item.ChrgitmLv == "3" {
  20705. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20706. // }
  20707. // }
  20708. //
  20709. // if item.MedChrgitmType == "08" { //材料费
  20710. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20711. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20712. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20713. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20714. // if item.ChrgitmLv == "1" {
  20715. //
  20716. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20717. //
  20718. // }
  20719. // if item.ChrgitmLv == "2" {
  20720. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20721. //
  20722. // }
  20723. // if item.ChrgitmLv == "3" {
  20724. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20725. // }
  20726. // }
  20727. // if item.MedChrgitmType == "09" { //西药费
  20728. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20729. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20730. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20731. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20732. // if item.ChrgitmLv == "1" {
  20733. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20734. // }
  20735. // if item.ChrgitmLv == "2" {
  20736. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20737. // }
  20738. // if item.ChrgitmLv == "3" {
  20739. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20740. // }
  20741. // }
  20742. // if item.MedChrgitmType == "10" { //中药饮片
  20743. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20744. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20745. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20746. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20747. // if item.ChrgitmLv == "1" {
  20748. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20749. // }
  20750. // if item.ChrgitmLv == "2" {
  20751. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20752. // }
  20753. // if item.ChrgitmLv == "3" {
  20754. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20755. // }
  20756. // }
  20757. //
  20758. // if item.MedChrgitmType == "11" { //中成费
  20759. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20760. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20761. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20762. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20763. // if item.ChrgitmLv == "1" {
  20764. //
  20765. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20766. //
  20767. // }
  20768. // if item.ChrgitmLv == "2" {
  20769. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20770. //
  20771. // }
  20772. // if item.ChrgitmLv == "3" {
  20773. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20774. // }
  20775. // }
  20776. //
  20777. // if item.MedChrgitmType == "12" { //中成费
  20778. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20779. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20780. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20781. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20782. // if item.ChrgitmLv == "1" {
  20783. //
  20784. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20785. //
  20786. // }
  20787. // if item.ChrgitmLv == "2" {
  20788. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20789. //
  20790. // }
  20791. // if item.ChrgitmLv == "3" {
  20792. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20793. // }
  20794. // }
  20795. //
  20796. // if item.MedChrgitmType == "13" { //中成费
  20797. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20798. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20799. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20800. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20801. // if item.ChrgitmLv == "1" {
  20802. //
  20803. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20804. //
  20805. // }
  20806. // if item.ChrgitmLv == "2" {
  20807. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20808. //
  20809. // }
  20810. // if item.ChrgitmLv == "3" {
  20811. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20812. // }
  20813. // }
  20814. //
  20815. // if item.MedChrgitmType == "14" { //其他费
  20816. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20817. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20818. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20819. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20820. // if item.ChrgitmLv == "1" {
  20821. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20822. //
  20823. // }
  20824. // if item.ChrgitmLv == "2" {
  20825. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20826. //
  20827. // }
  20828. // if item.ChrgitmLv == "3" {
  20829. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20830. // }
  20831. // }
  20832. //
  20833. // }
  20834. //
  20835. // var iteminfoStructs []service.IteminfoStruct
  20836. //
  20837. // if bedCostTotal != 0 {
  20838. // iteminfo.MedChrgitm = "01"
  20839. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20840. // iteminfo.Amt = bedCostTotal
  20841. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  20842. // iteminfo.ClabAmt = bed_clab_amt
  20843. // iteminfo.OthAmt = bed_other_amt
  20844. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20845. // }
  20846. //
  20847. // if examineCostTotal != 0 {
  20848. // iteminfo.MedChrgitm = "02"
  20849. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  20850. // iteminfo.Amt = examineCostTotal
  20851. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  20852. // iteminfo.ClabAmt = examine_clab_amt
  20853. // iteminfo.OthAmt = examine_other_amt
  20854. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20855. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20856. // }
  20857. //
  20858. // if checkCostTotal != 0 {
  20859. // iteminfo.MedChrgitm = "03"
  20860. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20861. // iteminfo.Amt = checkCostTotal
  20862. // iteminfo.ClaaSumfee = check_claa_sunmfee
  20863. // iteminfo.ClabAmt = check_clab_amt
  20864. // iteminfo.OthAmt = check_other_amt
  20865. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20866. //
  20867. // }
  20868. //
  20869. // if laboratoryCostTotal != 0 {
  20870. // iteminfo.MedChrgitm = "04"
  20871. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20872. // iteminfo.Amt = laboratoryCostTotal
  20873. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20874. // iteminfo.ClabAmt = laboratory_clab_amt
  20875. // iteminfo.OthAmt = laboratory_other_amt
  20876. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20877. //
  20878. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20879. //
  20880. // }
  20881. //
  20882. // if treatCostTotal != 0 {
  20883. // iteminfo.MedChrgitm = "05"
  20884. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20885. // iteminfo.Amt = treatCostTotal
  20886. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  20887. // iteminfo.ClabAmt = treat_clab_amt
  20888. // iteminfo.OthAmt = treat_other_amt
  20889. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20890. // //(struct4101.IteminfoStruct, iteminfo)
  20891. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20892. // }
  20893. //
  20894. // if operationCostTotal != 0 {
  20895. // iteminfo.MedChrgitm = "06"
  20896. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20897. // iteminfo.Amt = operationCostTotal
  20898. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  20899. // iteminfo.ClabAmt = operation_clab_amt
  20900. // iteminfo.OthAmt = operation_other_amt
  20901. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20902. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20903. // }
  20904. //
  20905. // if nursingCostTotal != 0 {
  20906. // iteminfo.MedChrgitm = "07"
  20907. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  20908. // iteminfo.Amt = nursingCostTotal
  20909. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  20910. // iteminfo.ClabAmt = nursing_clab_amt
  20911. // iteminfo.OthAmt = nursing_other_amt
  20912. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20913. // }
  20914. //
  20915. // if materialCostTotal != 0 {
  20916. // iteminfo.MedChrgitm = "08"
  20917. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20918. // iteminfo.Amt = materialCostTotal
  20919. // iteminfo.ClaaSumfee = material_claa_sunmfee
  20920. // iteminfo.ClabAmt = material_clab_amt
  20921. // iteminfo.OthAmt = material_other_amt
  20922. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20923. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20924. // }
  20925. //
  20926. // if westernMedicineCostTotal != 0 {
  20927. // iteminfo.MedChrgitm = "09"
  20928. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20929. // iteminfo.Amt = westernMedicineCostTotal
  20930. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20931. // iteminfo.ClabAmt = westernMedicine_clab_amt
  20932. // iteminfo.OthAmt = westernMedicine_other_amt
  20933. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20934. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20935. //
  20936. // }
  20937. //
  20938. // if chineseMedicineCostTotal != 0 {
  20939. // iteminfo.MedChrgitm = "10"
  20940. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  20941. // iteminfo.Amt = chineseMedicineCostTotal
  20942. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  20943. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  20944. // iteminfo.OthAmt = chinese_medicine_other_amt
  20945. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20946. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20947. //
  20948. // }
  20949. //
  20950. // if chineseTraditionalMedicineCostTotal != 0 {
  20951. // iteminfo.MedChrgitm = "11"
  20952. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20953. // iteminfo.Amt = westernMedicineCostTotal
  20954. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20955. // iteminfo.ClabAmt = westernMedicine_clab_amt
  20956. // iteminfo.OthAmt = westernMedicine_other_amt
  20957. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20958. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20959. //
  20960. // }
  20961. //
  20962. // if commonlyTreatmentCostTotal != 0 {
  20963. // iteminfo.MedChrgitm = "12"
  20964. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  20965. // iteminfo.Amt = commonlyTreatmentCostTotal
  20966. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  20967. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  20968. // iteminfo.OthAmt = commonly_treatment_other_amt
  20969. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20970. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20971. //
  20972. // }
  20973. //
  20974. // if registerCostTotal != 0 {
  20975. // iteminfo.MedChrgitm = "13"
  20976. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  20977. // iteminfo.Amt = registerCostTotal
  20978. // iteminfo.ClaaSumfee = register_claa_sunmfee
  20979. // iteminfo.ClabAmt = register_clab_amt
  20980. // iteminfo.OthAmt = register_other_amt
  20981. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20982. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20983. //
  20984. // }
  20985. //
  20986. // if otherCostTotal != 0 {
  20987. // iteminfo.MedChrgitm = "14"
  20988. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20989. // iteminfo.Amt = otherCostTotal
  20990. // iteminfo.ClaaSumfee = other_claa_sunmfee
  20991. // iteminfo.ClabAmt = other_clab_amt
  20992. // iteminfo.OthAmt = other_other_amt
  20993. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20994. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20995. //
  20996. // }
  20997. // struct4101.IteminfoStruct = iteminfoStructs
  20998. // time_arr := strings.Split(order.SetlTime, " ")
  20999. // struct4101.AdmTime = time_arr[0]
  21000. // struct4101.AdmEndTime = time_arr[0]
  21001. //
  21002. // struct4101.DoctorName = doctor.UserName
  21003. // struct4101.DoctorCode = doctor.DoctorNumber
  21004. //
  21005. // struct4101.Ntly = "中国"
  21006. // struct4101.AdmCaty = "A03.06"
  21007. // var res ResultSeventeen
  21008. // if miConfig.MdtrtareaAdmvs == "421300" {
  21009. // data := make(map[string]interface{})
  21010. // data["struct4101"] = struct4101
  21011. // data["secret_key"] = miConfig.SecretKey
  21012. // data["org_name"] = miConfig.OrgName
  21013. // data["opera"] = curRoles.UserName
  21014. // data["code"] = miConfig.Code
  21015. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21016. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21017. //
  21018. // client := &http.Client{}
  21019. // bytesData, _ := json.Marshal(data)
  21020. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21021. // resp, _ := client.Do(req)
  21022. // defer resp.Body.Close()
  21023. // body, ioErr := ioutil.ReadAll(resp.Body)
  21024. // if ioErr != nil {
  21025. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21026. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21027. // return
  21028. // }
  21029. // var respJSON map[string]interface{}
  21030. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21031. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21032. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21033. // return
  21034. // }
  21035. //
  21036. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21037. // userJSONBytes, _ := json.Marshal(respJSON)
  21038. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21039. // utils.ErrorLog("解析失败:%v", err)
  21040. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21041. // adminUser := c.GetAdminUserInfo()
  21042. // errlog := &models.HisOrderError{
  21043. // UserOrgId: adminUser.CurrentOrgId,
  21044. // Ctime: time.Now().Unix(),
  21045. // Mtime: time.Now().Unix(),
  21046. // ErrMsg: res.ErrMsg + "解析失败",
  21047. // Status: 1,
  21048. // PatientId: order_id,
  21049. // Stage: 10088,
  21050. // }
  21051. // service.CreateErrMsgLog(errlog)
  21052. // continue
  21053. // }
  21054. //
  21055. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  21056. // data := make(map[string]interface{})
  21057. // data["struct4101"] = struct4101
  21058. // data["secret_key"] = miConfig.SecretKey
  21059. // data["org_name"] = miConfig.OrgName
  21060. // data["opera"] = curRoles.UserName
  21061. // data["code"] = miConfig.Code
  21062. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21063. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21064. //
  21065. // client := &http.Client{}
  21066. // bytesData, _ := json.Marshal(data)
  21067. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21068. // resp, _ := client.Do(req)
  21069. // defer resp.Body.Close()
  21070. // body, ioErr := ioutil.ReadAll(resp.Body)
  21071. // if ioErr != nil {
  21072. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21073. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21074. // return
  21075. // }
  21076. // var respJSON map[string]interface{}
  21077. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21078. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21079. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21080. // return
  21081. // }
  21082. //
  21083. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21084. // userJSONBytes, _ := json.Marshal(respJSON)
  21085. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21086. // utils.ErrorLog("解析失败:%v", err)
  21087. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21088. // adminUser := c.GetAdminUserInfo()
  21089. // errlog := &models.HisOrderError{
  21090. // UserOrgId: adminUser.CurrentOrgId,
  21091. // Ctime: time.Now().Unix(),
  21092. // Mtime: time.Now().Unix(),
  21093. // ErrMsg: res.ErrMsg + "解析失败",
  21094. // Status: 1,
  21095. // PatientId: order_id,
  21096. // Stage: 10088,
  21097. // }
  21098. // service.CreateErrMsgLog(errlog)
  21099. // continue
  21100. // }
  21101. //
  21102. // } else {
  21103. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  21104. // fmt.Println(result)
  21105. //
  21106. // var dat map[string]interface{}
  21107. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21108. // fmt.Println(dat)
  21109. // } else {
  21110. // fmt.Println(err)
  21111. // }
  21112. // userJSONBytes, _ := json.Marshal(dat)
  21113. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21114. // utils.ErrorLog("解析失败:%v", err)
  21115. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21116. // adminUser := c.GetAdminUserInfo()
  21117. // errlog := &models.HisOrderError{
  21118. // UserOrgId: adminUser.CurrentOrgId,
  21119. // Ctime: time.Now().Unix(),
  21120. // Mtime: time.Now().Unix(),
  21121. // ErrMsg: res.ErrMsg + "解析失败",
  21122. // Status: 1,
  21123. // PatientId: order_id,
  21124. // Stage: 10106,
  21125. // }
  21126. // service.CreateErrMsgLog(errlog)
  21127. // continue
  21128. // }
  21129. // }
  21130. //
  21131. // if res.Infcode != 0 {
  21132. // adminUser := c.GetAdminUserInfo()
  21133. // errlog := &models.HisOrderError{
  21134. // UserOrgId: adminUser.CurrentOrgId,
  21135. // Ctime: time.Now().Unix(),
  21136. // Mtime: time.Now().Unix(),
  21137. // ErrMsg: res.ErrMsg,
  21138. // Status: 1,
  21139. // PatientId: order_id,
  21140. // Stage: 10106,
  21141. // }
  21142. // service.CreateErrMsgLog(errlog)
  21143. // continue
  21144. // } else {
  21145. // hisFundSettleListResult := &models.HisFundSettleListResult{
  21146. // Number: res.Output.SetlListId,
  21147. // Status: 1,
  21148. // Ctime: time.Now().Unix(),
  21149. // Mtime: time.Now().Unix(),
  21150. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21151. // IsUpload: 1,
  21152. // OrderId: order_id,
  21153. // }
  21154. // service.CreateUploadRecord(hisFundSettleListResult)
  21155. // continue
  21156. // }
  21157. // }
  21158. //}
  21159. func (c *HisApiController) GetOrgInfo() {
  21160. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  21161. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  21162. }
  21163. func (c *HisApiController) GetHisPatientInfo() {
  21164. medical_insurance_card := c.GetString("medical_insurance_card")
  21165. id_card_type, _ := c.GetInt64("id_card_type")
  21166. id_card := c.GetString("id_card")
  21167. adminInfo := c.GetAdminUserInfo()
  21168. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21169. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21170. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  21171. IdCardNo := ""
  21172. if id_card_type == 1 {
  21173. IdCardNo = medical_insurance_card
  21174. } else if id_card_type == 2 {
  21175. IdCardNo = id_card
  21176. }
  21177. if config.IsOpen == 1 {
  21178. 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
  21179. resp, requestErr := http.Get(api)
  21180. if requestErr != nil {
  21181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21182. return
  21183. }
  21184. defer resp.Body.Close()
  21185. body, ioErr := ioutil.ReadAll(resp.Body)
  21186. if ioErr != nil {
  21187. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21189. return
  21190. }
  21191. var respJSON map[string]interface{}
  21192. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21193. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21195. return
  21196. }
  21197. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21198. userJSONBytes, _ := json.Marshal(userJSON)
  21199. var res ResultTwo
  21200. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21201. utils.ErrorLog("解析失败:%v", err)
  21202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21203. return
  21204. }
  21205. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21206. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21207. infoStr := string(Iinfos)
  21208. idetinfoStr := string(Idetinfos)
  21209. if res.Infcode == 0 {
  21210. his := models.VMHisPatient{
  21211. Status: 1,
  21212. Ctime: time.Now().Unix(),
  21213. Mtime: time.Now().Unix(),
  21214. PsnNo: res.Output.Baseinfo.PsnNo,
  21215. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21216. Certno: res.Output.Baseinfo.Certno,
  21217. PsnName: res.Output.Baseinfo.PsnName,
  21218. Gend: res.Output.Baseinfo.Gend,
  21219. Naty: res.Output.Baseinfo.Naty,
  21220. Iinfo: infoStr,
  21221. Idetinfo: idetinfoStr,
  21222. UserOrgId: adminInfo.CurrentOrgId,
  21223. IsReturn: 1,
  21224. IdCardType: id_card_type,
  21225. }
  21226. c.ServeSuccessJSON(map[string]interface{}{
  21227. "info": his,
  21228. })
  21229. } else {
  21230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21231. return
  21232. }
  21233. }
  21234. }
  21235. //func GetBasBaseInfo() (jsonStr string, err error) {
  21236. //
  21237. // handle := syscall.NewLazyDLL("SSCard.dll")
  21238. // add := handle.NewProc("ReadCardBas")
  21239. // str := make([]byte, 1024)
  21240. // str1 := make([]byte, 1024)
  21241. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21242. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  21243. //
  21244. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  21245. //
  21246. // fmt.Println("> Add(4,5)的结果为:", ret)
  21247. // handle.Release()
  21248. //
  21249. // return "", nil
  21250. //
  21251. //}
  21252. //func GetQRBaseInfo() (jsonStr string, err error) {
  21253. // handle := syscall.LoadDLL("SSCard.dll")
  21254. // ReadCardBas := handle.FindProc("GetQRBase")
  21255. //
  21256. // str := make([]byte, 256)
  21257. // str1 := make([]byte, 256)
  21258. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21259. //
  21260. // fmt.Println(string(str))
  21261. // fmt.Println(r)
  21262. // return string(str), nil
  21263. //}
  21264. //func CardInit() int {
  21265. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21266. // add := DllTestDef.MustFindProc("Init")
  21267. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21268. // if err != nil {
  21269. // fmt.Println("SSCard的运算结果为:", ret)
  21270. // }
  21271. // result := int(ret)
  21272. // return result
  21273. //}
  21274. //func CardInit() int {
  21275. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21276. // if err != nil {
  21277. // fmt.Println("SSCard的运算结果为:", ret)
  21278. // }
  21279. // fmt.Println(err)
  21280. // result := int(ret)
  21281. // return result
  21282. //}
  21283. func IntPtr(n int) uintptr {
  21284. return uintptr(n)
  21285. }
  21286. func StrPtr(s string) uintptr {
  21287. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21288. }
  21289. type Result2001 struct {
  21290. Cainfo interface{} `json:"cainfo"`
  21291. ErrMsg string `json:"err_msg"`
  21292. InfRefmsgid string `json:"inf_refmsgid"`
  21293. Infcode int64 `json:"infcode"`
  21294. Output struct {
  21295. Trtinfo struct {
  21296. PsnNo string `json:"psn_no"`
  21297. TrtChkType string `json:"trt_chk_type"`
  21298. FundPayType string `json:"fund_pay_type"`
  21299. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21300. Begndate string `json:"begndate"`
  21301. Enddate string `json:"enddate"`
  21302. TrtChkRslt string `json:"trt_chk_rslt"`
  21303. } `json:"trtinfo"`
  21304. } `json:"output"`
  21305. RefmsgTime string `json:"refmsg_time"`
  21306. RespondTime string `json:"respond_time"`
  21307. Signtype interface{} `json:"signtype"`
  21308. WarnMsg interface{} `json:"warn_msg"`
  21309. }
  21310. type Result2001Org10265 struct {
  21311. Cainfo interface{} `json:"cainfo"`
  21312. ErrMsg string `json:"err_msg"`
  21313. InfRefmsgid string `json:"inf_refmsgid"`
  21314. Infcode string `json:"infcode"`
  21315. Output struct {
  21316. Trtinfo struct {
  21317. PsnNo string `json:"psn_no"`
  21318. TrtChkType string `json:"trt_chk_type"`
  21319. FundPayType string `json:"fund_pay_type"`
  21320. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21321. Begndate string `json:"begndate"`
  21322. Enddate string `json:"enddate"`
  21323. TrtChkRslt string `json:"trt_chk_rslt"`
  21324. } `json:"trtinfo"`
  21325. } `json:"output"`
  21326. RefmsgTime string `json:"refmsg_time"`
  21327. RespondTime string `json:"respond_time"`
  21328. Signtype interface{} `json:"signtype"`
  21329. WarnMsg interface{} `json:"warn_msg"`
  21330. }
  21331. type ResultTwo struct {
  21332. ErrMsg string `json:"err_msg"`
  21333. InfRefmsgid string `json:"inf_refmsgid"`
  21334. Infcode int64 `json:"infcode"`
  21335. Output struct {
  21336. Baseinfo struct {
  21337. //Brdy string `json:"brdy"`
  21338. Certno string `json:"certno"`
  21339. Gend string `json:"gend"`
  21340. Naty string `json:"naty"`
  21341. PsnCertType string `json:"psn_cert_type"`
  21342. PsnName string `json:"psn_name"`
  21343. PsnNo string `json:"psn_no"`
  21344. } `json:"baseinfo"`
  21345. Idetinfo []interface{} `json:"idetinfo"`
  21346. Iinfo []struct {
  21347. Balc float64 `json:"balc"`
  21348. CvlservFlag string `json:"cvlserv_flag"`
  21349. EmpName string `json:"emp_name"`
  21350. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21351. Insutype string `json:"insutype"`
  21352. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21353. //PausInsuDate string `json:"paus_insu_date"`
  21354. //PsnInsuDate string `json:"psn_insu_date"`
  21355. PsnInsuStas string `json:"psn_insu_stas"`
  21356. PsnType string `json:"psn_type"`
  21357. } `json:"insuinfo"`
  21358. } `json:"output"`
  21359. RefmsgTime string `json:"refmsg_time"`
  21360. RespondTime string `json:"respond_time"`
  21361. Signtype interface{} `json:"signtype"`
  21362. WarnInfo interface{} `json:"warn_info"`
  21363. }
  21364. type ResultTwo10265 struct {
  21365. ErrMsg string `json:"err_msg"`
  21366. InfRefmsgid string `json:"inf_refmsgid"`
  21367. Infcode string `json:"infcode"`
  21368. Output struct {
  21369. Baseinfo struct {
  21370. //Brdy string `json:"brdy"`
  21371. Certno string `json:"certno"`
  21372. Gend string `json:"gend"`
  21373. Naty string `json:"naty"`
  21374. PsnCertType string `json:"psn_cert_type"`
  21375. PsnName string `json:"psn_name"`
  21376. PsnNo string `json:"psn_no"`
  21377. } `json:"baseinfo"`
  21378. Idetinfo []interface{} `json:"idetinfo"`
  21379. Iinfo []struct {
  21380. Balc float64 `json:"balc"`
  21381. CvlservFlag string `json:"cvlserv_flag"`
  21382. EmpName string `json:"emp_name"`
  21383. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21384. Insutype string `json:"insutype"`
  21385. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21386. PsnInsuStas string `json:"psn_insu_stas"`
  21387. PsnType string `json:"psn_type"`
  21388. } `json:"insuinfo"`
  21389. } `json:"output"`
  21390. RefmsgTime string `json:"refmsg_time"`
  21391. RespondTime string `json:"respond_time"`
  21392. Signtype interface{} `json:"signtype"`
  21393. WarnInfo interface{} `json:"warn_info"`
  21394. }
  21395. type ResultThree struct {
  21396. Cainfo interface{} `json:"cainfo"`
  21397. ErrMsg string `json:"err_msg"`
  21398. InfRefmsgid string `json:"inf_refmsgid"`
  21399. Infcode int64 `json:"infcode"`
  21400. Output struct {
  21401. Data struct {
  21402. IptOtpNo string `json:"ipt_otp_no"`
  21403. MdtrtID string `json:"mdtrt_id"`
  21404. PsnNo string `json:"psn_no"`
  21405. } `json:"data"`
  21406. } `json:"output"`
  21407. RefmsgTime string `json:"refmsg_time"`
  21408. RespondTime string `json:"respond_time"`
  21409. Signtype interface{} `json:"signtype"`
  21410. WarnMsg interface{} `json:"warn_msg"`
  21411. }
  21412. type ResultThree10265 struct {
  21413. Cainfo interface{} `json:"cainfo"`
  21414. ErrMsg string `json:"err_msg"`
  21415. InfRefmsgid string `json:"inf_refmsgid"`
  21416. Infcode string `json:"infcode"`
  21417. Output struct {
  21418. Data struct {
  21419. IptOtpNo string `json:"ipt_otp_no"`
  21420. MdtrtID string `json:"mdtrt_id"`
  21421. PsnNo string `json:"psn_no"`
  21422. } `json:"data"`
  21423. } `json:"output"`
  21424. RefmsgTime string `json:"refmsg_time"`
  21425. RespondTime string `json:"respond_time"`
  21426. Signtype interface{} `json:"signtype"`
  21427. WarnMsg interface{} `json:"warn_msg"`
  21428. }
  21429. type ResultFour struct {
  21430. Cainfo string `json:"cainfo"`
  21431. ErrMsg string `json:"err_msg"`
  21432. InfRefmsgid string `json:"inf_refmsgid"`
  21433. Infcode int64 `json:"infcode"`
  21434. Output struct {
  21435. Result []struct {
  21436. BasMednFlag string `json:"bas_medn_flag"`
  21437. ChldMedcFlag string `json:"chld_medc_flag"`
  21438. ChrgitmLv string `json:"chrgitm_lv"`
  21439. Cnt float64 `json:"cnt"`
  21440. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21441. DrtReimFlag string `json:"drt_reim_flag"`
  21442. FeedetlSn string `json:"feedetl_sn"`
  21443. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21444. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21445. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21446. ListSpItemFlag string `json:"list_sp_item_flag"`
  21447. LmtUsedFlag string `json:"lmt_used_flag"`
  21448. MedChrgitmType string `json:"med_chrgitm_type"`
  21449. Memo string `json:"memo"`
  21450. OverlmtAmt float64 `json:"overlmt_amt"`
  21451. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21452. Pric float64 `json:"pric"`
  21453. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21454. SelfpayProp float64 `json:"selfpay_prop"`
  21455. } `json:"result"`
  21456. } `json:"output"`
  21457. RefmsgTime string `json:"refmsg_time"`
  21458. RespondTime string `json:"respond_time"`
  21459. Signtype string `json:"signtype"`
  21460. WarnMsg string `json:"warn_msg"`
  21461. }
  21462. type ResultFour10265 struct {
  21463. Cainfo string `json:"cainfo"`
  21464. ErrMsg string `json:"err_msg"`
  21465. InfRefmsgid string `json:"inf_refmsgid"`
  21466. Infcode string `json:"infcode"`
  21467. Output struct {
  21468. Result []struct {
  21469. BasMednFlag string `json:"bas_medn_flag"`
  21470. ChldMedcFlag string `json:"chld_medc_flag"`
  21471. ChrgitmLv string `json:"chrgitm_lv"`
  21472. Cnt float64 `json:"cnt"`
  21473. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21474. DrtReimFlag string `json:"drt_reim_flag"`
  21475. FeedetlSn string `json:"feedetl_sn"`
  21476. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21477. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21478. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21479. ListSpItemFlag string `json:"list_sp_item_flag"`
  21480. LmtUsedFlag string `json:"lmt_used_flag"`
  21481. MedChrgitmType string `json:"med_chrgitm_type"`
  21482. Memo string `json:"memo"`
  21483. OverlmtAmt float64 `json:"overlmt_amt"`
  21484. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21485. Pric float64 `json:"pric"`
  21486. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21487. SelfpayProp float64 `json:"selfpay_prop"`
  21488. } `json:"result"`
  21489. } `json:"output"`
  21490. RefmsgTime string `json:"refmsg_time"`
  21491. RespondTime string `json:"respond_time"`
  21492. Signtype string `json:"signtype"`
  21493. WarnMsg string `json:"warn_msg"`
  21494. }
  21495. type ResultMemo struct {
  21496. InsuAdmdvs string `json:"insuAdmdvs"`
  21497. }
  21498. // [{"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}]
  21499. type ResultIDInfo struct {
  21500. Begntime string `json:"begntime"`
  21501. Endtime string `json:"endtime"`
  21502. Memo string `json:"memo"`
  21503. }
  21504. type ResultFive struct {
  21505. Balc float64 `json:"balc"`
  21506. CvlservFlag string `json:"cvlserv_flag"`
  21507. EmpName string `json:"emp_name"`
  21508. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21509. Insutype string `json:"insutype"`
  21510. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21511. PausInsuDate string `json:"paus_insu_date"`
  21512. PsnInsuDate string `json:"psn_insu_date"`
  21513. PsnInsuStas string `json:"psn_insu_stas"`
  21514. PsnType string `json:"psn_type"`
  21515. }
  21516. type ResultSix struct {
  21517. Cainfo interface{} `json:"cainfo"`
  21518. ErrMsg string `json:"err_msg"`
  21519. InfRefmsgid string `json:"inf_refmsgid"`
  21520. Infcode int64 `json:"infcode"`
  21521. Output struct {
  21522. } `json:"output"`
  21523. RefmsgTime string `json:"refmsg_time"`
  21524. RespondTime string `json:"respond_time"`
  21525. Signtype interface{} `json:"signtype"`
  21526. WarnMsg interface{} `json:"warn_msg"`
  21527. }
  21528. type FJ3507Result struct {
  21529. Cainfo interface{} `json:"cainfo"`
  21530. ErrMsg string `json:"err_msg"`
  21531. InfRefmsgid string `json:"inf_refmsgid"`
  21532. Infcode int64 `json:"infcode"`
  21533. Output struct {
  21534. retRslt string `json:"retRslt"`
  21535. msgRslt string `json:"msgRslt"`
  21536. } `json:"output"`
  21537. RefmsgTime string `json:"refmsg_time"`
  21538. RespondTime string `json:"respond_time"`
  21539. Signtype interface{} `json:"signtype"`
  21540. WarnMsg interface{} `json:"warn_msg"`
  21541. }
  21542. type FJ3507ResultFor10188 struct {
  21543. Cainfo interface{} `json:"cainfo"`
  21544. ErrMsg string `json:"err_msg"`
  21545. InfRefmsgid string `json:"inf_refmsgid"`
  21546. Infcode string `json:"infcode"`
  21547. RefmsgTime string `json:"refmsg_time"`
  21548. RespondTime string `json:"respond_time"`
  21549. Signtype interface{} `json:"signtype"`
  21550. WarnMsg interface{} `json:"warn_msg"`
  21551. }
  21552. type Result2406 struct {
  21553. Cainfo interface{} `json:"cainfo"`
  21554. ErrMsg string `json:"err_msg"`
  21555. InfRefmsgid string `json:"inf_refmsgid"`
  21556. Infcode int64 `json:"infcode"`
  21557. Output struct {
  21558. Result struct {
  21559. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  21560. } `json:"result"`
  21561. } `json:"output"`
  21562. RefmsgTime string `json:"refmsg_time"`
  21563. RespondTime string `json:"respond_time"`
  21564. Signtype interface{} `json:"signtype"`
  21565. WarnMsg interface{} `json:"warn_msg"`
  21566. }
  21567. type GZResultSix struct {
  21568. Cainfo interface{} `json:"cainfo"`
  21569. ErrMsg string `json:"err_msg"`
  21570. InfRefmsgid string `json:"inf_refmsgid"`
  21571. Infcode int64 `json:"infcode"`
  21572. Output string `json:"output"`
  21573. RefmsgTime string `json:"refmsg_time"`
  21574. RespondTime string `json:"respond_time"`
  21575. Signtype interface{} `json:"signtype"`
  21576. WarnMsg interface{} `json:"warn_msg"`
  21577. }
  21578. type ResultSix10265 struct {
  21579. Cainfo interface{} `json:"cainfo"`
  21580. ErrMsg string `json:"err_msg"`
  21581. InfRefmsgid string `json:"inf_refmsgid"`
  21582. Infcode string `json:"infcode"`
  21583. Output struct {
  21584. } `json:"output"`
  21585. RefmsgTime string `json:"refmsg_time"`
  21586. RespondTime string `json:"respond_time"`
  21587. Signtype interface{} `json:"signtype"`
  21588. WarnMsg interface{} `json:"warn_msg"`
  21589. }
  21590. type ResultSeven struct {
  21591. Cainfo string `json:"cainfo"`
  21592. ErrMsg string `json:"err_msg"`
  21593. InfRefmsgid string `json:"inf_refmsgid"`
  21594. Infcode int64 `json:"infcode"`
  21595. Output struct {
  21596. Setlinfo struct {
  21597. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21598. AcctPay float64 `json:"acct_pay"`
  21599. ActPayDedc float64 `json:"act_pay_dedc"`
  21600. Age float64 `json:"age"`
  21601. Balc float64 `json:"balc"`
  21602. Certno string `json:"certno"`
  21603. ClrOptins string `json:"clr_optins"`
  21604. ClrType string `json:"clr_type"`
  21605. ClrWay string `json:"clr_way"`
  21606. CvlservFlag string `json:"cvlserv_flag"`
  21607. CvlservPay float64 `json:"cvlserv_pay"`
  21608. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21609. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21610. Gend string `json:"gend"`
  21611. HifesPay float64 `json:"hifes_pay"`
  21612. HifmiPay float64 `json:"hifmi_pay"`
  21613. HifpPay float64 `json:"hifp_pay"`
  21614. HospPartAmt float64 `json:"hosp_part_amt"`
  21615. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21616. Insutype string `json:"insutype"`
  21617. MafPay float64 `json:"maf_pay"`
  21618. MdtrtCertType string `json:"mdtrt_cert_type"`
  21619. HifobPay float64 `json:"hifob_pay"`
  21620. MdtrtID string `json:"mdtrt_id"`
  21621. MedType string `json:"med_type"`
  21622. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21623. MedinsSetlID string `json:"medins_setl_id"`
  21624. Naty string `json:"naty"`
  21625. OthPay float64 `json:"oth_pay"`
  21626. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21627. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21628. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21629. PsnCashPay float64 `json:"psn_cash_pay"`
  21630. PsnCertType string `json:"psn_cert_type"`
  21631. PsnName string `json:"psn_name"`
  21632. PsnNo string `json:"psn_no"`
  21633. PsnPartAmt float64 `json:"psn_part_amt"`
  21634. PsnType string `json:"psn_type"`
  21635. SetlID string `json:"setl_id"`
  21636. SetlTime string `json:"setl_time"`
  21637. } `json:"setlinfo"`
  21638. Setldetail interface{} `json:"setldetail"`
  21639. } `json:"output"`
  21640. RefmsgTime string `json:"refmsg_time"`
  21641. RespondTime string `json:"respond_time"`
  21642. Signtype interface{} `json:"signtype"`
  21643. WarnMsg interface{} `json:"warn_msg"`
  21644. }
  21645. type ResultSevenAH struct {
  21646. Cainfo string `json:"cainfo"`
  21647. ErrMsg string `json:"err_msg"`
  21648. InfRefmsgid string `json:"inf_refmsgid"`
  21649. Infcode int64 `json:"infcode"`
  21650. Output struct {
  21651. Setlinfo struct {
  21652. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21653. AcctPay float64 `json:"acct_pay"`
  21654. ActPayDedc float64 `json:"act_pay_dedc"`
  21655. Age float64 `json:"age"`
  21656. Balc float64 `json:"balc"`
  21657. Certno string `json:"certno"`
  21658. ClrOptins string `json:"clr_optins"`
  21659. ClrType string `json:"clr_type"`
  21660. ClrWay string `json:"clr_way"`
  21661. CvlservFlag string `json:"cvlserv_flag"`
  21662. CvlservPay float64 `json:"cvlserv_pay"`
  21663. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21664. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21665. Gend string `json:"gend"`
  21666. HifesPay float64 `json:"hifes_pay"`
  21667. HifmiPay float64 `json:"hifmi_pay"`
  21668. HifpPay float64 `json:"hifp_pay"`
  21669. HospPartAmt float64 `json:"hosp_part_amt"`
  21670. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21671. Insutype string `json:"insutype"`
  21672. MafPay float64 `json:"maf_pay"`
  21673. MdtrtCertType string `json:"mdtrt_cert_type"`
  21674. HifobPay float64 `json:"hifob_pay"`
  21675. MdtrtID string `json:"mdtrt_id"`
  21676. MedType string `json:"med_type"`
  21677. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21678. MedinsSetlID string `json:"medins_setl_id"`
  21679. Naty string `json:"naty"`
  21680. OthPay float64 `json:"oth_pay"`
  21681. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21682. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21683. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21684. PsnCashPay float64 `json:"psn_cash_pay"`
  21685. PsnCertType string `json:"psn_cert_type"`
  21686. PsnName string `json:"psn_name"`
  21687. PsnNo string `json:"psn_no"`
  21688. PsnPartAmt float64 `json:"psn_part_amt"`
  21689. PsnType string `json:"psn_type"`
  21690. SetlID string `json:"setl_id"`
  21691. SetlTime int64 `json:"setl_time"`
  21692. } `json:"setlinfo"`
  21693. Setldetail interface{} `json:"setldetail"`
  21694. } `json:"output"`
  21695. RefmsgTime string `json:"refmsg_time"`
  21696. RespondTime string `json:"respond_time"`
  21697. Signtype interface{} `json:"signtype"`
  21698. WarnMsg interface{} `json:"warn_msg"`
  21699. }
  21700. type ResultSeven10265 struct {
  21701. Cainfo string `json:"cainfo"`
  21702. ErrMsg string `json:"err_msg"`
  21703. InfRefmsgid string `json:"inf_refmsgid"`
  21704. Infcode string `json:"infcode"`
  21705. Output struct {
  21706. Setlinfo struct {
  21707. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21708. AcctPay float64 `json:"acct_pay"`
  21709. ActPayDedc float64 `json:"act_pay_dedc"`
  21710. Age float64 `json:"age"`
  21711. Balc float64 `json:"balc"`
  21712. Certno string `json:"certno"`
  21713. ClrOptins string `json:"clr_optins"`
  21714. ClrType string `json:"clr_type"`
  21715. ClrWay string `json:"clr_way"`
  21716. CvlservFlag string `json:"cvlserv_flag"`
  21717. CvlservPay float64 `json:"cvlserv_pay"`
  21718. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21719. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21720. Gend string `json:"gend"`
  21721. HifesPay float64 `json:"hifes_pay"`
  21722. HifmiPay float64 `json:"hifmi_pay"`
  21723. HifpPay float64 `json:"hifp_pay"`
  21724. HospPartAmt float64 `json:"hosp_part_amt"`
  21725. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21726. Insutype string `json:"insutype"`
  21727. MafPay float64 `json:"maf_pay"`
  21728. MdtrtCertType string `json:"mdtrt_cert_type"`
  21729. HifobPay float64 `json:"hifob_pay"`
  21730. MdtrtID string `json:"mdtrt_id"`
  21731. MedType string `json:"med_type"`
  21732. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21733. MedinsSetlID string `json:"medins_setl_id"`
  21734. Naty string `json:"naty"`
  21735. OthPay float64 `json:"oth_pay"`
  21736. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21737. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21738. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21739. PsnCashPay float64 `json:"psn_cash_pay"`
  21740. PsnCertType string `json:"psn_cert_type"`
  21741. PsnName string `json:"psn_name"`
  21742. PsnNo string `json:"psn_no"`
  21743. PsnPartAmt float64 `json:"psn_part_amt"`
  21744. PsnType string `json:"psn_type"`
  21745. SetlID string `json:"setl_id"`
  21746. SetlTime string `json:"setl_time"`
  21747. } `json:"setlinfo"`
  21748. Setldetail interface{} `json:"setldetail"`
  21749. } `json:"output"`
  21750. RefmsgTime string `json:"refmsg_time"`
  21751. RespondTime string `json:"respond_time"`
  21752. Signtype interface{} `json:"signtype"`
  21753. WarnMsg interface{} `json:"warn_msg"`
  21754. }
  21755. type ResultSeven10265Two struct {
  21756. Cainfo string `json:"cainfo"`
  21757. ErrMsg string `json:"err_msg"`
  21758. InfRefmsgid string `json:"inf_refmsgid"`
  21759. Infcode string `json:"infcode"`
  21760. Output struct {
  21761. Setlinfo struct {
  21762. AcctMulaidPay string `json:"acct_mulaid_pay"`
  21763. AcctPay float64 `json:"acct_pay"`
  21764. ActPayDedc float64 `json:"act_pay_dedc"`
  21765. Age float64 `json:"age"`
  21766. Balc float64 `json:"balc"`
  21767. Certno string `json:"certno"`
  21768. ClrOptins string `json:"clr_optins"`
  21769. ClrType string `json:"clr_type"`
  21770. ClrWay string `json:"clr_way"`
  21771. CvlservFlag string `json:"cvlserv_flag"`
  21772. CvlservPay float64 `json:"cvlserv_pay"`
  21773. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21774. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21775. Gend string `json:"gend"`
  21776. HifesPay float64 `json:"hifes_pay"`
  21777. HifmiPay float64 `json:"hifmi_pay"`
  21778. HifpPay float64 `json:"hifp_pay"`
  21779. HospPartAmt string `json:"hosp_part_amt"`
  21780. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21781. Insutype string `json:"insutype"`
  21782. MafPay float64 `json:"maf_pay"`
  21783. MdtrtCertType string `json:"mdtrt_cert_type"`
  21784. HifobPay float64 `json:"hifob_pay"`
  21785. MdtrtID string `json:"mdtrt_id"`
  21786. MedType string `json:"med_type"`
  21787. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21788. MedinsSetlID string `json:"medins_setl_id"`
  21789. Naty string `json:"naty"`
  21790. OthPay float64 `json:"oth_pay"`
  21791. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21792. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21793. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21794. PsnCashPay float64 `json:"psn_cash_pay"`
  21795. PsnCertType string `json:"psn_cert_type"`
  21796. PsnName string `json:"psn_name"`
  21797. PsnNo string `json:"psn_no"`
  21798. PsnPartAmt float64 `json:"psn_part_amt"`
  21799. PsnType string `json:"psn_type"`
  21800. SetlID string `json:"setl_id"`
  21801. SetlTime string `json:"setl_time"`
  21802. } `json:"setlinfo"`
  21803. Setldetail interface{} `json:"setldetail"`
  21804. } `json:"output"`
  21805. RefmsgTime string `json:"refmsg_time"`
  21806. RespondTime string `json:"respond_time"`
  21807. Signtype interface{} `json:"signtype"`
  21808. WarnMsg interface{} `json:"warn_msg"`
  21809. }
  21810. type GZResultSeven10265Two struct {
  21811. Cainfo string `json:"cainfo"`
  21812. ErrMsg string `json:"err_msg"`
  21813. InfRefmsgid string `json:"inf_refmsgid"`
  21814. Infcode int64 `json:"infcode"`
  21815. Output struct {
  21816. Setlinfo struct {
  21817. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21818. AcctPay float64 `json:"acct_pay"`
  21819. ActPayDedc float64 `json:"act_pay_dedc"`
  21820. Age float64 `json:"age"`
  21821. Balc float64 `json:"balc"`
  21822. Certno string `json:"certno"`
  21823. ClrOptins string `json:"clr_optins"`
  21824. ClrType string `json:"clr_type"`
  21825. ClrWay string `json:"clr_way"`
  21826. CvlservFlag string `json:"cvlserv_flag"`
  21827. CvlservPay float64 `json:"cvlserv_pay"`
  21828. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21829. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21830. Gend string `json:"gend"`
  21831. HifesPay float64 `json:"hifes_pay"`
  21832. HifmiPay float64 `json:"hifmi_pay"`
  21833. HifpPay float64 `json:"hifp_pay"`
  21834. HospPartAmt float64 `json:"hosp_part_amt"`
  21835. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21836. Insutype string `json:"insutype"`
  21837. MafPay float64 `json:"maf_pay"`
  21838. MdtrtCertType string `json:"mdtrt_cert_type"`
  21839. HifobPay float64 `json:"hifob_pay"`
  21840. MdtrtID string `json:"mdtrt_id"`
  21841. MedType string `json:"med_type"`
  21842. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21843. MedinsSetlID string `json:"medins_setl_id"`
  21844. Naty string `json:"naty"`
  21845. OthPay float64 `json:"oth_pay"`
  21846. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21847. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21848. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21849. PsnCashPay float64 `json:"psn_cash_pay"`
  21850. PsnCertType string `json:"psn_cert_type"`
  21851. PsnName string `json:"psn_name"`
  21852. PsnNo string `json:"psn_no"`
  21853. PsnPartAmt float64 `json:"psn_part_amt"`
  21854. PsnType string `json:"psn_type"`
  21855. SetlID string `json:"setl_id"`
  21856. SetlTime string `json:"setl_time"`
  21857. } `json:"setlinfo"`
  21858. Setldetail interface{} `json:"setldetail"`
  21859. } `json:"output"`
  21860. RefmsgTime string `json:"refmsg_time"`
  21861. RespondTime string `json:"respond_time"`
  21862. Signtype interface{} `json:"signtype"`
  21863. WarnMsg interface{} `json:"warn_msg"`
  21864. }
  21865. type ResultEight struct {
  21866. Cainfo string `json:"cainfo"`
  21867. ErrMsg string `json:"err_msg"`
  21868. InfRefmsgid string `json:"inf_refmsgid"`
  21869. Infcode int64 `json:"infcode"`
  21870. Output struct {
  21871. Stmtinfo struct {
  21872. SetlOptins string `json:"setl_optins"`
  21873. StmtRslt string `json:"stmt_rslt"`
  21874. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21875. } `json:"stmtinfo"`
  21876. } `json:"output"`
  21877. RefmsgTime string `json:"refmsg_time"`
  21878. RespondTime string `json:"respond_time"`
  21879. Signtype interface{} `json:"signtype"`
  21880. WarnMsg interface{} `json:"warn_msg"`
  21881. }
  21882. type ResultEightFor10188 struct {
  21883. Cainfo string `json:"cainfo"`
  21884. ErrMsg string `json:"err_msg"`
  21885. InfRefmsgid string `json:"inf_refmsgid"`
  21886. Infcode string `json:"infcode"`
  21887. Output struct {
  21888. Stmtinfo struct {
  21889. SetlOptins string `json:"setl_optins"`
  21890. StmtRslt string `json:"stmt_rslt"`
  21891. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21892. } `json:"stmtinfo"`
  21893. } `json:"output"`
  21894. RefmsgTime string `json:"refmsg_time"`
  21895. RespondTime string `json:"respond_time"`
  21896. Signtype interface{} `json:"signtype"`
  21897. WarnMsg interface{} `json:"warn_msg"`
  21898. }
  21899. type ResultNine struct {
  21900. Cainfo string `json:"cainfo"`
  21901. ErrMsg string `json:"err_msg"`
  21902. InfRefmsgid string `json:"inf_refmsgid"`
  21903. Infcode int64 `json:"infcode"`
  21904. Output struct {
  21905. FileQuryNo string `json:"file_qury_no"`
  21906. } `json:"output"`
  21907. RefmsgTime string `json:"refmsg_time"`
  21908. RespondTime string `json:"respond_time"`
  21909. Signtype interface{} `json:"signtype"`
  21910. WarnMsg interface{} `json:"warn_msg"`
  21911. }
  21912. type ResultTen struct {
  21913. Cainfo string `json:"cainfo"`
  21914. ErrMsg string `json:"err_msg"`
  21915. InfRefmsgid string `json:"inf_refmsgid"`
  21916. Infcode int64 `json:"infcode"`
  21917. Output struct {
  21918. Fileinfo struct {
  21919. DldEndtime string `json:"dld_endtime"`
  21920. FileQuryNo string `json:"file_qury_no"`
  21921. Filename string `json:"filename"`
  21922. } `json:"fileinfo"`
  21923. } `json:"output"`
  21924. RefmsgTime string `json:"refmsg_time"`
  21925. RespondTime string `json:"respond_time"`
  21926. Signtype interface{} `json:"signtype"`
  21927. WarnMsg interface{} `json:"warn_msg"`
  21928. }
  21929. type Result5262 struct {
  21930. ErrMsg string `json:"err_msg"`
  21931. InfRefmsgid string `json:"inf_refmsgid"`
  21932. Infcode int64 `json:"infcode"`
  21933. Output struct {
  21934. PageInfo struct {
  21935. Size int `json:"size"`
  21936. RecordCounts int `json:"record_counts"`
  21937. } `json:"page_info"`
  21938. Idetinfo []interface{} `json:"idetinfo"`
  21939. Result []struct {
  21940. SetlID string `json:"setl_id"`
  21941. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  21942. MdtrtID string `json:"mdtrt_id"`
  21943. InitSetlID string `json:"init_setl_id,omitempty"`
  21944. PsnNo string `json:"psn_no"`
  21945. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  21946. PsnName string `json:"psn_name"`
  21947. PsnCertType string `json:"psn_cert_type"`
  21948. Certno string `json:"certno"`
  21949. Gend string `json:"gend,omitempty"`
  21950. Naty string `json:"naty,omitempty"`
  21951. Brdy string `json:"brdy,omitempty"`
  21952. Age float64 `json:"age,omitempty"`
  21953. Insutype string `json:"insutype,omitempty"`
  21954. PsnType string `json:"psn_type"`
  21955. CvlservFlag string `json:"cvlserv_flag"`
  21956. CvlservLv string `json:"cvlserv_lv,omitempty"`
  21957. SpPsnType string `json:"sp_psn_type,omitempty"`
  21958. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  21959. ClctGrde string `json:"clct_grde,omitempty"`
  21960. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  21961. NwbFlag string `json:"nwb_flag,omitempty"`
  21962. InsuAdmdvs string `json:"insu_admdvs"`
  21963. EmpNo string `json:"emp_no,omitempty"`
  21964. EmpName string `json:"emp_name,omitempty"`
  21965. EmpType string `json:"emp_type,omitempty"`
  21966. EconType string `json:"econ_type,omitempty"`
  21967. AfilIndu string `json:"afil_indu,omitempty"`
  21968. AfilRlts string `json:"afil_rlts,omitempty"`
  21969. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  21970. PayLoc string `json:"pay_loc,omitempty"`
  21971. FixmedinsCode string `json:"fixmedins_code"`
  21972. FixmedinsName string `json:"fixmedins_name"`
  21973. HospLv string `json:"hosp_lv,omitempty"`
  21974. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  21975. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  21976. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  21977. Begndate string `json:"begndate"`
  21978. Enddate string `json:"enddate"`
  21979. SetlTime string `json:"setl_time"`
  21980. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  21981. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  21982. MedType string `json:"med_type"`
  21983. SetlType string `json:"setl_type,omitempty"`
  21984. ClrType string `json:"clr_type,omitempty"`
  21985. ClrWay string `json:"clr_way,omitempty"`
  21986. PsnSetlway string `json:"psn_setlway,omitempty"`
  21987. ClrOptins string `json:"clr_optins,omitempty"`
  21988. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  21989. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  21990. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  21991. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  21992. InscpAmt float64 `json:"inscp_amt,omitempty"`
  21993. DedcStd float64 `json:"dedc_std,omitempty"`
  21994. CrtDedc float64 `json:"crt_dedc,omitempty"`
  21995. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  21996. HifpPay float64 `json:"hifp_pay,omitempty"`
  21997. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  21998. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  21999. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22000. HifesPay float64 `json:"hifes_pay,omitempty"`
  22001. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22002. HifobPay float64 `json:"hifob_pay,omitempty"`
  22003. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22004. MafPay float64 `json:"maf_pay,omitempty"`
  22005. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22006. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22007. PsnPay float64 `json:"psn_pay,omitempty"`
  22008. AcctPay float64 `json:"acct_pay,omitempty"`
  22009. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22010. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22011. Balc float64 `json:"balc,omitempty"`
  22012. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22013. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22014. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22015. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22016. Year string `json:"year,omitempty"`
  22017. DiseNo string `json:"dise_no,omitempty"`
  22018. DiseName string `json:"dise_name,omitempty"`
  22019. Invono string `json:"invono,omitempty"`
  22020. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22021. ValiFlag string `json:"vali_flag,omitempty"`
  22022. Memo string `json:"memo,omitempty"`
  22023. Rid string `json:"rid"`
  22024. UpdtTime string `json:"updt_time,omitempty"`
  22025. CrterID string `json:"crter_id,omitempty"`
  22026. CrterName string `json:"crter_name,omitempty"`
  22027. CrteTime string `json:"crte_time,omitempty"`
  22028. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  22029. OpterID string `json:"opter_id,omitempty"`
  22030. OpterName string `json:"opter_name,omitempty"`
  22031. OptTime string `json:"opt_time,omitempty"`
  22032. OptinsNo string `json:"optins_no,omitempty"`
  22033. PoolareaNo string `json:"poolarea_no,omitempty"`
  22034. } `json:"result"`
  22035. } `json:"output"`
  22036. RefmsgTime string `json:"refmsg_time"`
  22037. RespondTime string `json:"respond_time"`
  22038. Signtype interface{} `json:"signtype"`
  22039. WarnInfo interface{} `json:"warn_info"`
  22040. }
  22041. type Result5267 struct {
  22042. ErrMsg string `json:"err_msg"`
  22043. InfRefmsgid string `json:"inf_refmsgid"`
  22044. Infcode int64 `json:"infcode"`
  22045. Output struct {
  22046. PageInfo struct {
  22047. Size int `json:"size"`
  22048. RecordCounts int `json:"record_counts"`
  22049. } `json:"pageinfo"`
  22050. Result []struct {
  22051. SetlID string `json:"setl_id"`
  22052. ClrOptins string `json:"clr_optins"`
  22053. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22054. MdtrtID string `json:"mdtrt_id"`
  22055. InitSetlID string `json:"init_setl_id,omitempty"`
  22056. PsnNo string `json:"psn_no"`
  22057. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22058. PsnName string `json:"psn_name"`
  22059. PsnCertType string `json:"psn_cert_type"`
  22060. Certno string `json:"certno"`
  22061. Gend string `json:"gend,omitempty"`
  22062. Naty string `json:"naty,omitempty"`
  22063. Brdy string `json:"brdy,omitempty"`
  22064. Age float64 `json:"age,omitempty"`
  22065. Insutype string `json:"insutype,omitempty"`
  22066. PsnType string `json:"psn_type"`
  22067. CvlservFlag string `json:"cvlserv_flag"`
  22068. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22069. SpPsnType string `json:"sp_psn_type,omitempty"`
  22070. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22071. ClctGrde string `json:"clct_grde,omitempty"`
  22072. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22073. NwbFlag string `json:"nwb_flag,omitempty"`
  22074. InsuAdmdvs string `json:"insu_admdvs"`
  22075. EmpNo string `json:"emp_no,omitempty"`
  22076. EmpName string `json:"emp_name,omitempty"`
  22077. EmpType string `json:"emp_type,omitempty"`
  22078. EconType string `json:"econ_type,omitempty"`
  22079. AfilIndu string `json:"afil_indu,omitempty"`
  22080. AfilRlts string `json:"afil_rlts,omitempty"`
  22081. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22082. PayLoc string `json:"pay_loc,omitempty"`
  22083. FixmedinsCode string `json:"fixmedins_code"`
  22084. FixmedinsName string `json:"fixmedins_name"`
  22085. HospLv string `json:"hosp_lv,omitempty"`
  22086. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22087. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22088. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22089. Begndate string `json:"begndate,omitempty"`
  22090. Enddate string `json:"enddate,omitempty"`
  22091. SetlTime string `json:"setl_time,omitempty"`
  22092. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22093. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22094. MedType string `json:"med_type"`
  22095. SetlType string `json:"setl_type,omitempty"`
  22096. ClrType string `json:"clr_type,omitempty"`
  22097. ClrWay string `json:"clr_way,omitempty"`
  22098. PsnSetlway string `json:"psn_setlway,omitempty"`
  22099. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22100. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22101. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22102. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22103. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22104. DedcStd float64 `json:"dedc_std,omitempty"`
  22105. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22106. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22107. HifpPay float64 `json:"hifp_pay,omitempty"`
  22108. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22109. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22110. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22111. HifesPay float64 `json:"hifes_pay,omitempty"`
  22112. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22113. HifobPay float64 `json:"hifob_pay,omitempty"`
  22114. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22115. MafPay float64 `json:"maf_pay,omitempty"`
  22116. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22117. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22118. PsnPay float64 `json:"psn_pay,omitempty"`
  22119. AcctPay float64 `json:"acct_pay,omitempty"`
  22120. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22121. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22122. Balc float64 `json:"balc,omitempty"`
  22123. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22124. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22125. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22126. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22127. Year string `json:"year,omitempty"`
  22128. DiseNo string `json:"dise_no,omitempty"`
  22129. DiseName string `json:"dise_name,omitempty"`
  22130. Invono string `json:"invono,omitempty"`
  22131. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22132. Memo string `json:"memo,omitempty"`
  22133. UpdtTime string `json:"updt_time,omitempty"`
  22134. OpterID string `json:"opter_id,omitempty"`
  22135. OpterName string `json:"opter_name,omitempty"`
  22136. OptTime string `json:"opt_time,omitempty"`
  22137. OptinsNo string `json:"optins_no,omitempty"`
  22138. PoolareaNo string `json:"poolarea_no,omitempty"`
  22139. } `json:"result"`
  22140. } `json:"output"`
  22141. RefmsgTime string `json:"refmsg_time"`
  22142. RespondTime string `json:"respond_time"`
  22143. Signtype interface{} `json:"signtype"`
  22144. WarnInfo interface{} `json:"warn_info"`
  22145. }
  22146. // type Autogenerated struct {
  22147. // Output struct {
  22148. // Setlinfo struct {
  22149. // SetlTime string `json:"setl_time"`
  22150. // CvlservPay float64 `json:"cvlserv_pay"`
  22151. // Year string `json:"year"`
  22152. // MedType string `json:"med_type"`
  22153. // PsnPay float64 `json:"psn_pay"`
  22154. // OpterID string `json:"opter_id"`
  22155. // Begndate string `json:"begndate"`
  22156. // FlxempeFlag string `json:"flxempe_flag"`
  22157. // HifmiPay float64 `json:"hifmi_pay"`
  22158. // PsnNo string `json:"psn_no"`
  22159. // ActPayDedc float64 `json:"act_pay_dedc"`
  22160. // MedinsSetlID interface{} `json:"medins_setl_id"`
  22161. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22162. // ClrWay string `json:"clr_way"`
  22163. // OthPay float64 `json:"oth_pay"`
  22164. // Gend string `json:"gend"`
  22165. // MdtrtID string `json:"mdtrt_id"`
  22166. // AcctPay float64 `json:"acct_pay"`
  22167. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  22168. // Insutype string `json:"insutype"`
  22169. // Invono interface{} `json:"invono"`
  22170. // Enddate string `json:"enddate"`
  22171. // CashPayamt float64 `json:"cash_payamt"`
  22172. // PsnType string `json:"psn_type"`
  22173. // FixmedinsName string `json:"fixmedins_name"`
  22174. // HifpPay float64 `json:"hifp_pay"`
  22175. // NewFlag interface{} `json:"new_flag"`
  22176. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22177. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  22178. // PayLoc string `json:"pay_loc"`
  22179. // ClrType string `json:"clr_type"`
  22180. // RefdSetlFlag string `json:"refd_setl_flag"`
  22181. // CvlservFlag string `json:"cvlserv_flag"`
  22182. // EmpName string `json:"emp_name"`
  22183. // Brdy string `json:"brdy"`
  22184. // Naty string `json:"naty"`
  22185. // Certno string `json:"certno"`
  22186. // DiseCode string `json:"dise_code"`
  22187. // FixmedinsCode string `json:"fixmedins_code"`
  22188. // DedcHospLv string `json:"dedc_hosp_lv"`
  22189. // OpterName string `json:"opter_name"`
  22190. // Balc float64 `json:"balc"`
  22191. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22192. // PsnCertType string `json:"psn_cert_type"`
  22193. // HifobPay float64 `json:"hifob_pay"`
  22194. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  22195. // HifesPay float64 `json:"hifes_pay"`
  22196. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22197. // OptTime string `json:"opt_time"`
  22198. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22199. // SetlID string `json:"setl_id"`
  22200. // MafPay float64 `json:"maf_pay"`
  22201. // PsnName string `json:"psn_name"`
  22202. // InsuOptins interface{} `json:"insu_optins"`
  22203. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22204. // ClrOptins string `json:"clr_optins"`
  22205. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22206. // DiseName string `json:"dise_name"`
  22207. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22208. // Age float64 `json:"age"`
  22209. // DtrtCertType string `json:"dtrt_cert_type"`
  22210. // HospLv string `json:"hosp_lv"`
  22211. // } `json:"setlinfo"`
  22212. // Setldetail []struct {
  22213. // FundPayType string `json:"fund_pay_type"`
  22214. // FundPayamt float64 `json:"fund_payamt"`
  22215. // SetlProcInfo interface{} `json:"setl_proc_info"`
  22216. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  22217. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  22218. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  22219. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22220. // } `json:"setldetail"`
  22221. // } `json:"output"`
  22222. // Infcode int `json:"infcode"`
  22223. // WarnMsg interface{} `json:"warn_msg"`
  22224. // Cainfo interface{} `json:"cainfo"`
  22225. // ErrMsg interface{} `json:"err_msg"`
  22226. // RefmsgTime string `json:"refmsg_time"`
  22227. // Signtype interface{} `json:"signtype"`
  22228. // RespondTime string `json:"respond_time"`
  22229. // InfRefmsgid string `json:"inf_refmsgid"`
  22230. // }
  22231. type Result002 struct {
  22232. Cainfo interface{} `json:"cainfo"`
  22233. ErrMsg string `json:"err_msg"`
  22234. InfRefmsgid string `json:"inf_refmsgid"`
  22235. Infcode int64 `json:"infcode"`
  22236. Output struct {
  22237. RxFile string `json:"rx_file"`
  22238. SignDigest string `json:"sign_digest"`
  22239. SignCertSn string `json:"sign_cert_sn"`
  22240. SignCertDn string `json:"sign_cert_dn"`
  22241. } `json:"output"`
  22242. RefmsgTime string `json:"refmsg_time"`
  22243. RespondTime string `json:"respond_time"`
  22244. Signtype interface{} `json:"signtype"`
  22245. WarnMsg interface{} `json:"warn_msg"`
  22246. }
  22247. type Result003 struct {
  22248. Cainfo interface{} `json:"cainfo"`
  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. WarnMsg interface{} `json:"warn_msg"`
  22261. }
  22262. type ResultEleven struct {
  22263. Cainfo string `json:"cainfo"`
  22264. ErrMsg string `json:"err_msg"`
  22265. InfRefmsgid string `json:"inf_refmsgid"`
  22266. Infcode int64 `json:"infcode"`
  22267. Output struct {
  22268. Setlinfo struct {
  22269. SetlTime string `json:"setl_time"`
  22270. CvlservPay float64 `json:"cvlserv_pay"`
  22271. Year string `json:"year"`
  22272. MedType string `json:"med_type"`
  22273. PsnPay float64 `json:"psn_pay"`
  22274. OpterID string `json:"opter_id"`
  22275. Begndate string `json:"begndate"`
  22276. FlxempeFlag string `json:"flxempe_flag"`
  22277. HifmiPay float64 `json:"hifmi_pay"`
  22278. PsnNo string `json:"psn_no"`
  22279. ActPayDedc float64 `json:"act_pay_dedc"`
  22280. MedinsSetlID interface{} `json:"medins_setl_id"`
  22281. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22282. ClrWay string `json:"clr_way"`
  22283. OthPay float64 `json:"oth_pay"`
  22284. Gend string `json:"gend"`
  22285. MdtrtID string `json:"mdtrt_id"`
  22286. AcctPay float64 `json:"acct_pay"`
  22287. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22288. Insutype string `json:"insutype"`
  22289. Invono interface{} `json:"invono"`
  22290. Enddate string `json:"enddate"`
  22291. CashPayamt float64 `json:"cash_payamt"`
  22292. PsnType string `json:"psn_type"`
  22293. FixmedinsName string `json:"fixmedins_name"`
  22294. HifpPay float64 `json:"hifp_pay"`
  22295. NewFlag interface{} `json:"new_flag"`
  22296. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22297. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22298. PayLoc string `json:"pay_loc"`
  22299. ClrType string `json:"clr_type"`
  22300. RefdSetlFlag string `json:"refd_setl_flag"`
  22301. CvlservFlag string `json:"cvlserv_flag"`
  22302. EmpName string `json:"emp_name"`
  22303. Brdy string `json:"brdy"`
  22304. Naty string `json:"naty"`
  22305. Certno string `json:"certno"`
  22306. DiseCode string `json:"dise_code"`
  22307. FixmedinsCode string `json:"fixmedins_code"`
  22308. DedcHospLv string `json:"dedc_hosp_lv"`
  22309. OpterName string `json:"opter_name"`
  22310. Balc float64 `json:"balc"`
  22311. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22312. PsnCertType string `json:"psn_cert_type"`
  22313. HifobPay float64 `json:"hifob_pay"`
  22314. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22315. HifesPay float64 `json:"hifes_pay"`
  22316. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22317. OptTime string `json:"opt_time"`
  22318. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22319. SetlID string `json:"setl_id"`
  22320. MafPay float64 `json:"maf_pay"`
  22321. PsnName string `json:"psn_name"`
  22322. InsuOptins interface{} `json:"insu_optins"`
  22323. PrefFundPay interface{} `json:"pref_fund_pay"`
  22324. ClrOptins string `json:"clr_optins"`
  22325. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22326. DiseName string `json:"dise_name"`
  22327. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22328. Age float64 `json:"age"`
  22329. DtrtCertType string `json:"dtrt_cert_type"`
  22330. HospLv string `json:"hosp_lv"`
  22331. PsnCashPay float64 `json:"psn_cash_pay"`
  22332. } `json:"setlinfo"`
  22333. } `json:"output"`
  22334. RefmsgTime string `json:"refmsg_time"`
  22335. RespondTime string `json:"respond_time"`
  22336. Signtype interface{} `json:"signtype"`
  22337. WarnMsg interface{} `json:"warn_msg"`
  22338. }
  22339. type ResultElevenah struct {
  22340. Cainfo string `json:"cainfo"`
  22341. ErrMsg string `json:"err_msg"`
  22342. InfRefmsgid string `json:"inf_refmsgid"`
  22343. Infcode int64 `json:"infcode"`
  22344. Output struct {
  22345. Setlinfo struct {
  22346. SetlTime int64 `json:"setl_time"`
  22347. CvlservPay float64 `json:"cvlserv_pay"`
  22348. Year string `json:"year"`
  22349. MedType string `json:"med_type"`
  22350. PsnPay float64 `json:"psn_pay"`
  22351. OpterID string `json:"opter_id"`
  22352. Begndate int64 `json:"begndate"`
  22353. FlxempeFlag string `json:"flxempe_flag"`
  22354. HifmiPay float64 `json:"hifmi_pay"`
  22355. PsnNo string `json:"psn_no"`
  22356. ActPayDedc float64 `json:"act_pay_dedc"`
  22357. MedinsSetlID interface{} `json:"medins_setl_id"`
  22358. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22359. ClrWay string `json:"clr_way"`
  22360. OthPay float64 `json:"oth_pay"`
  22361. Gend string `json:"gend"`
  22362. MdtrtID string `json:"mdtrt_id"`
  22363. AcctPay float64 `json:"acct_pay"`
  22364. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22365. Insutype string `json:"insutype"`
  22366. Invono interface{} `json:"invono"`
  22367. Enddate int64 `json:"enddate"`
  22368. CashPayamt float64 `json:"cash_payamt"`
  22369. PsnType string `json:"psn_type"`
  22370. FixmedinsName string `json:"fixmedins_name"`
  22371. HifpPay float64 `json:"hifp_pay"`
  22372. NewFlag interface{} `json:"new_flag"`
  22373. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22374. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22375. PayLoc string `json:"pay_loc"`
  22376. ClrType string `json:"clr_type"`
  22377. RefdSetlFlag string `json:"refd_setl_flag"`
  22378. CvlservFlag string `json:"cvlserv_flag"`
  22379. EmpName string `json:"emp_name"`
  22380. Brdy int64 `json:"brdy"`
  22381. Naty string `json:"naty"`
  22382. Certno string `json:"certno"`
  22383. DiseCode string `json:"dise_code"`
  22384. FixmedinsCode string `json:"fixmedins_code"`
  22385. DedcHospLv string `json:"dedc_hosp_lv"`
  22386. OpterName string `json:"opter_name"`
  22387. Balc float64 `json:"balc"`
  22388. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22389. PsnCertType string `json:"psn_cert_type"`
  22390. HifobPay float64 `json:"hifob_pay"`
  22391. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22392. HifesPay float64 `json:"hifes_pay"`
  22393. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22394. OptTime int64 `json:"opt_time"`
  22395. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22396. SetlID string `json:"setl_id"`
  22397. MafPay float64 `json:"maf_pay"`
  22398. PsnName string `json:"psn_name"`
  22399. InsuOptins interface{} `json:"insu_optins"`
  22400. PrefFundPay interface{} `json:"pref_fund_pay"`
  22401. ClrOptins string `json:"clr_optins"`
  22402. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22403. DiseName string `json:"dise_name"`
  22404. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22405. Age float64 `json:"age"`
  22406. DtrtCertType string `json:"dtrt_cert_type"`
  22407. HospLv string `json:"hosp_lv"`
  22408. PsnCashPay float64 `json:"psn_cash_pay"`
  22409. } `json:"setlinfo"`
  22410. } `json:"output"`
  22411. RefmsgTime string `json:"refmsg_time"`
  22412. RespondTime string `json:"respond_time"`
  22413. Signtype interface{} `json:"signtype"`
  22414. WarnMsg interface{} `json:"warn_msg"`
  22415. }
  22416. type ResultEleven10265 struct {
  22417. Cainfo string `json:"cainfo"`
  22418. ErrMsg string `json:"err_msg"`
  22419. InfRefmsgid string `json:"inf_refmsgid"`
  22420. Infcode string `json:"infcode"`
  22421. Output struct {
  22422. Setlinfo struct {
  22423. SetlTime string `json:"setl_time"`
  22424. CvlservPay float64 `json:"cvlserv_pay"`
  22425. Year string `json:"year"`
  22426. MedType string `json:"med_type"`
  22427. PsnPay float64 `json:"psn_pay"`
  22428. OpterID string `json:"opter_id"`
  22429. Begndate string `json:"begndate"`
  22430. FlxempeFlag string `json:"flxempe_flag"`
  22431. HifmiPay float64 `json:"hifmi_pay"`
  22432. PsnNo string `json:"psn_no"`
  22433. ActPayDedc float64 `json:"act_pay_dedc"`
  22434. MedinsSetlID interface{} `json:"medins_setl_id"`
  22435. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22436. ClrWay string `json:"clr_way"`
  22437. OthPay float64 `json:"oth_pay"`
  22438. Gend string `json:"gend"`
  22439. MdtrtID string `json:"mdtrt_id"`
  22440. AcctPay float64 `json:"acct_pay"`
  22441. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22442. Insutype string `json:"insutype"`
  22443. Invono interface{} `json:"invono"`
  22444. Enddate string `json:"enddate"`
  22445. CashPayamt float64 `json:"cash_payamt"`
  22446. PsnType string `json:"psn_type"`
  22447. FixmedinsName string `json:"fixmedins_name"`
  22448. HifpPay float64 `json:"hifp_pay"`
  22449. NewFlag interface{} `json:"new_flag"`
  22450. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22451. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22452. PayLoc string `json:"pay_loc"`
  22453. ClrType string `json:"clr_type"`
  22454. RefdSetlFlag string `json:"refd_setl_flag"`
  22455. CvlservFlag string `json:"cvlserv_flag"`
  22456. EmpName string `json:"emp_name"`
  22457. Brdy string `json:"brdy"`
  22458. Naty string `json:"naty"`
  22459. Certno string `json:"certno"`
  22460. DiseCode string `json:"dise_code"`
  22461. FixmedinsCode string `json:"fixmedins_code"`
  22462. DedcHospLv string `json:"dedc_hosp_lv"`
  22463. OpterName string `json:"opter_name"`
  22464. Balc float64 `json:"balc"`
  22465. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22466. PsnCertType string `json:"psn_cert_type"`
  22467. HifobPay float64 `json:"hifob_pay"`
  22468. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22469. HifesPay float64 `json:"hifes_pay"`
  22470. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22471. OptTime string `json:"opt_time"`
  22472. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22473. SetlID string `json:"setl_id"`
  22474. MafPay float64 `json:"maf_pay"`
  22475. PsnName string `json:"psn_name"`
  22476. InsuOptins interface{} `json:"insu_optins"`
  22477. PrefFundPay interface{} `json:"pref_fund_pay"`
  22478. ClrOptins string `json:"clr_optins"`
  22479. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22480. DiseName string `json:"dise_name"`
  22481. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22482. Age float64 `json:"age"`
  22483. DtrtCertType string `json:"dtrt_cert_type"`
  22484. HospLv string `json:"hosp_lv"`
  22485. PsnCashPay float64 `json:"psn_cash_pay"`
  22486. } `json:"setlinfo"`
  22487. } `json:"output"`
  22488. RefmsgTime string `json:"refmsg_time"`
  22489. RespondTime string `json:"respond_time"`
  22490. Signtype interface{} `json:"signtype"`
  22491. WarnMsg interface{} `json:"warn_msg"`
  22492. }
  22493. type ResultTwelve struct {
  22494. Cainfo string `json:"cainfo"`
  22495. ErrMsg string `json:"err_msg"`
  22496. InfRefmsgid string `json:"inf_refmsgid"`
  22497. Infcode int64 `json:"infcode"`
  22498. Output struct {
  22499. MdtrtId string `json:"mdtrt_id"`
  22500. ChrgBchno string `json:"chrg_bchno"`
  22501. PsnNo string `json:"psn_no"`
  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 ResultThirteen struct {
  22509. ErrMsg string `json:"err_msg"`
  22510. InfRefmsgid string `json:"inf_refmsgid"`
  22511. Infcode int64 `json:"infcode"`
  22512. Output struct {
  22513. Result struct {
  22514. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22515. } `json:"result"`
  22516. } `json:"output"`
  22517. RefmsgTime string `json:"refmsg_time"`
  22518. RespondTime string `json:"respond_time"`
  22519. Signtype interface{} `json:"signtype"`
  22520. WarnInfo interface{} `json:"warn_info"`
  22521. }
  22522. type ResultThirteen10265 struct {
  22523. ErrMsg string `json:"err_msg"`
  22524. InfRefmsgid string `json:"inf_refmsgid"`
  22525. Infcode string `json:"infcode"`
  22526. Output struct {
  22527. Result struct {
  22528. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22529. } `json:"result"`
  22530. } `json:"output"`
  22531. RefmsgTime string `json:"refmsg_time"`
  22532. RespondTime string `json:"respond_time"`
  22533. Signtype interface{} `json:"signtype"`
  22534. WarnInfo interface{} `json:"warn_info"`
  22535. }
  22536. type ResultFourteen struct {
  22537. ErrMsg string `json:"err_msg"`
  22538. InfRefmsgid string `json:"inf_refmsgid"`
  22539. Infcode int64 `json:"infcode"`
  22540. Output struct {
  22541. } `json:"output"`
  22542. RefmsgTime string `json:"refmsg_time"`
  22543. RespondTime string `json:"respond_time"`
  22544. Signtype interface{} `json:"signtype"`
  22545. WarnInfo interface{} `json:"warn_info"`
  22546. }
  22547. type ResultCFYLJG001 struct {
  22548. ErrMsg string `json:"err_msg"`
  22549. InfRefmsgid string `json:"inf_refmsgid"`
  22550. Infcode int64 `json:"infcode"`
  22551. Output struct {
  22552. RxTraceCode string `json:"rx_trace_code"`
  22553. HiRxno string `json:"hi_rxno"`
  22554. } `json:"output"`
  22555. RefmsgTime string `json:"refmsg_time"`
  22556. RespondTime string `json:"respond_time"`
  22557. Signtype interface{} `json:"signtype"`
  22558. WarnInfo interface{} `json:"warn_info"`
  22559. }
  22560. type ResultCFYLJG007 struct {
  22561. ErrMsg string `json:"err_msg"`
  22562. InfRefmsgid string `json:"inf_refmsgid"`
  22563. Infcode int64 `json:"infcode"`
  22564. Output struct {
  22565. HiRxno string `json:"hi_rxno"`
  22566. RxStasName string `json:"rx_stas_name"`
  22567. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  22568. Seltdelts []interface{} `json:"seltdelts"`
  22569. RxUsedStasName string `json:"rx_used_stas_name"`
  22570. RxStasCodg string `json:"rx_stas_codg"`
  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 ResultCFYLJG002 struct {
  22578. ErrMsg string `json:"err_msg"`
  22579. InfRefmsgid string `json:"inf_refmsgid"`
  22580. Infcode int64 `json:"infcode"`
  22581. Output struct {
  22582. RxFile string `json:"rx_file"`
  22583. SignDigest string `json:"sign_digest"`
  22584. SignCertSn string `json:"sign_cert_sn"`
  22585. SignCertDn string `json:"sign_cert_dn"`
  22586. } `json:"output"`
  22587. RefmsgTime string `json:"refmsg_time"`
  22588. RespondTime string `json:"respond_time"`
  22589. Signtype interface{} `json:"signtype"`
  22590. WarnInfo interface{} `json:"warn_info"`
  22591. }
  22592. type ResultCFYLJG003 struct {
  22593. ErrMsg string `json:"err_msg"`
  22594. InfRefmsgid string `json:"inf_refmsgid"`
  22595. Infcode int64 `json:"infcode"`
  22596. Output struct {
  22597. HiRxno string `json:"hi_rxno"`
  22598. RxStasCodg string `json:"rx_stas_codg"`
  22599. RxStasName string `json:"rx_stas_name"`
  22600. } `json:"output"`
  22601. RefmsgTime string `json:"refmsg_time"`
  22602. RespondTime string `json:"respond_time"`
  22603. Signtype interface{} `json:"signtype"`
  22604. WarnInfo interface{} `json:"warn_info"`
  22605. }
  22606. type ResultCFYLJG004 struct {
  22607. ErrMsg string `json:"err_msg"`
  22608. InfRefmsgid string `json:"inf_refmsgid"`
  22609. Infcode int64 `json:"infcode"`
  22610. Output struct {
  22611. HiRxno string `json:"hi_rxno"`
  22612. RxStasCodg string `json:"rx_stas_codg"`
  22613. RxStasName string `json:"rx_stas_name"`
  22614. } `json:"output"`
  22615. RefmsgTime string `json:"refmsg_time"`
  22616. RespondTime string `json:"respond_time"`
  22617. Signtype interface{} `json:"signtype"`
  22618. WarnInfo interface{} `json:"warn_info"`
  22619. }
  22620. type ResultCFYLJG008 struct {
  22621. ErrMsg string `json:"err_msg"`
  22622. InfRefmsgid string `json:"inf_refmsgid"`
  22623. Infcode int64 `json:"infcode"`
  22624. Output struct {
  22625. PoolareaNo string `json:"poolareaNo"`
  22626. AdmdvsName string `json:"admdvsName"`
  22627. Count string `json:"count"`
  22628. } `json:"output"`
  22629. RefmsgTime string `json:"refmsg_time"`
  22630. RespondTime string `json:"respond_time"`
  22631. Signtype interface{} `json:"signtype"`
  22632. WarnInfo interface{} `json:"warn_info"`
  22633. }
  22634. type ResultCFYLJG005 struct {
  22635. ErrMsg string `json:"err_msg"`
  22636. InfRefmsgid string `json:"inf_refmsgid"`
  22637. Infcode int64 `json:"infcode"`
  22638. Output struct {
  22639. HiRxNo string `json:"hi_rxno"`
  22640. FixMedinsCode string `json:"fixmedins_code"`
  22641. FixMedinsName string `json:"fixmedins_name"`
  22642. RxStasCodg string `json:"rx_stas_codg"`
  22643. RxStasName string `json:"rx_stas_name"`
  22644. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  22645. RxUserdStasName string `json:"rx_userd_stas_name"`
  22646. PrscTime string `json:"prsc_time"`
  22647. RxDrugCnt float64 `json:"rx_drug_cnt"`
  22648. RxUsedWayCodg string `json:"rx_used_way_codg"`
  22649. RxUsedWayName string `json:"rx_used_way_name"`
  22650. RxFrquCodg string `json:"rx_frqu_codg"`
  22651. RxFrquName string `json:"rx_frqu_name"`
  22652. RxDosunt string `json:"rx_dosunt"`
  22653. RxDoscnt float64 `json:"rx_doscnt"`
  22654. RxDrordDscr string `json:"rx_drord_dscr"`
  22655. ValiDays int64 `json:"vali_days"`
  22656. ValiEndTime string `json:"vali_end_time"`
  22657. ReptFlag string `json:"rept_flag"`
  22658. MaxReptCnt int64 `json:"max_rept_cnt"`
  22659. ReptdCnt int64 `json:"reptd_cnt"`
  22660. MinInrvDays int64 `json:"min_inrv_days"`
  22661. RxTypeCode string `json:"rx_type_code"`
  22662. RxTypeName string `json:"rx_type_name"`
  22663. LongRxFlag string `json:"long_rx_flag"`
  22664. RxDetlList []struct {
  22665. MedListCodg string `json:"med_list_codg"`
  22666. MedinsListCodg string `json:"medins_list_codg"`
  22667. HospPrepFlag string `json:"hosp_prep_flag"`
  22668. RxItemTypeCode string `json:"rx_item_type_code"`
  22669. RxItemTypeName string `json:"rx_item_type_name"`
  22670. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  22671. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  22672. TcmHerbFoote string `json:"tcmherb_foote"`
  22673. MednTypeCode string `json:"medn_type_code"`
  22674. MednTypeName string `json:"medn_type_name"`
  22675. MainMedcFlag string `json:"main_medc_flag"`
  22676. UrgtFlag string `json:"urgt_flag"`
  22677. BasMednFlag string `json:"bas_medn_flag"`
  22678. ImpDrugFlag string `json:"imp_drug_flag"`
  22679. ProdBarc string `json:"prod_barc"`
  22680. DrugProdname string `json:"drug_prodname"`
  22681. GennameCodg string `json:"genname_codg"`
  22682. DrugGenname string `json:"drug_genname"`
  22683. DrugDosform string `json:"drug_dosform"`
  22684. DrugSpec string `json:"drug_spec"`
  22685. PrdrName string `json:"prdr_name"`
  22686. MedcWayCodg string `json:"medc_way_codg"`
  22687. MedcWayDscr string `json:"medc_way_dscr"`
  22688. MedcBegntime string `json:"medc_begntime"`
  22689. MedcEndtime string `json:"medc_endtime"`
  22690. MedcDays float64 `json:"medc_days"`
  22691. DrugPric float64 `json:"drug_pric"`
  22692. DrugSumamt float64 `json:"drug_sumamt"`
  22693. DrugCnt float64 `json:"drug_cnt"`
  22694. DrugDosunt string `json:"drug_dosunt"`
  22695. SinDoscnt float64 `json:"sin_doscnt"`
  22696. SinDosunt string `json:"sin_dosunt"`
  22697. UsedFrquCodg string `json:"used_frqu_codg"`
  22698. UsedFrquName string `json:"used_frqu_name"`
  22699. DrugTotlcnt string `json:"drug_totlcnt"`
  22700. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  22701. DiseCodg string `json:"dise_codg"`
  22702. HospApprFlag string `json:"hosp_appr_flag"`
  22703. } `json:"rx_detl_list"`
  22704. RxOtpinfo struct {
  22705. MedType string `json:"med_type"`
  22706. IptOtpNo string `json:"ipt_otp_no"`
  22707. OtpIptFlag string `json:"otp_ipt_flag"`
  22708. PatnName string `json:"patn_name"`
  22709. PatnAge float64 `json:"patn_age"`
  22710. PatnHgt float64 `json:"patn_hgt"`
  22711. PatnWt float64 `json:"patn_wt"`
  22712. Gend string `json:"gend"`
  22713. GesoVal float64 `json:"geso_val"`
  22714. NwbFlag string `json:"nwb_flag"`
  22715. NwbAge string `json:"nwb_age"`
  22716. SuckPrdFlag string `json:"suck_prd_flag"`
  22717. AlgsHis string `json:"algs_his"`
  22718. Insutype string `json:"insutype"`
  22719. PrscDeptName string `json:"prsc_dept_name"`
  22720. PrscDrName string `json:"prsc_dr_name"`
  22721. PharName string `json:"phar_name"`
  22722. PharChkTime string `json:"phar_chk_time"`
  22723. MdtrtTime string `json:"mdtrt_time"`
  22724. DiseCodg string `json:"dise_codg"`
  22725. DiseName string `json:"dise_name"`
  22726. SpDiseFlag string `json:"sp_dise_flag"`
  22727. MaindiagCode string `json:"maindiag_code"`
  22728. MaindiagName string `json:"maindiag_name"`
  22729. DiseCondDscr string `json:"dise_cond_dscr"`
  22730. FstdiagFlag string `json:"fstdiag_flag"`
  22731. } `json:"rx_otpinfo"`
  22732. RxDiseList []struct {
  22733. DiagType string `json:"diag_type"`
  22734. MaindiagFlag string `json:"maindiag_flag"`
  22735. DiagSrtNo string `json:"diag_srt_no"`
  22736. DiagCode string `json:"diag_code"`
  22737. DiagName string `json:"diag_name"`
  22738. DiagDept string `json:"diag_dept"`
  22739. DiagDrNo string `json:"diag_dr_no"`
  22740. DiagDrName string `json:"diag_dr_name"`
  22741. DiagTime string `json:"diag_time"`
  22742. TcmDiseCode string `json:"tcm_dise_code"`
  22743. TcmDiseName string `json:"tcm_dise_name"`
  22744. TcmSympCode string `json:"tcmsymp_code"`
  22745. TcmSymp string `json:"tcmsymp"`
  22746. } `json:"rx_dise_list"`
  22747. } `json:"output"`
  22748. RefmsgTime string `json:"refmsg_time"`
  22749. RespondTime string `json:"respond_time"`
  22750. Signtype interface{} `json:"signtype"`
  22751. WarnInfo interface{} `json:"warn_info"`
  22752. }
  22753. type ResultCFYLJG006 struct {
  22754. ErrMsg string `json:"err_msg"`
  22755. InfRefmsgid string `json:"inf_refmsgid"`
  22756. Infcode int64 `json:"infcode"`
  22757. Output struct {
  22758. HiRxNo string `json:"hi_rxno"`
  22759. PharCode string `json:"phar_code"`
  22760. PharName string `json:"phar_name"`
  22761. RxChkOpnn string `json:"rx_chk_opnn"`
  22762. RxChkTime string `json:"rx_chk_time"`
  22763. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  22764. RxChkStasName string `json:"rx_chk_stas_name"`
  22765. RxStasCodg string `json:"rx_stas_codg"`
  22766. RxStasName string `json:"rx_stas_name"`
  22767. } `json:"output"`
  22768. RefmsgTime string `json:"refmsg_time"`
  22769. RespondTime string `json:"respond_time"`
  22770. Signtype interface{} `json:"signtype"`
  22771. WarnInfo interface{} `json:"warn_info"`
  22772. }
  22773. type ResultFourteen10265 struct {
  22774. ErrMsg string `json:"err_msg"`
  22775. InfRefmsgid string `json:"inf_refmsgid"`
  22776. Infcode string `json:"infcode"`
  22777. Output struct {
  22778. } `json:"output"`
  22779. RefmsgTime string `json:"refmsg_time"`
  22780. RespondTime string `json:"respond_time"`
  22781. Signtype interface{} `json:"signtype"`
  22782. WarnInfo interface{} `json:"warn_info"`
  22783. }
  22784. type ResultSixteen struct {
  22785. Cainfo string `json:"cainfo"`
  22786. ErrMsg string `json:"err_msg"`
  22787. InfRefmsgid string `json:"inf_refmsgid"`
  22788. Infcode int64 `json:"infcode"`
  22789. Output struct {
  22790. Setlinfo struct {
  22791. MdtrtID string `json:"mdtrt_id"`
  22792. SetlID string `json:"setl_id"`
  22793. ClrOptins string `json:"clr_optins"`
  22794. SetlTime string `json:"setl_time"`
  22795. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22796. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22797. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22798. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22799. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22800. ActPayDedc float64 `json:"act_pay_dedc"`
  22801. HifpPay float64 `json:"hifp_pay"`
  22802. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22803. Lfpay float64 `json:"selfpay"`
  22804. CvlservPay float64 `json:"cvlserv_pay"`
  22805. HifesPay float64 `json:"hifes_pay"`
  22806. HifmiPay float64 `json:"hifmi_pay"`
  22807. HifobPay float64 `json:"hifob_pay"`
  22808. MafPay float64 `json:"maf_pay"`
  22809. OthPay float64 `json:"oth_pay"`
  22810. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22811. PsnPartAmt float64 `json:"psn_part_amt"`
  22812. AcctPay float64 `json:"acct_pay"`
  22813. Balc float64 `json:"balc"`
  22814. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22815. HospPartAmt float64 `json:"hosp_part_amt"`
  22816. MedinsSetlID string `json:"medins_setl_id"`
  22817. PdnCashPay string `json:"pdn_cash_pay"`
  22818. } `json:"setlinfo"`
  22819. } `json:"output"`
  22820. RefmsgTime string `json:"refmsg_time"`
  22821. RespondTime string `json:"respond_time"`
  22822. Signtype interface{} `json:"signtype"`
  22823. WarnMsg interface{} `json:"warn_msg"`
  22824. }
  22825. type ResultSixteen10265 struct {
  22826. Cainfo string `json:"cainfo"`
  22827. ErrMsg string `json:"err_msg"`
  22828. InfRefmsgid string `json:"inf_refmsgid"`
  22829. Infcode string `json:"infcode"`
  22830. Output struct {
  22831. Setlinfo struct {
  22832. MdtrtID string `json:"mdtrt_id"`
  22833. SetlID string `json:"setl_id"`
  22834. ClrOptins string `json:"clr_optins"`
  22835. SetlTime string `json:"setl_time"`
  22836. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22837. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22838. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22839. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22840. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22841. ActPayDedc float64 `json:"act_pay_dedc"`
  22842. HifpPay float64 `json:"hifp_pay"`
  22843. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22844. Lfpay float64 `json:"selfpay"`
  22845. CvlservPay float64 `json:"cvlserv_pay"`
  22846. HifesPay float64 `json:"hifes_pay"`
  22847. HifmiPay float64 `json:"hifmi_pay"`
  22848. HifobPay float64 `json:"hifob_pay"`
  22849. MafPay float64 `json:"maf_pay"`
  22850. OthPay float64 `json:"oth_pay"`
  22851. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22852. PsnPartAmt float64 `json:"psn_part_amt"`
  22853. AcctPay float64 `json:"acct_pay"`
  22854. Balc float64 `json:"balc"`
  22855. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22856. HospPartAmt float64 `json:"hosp_part_amt"`
  22857. MedinsSetlID string `json:"medins_setl_id"`
  22858. PdnCashPay string `json:"pdn_cash_pay"`
  22859. } `json:"setlinfo"`
  22860. } `json:"output"`
  22861. RefmsgTime string `json:"refmsg_time"`
  22862. RespondTime string `json:"respond_time"`
  22863. Signtype interface{} `json:"signtype"`
  22864. WarnMsg interface{} `json:"warn_msg"`
  22865. }
  22866. type ResultSixteen10265Two struct {
  22867. Cainfo string `json:"cainfo"`
  22868. ErrMsg string `json:"err_msg"`
  22869. InfRefmsgid string `json:"inf_refmsgid"`
  22870. Infcode string `json:"infcode"`
  22871. Output struct {
  22872. Setlinfo interface{} `json:"setlinfo"`
  22873. } `json:"output"`
  22874. RefmsgTime string `json:"refmsg_time"`
  22875. RespondTime string `json:"respond_time"`
  22876. Signtype interface{} `json:"signtype"`
  22877. WarnMsg interface{} `json:"warn_msg"`
  22878. }
  22879. type ResultgzSixteen10265Two struct {
  22880. Cainfo string `json:"cainfo"`
  22881. ErrMsg string `json:"err_msg"`
  22882. InfRefmsgid string `json:"inf_refmsgid"`
  22883. Infcode int64 `json:"infcode"`
  22884. Output struct {
  22885. Setlinfo interface{} `json:"setlinfo"`
  22886. } `json:"output"`
  22887. RefmsgTime string `json:"refmsg_time"`
  22888. RespondTime string `json:"respond_time"`
  22889. Signtype interface{} `json:"signtype"`
  22890. WarnMsg interface{} `json:"warn_msg"`
  22891. }
  22892. type ResultSeventeen struct {
  22893. ErrMsg string `json:"err_msg"`
  22894. InfRefmsgid string `json:"inf_refmsgid"`
  22895. Infcode int64 `json:"infcode"`
  22896. Output struct {
  22897. SetlListId string `json:"setl_list_id"`
  22898. } `json:"output"`
  22899. RefmsgTime string `json:"refmsg_time"`
  22900. RespondTime string `json:"respond_time"`
  22901. Signtype string `json:"signtype"`
  22902. WarnInfo string `json:"warn_info"`
  22903. }
  22904. type ResultSeventeenOther struct {
  22905. ErrMsg string `json:"err_msg"`
  22906. InfRefmsgid string `json:"inf_refmsgid"`
  22907. Infcode string `json:"infcode"`
  22908. Output struct {
  22909. SetlListId string `json:"setl_list_id"`
  22910. } `json:"output"`
  22911. RefmsgTime string `json:"refmsg_time"`
  22912. RespondTime string `json:"respond_time"`
  22913. Signtype string `json:"signtype"`
  22914. WarnInfo string `json:"warn_info"`
  22915. }
  22916. type Result90991 struct {
  22917. ErrMsg string `json:"err_msg"`
  22918. InfRefmsgid string `json:"inf_refmsgid"`
  22919. Infcode int64 `json:"infcode"`
  22920. Output struct {
  22921. Result struct {
  22922. PsnNo string `json:"psn_no"`
  22923. CardStat string `json:"card_stat"`
  22924. Certno string `json:"certno"`
  22925. PsnName string `json:"psn_name"`
  22926. CheckStat string `json:"check_stat"`
  22927. SscnoCheckStat string `json:"sscno_check_stat"`
  22928. } `json:"result"`
  22929. } `json:"output"`
  22930. RefmsgTime string `json:"refmsg_time"`
  22931. RespondTime string `json:"respond_time"`
  22932. Signtype interface{} `json:"signtype"`
  22933. WarnInfo interface{} `json:"warn_info"`
  22934. }
  22935. type Result90100 struct {
  22936. ErrMsg string `json:"err_msg"`
  22937. InfRefmsgid string `json:"inf_refmsgid"`
  22938. Infcode int64 `json:"infcode"`
  22939. Output struct {
  22940. PoolareaNo string `json:"poolarea_no"`
  22941. PoolareaNoName string `json:"poolarea_no_name"`
  22942. Insutype string `json:"insutype"`
  22943. InsutypeName string `json:"insutype_name"`
  22944. ClctType string `json:"clct_type"`
  22945. ClctTypeName string `json:"clct_type_name"`
  22946. ClctFlag string `json:"clct_flag"`
  22947. ClctFlagName string `json:"clct_flag_name"`
  22948. AccrymBegn string `json:"accrym_begn"`
  22949. AccrymEnd string `json:"accrym_end"`
  22950. ClctTime string `json:"clct_time"`
  22951. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  22952. } `json:"output"`
  22953. RefmsgTime string `json:"refmsg_time"`
  22954. RespondTime string `json:"respond_time"`
  22955. Signtype interface{} `json:"signtype"`
  22956. WarnInfo interface{} `json:"warn_info"`
  22957. }
  22958. type Custom struct {
  22959. DetItemFeeSumamt string
  22960. Cut string
  22961. FeedetlSn string
  22962. Price string
  22963. MedListCodg string
  22964. Type int64
  22965. AdviceId int64
  22966. ProjectId int64
  22967. ItemId int64
  22968. }
  22969. type Result5301 struct {
  22970. ErrMsg string `json:"err_msg"`
  22971. InfRefmsgid string `json:"inf_refmsgid"`
  22972. Infcode int64 `json:"infcode"`
  22973. Output struct {
  22974. Result []struct {
  22975. OpspDiseCode string `json:"opsp_dise_code"`
  22976. OpspDiseName string `json:"opsp_dise_name"`
  22977. Begndate string `json:"begndate"`
  22978. Enddate string `json:"enddate"`
  22979. } `json:"feedetail"`
  22980. } `json:"output"`
  22981. RefmsgTime string `json:"refmsg_time"`
  22982. RespondTime string `json:"respond_time"`
  22983. Signtype interface{} `json:"signtype"`
  22984. WarnInfo interface{} `json:"warn_info"`
  22985. }
  22986. type Result5301For10265 struct {
  22987. ErrMsg string `json:"err_msg"`
  22988. InfRefmsgid string `json:"inf_refmsgid"`
  22989. Infcode string `json:"infcode"`
  22990. Output struct {
  22991. Result []struct {
  22992. OpspDiseCode string `json:"opsp_dise_code"`
  22993. OpspDiseName string `json:"opsp_dise_name"`
  22994. Begndate string `json:"begndate"`
  22995. Enddate string `json:"enddate"`
  22996. } `json:"feedetail"`
  22997. } `json:"output"`
  22998. RefmsgTime string `json:"refmsg_time"`
  22999. RespondTime string `json:"respond_time"`
  23000. Signtype interface{} `json:"signtype"`
  23001. WarnInfo interface{} `json:"warn_info"`
  23002. }
  23003. //获取个人信息----挂号-----上传就诊信息
  23004. func (c *HisApiController) GetRegisterInfo() {
  23005. id, _ := c.GetInt64("id")
  23006. record_time := c.GetString("record_time")
  23007. settlementValue, _ := c.GetInt64("settlement_value")
  23008. medical_insurance_card := c.GetString("medical_insurance_card")
  23009. name := c.GetString("name")
  23010. id_card_type, _ := c.GetInt64("id_card_type")
  23011. certificates, _ := c.GetInt64("certificates")
  23012. medical_care, _ := c.GetInt64("medical_care")
  23013. birthday := c.GetString("birthday")
  23014. id_card := c.GetString("id_card")
  23015. register_type, _ := c.GetInt64("register")
  23016. doctor, _ := c.GetInt64("doctor")
  23017. department, _ := c.GetInt64("department")
  23018. gender, _ := c.GetInt64("sex")
  23019. registration_fee, _ := c.GetFloat("registration_fee")
  23020. medical_expenses, _ := c.GetFloat("medical_expenses")
  23021. social_type, _ := c.GetInt64("social_type")
  23022. admin_user_id, _ := c.GetInt64("admin_user_id")
  23023. insuplc_admdvs := c.GetString("insuplc_admdvs")
  23024. mdtrt_type := c.GetString("mdtrt_type")
  23025. if id_card_type == 5 {
  23026. id_card_type = 4
  23027. }
  23028. timeLayout := "2006-01-02"
  23029. loc, _ := time.LoadLocation("Local")
  23030. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  23031. birthUnix := birthdays.Unix()
  23032. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23033. if err != nil {
  23034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23035. return
  23036. }
  23037. recordDateTime := theTime.Unix()
  23038. adminInfo := c.GetAdminUserInfo()
  23039. var patient service.Patients
  23040. if id == 0 {
  23041. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  23042. } else {
  23043. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  23044. }
  23045. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23046. if patientPrescription.ID == 0 {
  23047. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23048. }
  23049. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  23050. if patient.ID == 0 {
  23051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  23052. return
  23053. }
  23054. if len(patient.IdCardNo) == 0 {
  23055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  23056. return
  23057. }
  23058. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  23059. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  23060. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  23061. //就诊结算未完成,不能进行二次挂号
  23062. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  23063. if len(his) >= 1 {
  23064. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  23065. if len(his) >= 1 && order.ID == 0 {
  23066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  23067. return
  23068. }
  23069. }
  23070. //var register_log string
  23071. if config.IsOpen == 1 {
  23072. var res ResultTwo
  23073. var res10265 ResultTwo10265
  23074. var PsnNo string
  23075. var PsnCertType string
  23076. var Certno string
  23077. var PsnName string
  23078. var Gend string
  23079. var Naty string
  23080. var Brdy string
  23081. var Age float64
  23082. var infoStr string
  23083. var idetinfoStr string
  23084. var infocode int64
  23085. var verify_number string
  23086. fmt.Println(verify_number)
  23087. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  23088. psn_info, _ := service.GetPsnByPatientId(id)
  23089. PsnNo = psn_info.PsnNo
  23090. PsnCertType = psn_info.PsnCertType
  23091. Certno = psn_info.Certno
  23092. PsnName = psn_info.PsnName
  23093. Gend = psn_info.Gend
  23094. Naty = psn_info.Naty
  23095. Brdy = psn_info.Brdy
  23096. Age = psn_info.Age
  23097. infoStr = psn_info.Insuinfo
  23098. idetinfoStr = psn_info.Idetinfo
  23099. infocode = 0
  23100. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23101. psn_info, _ := service.GetPsnByPatientId(id)
  23102. PsnNo = psn_info.PsnNo
  23103. PsnCertType = psn_info.PsnCertType
  23104. Certno = psn_info.Certno
  23105. PsnName = psn_info.PsnName
  23106. Gend = psn_info.Gend
  23107. Naty = psn_info.Naty
  23108. Brdy = psn_info.Brdy
  23109. Age = psn_info.Age
  23110. infoStr = psn_info.Insuinfo
  23111. idetinfoStr = psn_info.Idetinfo
  23112. infocode = 0
  23113. verify_number = psn_info.VerifyNumber
  23114. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23115. if id_card_type == 2 {
  23116. //请求内网数据
  23117. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  23118. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23119. "&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
  23120. resp, requestErr := http.Get(api)
  23121. if requestErr != nil {
  23122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23123. return
  23124. }
  23125. body, ioErr := ioutil.ReadAll(resp.Body)
  23126. if ioErr != nil {
  23127. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23129. return
  23130. }
  23131. var respJSON map[string]interface{}
  23132. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23133. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23135. return
  23136. }
  23137. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23138. result_byte, _ := json.Marshal(respJSON)
  23139. result := string(result_byte)
  23140. var dat map[string]interface{}
  23141. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23142. fmt.Println(dat)
  23143. } else {
  23144. fmt.Println(err)
  23145. }
  23146. userJSONBytes, _ := json.Marshal(dat)
  23147. var res ResultTwo
  23148. var resTwo10265 ResultTwo10265
  23149. if miConfig.Code == "H15049901371" {
  23150. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  23151. utils.ErrorLog("解析失败:%v", err)
  23152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23153. return
  23154. }
  23155. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  23156. res.Infcode = Infcode
  23157. res.ErrMsg = resTwo10265.ErrMsg
  23158. res.Output = resTwo10265.Output
  23159. res.InfRefmsgid = resTwo10265.InfRefmsgid
  23160. res.RespondTime = resTwo10265.RespondTime
  23161. res.WarnInfo = resTwo10265.WarnInfo
  23162. } else {
  23163. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23164. utils.ErrorLog("解析失败:%v", err)
  23165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23166. return
  23167. }
  23168. }
  23169. //var insutypes []string
  23170. //var insutype string
  23171. //var is390 int = 0
  23172. //var is310 int = 0
  23173. //for _, item := range res.Output.Iinfo {
  23174. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23175. // insutypes = append(insutypes, item.Insutype)
  23176. // }
  23177. //}
  23178. //if len(insutypes) == 1 {
  23179. // insutype = insutypes[0]
  23180. //} else {
  23181. // for _, i := range insutypes {
  23182. // if i == "390" {
  23183. // is390 = 1
  23184. // }
  23185. //
  23186. // if i == "310" {
  23187. // is310 = 1
  23188. // }
  23189. // }
  23190. //}
  23191. //if is390 == 1 {
  23192. // insutype = "390"
  23193. //}
  23194. //if is310 == 1 {
  23195. // insutype = "310"
  23196. //}
  23197. //if len(insutypes) == 0 {
  23198. // insutype = "310"
  23199. //}
  23200. PsnNo = res.Output.Baseinfo.PsnNo
  23201. PsnCertType = res.Output.Baseinfo.PsnCertType
  23202. Certno = res.Output.Baseinfo.Certno
  23203. PsnName = res.Output.Baseinfo.PsnName
  23204. Gend = res.Output.Baseinfo.Gend
  23205. Naty = res.Output.Baseinfo.Naty
  23206. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23207. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23208. infoStr = string(Iinfos)
  23209. idetinfoStr = string(Idetinfos)
  23210. infocode = res.Infcode
  23211. //infocode = 0
  23212. //verify_number = psn_info.VerifyNumber
  23213. } else {
  23214. psn_info, _ := service.GetPsnByPatientId(id)
  23215. PsnNo = psn_info.PsnNo
  23216. PsnCertType = psn_info.PsnCertType
  23217. Certno = psn_info.Certno
  23218. PsnName = psn_info.PsnName
  23219. Gend = psn_info.Gend
  23220. Naty = psn_info.Naty
  23221. Brdy = psn_info.Brdy
  23222. Age = psn_info.Age
  23223. infoStr = psn_info.Insuinfo
  23224. idetinfoStr = psn_info.Idetinfo
  23225. infocode = 0
  23226. verify_number = psn_info.VerifyNumber
  23227. }
  23228. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23229. if id_card_type == 1 {
  23230. psn_info, _ := service.GetPsnByPatientId(id)
  23231. PsnNo = psn_info.PsnNo
  23232. PsnCertType = psn_info.PsnCertType
  23233. Certno = psn_info.Certno
  23234. PsnName = psn_info.PsnName
  23235. Gend = psn_info.Gend
  23236. Naty = psn_info.Naty
  23237. Brdy = psn_info.Brdy
  23238. Age = psn_info.Age
  23239. infoStr = psn_info.Insuinfo
  23240. idetinfoStr = psn_info.Idetinfo
  23241. infocode = 0
  23242. verify_number = psn_info.VerifyNumber
  23243. } else if id_card_type == 2 {
  23244. 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)
  23245. fmt.Println(errMsgLog)
  23246. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23247. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23248. utils.ErrorLog("解析失败:%v", err)
  23249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23250. return
  23251. }
  23252. PsnNo = res.Output.Baseinfo.PsnNo
  23253. PsnCertType = res.Output.Baseinfo.PsnCertType
  23254. Certno = res.Output.Baseinfo.Certno
  23255. PsnName = res.Output.Baseinfo.PsnName
  23256. Gend = res.Output.Baseinfo.Gend
  23257. Naty = res.Output.Baseinfo.Naty
  23258. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23259. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23260. infoStr = string(Iinfos)
  23261. idetinfoStr = string(Idetinfos)
  23262. infocode = res.Infcode
  23263. }
  23264. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23265. if id_card_type == 1 {
  23266. psn_info, _ := service.GetPsnByPatientId(id)
  23267. PsnNo = psn_info.PsnNo
  23268. PsnCertType = psn_info.PsnCertType
  23269. Certno = psn_info.Certno
  23270. PsnName = psn_info.PsnName
  23271. Gend = psn_info.Gend
  23272. Naty = psn_info.Naty
  23273. Brdy = psn_info.Brdy
  23274. Age = psn_info.Age
  23275. infoStr = psn_info.Insuinfo
  23276. idetinfoStr = psn_info.Idetinfo
  23277. infocode = 0
  23278. verify_number = psn_info.VerifyNumber
  23279. } else if id_card_type == 2 {
  23280. 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, "")
  23281. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23282. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23283. utils.ErrorLog("解析失败:%v", err)
  23284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23285. return
  23286. }
  23287. PsnNo = res.Output.Baseinfo.PsnNo
  23288. PsnCertType = res.Output.Baseinfo.PsnCertType
  23289. Certno = res.Output.Baseinfo.Certno
  23290. PsnName = res.Output.Baseinfo.PsnName
  23291. Gend = res.Output.Baseinfo.Gend
  23292. Naty = res.Output.Baseinfo.Naty
  23293. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23294. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23295. infoStr = string(Iinfos)
  23296. idetinfoStr = string(Idetinfos)
  23297. infocode = res.Infcode
  23298. } else {
  23299. psn_info, _ := service.GetPsnByPatientId(id)
  23300. PsnNo = psn_info.PsnNo
  23301. PsnCertType = psn_info.PsnCertType
  23302. Certno = psn_info.Certno
  23303. PsnName = psn_info.PsnName
  23304. Gend = psn_info.Gend
  23305. Naty = psn_info.Naty
  23306. Brdy = psn_info.Brdy
  23307. Age = psn_info.Age
  23308. infoStr = psn_info.Insuinfo
  23309. idetinfoStr = psn_info.Idetinfo
  23310. infocode = 0
  23311. verify_number = psn_info.VerifyNumber
  23312. }
  23313. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23314. if id_card_type == 1 {
  23315. psn_info, _ := service.GetPsnByPatientId(id)
  23316. PsnNo = psn_info.PsnNo
  23317. PsnCertType = psn_info.PsnCertType
  23318. Certno = psn_info.Certno
  23319. PsnName = psn_info.PsnName
  23320. Gend = psn_info.Gend
  23321. Naty = psn_info.Naty
  23322. Brdy = psn_info.Brdy
  23323. Age = psn_info.Age
  23324. infoStr = psn_info.Insuinfo
  23325. idetinfoStr = psn_info.Idetinfo
  23326. infocode = 0
  23327. verify_number = psn_info.VerifyNumber
  23328. } else if id_card_type == 2 {
  23329. psn_info, _ := service.GetPsnByPatientId(id)
  23330. PsnNo = psn_info.PsnNo
  23331. PsnCertType = psn_info.PsnCertType
  23332. Certno = psn_info.Certno
  23333. PsnName = psn_info.PsnName
  23334. Gend = psn_info.Gend
  23335. Naty = psn_info.Naty
  23336. Brdy = psn_info.Brdy
  23337. Age = psn_info.Age
  23338. infoStr = psn_info.Insuinfo
  23339. idetinfoStr = psn_info.Idetinfo
  23340. infocode = 0
  23341. verify_number = psn_info.VerifyNumber
  23342. } else {
  23343. psn_info, _ := service.GetPsnByPatientId(id)
  23344. PsnNo = psn_info.PsnNo
  23345. PsnCertType = psn_info.PsnCertType
  23346. Certno = psn_info.Certno
  23347. PsnName = psn_info.PsnName
  23348. Gend = psn_info.Gend
  23349. Naty = psn_info.Naty
  23350. Brdy = psn_info.Brdy
  23351. Age = psn_info.Age
  23352. infoStr = psn_info.Insuinfo
  23353. idetinfoStr = psn_info.Idetinfo
  23354. infocode = 0
  23355. verify_number = psn_info.VerifyNumber
  23356. }
  23357. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23358. psn_info, _ := service.GetPsnByPatientId(id)
  23359. PsnNo = psn_info.PsnNo
  23360. PsnCertType = psn_info.PsnCertType
  23361. Certno = psn_info.Certno
  23362. PsnName = psn_info.PsnName
  23363. Gend = psn_info.Gend
  23364. Naty = psn_info.Naty
  23365. Brdy = psn_info.Brdy
  23366. Age = psn_info.Age
  23367. infoStr = psn_info.Insuinfo
  23368. idetinfoStr = psn_info.Idetinfo
  23369. infocode = 0
  23370. verify_number = psn_info.VerifyNumber
  23371. idetinfoStr = psn_info.Idetinfo
  23372. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23373. if id_card_type == 1 {
  23374. psn_info, _ := service.GetPsnByPatientId(id)
  23375. PsnNo = psn_info.PsnNo
  23376. PsnCertType = psn_info.PsnCertType
  23377. Certno = psn_info.Certno
  23378. PsnName = psn_info.PsnName
  23379. Gend = psn_info.Gend
  23380. Naty = psn_info.Naty
  23381. Brdy = psn_info.Brdy
  23382. Age = psn_info.Age
  23383. infoStr = psn_info.Insuinfo
  23384. idetinfoStr = psn_info.Idetinfo
  23385. infocode = 0
  23386. verify_number = psn_info.VerifyNumber
  23387. } else if id_card_type == 2 {
  23388. 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)
  23389. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23390. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23391. utils.ErrorLog("解析失败:%v", err)
  23392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23393. return
  23394. }
  23395. PsnNo = res.Output.Baseinfo.PsnNo
  23396. PsnCertType = res.Output.Baseinfo.PsnCertType
  23397. Certno = res.Output.Baseinfo.Certno
  23398. PsnName = res.Output.Baseinfo.PsnName
  23399. Gend = res.Output.Baseinfo.Gend
  23400. Naty = res.Output.Baseinfo.Naty
  23401. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23402. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23403. infoStr = string(Iinfos)
  23404. idetinfoStr = string(Idetinfos)
  23405. infocode = res.Infcode
  23406. } else if id_card_type == 4 {
  23407. psn_info, _ := service.GetPsnByPatientId(id)
  23408. PsnNo = psn_info.PsnNo
  23409. PsnCertType = psn_info.PsnCertType
  23410. Certno = psn_info.Certno
  23411. PsnName = psn_info.PsnName
  23412. Gend = psn_info.Gend
  23413. Naty = psn_info.Naty
  23414. Brdy = psn_info.Brdy
  23415. Age = psn_info.Age
  23416. infoStr = psn_info.Insuinfo
  23417. idetinfoStr = psn_info.Idetinfo
  23418. infocode = 0
  23419. verify_number = psn_info.VerifyNumber
  23420. }
  23421. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23422. var result string
  23423. var requestLog string
  23424. 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), "")
  23425. if id_card_type == 4 {
  23426. psn_info, _ := service.GetPsnByPatientId(id)
  23427. PsnNo = psn_info.PsnNo
  23428. PsnCertType = psn_info.PsnCertType
  23429. Certno = psn_info.Certno
  23430. PsnName = psn_info.PsnName
  23431. Gend = psn_info.Gend
  23432. Naty = psn_info.Naty
  23433. Brdy = psn_info.Brdy
  23434. Age = psn_info.Age
  23435. infoStr = psn_info.Insuinfo
  23436. idetinfoStr = psn_info.Idetinfo
  23437. infocode = 0
  23438. verify_number = psn_info.VerifyNumber
  23439. } else {
  23440. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23441. if miConfig.Code == "H15049901371" {
  23442. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23443. utils.ErrorLog("解析失败:%v", err)
  23444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23445. return
  23446. }
  23447. res.ErrMsg = res10265.ErrMsg
  23448. res.Output = res10265.Output
  23449. res.InfRefmsgid = res10265.InfRefmsgid
  23450. } else {
  23451. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23452. utils.ErrorLog("解析失败:%v", err)
  23453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23454. return
  23455. }
  23456. }
  23457. PsnNo = res.Output.Baseinfo.PsnNo
  23458. PsnCertType = res.Output.Baseinfo.PsnCertType
  23459. Certno = res.Output.Baseinfo.Certno
  23460. PsnName = res.Output.Baseinfo.PsnName
  23461. Gend = res.Output.Baseinfo.Gend
  23462. Naty = res.Output.Baseinfo.Naty
  23463. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23464. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23465. infoStr = string(Iinfos)
  23466. idetinfoStr = string(Idetinfos)
  23467. if miConfig.Code == "H15049901371" {
  23468. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23469. } else {
  23470. infocode = res.Infcode
  23471. }
  23472. }
  23473. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23474. psn_info, _ := service.GetPsnByPatientId(id)
  23475. PsnNo = psn_info.PsnNo
  23476. PsnCertType = psn_info.PsnCertType
  23477. Certno = psn_info.Certno
  23478. PsnName = psn_info.PsnName
  23479. Gend = psn_info.Gend
  23480. Naty = psn_info.Naty
  23481. Brdy = psn_info.Brdy
  23482. Age = psn_info.Age
  23483. infoStr = psn_info.Insuinfo
  23484. idetinfoStr = psn_info.Idetinfo
  23485. infocode = 0
  23486. verify_number = psn_info.VerifyNumber
  23487. } else if miConfig.MdtrtareaAdmvs == "450721" {
  23488. psn_info, _ := service.GetPsnByPatientId(id)
  23489. PsnNo = psn_info.PsnNo
  23490. PsnCertType = psn_info.PsnCertType
  23491. Certno = psn_info.Certno
  23492. PsnName = psn_info.PsnName
  23493. Gend = psn_info.Gend
  23494. Naty = psn_info.Naty
  23495. Brdy = psn_info.Brdy
  23496. Age = psn_info.Age
  23497. infoStr = psn_info.Insuinfo
  23498. idetinfoStr = psn_info.Idetinfo
  23499. infocode = 0
  23500. verify_number = psn_info.VerifyNumber
  23501. } else {
  23502. var result string
  23503. var requestLog string
  23504. //if miConfig.UserOrgId == 10138 {
  23505. if id_card_type != 4 || id_card_type != 1 {
  23506. var insa string
  23507. if len(patient.InsuplcAdmdvs) > 0 {
  23508. insa = patient.InsuplcAdmdvs
  23509. } else {
  23510. insa = miConfig.InsuplcAdmdvs
  23511. }
  23512. //psn_info, _ := service.GetPsnByPatientId(id)
  23513. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  23514. 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)
  23515. }
  23516. //}
  23517. //else {
  23518. // var insa string
  23519. // if len(patient.InsuplcAdmdvs) > 0 {
  23520. // insa = patient.InsuplcAdmdvs
  23521. // } else {
  23522. // insa = miConfig.InsuplcAdmdvs
  23523. // }
  23524. // 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)
  23525. //}
  23526. if id_card_type == 4 || id_card_type == 1 {
  23527. psn_info, _ := service.GetPsnByPatientId(id)
  23528. PsnNo = psn_info.PsnNo
  23529. PsnCertType = psn_info.PsnCertType
  23530. Certno = psn_info.Certno
  23531. PsnName = psn_info.PsnName
  23532. Gend = psn_info.Gend
  23533. Naty = psn_info.Naty
  23534. Brdy = psn_info.Brdy
  23535. Age = psn_info.Age
  23536. infoStr = psn_info.Insuinfo
  23537. idetinfoStr = psn_info.Idetinfo
  23538. infocode = 0
  23539. verify_number = psn_info.VerifyNumber
  23540. } else {
  23541. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23542. if miConfig.Code == "H15049901371" {
  23543. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23544. utils.ErrorLog("解析失败:%v", err)
  23545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23546. return
  23547. }
  23548. res.ErrMsg = res10265.ErrMsg
  23549. res.Output = res10265.Output
  23550. res.InfRefmsgid = res10265.InfRefmsgid
  23551. } else {
  23552. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23553. utils.ErrorLog("解析失败:%v", err)
  23554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23555. return
  23556. }
  23557. }
  23558. PsnNo = res.Output.Baseinfo.PsnNo
  23559. PsnCertType = res.Output.Baseinfo.PsnCertType
  23560. Certno = res.Output.Baseinfo.Certno
  23561. PsnName = res.Output.Baseinfo.PsnName
  23562. Gend = res.Output.Baseinfo.Gend
  23563. Naty = res.Output.Baseinfo.Naty
  23564. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23565. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23566. infoStr = string(Iinfos)
  23567. idetinfoStr = string(Idetinfos)
  23568. if miConfig.Code == "H15049901371" {
  23569. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23570. } else {
  23571. infocode = res.Infcode
  23572. }
  23573. }
  23574. }
  23575. if infocode == 0 {
  23576. his := models.VMHisPatient{
  23577. Name: name,
  23578. Gender: gender,
  23579. Birthday: birthUnix,
  23580. MedicalTreatmentType: medical_care,
  23581. IdType: certificates,
  23582. IdCardNo: id_card,
  23583. BalanceAccountsType: settlementValue,
  23584. SocialType: social_type,
  23585. MedicalInsuranceNumber: medical_insurance_card,
  23586. RegisterType: register_type,
  23587. RegisterCost: registration_fee,
  23588. TreatmentCost: medical_expenses,
  23589. Status: 1,
  23590. Ctime: time.Now().Unix(),
  23591. Mtime: time.Now().Unix(),
  23592. PsnNo: PsnNo,
  23593. PsnCertType: PsnCertType,
  23594. Certno: Certno,
  23595. PsnName: PsnName,
  23596. Gend: Gend,
  23597. Naty: Naty,
  23598. Brdy: Brdy,
  23599. Age: Age,
  23600. Iinfo: infoStr,
  23601. Idetinfo: idetinfoStr,
  23602. PatientId: patient.ID,
  23603. RecordDate: theTime.Unix(),
  23604. UserOrgId: adminInfo.CurrentOrgId,
  23605. AdminUserId: admin_user_id,
  23606. IsReturn: 1,
  23607. IdCardType: id_card_type,
  23608. Doctor: doctor,
  23609. Departments: department,
  23610. MdtrtGrpType: mdtrt_type,
  23611. }
  23612. timestamp := time.Now().Unix()
  23613. tempTime := time.Unix(timestamp, 0)
  23614. timeFormat := tempTime.Format("20060102150405")
  23615. chrgBchno := rand.Intn(100000) + 10000
  23616. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23617. his.Number = ipt_otp_no
  23618. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  23619. department, _ := service.GetDepartMentDetail(department)
  23620. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  23621. IdCardNo := ""
  23622. if id_card_type == 1 {
  23623. // IdCardNo = medical_insurance_card
  23624. IdCardNo = patient.IdCardNo
  23625. } else {
  23626. IdCardNo = patient.IdCardNo
  23627. }
  23628. var rf []*ResultFive
  23629. json.Unmarshal([]byte(his.Iinfo), &rf)
  23630. var insutypes []*ResultFive
  23631. var insutype string
  23632. var insuplc_admdvs_temp string
  23633. var is390 int = 0
  23634. var is310 int = 0
  23635. for _, item := range rf {
  23636. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23637. insutypes = append(insutypes, item)
  23638. }
  23639. }
  23640. if len(insutypes) == 1 {
  23641. insutype = insutypes[0].Insutype
  23642. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23643. if insutype == "390" {
  23644. is390 = 1
  23645. }
  23646. if insutype == "310" {
  23647. is310 = 1
  23648. }
  23649. } else {
  23650. for _, i := range insutypes {
  23651. if i.Insutype == "390" {
  23652. is390 = 1
  23653. }
  23654. if i.Insutype == "310" {
  23655. is310 = 1
  23656. }
  23657. }
  23658. }
  23659. if is390 == 1 {
  23660. insutype = "390"
  23661. }
  23662. if is310 == 1 {
  23663. insutype = "310"
  23664. }
  23665. fmt.Println(social_type)
  23666. if social_type > 0 {
  23667. insutype = strconv.FormatInt(social_type, 10)
  23668. }
  23669. var infocode int64
  23670. var resThree ResultThree
  23671. var resThree10265 ResultThree10265
  23672. if len(insuplc_admdvs) == 0 {
  23673. psn_info, _ := service.GetPsnByPatientId(id)
  23674. //if len(psn_info.InsuplcAdmdvs) > 0 {
  23675. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23676. //}
  23677. } else {
  23678. insuplc_admdvs_temp = insuplc_admdvs
  23679. }
  23680. if miConfig.MdtrtareaAdmvs == "421300" {
  23681. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23682. psn_info, _ := service.GetPsnByPatientId(id)
  23683. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23684. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23685. "&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
  23686. resp, requestErr := http.Get(api)
  23687. if requestErr != nil {
  23688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23689. return
  23690. }
  23691. body, ioErr := ioutil.ReadAll(resp.Body)
  23692. if ioErr != nil {
  23693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23695. return
  23696. }
  23697. var respJSON map[string]interface{}
  23698. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23701. return
  23702. }
  23703. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23704. result, _ := json.Marshal(respJSON)
  23705. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23706. utils.ErrorLog("解析失败:%v", err)
  23707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23708. return
  23709. }
  23710. infocode = resThree.Infcode
  23711. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23712. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23713. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23714. // insuplc_admdvs_temp =
  23715. //}
  23716. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23717. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23718. //}
  23719. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23720. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23721. "&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
  23722. resp, requestErr := http.Get(api)
  23723. if requestErr != nil {
  23724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23725. return
  23726. }
  23727. body, ioErr := ioutil.ReadAll(resp.Body)
  23728. if ioErr != nil {
  23729. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23731. return
  23732. }
  23733. var respJSON map[string]interface{}
  23734. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23737. return
  23738. }
  23739. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23740. result, _ := json.Marshal(respJSON)
  23741. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23742. utils.ErrorLog("解析失败:%v", err)
  23743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23744. return
  23745. }
  23746. infocode = resThree.Infcode
  23747. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23748. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23749. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23750. // insuplc_admdvs_temp =
  23751. //}
  23752. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23753. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23754. //}
  23755. utils.ErrorLog("解析失败:%v", insutype)
  23756. utils.ErrorLog("解析失败:%v", PsnNo)
  23757. utils.ErrorLog("解析失败:%v", Certno)
  23758. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  23759. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  23760. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  23761. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  23762. utils.ErrorLog("解析失败:%v", PsnNo)
  23763. utils.ErrorLog("解析失败:%v", department.Number)
  23764. utils.ErrorLog("解析失败:%v", department.Name)
  23765. utils.ErrorLog("解析失败:%v", roles.UserName)
  23766. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23767. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23768. "&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
  23769. resp, requestErr := http.Get(api)
  23770. if requestErr != nil {
  23771. utils.ErrorLog("解析失败:%v", requestErr)
  23772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23773. return
  23774. }
  23775. body, ioErr := ioutil.ReadAll(resp.Body)
  23776. if ioErr != nil {
  23777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23779. return
  23780. }
  23781. var respJSON map[string]interface{}
  23782. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23785. return
  23786. }
  23787. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23788. result, _ := json.Marshal(respJSON)
  23789. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23790. utils.ErrorLog("解析失败:%v", err)
  23791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23792. return
  23793. }
  23794. infocode = resThree.Infcode
  23795. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23796. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23797. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23798. // insuplc_admdvs_temp =
  23799. //}
  23800. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23801. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23802. //}
  23803. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23804. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23805. "&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
  23806. resp, requestErr := http.Get(api)
  23807. if requestErr != nil {
  23808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23809. return
  23810. }
  23811. body, ioErr := ioutil.ReadAll(resp.Body)
  23812. if ioErr != nil {
  23813. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23815. return
  23816. }
  23817. var respJSON map[string]interface{}
  23818. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23821. return
  23822. }
  23823. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23824. result, _ := json.Marshal(respJSON)
  23825. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23826. utils.ErrorLog("解析失败:%v", err)
  23827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23828. return
  23829. }
  23830. infocode = resThree.Infcode
  23831. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23832. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23833. psn_info, _ := service.GetPsnByPatientId(id)
  23834. var verify_number string
  23835. if id_card_type == 4 {
  23836. verify_number = psn_info.VerifyNumber
  23837. } else if id_card_type == 1 {
  23838. bas := strings.Split(psn_info.CardInfo, "|")
  23839. cardNumber := bas[2]
  23840. verify_number = cardNumber
  23841. }
  23842. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23843. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23844. "&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
  23845. resp, requestErr := http.Get(api)
  23846. if requestErr != nil {
  23847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23848. return
  23849. }
  23850. body, ioErr := ioutil.ReadAll(resp.Body)
  23851. if ioErr != nil {
  23852. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23854. return
  23855. }
  23856. var respJSON map[string]interface{}
  23857. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23858. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23860. return
  23861. }
  23862. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23863. result, _ := json.Marshal(respJSON)
  23864. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23865. // utils.ErrorLog("解析失败:%v", err)
  23866. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23867. // return
  23868. //}
  23869. //infocode = resThree.Infcode
  23870. //result, _ := json.Marshal(respJSON)
  23871. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23872. utils.ErrorLog("解析失败:%v", err)
  23873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23874. return
  23875. }
  23876. resThree.ErrMsg = resThree10265.ErrMsg
  23877. resThree.Output = resThree10265.Output
  23878. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23879. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23880. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23881. psn_info, _ := service.GetPsnByPatientId(id)
  23882. his.PsnNo = psn_info.PsnNo
  23883. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23884. var cert_no string
  23885. if id_card_type == 3 {
  23886. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  23887. cert_no = IdCardNo
  23888. } else if id_card_type == 4 {
  23889. cert_no = IdCardNo
  23890. psn_info.VerifyNumber = psn_info.VerifyNumber
  23891. } else {
  23892. bas := strings.Split(psn_info.CardInfo, "|")
  23893. cert_no = bas[2]
  23894. }
  23895. var hisPrescription []*models.HisPrescription
  23896. for _, item := range rf {
  23897. if item.Insutype == insutype {
  23898. //insuplc_admdvs = item.InsuplcAdmdvs
  23899. his.InsuplcAdmdvs = insuplc_admdvs
  23900. }
  23901. }
  23902. his.Insutype = insutype
  23903. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  23904. fmt.Println(res3101)
  23905. fmt.Println(res3101.Infcode)
  23906. if res3101.Infcode == "0" {
  23907. fmt.Println("33333333")
  23908. if len(res3101.Output.Result) > 0 {
  23909. fmt.Println("222222")
  23910. for _, item := range res3101.Output.Result {
  23911. if len(res3101.ErrMsg) == 0 {
  23912. res3101.ErrMsg = item.VolaCont
  23913. } else {
  23914. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  23915. }
  23916. }
  23917. c.ServeSuccessJSON(map[string]interface{}{
  23918. "failed_code": -10,
  23919. "msg": res3101.ErrMsg,
  23920. })
  23921. return
  23922. } else {
  23923. fmt.Println("11111")
  23924. var api string
  23925. if miConfig.MdtrtareaAdmvs == "320921" {
  23926. ipt_otp_no = timeFormat
  23927. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23928. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23929. "&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
  23930. } else {
  23931. ipt_otp_no = timeFormat
  23932. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23933. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23934. "&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
  23935. }
  23936. resp, requestErr := http.Get(api)
  23937. if requestErr != nil {
  23938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23939. return
  23940. }
  23941. body, ioErr := ioutil.ReadAll(resp.Body)
  23942. if ioErr != nil {
  23943. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23945. return
  23946. }
  23947. var respJSON map[string]interface{}
  23948. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23949. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23951. return
  23952. }
  23953. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23954. result, _ := json.Marshal(respJSON)
  23955. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23956. utils.ErrorLog("解析失败:%v", err)
  23957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23958. return
  23959. }
  23960. resThree.ErrMsg = resThree10265.ErrMsg
  23961. resThree.Output = resThree10265.Output
  23962. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23963. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23964. }
  23965. } else if res3101.Infcode != "0" {
  23966. c.ServeSuccessJSON(map[string]interface{}{
  23967. "failed_code": -10,
  23968. "msg": res3101.ErrMsg,
  23969. })
  23970. return
  23971. }
  23972. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23973. psn_info, _ := service.GetPsnByPatientId(id)
  23974. var cert_no string
  23975. if id_card_type == 1 {
  23976. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  23977. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23978. } else if id_card_type == 4 {
  23979. cert_no = psn_info.VerifyNumber
  23980. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23981. } else {
  23982. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23983. cert_no = psn_info.VerifyNumber
  23984. }
  23985. 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)
  23986. saveLog(result, requestLog, "2201", "挂号")
  23987. if miConfig.Code == "H15049901371" {
  23988. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23989. utils.ErrorLog("解析失败:%v", err)
  23990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23991. return
  23992. }
  23993. resThree.ErrMsg = resThree10265.ErrMsg
  23994. resThree.Output = resThree10265.Output
  23995. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23996. } else {
  23997. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23998. utils.ErrorLog("解析失败:%v", err)
  23999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24000. return
  24001. }
  24002. }
  24003. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24004. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  24005. psn_info, _ := service.GetPsnByPatientId(id)
  24006. var result string
  24007. var requestLog string
  24008. if id_card_type == 1 {
  24009. bas := strings.Split(psn_info.CardInfo, "|")
  24010. basNumber := bas[2]
  24011. card_sn := bas[3]
  24012. 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)
  24013. saveLog(result, requestLog, "2201A", "挂号")
  24014. } else if id_card_type == 2 {
  24015. 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, "", "", "", "", "", "")
  24016. saveLog(result, requestLog, "2201A", "挂号")
  24017. } else {
  24018. 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)
  24019. saveLog(result, requestLog, "2201A", "挂号")
  24020. }
  24021. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24022. utils.ErrorLog("解析失败:%v", err)
  24023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24024. return
  24025. }
  24026. infocode = resThree.Infcode
  24027. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  24028. psn_info, _ := service.GetPsnByPatientId(id)
  24029. var result string
  24030. var requestLog string
  24031. if id_card_type == 1 {
  24032. bas := strings.Split(psn_info.CardInfo, "|")
  24033. basNumber := bas[2]
  24034. card_sn := ""
  24035. 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)
  24036. saveLog(result, requestLog, "2201A", "挂号")
  24037. } else if id_card_type == 2 {
  24038. 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, "", "", "", "", "", "")
  24039. saveLog(result, requestLog, "2201A", "挂号")
  24040. } else {
  24041. 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)
  24042. saveLog(result, requestLog, "2201A", "挂号")
  24043. }
  24044. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24045. utils.ErrorLog("解析失败:%v", err)
  24046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24047. return
  24048. }
  24049. infocode = resThree.Infcode
  24050. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24051. psn_info, _ := service.GetPsnByPatientId(id)
  24052. his.PsnNo = psn_info.PsnNo
  24053. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24054. var cert_no string
  24055. if id_card_type == 1 {
  24056. bas := strings.Split(psn_info.CardInfo, "|")
  24057. cert_no = bas[2]
  24058. } else if id_card_type == 4 {
  24059. cert_no = psn_info.VerifyNumber
  24060. psn_info.VerifyNumber = psn_info.VerifyNumber
  24061. IdCardNo = psn_info.VerifyNumber
  24062. } else {
  24063. cert_no = IdCardNo
  24064. psn_info.VerifyNumber = cert_no
  24065. }
  24066. for _, item := range rf {
  24067. if item.Insutype == insutype {
  24068. his.InsuplcAdmdvs = insuplc_admdvs
  24069. }
  24070. }
  24071. his.Insutype = insutype
  24072. var api string
  24073. ipt_otp_no = timeFormat
  24074. 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 +
  24075. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24076. "&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
  24077. resp, requestErr := http.Get(api)
  24078. if requestErr != nil {
  24079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24080. return
  24081. }
  24082. body, ioErr := ioutil.ReadAll(resp.Body)
  24083. if ioErr != nil {
  24084. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24086. return
  24087. }
  24088. var respJSON map[string]interface{}
  24089. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24092. return
  24093. }
  24094. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24095. if status == "0" {
  24096. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24097. c.ServeSuccessJSON(map[string]interface{}{
  24098. "failed_code": -10,
  24099. "msg": err_msg,
  24100. })
  24101. return
  24102. }
  24103. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24104. result, _ := json.Marshal(respJSON)
  24105. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24106. utils.ErrorLog("解析失败:%v", err)
  24107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24108. return
  24109. }
  24110. infocode = resThree.Infcode
  24111. } else if miConfig.MdtrtareaAdmvs == "340699" {
  24112. psn_info, _ := service.GetPsnByPatientId(id)
  24113. his.PsnNo = psn_info.PsnNo
  24114. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24115. var cert_no string
  24116. if id_card_type == 1 {
  24117. bas := strings.Split(psn_info.CardInfo, "|")
  24118. cert_no = bas[2]
  24119. } else if id_card_type == 4 {
  24120. cert_no = psn_info.VerifyNumber
  24121. psn_info.VerifyNumber = psn_info.VerifyNumber
  24122. IdCardNo = psn_info.VerifyNumber
  24123. } else {
  24124. cert_no = IdCardNo
  24125. psn_info.VerifyNumber = cert_no
  24126. }
  24127. for _, item := range rf {
  24128. if item.Insutype == insutype {
  24129. his.InsuplcAdmdvs = insuplc_admdvs
  24130. patient.InsuplcAdmdvs = insuplc_admdvs
  24131. }
  24132. }
  24133. his.Insutype = insutype
  24134. var api string
  24135. ipt_otp_no = timeFormat
  24136. 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 +
  24137. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24138. "&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
  24139. resp, requestErr := http.Get(api)
  24140. if requestErr != nil {
  24141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24142. return
  24143. }
  24144. body, ioErr := ioutil.ReadAll(resp.Body)
  24145. if ioErr != nil {
  24146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24148. return
  24149. }
  24150. var respJSON map[string]interface{}
  24151. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24154. return
  24155. }
  24156. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24157. if status == "0" {
  24158. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24159. c.ServeSuccessJSON(map[string]interface{}{
  24160. "failed_code": -10,
  24161. "msg": err_msg,
  24162. })
  24163. return
  24164. }
  24165. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24166. result, _ := json.Marshal(respJSON)
  24167. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24168. utils.ErrorLog("解析失败:%v", err)
  24169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24170. return
  24171. }
  24172. infocode = resThree.Infcode
  24173. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24174. psn_info, _ := service.GetPsnByPatientId(id)
  24175. var result string
  24176. var requestLog string
  24177. if id_card_type == 1 {
  24178. bas := strings.Split(psn_info.CardInfo, "|")
  24179. basNumber := bas[2]
  24180. card_sn := bas[3]
  24181. 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)
  24182. saveLog(result, requestLog, "2201A", "挂号")
  24183. } else if id_card_type == 2 {
  24184. 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, "", "")
  24185. saveLog(result, requestLog, "2201A", "挂号")
  24186. } else {
  24187. 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, "", "")
  24188. saveLog(result, requestLog, "2201A", "挂号")
  24189. }
  24190. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24191. utils.ErrorLog("解析失败:%v", err)
  24192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24193. return
  24194. }
  24195. infocode = resThree.Infcode
  24196. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24197. psn_info, _ := service.GetPsnByPatientId(id)
  24198. 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)
  24199. saveLog(result, requestLog, "2201A", "挂号")
  24200. if miConfig.Code == "H15049901371" {
  24201. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24202. utils.ErrorLog("解析失败:%v", err)
  24203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24204. return
  24205. }
  24206. resThree.ErrMsg = resThree10265.ErrMsg
  24207. resThree.Output = resThree10265.Output
  24208. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24209. } else {
  24210. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24211. utils.ErrorLog("解析失败:%v", err)
  24212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24213. return
  24214. }
  24215. }
  24216. if miConfig.Code == "H15049901371" {
  24217. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24218. } else {
  24219. infocode = resThree.Infcode
  24220. }
  24221. } else {
  24222. psn_info, _ := service.GetPsnByPatientId(id)
  24223. if id_card_type == 4 || id_card_type == 1 {
  24224. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24225. }
  24226. var rf []*ResultFive
  24227. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24228. var insutypes []*ResultFive
  24229. var insutype string
  24230. var is390 int = 0
  24231. var is310 int = 0
  24232. for _, item := range rf {
  24233. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24234. insutypes = append(insutypes, item)
  24235. }
  24236. }
  24237. if len(insutypes) == 1 {
  24238. insutype = insutypes[0].Insutype
  24239. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24240. } else {
  24241. for _, i := range insutypes {
  24242. if i.Insutype == "390" {
  24243. is390 = 1
  24244. }
  24245. if i.Insutype == "310" {
  24246. is310 = 1
  24247. }
  24248. }
  24249. }
  24250. if is390 == 1 {
  24251. insutype = "390"
  24252. }
  24253. if is310 == 1 {
  24254. insutype = "310"
  24255. }
  24256. fmt.Println(len(insutypes))
  24257. if len(insutypes) == 0 {
  24258. for index, item := range rf {
  24259. if index == 0 {
  24260. insutype = item.Insutype
  24261. insuplc_admdvs = item.InsuplcAdmdvs
  24262. }
  24263. }
  24264. fmt.Println(insutype)
  24265. fmt.Println(insuplc_admdvs)
  24266. }
  24267. if social_type > 0 {
  24268. insutype = strconv.FormatInt(social_type, 10)
  24269. }
  24270. fmt.Println("--------")
  24271. fmt.Println(psn_info)
  24272. fmt.Println(psn_info.PsnNo)
  24273. if miConfig.MdtrtareaAdmvs == "441202" {
  24274. var hisPrescription []*models.HisPrescription
  24275. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24276. if res3101.Infcode == 0 {
  24277. fmt.Println("33333333")
  24278. if len(res3101.Output.Result) > 0 {
  24279. fmt.Println("222222")
  24280. for _, item := range res3101.Output.Result {
  24281. if len(res3101.ErrMsg) == 0 {
  24282. res3101.ErrMsg = item.VolaCont
  24283. } else {
  24284. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24285. }
  24286. }
  24287. c.ServeSuccessJSON(map[string]interface{}{
  24288. "failed_code": -10,
  24289. "msg": res3101.ErrMsg,
  24290. })
  24291. return
  24292. } else {
  24293. hour := time.Now().Format("15")
  24294. min := time.Now().Format("04")
  24295. sec := time.Now().Format("05")
  24296. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24297. fmt.Println(record_time_two)
  24298. 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)
  24299. saveLog(result, requestLog, "2201A", "挂号")
  24300. if miConfig.Code == "H15049901371" {
  24301. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24302. utils.ErrorLog("解析失败:%v", err)
  24303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24304. return
  24305. }
  24306. resThree.ErrMsg = resThree10265.ErrMsg
  24307. resThree.Output = resThree10265.Output
  24308. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24309. } else {
  24310. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24311. utils.ErrorLog("解析失败:%v", err)
  24312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24313. return
  24314. }
  24315. }
  24316. if miConfig.Code == "H15049901371" {
  24317. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24318. } else {
  24319. infocode = resThree.Infcode
  24320. }
  24321. }
  24322. } else if res3101.Infcode != 0 {
  24323. c.ServeSuccessJSON(map[string]interface{}{
  24324. "failed_code": -10,
  24325. "msg": res3101.ErrMsg,
  24326. })
  24327. return
  24328. }
  24329. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24330. var hisPrescription []*models.HisPrescription
  24331. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24332. if res3101.Infcode == 0 {
  24333. fmt.Println("33333333")
  24334. if len(res3101.Output.Result) > 0 {
  24335. fmt.Println("222222")
  24336. for _, item := range res3101.Output.Result {
  24337. if len(res3101.ErrMsg) == 0 {
  24338. res3101.ErrMsg = item.VolaCont
  24339. } else {
  24340. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24341. }
  24342. }
  24343. c.ServeSuccessJSON(map[string]interface{}{
  24344. "failed_code": -10,
  24345. "msg": res3101.ErrMsg,
  24346. })
  24347. return
  24348. } else {
  24349. hour := time.Now().Format("15")
  24350. min := time.Now().Format("04")
  24351. sec := time.Now().Format("05")
  24352. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24353. fmt.Println(record_time_two)
  24354. 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)
  24355. saveLog(result, requestLog, "2201A", "挂号")
  24356. if miConfig.Code == "H15049901371" {
  24357. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24358. utils.ErrorLog("解析失败:%v", err)
  24359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24360. return
  24361. }
  24362. resThree.ErrMsg = resThree10265.ErrMsg
  24363. resThree.Output = resThree10265.Output
  24364. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24365. } else {
  24366. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24367. utils.ErrorLog("解析失败:%v", err)
  24368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24369. return
  24370. }
  24371. }
  24372. if miConfig.Code == "H15049901371" {
  24373. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24374. } else {
  24375. infocode = resThree.Infcode
  24376. }
  24377. }
  24378. } else if res3101.Infcode != 0 {
  24379. c.ServeSuccessJSON(map[string]interface{}{
  24380. "failed_code": -10,
  24381. "msg": res3101.ErrMsg,
  24382. })
  24383. return
  24384. }
  24385. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24386. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24387. psn_info, _ := service.GetPsnByPatientId(id)
  24388. var verify_number string
  24389. if id_card_type == 4 {
  24390. verify_number = psn_info.VerifyNumber
  24391. } else if id_card_type == 1 {
  24392. bas := strings.Split(psn_info.CardInfo, "|")
  24393. cardNumber := bas[2]
  24394. verify_number = cardNumber
  24395. } else {
  24396. verify_number = psn_info.Certno
  24397. }
  24398. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24399. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24400. "&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
  24401. resp, requestErr := http.Get(api)
  24402. if requestErr != nil {
  24403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24404. return
  24405. }
  24406. body, ioErr := ioutil.ReadAll(resp.Body)
  24407. if ioErr != nil {
  24408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24410. return
  24411. }
  24412. var respJSON map[string]interface{}
  24413. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24416. return
  24417. }
  24418. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24419. result, _ := json.Marshal(respJSON)
  24420. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24421. utils.ErrorLog("解析失败:%v", err)
  24422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24423. return
  24424. }
  24425. infocode = resThree.Infcode
  24426. } else {
  24427. hour := time.Now().Format("15")
  24428. min := time.Now().Format("04")
  24429. sec := time.Now().Format("05")
  24430. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24431. if id_card_type == 1 {
  24432. for _, item := range rf {
  24433. if item.Insutype == strconv.FormatInt(social_type, 10) {
  24434. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  24435. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24436. } else if strconv.FormatInt(social_type, 10) == "390" {
  24437. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24438. } else {
  24439. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24440. }
  24441. }
  24442. }
  24443. }
  24444. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  24445. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24446. }
  24447. if id_card_type == 1 {
  24448. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  24449. bas := strings.Split(psn_info.CardInfo, "|")
  24450. basNumber := bas[1]
  24451. IdCardNo = basNumber
  24452. }
  24453. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  24454. IdCardNo = psn_info.VerifyNumber
  24455. }
  24456. if len(insuplc_admdvs_temp) == 0 {
  24457. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24458. }
  24459. var result string
  24460. var requestLog string
  24461. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  24462. var hisPrescription []*models.HisPrescription
  24463. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24464. if res3101.Infcode == 0 {
  24465. if len(res3101.Output.Result) > 0 {
  24466. for _, item := range res3101.Output.Result {
  24467. if len(res3101.ErrMsg) == 0 {
  24468. res3101.ErrMsg = item.VolaCont
  24469. } else {
  24470. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24471. }
  24472. }
  24473. c.ServeSuccessJSON(map[string]interface{}{
  24474. "failed_code": -10,
  24475. "msg": res3101.ErrMsg,
  24476. })
  24477. return
  24478. } else {
  24479. hour := time.Now().Format("15")
  24480. min := time.Now().Format("04")
  24481. sec := time.Now().Format("05")
  24482. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24483. fmt.Println(record_time_two)
  24484. 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)
  24485. saveLog(result, requestLog, "2201A", "挂号")
  24486. if miConfig.Code == "H15049901371" {
  24487. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24488. utils.ErrorLog("解析失败:%v", err)
  24489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24490. return
  24491. }
  24492. resThree.ErrMsg = resThree10265.ErrMsg
  24493. resThree.Output = resThree10265.Output
  24494. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24495. } else {
  24496. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24497. utils.ErrorLog("解析失败:%v", err)
  24498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24499. return
  24500. }
  24501. }
  24502. if miConfig.Code == "H15049901371" {
  24503. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24504. } else {
  24505. infocode = resThree.Infcode
  24506. }
  24507. }
  24508. } else if res3101.Infcode != 0 {
  24509. c.ServeSuccessJSON(map[string]interface{}{
  24510. "failed_code": -10,
  24511. "msg": res3101.ErrMsg,
  24512. })
  24513. return
  24514. }
  24515. } else {
  24516. psn_info, _ := service.GetPsnByPatientId(id)
  24517. var rf []*ResultFive
  24518. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24519. //var insutypes []*ResultFive
  24520. var insutype string
  24521. if social_type > 0 {
  24522. insutype = strconv.FormatInt(social_type, 10)
  24523. }
  24524. for _, item := range rf {
  24525. if item.Insutype == insutype {
  24526. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24527. }
  24528. }
  24529. 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)
  24530. saveLog(result, requestLog, "2201A", "挂号")
  24531. }
  24532. if miConfig.Code == "H15049901371" {
  24533. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24534. utils.ErrorLog("解析失败:%v", err)
  24535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24536. return
  24537. }
  24538. resThree.ErrMsg = resThree10265.ErrMsg
  24539. resThree.Output = resThree10265.Output
  24540. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24541. } else {
  24542. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24543. utils.ErrorLog("解析失败:%v", err)
  24544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24545. return
  24546. }
  24547. }
  24548. if miConfig.Code == "H15049901371" {
  24549. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24550. } else {
  24551. infocode = resThree.Infcode
  24552. }
  24553. }
  24554. }
  24555. if infocode == -1 {
  24556. adminUser := c.GetAdminUserInfo()
  24557. errlog := &models.HisOrderError{
  24558. UserOrgId: adminUser.CurrentOrgId,
  24559. Ctime: time.Now().Unix(),
  24560. Mtime: time.Now().Unix(),
  24561. ErrMsg: resThree.ErrMsg,
  24562. Status: 1,
  24563. PatientId: id,
  24564. RecordTime: recordDateTime,
  24565. Stage: 2,
  24566. }
  24567. service.CreateErrMsgLog(errlog)
  24568. c.ServeSuccessJSON(map[string]interface{}{
  24569. "failed_code": -10,
  24570. "msg": resThree.ErrMsg,
  24571. })
  24572. return
  24573. }
  24574. his.Number = resThree.Output.Data.MdtrtID
  24575. his.PsnNo = resThree.Output.Data.PsnNo
  24576. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  24577. his.IdCardNo = patient.IdCardNo
  24578. his.PhoneNumber = patient.Phone
  24579. his.UserOrgId = adminInfo.CurrentOrgId
  24580. his.Insutype = insutype
  24581. his.Ctime = time.Now().Unix()
  24582. his.Mtime = time.Now().Unix()
  24583. his.InsuplcAdmdvs = insuplc_admdvs_temp
  24584. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  24585. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24586. }
  24587. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  24588. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24589. }
  24590. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  24591. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24592. }
  24593. his.Status = 1
  24594. his.MdtrtGrpType = mdtrt_type
  24595. service.UpdateHisPatientStatus(&his)
  24596. service.UpdateHisPatient123(&patient)
  24597. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  24598. c.ServeSuccessJSON(map[string]interface{}{
  24599. "his_info": his,
  24600. })
  24601. } else {
  24602. adminUser := c.GetAdminUserInfo()
  24603. errlog := &models.HisOrderError{
  24604. UserOrgId: adminUser.CurrentOrgId,
  24605. Ctime: time.Now().Unix(),
  24606. Mtime: time.Now().Unix(),
  24607. ErrMsg: res.ErrMsg,
  24608. Status: 1,
  24609. PatientId: id,
  24610. RecordTime: recordDateTime,
  24611. Stage: 1,
  24612. }
  24613. service.CreateErrMsgLog(errlog)
  24614. c.ServeSuccessJSON(map[string]interface{}{
  24615. "failed_code": -10,
  24616. "msg": res.ErrMsg,
  24617. })
  24618. return
  24619. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  24620. }
  24621. }
  24622. }
  24623. func (c *HisApiController) GetUploadInfo() {
  24624. id, _ := c.GetInt64("id")
  24625. record_time := c.GetString("record_time")
  24626. his_patient_id, _ := c.GetInt64("his_patient_id")
  24627. order_id, _ := c.GetInt64("order_id")
  24628. pay_way, _ := c.GetInt64("pay_way")
  24629. pay_ways := c.GetString("pay_ways")
  24630. oth_desc := c.GetString("oth_desc")
  24631. pay_price, _ := c.GetFloat("pay_price")
  24632. pay_card_no := c.GetString("pay_card_no")
  24633. discount_price, _ := c.GetFloat("discount_price")
  24634. preferential_price, _ := c.GetFloat("preferential_price")
  24635. reality_price, _ := c.GetFloat("reality_price")
  24636. found_price, _ := c.GetFloat("found_price")
  24637. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  24638. private_price, _ := c.GetFloat("private_price")
  24639. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  24640. admin_user_id, _ := c.GetInt64("admin_user_id")
  24641. fapiao_code := c.GetString("fapiao_code")
  24642. fapiao_number := c.GetString("fapiao_number")
  24643. diagnosis_id := c.GetString("diagnosis")
  24644. sick_type, _ := c.GetInt64("sick_type")
  24645. reg_type, _ := c.GetInt64("p_type")
  24646. begin_time := c.GetString("begin_time")
  24647. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  24648. cash_pay := c.GetString("cash_pay")
  24649. band_card_pay := c.GetString("band_card_pay")
  24650. wechat_pay := c.GetString("wechat_pay")
  24651. ali_pay := c.GetString("ali_pay")
  24652. jifen_pay := c.GetString("jifen_pay")
  24653. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  24654. fmt.Println(acct_used_flag)
  24655. id_str := c.GetString("ids")
  24656. ids_arr := strings.Split(id_str, ",")
  24657. timeLayout := "2006-01-02"
  24658. loc, _ := time.LoadLocation("Local")
  24659. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24660. if err != nil {
  24661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24662. return
  24663. }
  24664. recordDateTime := theTime.Unix()
  24665. adminUser := c.GetAdminUserInfo()
  24666. var tempOrder models.HisOrder
  24667. tempOrder, _ = service.GetHisOrderByID(order_id)
  24668. var prescriptions []*models.HisPrescription
  24669. var start_time int64
  24670. var end_time int64
  24671. //押金模块
  24672. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  24673. tmp_decimal := c.GetString("tmp_decimal")
  24674. var decimal float64 //本次使用的押金
  24675. var errmsg error
  24676. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  24677. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  24678. return
  24679. }
  24680. if len(tmp_decimal) > 0 {
  24681. if tmp_decimal[0] == 45 {
  24682. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  24683. return
  24684. }
  24685. }
  24686. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  24687. fmt.Println(errs)
  24688. decimal = tt
  24689. //if adminUser.CurrentOrgId == 10106{
  24690. // if len(fapiao_code) == 0{
  24691. // fapiao_code = "144072080589"
  24692. // }
  24693. // if len(fapiao_number) == 0{
  24694. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  24695. // if order.ID == 0{
  24696. // fapiao_number = "00001520"
  24697. // }else{
  24698. // //fapiao_code = "00001520"
  24699. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  24700. // var zero string
  24701. // if fpNumber >= 1000{
  24702. // zero = "0000" + strconv.Itoa(fpNumber)
  24703. // }else if fpNumber >= 10000{
  24704. // zero = "000" + strconv.Itoa(fpNumber)
  24705. // } else if fpNumber >= 100000{
  24706. // zero = "00" + strconv.Itoa(fpNumber)
  24707. // } else if fpNumber >= 1000000{
  24708. // zero = "0" + strconv.Itoa(fpNumber)
  24709. // }else {
  24710. // zero = strconv.Itoa(fpNumber)
  24711. // }
  24712. // fapiao_number = zero
  24713. // }
  24714. // }
  24715. //}
  24716. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24717. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24718. var patientPrescription models.HisPrescriptionInfo
  24719. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24720. if patientPrescription.ID == 0 {
  24721. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  24722. }
  24723. //if patientPrescription.Do
  24724. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24725. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  24726. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  24727. diagnosis_ids := strings.Split(diagnosis_id, ",")
  24728. var config []*models.HisXtDiagnoseConfig
  24729. for _, item := range diagnosis_ids {
  24730. id, _ := strconv.ParseInt(item, 10, 64)
  24731. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24732. config = append(config, &diagnosisConfig)
  24733. }
  24734. sickConfig, _ := service.FindSickById(sick_type)
  24735. //if tempOrder.ID == 0 {
  24736. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  24737. //}
  24738. if tempOrder.ID == 0 {
  24739. var result string
  24740. var requestLog string
  24741. var res2 ResultSix
  24742. var res3 GZResultSix
  24743. var ressix10265 ResultSix10265
  24744. if miConfig.MdtrtareaAdmvs == "421300" {
  24745. data := make(map[string]interface{})
  24746. client := &http.Client{}
  24747. data["psn_no"] = his.PsnNo
  24748. data["mdtrt_id"] = his.Number
  24749. data["opter"] = roles.UserName
  24750. data["org_name"] = miConfig.OrgName
  24751. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24752. data["doctor_id"] = doctor_info.DoctorNumber
  24753. data["doctor_name"] = doctor_info.UserName
  24754. data["department"] = department.Name
  24755. data["fixmedins_code"] = miConfig.Code
  24756. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24757. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24758. data["secret_key"] = miConfig.SecretKey
  24759. data["sick_code"] = sickConfig.CountryCode
  24760. data["sick_name"] = sickConfig.ClassName
  24761. data["dept"] = strconv.FormatInt(department.ID, 10)
  24762. data["config"] = config
  24763. data["begin_time"] = begin_time
  24764. bytesData, _ := json.Marshal(data)
  24765. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24766. resp, _ := client.Do(req)
  24767. defer resp.Body.Close()
  24768. body, ioErr := ioutil.ReadAll(resp.Body)
  24769. if ioErr != nil {
  24770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24772. return
  24773. }
  24774. var respJSON map[string]interface{}
  24775. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24776. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24778. return
  24779. }
  24780. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24781. userJSONBytes, _ := json.Marshal(respJSON)
  24782. fmt.Println("log")
  24783. fmt.Println(string(userJSONBytes))
  24784. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24785. utils.ErrorLog("解析失败:%v", err)
  24786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24787. return
  24788. }
  24789. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24790. data := make(map[string]interface{})
  24791. client := &http.Client{}
  24792. data["psn_no"] = his.PsnNo
  24793. data["mdtrt_id"] = his.Number
  24794. data["opter"] = roles.UserName
  24795. data["org_name"] = miConfig.OrgName
  24796. if reg_type == 11 && his.Insutype == "390" {
  24797. data["med_type"] = "110104"
  24798. } else {
  24799. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24800. }
  24801. data["doctor_id"] = doctor_info.DoctorNumber
  24802. data["doctor_name"] = doctor_info.UserName
  24803. data["department"] = department.Name
  24804. data["fixmedins_code"] = miConfig.Code
  24805. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24806. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24807. data["secret_key"] = miConfig.SecretKey
  24808. data["sick_code"] = sickConfig.CountryCode
  24809. data["sick_name"] = sickConfig.ClassName
  24810. data["dept"] = strconv.FormatInt(department.ID, 10)
  24811. data["config"] = config
  24812. data["begin_time"] = begin_time
  24813. bytesData, _ := json.Marshal(data)
  24814. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24815. resp, _ := client.Do(req)
  24816. defer resp.Body.Close()
  24817. body, ioErr := ioutil.ReadAll(resp.Body)
  24818. if ioErr != nil {
  24819. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24821. return
  24822. }
  24823. var respJSON map[string]interface{}
  24824. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24827. return
  24828. }
  24829. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24830. userJSONBytes, _ := json.Marshal(respJSON)
  24831. fmt.Println("log")
  24832. fmt.Println(string(userJSONBytes))
  24833. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24834. utils.ErrorLog("解析失败:%v", err)
  24835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24836. return
  24837. }
  24838. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24839. data := make(map[string]interface{})
  24840. client := &http.Client{}
  24841. data["psn_no"] = his.PsnNo
  24842. data["mdtrt_id"] = his.Number
  24843. data["opter"] = roles.UserName
  24844. data["org_name"] = miConfig.OrgName
  24845. if reg_type == 11 && his.Insutype == "390" {
  24846. data["med_type"] = "110104"
  24847. } else {
  24848. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24849. }
  24850. data["doctor_id"] = doctor_info.DoctorNumber
  24851. data["doctor_name"] = doctor_info.UserName
  24852. data["department"] = department.Name
  24853. data["fixmedins_code"] = miConfig.Code
  24854. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24855. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24856. data["secret_key"] = miConfig.SecretKey
  24857. data["sick_code"] = sickConfig.CountryCode
  24858. data["sick_name"] = sickConfig.ClassName
  24859. data["dept"] = strconv.FormatInt(department.ID, 10)
  24860. data["config"] = config
  24861. data["begin_time"] = begin_time
  24862. bytesData, _ := json.Marshal(data)
  24863. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24864. resp, _ := client.Do(req)
  24865. defer resp.Body.Close()
  24866. body, ioErr := ioutil.ReadAll(resp.Body)
  24867. if ioErr != nil {
  24868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24870. return
  24871. }
  24872. var respJSON map[string]interface{}
  24873. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24876. return
  24877. }
  24878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24879. userJSONBytes, _ := json.Marshal(respJSON)
  24880. fmt.Println("log")
  24881. fmt.Println(string(userJSONBytes))
  24882. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24883. utils.ErrorLog("解析失败:%v", err)
  24884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24885. return
  24886. }
  24887. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24888. data := make(map[string]interface{})
  24889. client := &http.Client{}
  24890. data["psn_no"] = his.PsnNo
  24891. data["mdtrt_id"] = his.Number
  24892. data["opter"] = roles.UserName
  24893. data["org_name"] = miConfig.OrgName
  24894. if reg_type == 11 && his.Insutype == "390" {
  24895. data["med_type"] = "110104"
  24896. } else {
  24897. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24898. }
  24899. data["doctor_id"] = doctor_info.DoctorNumber
  24900. data["doctor_name"] = doctor_info.UserName
  24901. data["department"] = department.Name
  24902. data["fixmedins_code"] = miConfig.Code
  24903. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24904. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24905. data["secret_key"] = miConfig.SecretKey
  24906. data["sick_code"] = sickConfig.CountryCode
  24907. data["sick_name"] = sickConfig.ClassName
  24908. data["dept"] = strconv.FormatInt(department.ID, 10)
  24909. data["config"] = config
  24910. data["begin_time"] = begin_time
  24911. bytesData, _ := json.Marshal(data)
  24912. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24913. resp, _ := client.Do(req)
  24914. defer resp.Body.Close()
  24915. body, ioErr := ioutil.ReadAll(resp.Body)
  24916. if ioErr != nil {
  24917. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24919. return
  24920. }
  24921. var respJSON map[string]interface{}
  24922. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24923. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24925. return
  24926. }
  24927. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24928. userJSONBytes, _ := json.Marshal(respJSON)
  24929. fmt.Println("log")
  24930. fmt.Println(string(userJSONBytes))
  24931. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24932. utils.ErrorLog("解析失败:%v", err)
  24933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24934. return
  24935. }
  24936. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24937. data := make(map[string]interface{})
  24938. client := &http.Client{}
  24939. data["psn_no"] = his.PsnNo
  24940. data["mdtrt_id"] = his.Number
  24941. data["doctor"] = roles.UserName
  24942. data["department"] = department.Name
  24943. data["org_name"] = miConfig.OrgName
  24944. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24945. data["doctor_id"] = doctor_info.DoctorNumber
  24946. data["new_doctor_name"] = doctor_info.UserName
  24947. data["fixmedins_code"] = miConfig.Code
  24948. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24949. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24950. data["secret_key"] = miConfig.SecretKey
  24951. data["sick_code"] = sickConfig.CountryCode
  24952. data["sick_name"] = sickConfig.ClassName
  24953. data["url"] = miConfig.Url
  24954. data["ak"] = miConfig.AccessKey
  24955. data["begin_time"] = begin_time
  24956. data["cainfo"] = miConfig.Cainfo
  24957. data["dept"] = strconv.FormatInt(department.ID, 10)
  24958. data["config"] = config
  24959. bytesData, _ := json.Marshal(data)
  24960. var req *http.Request
  24961. if miConfig.MdtrtareaAdmvs == "320921" {
  24962. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  24963. //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 +
  24964. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  24965. } else {
  24966. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  24967. }
  24968. resp, _ := client.Do(req)
  24969. defer resp.Body.Close()
  24970. body, ioErr := ioutil.ReadAll(resp.Body)
  24971. if ioErr != nil {
  24972. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24974. return
  24975. }
  24976. var respJSON map[string]interface{}
  24977. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24980. return
  24981. }
  24982. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24983. userJSONBytes, _ := json.Marshal(respJSON)
  24984. fmt.Println("log")
  24985. fmt.Println(string(userJSONBytes))
  24986. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  24987. utils.ErrorLog("解析失败:%v", err)
  24988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24989. return
  24990. }
  24991. res2.InfRefmsgid = ressix10265.InfRefmsgid
  24992. res2.Output = ressix10265.Output
  24993. res2.ErrMsg = ressix10265.ErrMsg
  24994. res2.Cainfo = ressix10265.Cainfo
  24995. res2.WarnMsg = ressix10265.WarnMsg
  24996. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  24997. res2.Infcode = infocode
  24998. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24999. data := make(map[string]interface{})
  25000. client := &http.Client{}
  25001. data["psn_no"] = his.PsnNo
  25002. data["mdtrt_id"] = his.Number
  25003. data["doctor"] = roles.UserName
  25004. data["department"] = department.Name
  25005. data["org_name"] = miConfig.OrgName
  25006. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25007. data["doctor_id"] = doctor_info.DoctorNumber
  25008. data["new_doctor_name"] = doctor_info.UserName
  25009. data["fixmedins_code"] = miConfig.Code
  25010. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25011. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25012. data["secret_key"] = miConfig.SecretKey
  25013. data["sick_code"] = sickConfig.CountryCode
  25014. data["sick_name"] = sickConfig.ClassName
  25015. data["url"] = miConfig.Url
  25016. data["ak"] = miConfig.AccessKey
  25017. data["begin_time"] = begin_time
  25018. data["cainfo"] = miConfig.Cainfo
  25019. data["dept"] = strconv.FormatInt(department.ID, 10)
  25020. data["config"] = config
  25021. bytesData, _ := json.Marshal(data)
  25022. var req *http.Request
  25023. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25024. resp, _ := client.Do(req)
  25025. defer resp.Body.Close()
  25026. body, ioErr := ioutil.ReadAll(resp.Body)
  25027. if ioErr != nil {
  25028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25030. return
  25031. }
  25032. var respJSON map[string]interface{}
  25033. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25036. return
  25037. }
  25038. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25039. userJSONBytes, _ := json.Marshal(respJSON)
  25040. fmt.Println("log")
  25041. fmt.Println(string(userJSONBytes))
  25042. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25043. utils.ErrorLog("解析失败:%v", err)
  25044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25045. return
  25046. }
  25047. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25048. res2.Output = ressix10265.Output
  25049. res2.ErrMsg = ressix10265.ErrMsg
  25050. res2.Cainfo = ressix10265.Cainfo
  25051. res2.WarnMsg = ressix10265.WarnMsg
  25052. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25053. res2.Infcode = infocode
  25054. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25055. 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)
  25056. saveLog(result, requestLog, "2203", "上传就诊信息")
  25057. var respJSON2 map[string]interface{}
  25058. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25059. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25061. return
  25062. }
  25063. userJSONBytes2, _ := json.Marshal(respJSON2)
  25064. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25065. utils.ErrorLog("解析失败:%v", err)
  25066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25067. return
  25068. }
  25069. 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)
  25070. fmt.Println(result2)
  25071. fmt.Println(src_request)
  25072. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25073. data := make(map[string]interface{})
  25074. client := &http.Client{}
  25075. data["psn_no"] = his.PsnNo
  25076. data["mdtrt_id"] = his.Number
  25077. data["doctor"] = roles.UserName
  25078. data["department"] = department.Name
  25079. data["org_name"] = miConfig.OrgName
  25080. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25081. data["doctor_id"] = doctor_info.DoctorNumber
  25082. data["new_doctor_name"] = doctor_info.UserName
  25083. data["fixmedins_code"] = miConfig.Code
  25084. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25085. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25086. data["secret_key"] = miConfig.SecretKey
  25087. data["sick_code"] = sickConfig.CountryCode
  25088. data["sick_name"] = sickConfig.ClassName
  25089. data["url"] = miConfig.Url
  25090. data["ak"] = miConfig.AccessKey
  25091. data["begin_time"] = begin_time
  25092. data["cainfo"] = miConfig.Cainfo
  25093. data["dept"] = strconv.FormatInt(department.ID, 10)
  25094. data["config"] = config
  25095. bytesData, _ := json.Marshal(data)
  25096. var req *http.Request
  25097. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  25098. resp, _ := client.Do(req)
  25099. defer resp.Body.Close()
  25100. body, ioErr := ioutil.ReadAll(resp.Body)
  25101. if ioErr != nil {
  25102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25104. return
  25105. }
  25106. var respJSON map[string]interface{}
  25107. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25110. return
  25111. }
  25112. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25113. userJSONBytes, _ := json.Marshal(respJSON)
  25114. fmt.Println("log")
  25115. fmt.Println(string(userJSONBytes))
  25116. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25117. utils.ErrorLog("解析失败:%v", err)
  25118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25119. return
  25120. }
  25121. } else {
  25122. if miConfig.MdtrtareaAdmvs == "440781" { //
  25123. 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)
  25124. } else {
  25125. if miConfig.Code == "H15049901371" {
  25126. //赤峰地区国家医保医疗类别
  25127. //职工透析:医疗类别选特殊情况门诊990502
  25128. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25129. var med_type string
  25130. if his.Insutype == "390" {
  25131. if reg_type == 14 {
  25132. med_type = "9933"
  25133. } else if reg_type == 11 {
  25134. med_type = "11"
  25135. }
  25136. } else if his.Insutype == "310" {
  25137. if reg_type == 14 {
  25138. med_type = "990502"
  25139. } else if reg_type == 11 {
  25140. med_type = "11"
  25141. }
  25142. }
  25143. 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)
  25144. } else {
  25145. 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)
  25146. }
  25147. }
  25148. saveLog(result, requestLog, "2203", "上传就诊信息")
  25149. var respJSON2 map[string]interface{}
  25150. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25153. return
  25154. }
  25155. userJSONBytes2, _ := json.Marshal(respJSON2)
  25156. if miConfig.Code == "H15049901371" {
  25157. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  25158. utils.ErrorLog("解析失败:%v", err)
  25159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25160. return
  25161. }
  25162. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25163. res2.Output = ressix10265.Output
  25164. res2.ErrMsg = ressix10265.ErrMsg
  25165. res2.Cainfo = ressix10265.Cainfo
  25166. res2.WarnMsg = ressix10265.WarnMsg
  25167. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25168. res2.Infcode = infocode
  25169. } else {
  25170. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25171. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  25172. utils.ErrorLog("解析失败:%v", err)
  25173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25174. return
  25175. }
  25176. res2.Infcode = res3.Infcode
  25177. } else {
  25178. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25179. utils.ErrorLog("解析失败:%v", err)
  25180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25181. return
  25182. }
  25183. }
  25184. }
  25185. }
  25186. if res2.Infcode == -1 {
  25187. adminUser := c.GetAdminUserInfo()
  25188. errlog := &models.HisOrderError{
  25189. UserOrgId: adminUser.CurrentOrgId,
  25190. Ctime: time.Now().Unix(),
  25191. Mtime: time.Now().Unix(),
  25192. ErrMsg: res2.ErrMsg,
  25193. Status: 1,
  25194. PatientId: id,
  25195. RecordTime: recordDateTime,
  25196. Stage: 3,
  25197. }
  25198. service.CreateErrMsgLog(errlog)
  25199. c.ServeSuccessJSON(map[string]interface{}{
  25200. "failed_code": -10,
  25201. "msg": res2.ErrMsg,
  25202. })
  25203. return
  25204. } else {
  25205. his.Diagnosis = diagnosis_id
  25206. his.SickType = sickConfig.ID
  25207. //var p_type int64
  25208. //if reg_type == 1111 || reg_type == 1112 {
  25209. // p_type = 11
  25210. //
  25211. //}
  25212. his.PType = fmt.Sprintf("%d", reg_type)
  25213. service.UpdateHisPatientThree(&his)
  25214. data := make(map[string]interface{})
  25215. if settle_accounts_type == 1 { //日结
  25216. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25217. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25218. } else {
  25219. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25220. }
  25221. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  25222. data["pre"] = prescriptions
  25223. } else { //月结
  25224. start_time_str := c.GetString("start_time")
  25225. end_time_str := c.GetString("end_time")
  25226. timeLayout := "2006-01-02"
  25227. loc, _ := time.LoadLocation("Local")
  25228. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25229. if err != nil {
  25230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25231. return
  25232. }
  25233. recordStartTime := theStartTime.Unix()
  25234. start_time = recordStartTime
  25235. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25236. if err != nil {
  25237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25238. return
  25239. }
  25240. recordEndTime := theEndTime.Unix()
  25241. end_time = recordEndTime
  25242. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25243. data["pre"] = prescriptions
  25244. }
  25245. timestamp := time.Now().Unix()
  25246. tempTime := time.Unix(timestamp, 0)
  25247. timeFormat := tempTime.Format("20060102150405")
  25248. chrgBchno := rand.Intn(100000) + 10000
  25249. new_chrg_bchno := ""
  25250. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25251. new_chrg_bchno = chrg_bchno
  25252. strconv.FormatInt(his.PatientId, 10)
  25253. client := &http.Client{}
  25254. if adminUser.CurrentOrgId == 10265 {
  25255. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25256. new_chrg_bchno = "0000"
  25257. }
  25258. }
  25259. data["psn_no"] = his.PsnNo
  25260. data["mdtrt_id"] = his.Number
  25261. data["chrg_bchno"] = new_chrg_bchno
  25262. data["org_name"] = miConfig.OrgName
  25263. data["doctor"] = doctor_info.UserName
  25264. data["doctor_id"] = doctor_info.DoctorNumber
  25265. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25266. data["fixmedins_code"] = miConfig.Code
  25267. data["dept_code"] = department.Number
  25268. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25269. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25270. data["secret_key"] = miConfig.SecretKey
  25271. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25272. data["url"] = miConfig.Url
  25273. data["ak"] = miConfig.AccessKey
  25274. data["new_doctor_name"] = patientPrescription.Doctor
  25275. data["diag_code"] = sickConfig.CountryCode
  25276. data["cainfo"] = miConfig.Cainfo
  25277. data["opter"] = roles.UserName
  25278. var ids []int64
  25279. for _, item := range prescriptions {
  25280. ids = append(ids, item.ID)
  25281. }
  25282. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25283. if config.IsOpen == 1 { //对接了医保,走医保流程
  25284. var res ResultFour
  25285. var resFour10265 ResultFour10265
  25286. if miConfig.MdtrtareaAdmvs == "421300" {
  25287. bytesData, _ := json.Marshal(data)
  25288. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25289. resp, _ := client.Do(req)
  25290. defer resp.Body.Close()
  25291. body, ioErr := ioutil.ReadAll(resp.Body)
  25292. if ioErr != nil {
  25293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25295. return
  25296. }
  25297. var respJSON map[string]interface{}
  25298. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25301. return
  25302. }
  25303. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25304. userJSONBytes, _ := json.Marshal(respJSON)
  25305. fmt.Println("log")
  25306. fmt.Println(string(userJSONBytes))
  25307. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25308. utils.ErrorLog("解析失败:%v", err)
  25309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25310. return
  25311. }
  25312. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25313. bytesData, _ := json.Marshal(data)
  25314. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25315. resp, _ := client.Do(req)
  25316. defer resp.Body.Close()
  25317. body, ioErr := ioutil.ReadAll(resp.Body)
  25318. if ioErr != nil {
  25319. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25321. return
  25322. }
  25323. var respJSON map[string]interface{}
  25324. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25327. return
  25328. }
  25329. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25330. userJSONBytes, _ := json.Marshal(respJSON)
  25331. fmt.Println("log")
  25332. fmt.Println(string(userJSONBytes))
  25333. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25334. utils.ErrorLog("解析失败:%v", err)
  25335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25336. return
  25337. }
  25338. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25339. bytesData, _ := json.Marshal(data)
  25340. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25341. resp, _ := client.Do(req)
  25342. defer resp.Body.Close()
  25343. body, ioErr := ioutil.ReadAll(resp.Body)
  25344. if ioErr != nil {
  25345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25347. return
  25348. }
  25349. var respJSON map[string]interface{}
  25350. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25353. return
  25354. }
  25355. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25356. userJSONBytes, _ := json.Marshal(respJSON)
  25357. fmt.Println("log")
  25358. fmt.Println(string(userJSONBytes))
  25359. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25360. utils.ErrorLog("解析失败:%v", err)
  25361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25362. return
  25363. }
  25364. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25365. bytesData, _ := json.Marshal(data)
  25366. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25367. resp, _ := client.Do(req)
  25368. defer resp.Body.Close()
  25369. body, ioErr := ioutil.ReadAll(resp.Body)
  25370. if ioErr != nil {
  25371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25373. return
  25374. }
  25375. var respJSON map[string]interface{}
  25376. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25379. return
  25380. }
  25381. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25382. userJSONBytes, _ := json.Marshal(respJSON)
  25383. fmt.Println("log")
  25384. fmt.Println(string(userJSONBytes))
  25385. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25386. utils.ErrorLog("解析失败:%v", err)
  25387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25388. return
  25389. }
  25390. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25391. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25392. if result3101.Infcode == "0" {
  25393. if len(result3101.Output.Result) > 0 {
  25394. var errMsgs []string
  25395. for _, item := range result3101.Output.Result {
  25396. errMsgs = append(errMsgs, item.VolaCont)
  25397. }
  25398. c.ServeSuccessJSON(map[string]interface{}{
  25399. "failed_code": -10,
  25400. "msg": errMsgs,
  25401. })
  25402. return
  25403. }
  25404. }
  25405. bytesData, _ := json.Marshal(data)
  25406. var req *http.Request
  25407. if miConfig.MdtrtareaAdmvs == "320921" {
  25408. data["diag_code"] = sickConfig.CountryCode
  25409. fmt.Println(data)
  25410. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25411. } else {
  25412. data["diag_code"] = sickConfig.CountryCode
  25413. fmt.Println(data)
  25414. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25415. }
  25416. resp, _ := client.Do(req)
  25417. defer resp.Body.Close()
  25418. body, ioErr := ioutil.ReadAll(resp.Body)
  25419. if ioErr != nil {
  25420. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25422. return
  25423. }
  25424. var respJSON map[string]interface{}
  25425. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25426. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25428. return
  25429. }
  25430. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25431. userJSONBytes, _ := json.Marshal(respJSON)
  25432. fmt.Println("log")
  25433. fmt.Println(string(userJSONBytes))
  25434. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25435. utils.ErrorLog("解析失败:%v", err)
  25436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25437. return
  25438. }
  25439. res.InfRefmsgid = resFour10265.InfRefmsgid
  25440. res.Output = resFour10265.Output
  25441. res.ErrMsg = resFour10265.ErrMsg
  25442. res.Cainfo = resFour10265.Cainfo
  25443. res.WarnMsg = resFour10265.WarnMsg
  25444. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25445. res.Infcode = infocode
  25446. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25447. var pagesize int = 2
  25448. var start int = 1
  25449. var stop int
  25450. var pagecount int
  25451. var curpage int
  25452. var isSuccess bool = true
  25453. data["doctor_id"] = doctor_info.DoctorNumber
  25454. //总页数,向上取整,注意除之前要先转换类型为float64
  25455. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  25456. for curpage = 1; curpage <= pagecount; curpage++ {
  25457. if curpage == 1 {
  25458. start = 1
  25459. } else {
  25460. start = (curpage-1)*pagesize + 1
  25461. }
  25462. stop = curpage * pagesize
  25463. if stop > len(prescriptions) {
  25464. stop = len(prescriptions)
  25465. }
  25466. //var requestLog string
  25467. data["pre"] = prescriptions[start-1 : stop]
  25468. fmt.Println(data["pre"])
  25469. bytesData, _ := json.Marshal(data)
  25470. var req *http.Request
  25471. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  25472. resp, _ := client.Do(req)
  25473. defer resp.Body.Close()
  25474. body, ioErr := ioutil.ReadAll(resp.Body)
  25475. if ioErr != nil {
  25476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25478. return
  25479. }
  25480. var respJSON map[string]interface{}
  25481. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25484. return
  25485. }
  25486. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25487. userJSONBytes, _ := json.Marshal(respJSON)
  25488. fmt.Println("log")
  25489. fmt.Println(string(userJSONBytes))
  25490. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25491. utils.ErrorLog("解析失败:%v", err)
  25492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25493. return
  25494. }
  25495. res.InfRefmsgid = resFour10265.InfRefmsgid
  25496. res.Output = resFour10265.Output
  25497. res.ErrMsg = resFour10265.ErrMsg
  25498. res.Cainfo = resFour10265.Cainfo
  25499. res.WarnMsg = resFour10265.WarnMsg
  25500. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25501. res.Infcode = infocode
  25502. if infocode == 0 {
  25503. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  25504. } else {
  25505. isSuccess = false
  25506. errlog := &models.HisOrderError{
  25507. UserOrgId: adminUser.CurrentOrgId,
  25508. Ctime: time.Now().Unix(),
  25509. Mtime: time.Now().Unix(),
  25510. Number: chrg_bchno,
  25511. ErrMsg: "",
  25512. Status: 1,
  25513. PatientId: id,
  25514. RecordTime: recordDateTime,
  25515. Stage: 4,
  25516. }
  25517. service.CreateErrMsgLog(errlog)
  25518. c.ServeSuccessJSON(map[string]interface{}{
  25519. "failed_code": -10,
  25520. "msg": res.ErrMsg,
  25521. })
  25522. return
  25523. }
  25524. }
  25525. if isSuccess {
  25526. res.Infcode = 0
  25527. }
  25528. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25529. 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)
  25530. var dat map[string]interface{}
  25531. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25532. fmt.Println(dat)
  25533. } else {
  25534. fmt.Println(err)
  25535. }
  25536. saveLog(result, request_log, "2204", "上传费用明细")
  25537. userJSONBytes, _ := json.Marshal(dat)
  25538. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25539. utils.ErrorLog("解析失败:%v", err)
  25540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25541. return
  25542. }
  25543. res.InfRefmsgid = resFour10265.InfRefmsgid
  25544. res.Output = resFour10265.Output
  25545. res.ErrMsg = resFour10265.ErrMsg
  25546. res.Cainfo = resFour10265.Cainfo
  25547. res.WarnMsg = resFour10265.WarnMsg
  25548. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25549. res.Infcode = infocode
  25550. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25551. bytesData, _ := json.Marshal(data)
  25552. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  25553. resp, _ := client.Do(req)
  25554. defer resp.Body.Close()
  25555. body, ioErr := ioutil.ReadAll(resp.Body)
  25556. if ioErr != nil {
  25557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25559. return
  25560. }
  25561. var respJSON map[string]interface{}
  25562. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25565. return
  25566. }
  25567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25568. userJSONBytes, _ := json.Marshal(respJSON)
  25569. fmt.Println("log")
  25570. fmt.Println(string(userJSONBytes))
  25571. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25572. utils.ErrorLog("解析失败:%v", err)
  25573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25574. return
  25575. }
  25576. } else {
  25577. if miConfig.Code == "H15049901371" {
  25578. 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)
  25579. var dat map[string]interface{}
  25580. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25581. fmt.Println(dat)
  25582. } else {
  25583. fmt.Println(err)
  25584. }
  25585. saveLog(result, request_log, "2204", "上传费用明细")
  25586. userJSONBytes, _ := json.Marshal(dat)
  25587. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25588. utils.ErrorLog("解析失败:%v", err)
  25589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25590. return
  25591. }
  25592. res.InfRefmsgid = resFour10265.InfRefmsgid
  25593. res.Output = resFour10265.Output
  25594. res.ErrMsg = resFour10265.ErrMsg
  25595. res.Cainfo = resFour10265.Cainfo
  25596. res.WarnMsg = resFour10265.WarnMsg
  25597. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25598. res.Infcode = infocode
  25599. } else {
  25600. 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)
  25601. var dat map[string]interface{}
  25602. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25603. fmt.Println(dat)
  25604. } else {
  25605. fmt.Println(err)
  25606. }
  25607. saveLog(result, request_log, "2204", "上传费用明细")
  25608. userJSONBytes, _ := json.Marshal(dat)
  25609. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25610. utils.ErrorLog("解析失败:%v", err)
  25611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25612. return
  25613. }
  25614. }
  25615. }
  25616. if res.Infcode == 0 {
  25617. order := &models.HisOrder{
  25618. UserOrgId: adminUser.CurrentOrgId,
  25619. HisPatientId: his.ID,
  25620. PatientId: his.PatientId,
  25621. SettleAccountsDate: recordDateTime,
  25622. MdtrtId: his.Number,
  25623. PsnNo: his.PsnNo,
  25624. MedType: strconv.FormatInt(reg_type, 10),
  25625. Ctime: time.Now().Unix(),
  25626. Mtime: time.Now().Unix(),
  25627. Status: 1,
  25628. Number: chrg_bchno,
  25629. Infcode: res.Infcode,
  25630. WarnMsg: res.WarnMsg,
  25631. Cainfo: res.Cainfo,
  25632. ErrMsg: res.ErrMsg,
  25633. RespondTime: res.RefmsgTime,
  25634. InfRefmsgid: res.InfRefmsgid,
  25635. OrderStatus: 1,
  25636. PayWay: pay_way,
  25637. PayWays: pay_ways,
  25638. OthDesc: oth_desc,
  25639. PayPrice: pay_price,
  25640. PayCardNo: pay_card_no,
  25641. DiscountPrice: discount_price,
  25642. PreferentialPrice: preferential_price,
  25643. RealityPrice: reality_price,
  25644. FoundPrice: found_price,
  25645. MedicalInsurancePrice: medical_insurance_price,
  25646. PrivatePrice: private_price,
  25647. IsMedicineInsurance: 1,
  25648. SettleType: settle_accounts_type,
  25649. SettleStartTime: start_time,
  25650. SettleEndTime: end_time,
  25651. Creator: roles.AdminUserId,
  25652. Modify: roles.AdminUserId,
  25653. FaPiaoNumber: fapiao_number,
  25654. FaPiaoCode: fapiao_code,
  25655. PType: 2,
  25656. Diagnosis: diagnosis_id,
  25657. CashPay: cash_pay,
  25658. WechatPay: wechat_pay,
  25659. AliPay: ali_pay,
  25660. JifenPay: jifen_pay,
  25661. BandCardPay: band_card_pay,
  25662. }
  25663. err = service.CreateOrder(order)
  25664. if err != nil {
  25665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25666. return
  25667. }
  25668. for _, item := range res.Output.Result {
  25669. temp := strings.Split(item.FeedetlSn, "-")
  25670. var advice_id int64 = 0
  25671. var project_id int64 = 0
  25672. var types int64 = 0
  25673. id, _ := strconv.ParseInt(temp[2], 10, 64)
  25674. types, _ = strconv.ParseInt(temp[1], 10, 64)
  25675. if temp[1] == "1" {
  25676. advice_id = id
  25677. project_id = 0
  25678. } else if temp[1] == "2" {
  25679. advice_id = 0
  25680. project_id = id
  25681. }
  25682. if item.MedChrgitmType == "9" {
  25683. item.MedChrgitmType = "09"
  25684. }
  25685. info := &models.HisOrderInfo{
  25686. OrderNumber: order.Number,
  25687. FeedetlSn: item.FeedetlSn,
  25688. UploadDate: time.Now().Unix(),
  25689. AdviceId: advice_id,
  25690. DetItemFeeSumamt: item.DetItemFeeSumamt,
  25691. Cnt: item.Cnt,
  25692. Pric: float64(item.Pric),
  25693. PatientId: his.PatientId,
  25694. PricUplmtAmt: item.PricUplmtAmt,
  25695. SelfpayProp: item.SelfpayProp,
  25696. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  25697. OverlmtAmt: item.OverlmtAmt,
  25698. PreselfpayAmt: item.PreselfpayAmt,
  25699. BasMednFlag: item.BasMednFlag,
  25700. MedChrgitmType: item.MedChrgitmType,
  25701. HiNegoDrugFlag: item.HiNegoDrugFlag,
  25702. Status: 1,
  25703. Memo: item.Memo,
  25704. Mtime: time.Now().Unix(),
  25705. InscpScpAmt: item.InscpScpAmt,
  25706. DrtReimFlag: item.DrtReimFlag,
  25707. Ctime: time.Now().Unix(),
  25708. ListSpItemFlag: item.ListSpItemFlag,
  25709. ChldMedcFlag: item.ChldMedcFlag,
  25710. LmtUsedFlag: item.LmtUsedFlag,
  25711. ChrgitmLv: item.ChrgitmLv,
  25712. UserOrgId: adminUser.CurrentOrgId,
  25713. HisPatientId: his.ID,
  25714. OrderId: order.ID,
  25715. ProjectId: project_id,
  25716. Type: types,
  25717. }
  25718. service.CreateOrderInfo(info)
  25719. }
  25720. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  25721. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  25722. var total float64
  25723. for _, item := range prescriptions {
  25724. if item.Type == 1 { //药品
  25725. for _, subItem := range item.HisDoctorAdviceInfo {
  25726. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25727. total_one := price * subItem.PrescribingNumber
  25728. total = total + total_one
  25729. }
  25730. }
  25731. if item.Type == 2 { //项目
  25732. for _, subItem := range item.HisPrescriptionProject {
  25733. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  25734. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25735. total_one := price * cnt
  25736. total = total + total_one
  25737. }
  25738. }
  25739. }
  25740. allTotal := fmt.Sprintf("%.2f", total)
  25741. //if adminUser.CurrentOrgId == 9919 {
  25742. //
  25743. // allTotal = fmt.Sprintf("%.2f", total)
  25744. //
  25745. //} else {
  25746. //
  25747. // allTotal = fmt.Sprintf("%.2f", total)
  25748. //
  25749. //}
  25750. if res.Infcode == 0 {
  25751. var rf []*ResultFive
  25752. json.Unmarshal([]byte(his.Iinfo), &rf)
  25753. chrg_bchno := chrg_bchno
  25754. cert_no := his.Certno
  25755. var insutypes []string
  25756. var insutype string
  25757. var is390 int = 0
  25758. var is310 int = 0
  25759. for _, item := range rf {
  25760. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25761. insutypes = append(insutypes, item.Insutype)
  25762. }
  25763. }
  25764. if len(insutypes) == 1 {
  25765. insutype = insutypes[0]
  25766. } else {
  25767. for _, i := range insutypes {
  25768. if i == "390" {
  25769. is390 = 1
  25770. }
  25771. if i == "310" {
  25772. is310 = 1
  25773. }
  25774. }
  25775. }
  25776. if is390 == 1 {
  25777. insutype = "390"
  25778. }
  25779. if is310 == 1 {
  25780. insutype = "310"
  25781. }
  25782. if len(insutypes) == 0 {
  25783. insutype = "310"
  25784. }
  25785. if len(insutypes) == 2 {
  25786. insutype = strconv.FormatInt(his.SocialType, 10)
  25787. }
  25788. insutype = strconv.FormatInt(his.SocialType, 10)
  25789. //insutype = "390"
  25790. if his.IdCardType == 1 {
  25791. // cert_no = his.MedicalInsuranceNumber
  25792. cert_no = his.Certno
  25793. } else {
  25794. cert_no = his.Certno
  25795. }
  25796. var res ResultSeven
  25797. var resSeven10265 ResultSeven10265
  25798. var gzresSeven10265Two GZResultSeven10265Two
  25799. var src_resquest string
  25800. var result2 string
  25801. if miConfig.MdtrtareaAdmvs == "421300" {
  25802. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25803. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25804. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25805. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25806. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25807. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25808. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25809. resp, requestErr := http.Get(api)
  25810. if requestErr != nil {
  25811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25812. return
  25813. }
  25814. body, ioErr := ioutil.ReadAll(resp.Body)
  25815. if ioErr != nil {
  25816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25818. return
  25819. }
  25820. var respJSON map[string]interface{}
  25821. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25824. return
  25825. }
  25826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25827. result, _ := json.Marshal(respJSON)
  25828. if miConfig.Code == "H15049901371" {
  25829. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25830. utils.ErrorLog("解析失败:%v", err)
  25831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25832. return
  25833. }
  25834. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25835. res.Output = resSeven10265.Output
  25836. res.ErrMsg = resSeven10265.ErrMsg
  25837. res.Cainfo = resSeven10265.Cainfo
  25838. res.WarnMsg = resSeven10265.WarnMsg
  25839. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25840. res.Infcode = infocode
  25841. } else {
  25842. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25843. utils.ErrorLog("解析失败:%v", err)
  25844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25845. return
  25846. }
  25847. }
  25848. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25849. if reg_type == 11 && his.Insutype == "390" {
  25850. reg_type = 110104
  25851. }
  25852. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25853. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25854. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25855. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25856. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25857. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25858. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25859. resp, requestErr := http.Get(api)
  25860. if requestErr != nil {
  25861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25862. return
  25863. }
  25864. body, ioErr := ioutil.ReadAll(resp.Body)
  25865. if ioErr != nil {
  25866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25868. return
  25869. }
  25870. var respJSON map[string]interface{}
  25871. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25874. return
  25875. }
  25876. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25877. result, _ := json.Marshal(respJSON)
  25878. if miConfig.Code == "H15049901371" {
  25879. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25880. utils.ErrorLog("解析失败:%v", err)
  25881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25882. return
  25883. }
  25884. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25885. res.Output = resSeven10265.Output
  25886. res.ErrMsg = resSeven10265.ErrMsg
  25887. res.Cainfo = resSeven10265.Cainfo
  25888. res.WarnMsg = resSeven10265.WarnMsg
  25889. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25890. res.Infcode = infocode
  25891. } else {
  25892. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25893. utils.ErrorLog("解析失败:%v", err)
  25894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25895. return
  25896. }
  25897. }
  25898. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25899. if reg_type == 11 && his.Insutype == "390" {
  25900. reg_type = 110104
  25901. }
  25902. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25903. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25904. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25905. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25906. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25907. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25908. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25909. resp, requestErr := http.Get(api)
  25910. if requestErr != nil {
  25911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25912. return
  25913. }
  25914. body, ioErr := ioutil.ReadAll(resp.Body)
  25915. if ioErr != nil {
  25916. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25918. return
  25919. }
  25920. var respJSON map[string]interface{}
  25921. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25924. return
  25925. }
  25926. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25927. result, _ := json.Marshal(respJSON)
  25928. if miConfig.Code == "H15049901371" {
  25929. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25930. utils.ErrorLog("解析失败:%v", err)
  25931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25932. return
  25933. }
  25934. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25935. res.Output = resSeven10265.Output
  25936. res.ErrMsg = resSeven10265.ErrMsg
  25937. res.Cainfo = resSeven10265.Cainfo
  25938. res.WarnMsg = resSeven10265.WarnMsg
  25939. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25940. res.Infcode = infocode
  25941. } else {
  25942. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25943. utils.ErrorLog("解析失败:%v", err)
  25944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25945. return
  25946. }
  25947. }
  25948. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25949. if reg_type == 11 && his.Insutype == "390" {
  25950. reg_type = 110104
  25951. }
  25952. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25953. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25954. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25955. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25956. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25957. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25958. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25959. resp, requestErr := http.Get(api)
  25960. if requestErr != nil {
  25961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25962. return
  25963. }
  25964. body, ioErr := ioutil.ReadAll(resp.Body)
  25965. if ioErr != nil {
  25966. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25968. return
  25969. }
  25970. var respJSON map[string]interface{}
  25971. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25974. return
  25975. }
  25976. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25977. result, _ := json.Marshal(respJSON)
  25978. if miConfig.Code == "H15049901371" {
  25979. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25980. utils.ErrorLog("解析失败:%v", err)
  25981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25982. return
  25983. }
  25984. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25985. res.Output = resSeven10265.Output
  25986. res.ErrMsg = resSeven10265.ErrMsg
  25987. res.Cainfo = resSeven10265.Cainfo
  25988. res.WarnMsg = resSeven10265.WarnMsg
  25989. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25990. res.Infcode = infocode
  25991. } else {
  25992. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25993. utils.ErrorLog("解析失败:%v", err)
  25994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25995. return
  25996. }
  25997. }
  25998. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25999. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  26000. if result3101.Infcode == "0" {
  26001. if len(result3101.Output.Result) > 0 {
  26002. var errMsgs []string
  26003. for _, item := range result3101.Output.Result {
  26004. errMsgs = append(errMsgs, item.VolaCont)
  26005. }
  26006. c.ServeSuccessJSON(map[string]interface{}{
  26007. "failed_code": -10,
  26008. "msg": errMsgs,
  26009. })
  26010. return
  26011. } else {
  26012. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26013. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26014. bas := strings.Split(psn_info.CardInfo, "|")
  26015. if his.IdCardType == 1 {
  26016. cert_no = bas[2]
  26017. } else if his.IdCardType == 3 {
  26018. cert_no = his.Certno
  26019. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26020. } else if his.IdCardType == 4 {
  26021. cert_no = his.Certno
  26022. psn_info.VerifyNumber = psn_info.VerifyNumber
  26023. }
  26024. var api string
  26025. if miConfig.MdtrtareaAdmvs == "320921" {
  26026. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26027. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26028. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26029. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26030. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26031. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26032. "&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
  26033. } else {
  26034. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26035. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26036. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26037. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26038. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26039. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26040. "&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
  26041. }
  26042. resp, requestErr := http.Get(api)
  26043. if requestErr != nil {
  26044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26045. return
  26046. }
  26047. body, ioErr := ioutil.ReadAll(resp.Body)
  26048. if ioErr != nil {
  26049. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26051. return
  26052. }
  26053. var respJSON map[string]interface{}
  26054. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26055. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26057. return
  26058. }
  26059. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26060. result, _ := json.Marshal(respJSON)
  26061. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26062. utils.ErrorLog("解析失败:%v", err)
  26063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26064. return
  26065. }
  26066. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26067. res.Output = resSeven10265.Output
  26068. res.ErrMsg = resSeven10265.ErrMsg
  26069. res.Cainfo = resSeven10265.Cainfo
  26070. res.WarnMsg = resSeven10265.WarnMsg
  26071. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26072. res.Infcode = infocode
  26073. }
  26074. }
  26075. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26076. psn_info, _ := service.GetPsnByPatientId(id)
  26077. var verify_number string
  26078. if psn_info.IdCardType == 4 {
  26079. verify_number = psn_info.VerifyNumber
  26080. } else if psn_info.IdCardType == 1 {
  26081. bas := strings.Split(psn_info.CardInfo, "|")
  26082. cardNumber := bas[2]
  26083. verify_number = cardNumber
  26084. } else {
  26085. psn_info.IdCardType = 2
  26086. verify_number = psn_info.Certno
  26087. }
  26088. var api string
  26089. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26090. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26091. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26092. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26093. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26094. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26095. "&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
  26096. resp, requestErr := http.Get(api)
  26097. if requestErr != nil {
  26098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26099. return
  26100. }
  26101. body, ioErr := ioutil.ReadAll(resp.Body)
  26102. if ioErr != nil {
  26103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26105. return
  26106. }
  26107. var respJSON map[string]interface{}
  26108. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26111. return
  26112. }
  26113. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26114. result, _ := json.Marshal(respJSON)
  26115. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26116. utils.ErrorLog("解析失败:%v", err)
  26117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26118. return
  26119. }
  26120. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26121. res.Output = resSeven10265.Output
  26122. res.ErrMsg = resSeven10265.ErrMsg
  26123. res.Cainfo = resSeven10265.Cainfo
  26124. res.WarnMsg = resSeven10265.WarnMsg
  26125. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26126. res.Infcode = infocode
  26127. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26128. var cert_no string
  26129. if his.IdCardType == 4 {
  26130. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26131. cert_no = psn_info.VerifyNumber
  26132. 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)
  26133. } else if his.IdCardType == 1 {
  26134. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26135. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26136. 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)
  26137. }
  26138. //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)
  26139. var dat map[string]interface{}
  26140. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26141. fmt.Println(dat)
  26142. } else {
  26143. fmt.Println(err)
  26144. }
  26145. saveLog(result2, src_resquest, "2207", "结算")
  26146. userJSONBytes, _ := json.Marshal(dat)
  26147. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26148. utils.ErrorLog("解析失败:%v", err)
  26149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26150. return
  26151. }
  26152. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26153. res.Output = resSeven10265.Output
  26154. res.ErrMsg = resSeven10265.ErrMsg
  26155. res.Cainfo = resSeven10265.Cainfo
  26156. res.WarnMsg = resSeven10265.WarnMsg
  26157. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26158. res.Infcode = infocode
  26159. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26160. res2 := c.GetoleInfo()
  26161. if res2.Infcode == 0 {
  26162. var result string
  26163. var request_log string
  26164. var result_log string
  26165. if res2.Output.MdtrtCertType == "02" {
  26166. 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)
  26167. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26168. } else if res2.Output.MdtrtCertType == "01" {
  26169. 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)
  26170. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26171. } else {
  26172. 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)
  26173. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26174. }
  26175. var dat map[string]interface{}
  26176. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26177. fmt.Println(dat)
  26178. } else {
  26179. fmt.Println(err)
  26180. }
  26181. userJSONBytes, _ := json.Marshal(dat)
  26182. var res5 ResultTwo
  26183. //var resTwo10265 ResultTwo10265
  26184. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26185. utils.ErrorLog("解析失败:%v", err)
  26186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26187. return
  26188. }
  26189. if res5.Infcode == -1 {
  26190. c.ServeSuccessJSON(map[string]interface{}{
  26191. "failed_code": -10,
  26192. "msg": res5.ErrMsg,
  26193. })
  26194. return
  26195. }
  26196. var insutypes []string
  26197. var insutype string
  26198. var is390 int = 0
  26199. var is310 int = 0
  26200. for _, item := range res5.Output.Iinfo {
  26201. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26202. insutypes = append(insutypes, item.Insutype)
  26203. }
  26204. }
  26205. if len(insutypes) == 1 {
  26206. insutype = insutypes[0]
  26207. } else {
  26208. for _, i := range insutypes {
  26209. if i == "390" {
  26210. is390 = 1
  26211. }
  26212. if i == "310" {
  26213. is310 = 1
  26214. }
  26215. }
  26216. }
  26217. if is390 == 1 {
  26218. insutype = "390"
  26219. }
  26220. if is310 == 1 {
  26221. insutype = "310"
  26222. }
  26223. if len(insutypes) == 0 {
  26224. insutype = "310"
  26225. }
  26226. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26227. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26228. infoStr := string(Iinfos)
  26229. idetinfoStr := string(Idetinfos)
  26230. psn := &models.HisPsn{
  26231. PsnNo: res5.Output.Baseinfo.PsnNo,
  26232. PatientId: id,
  26233. Certno: res5.Output.Baseinfo.Certno,
  26234. Gend: res5.Output.Baseinfo.Gend,
  26235. Naty: res5.Output.Baseinfo.Naty,
  26236. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26237. PsnName: res5.Output.Baseinfo.PsnName,
  26238. Idetinfo: idetinfoStr,
  26239. Insuinfo: infoStr,
  26240. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26241. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26242. VerifyNumber: res2.Output.EcToken,
  26243. }
  26244. if res2.Output.MdtrtCertType == "01" {
  26245. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26246. psn.VerifyNumber = res2.Output.EcToken
  26247. } else if res2.Output.MdtrtCertType == "02" {
  26248. psn.VerifyNumber = res2.Output.CardNo
  26249. } else {
  26250. psn.VerifyNumber = res2.Output.MdtrtCertNo
  26251. }
  26252. service.CreateHisPsn(psn)
  26253. if res2.Output.MdtrtCertType == "01" {
  26254. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26255. token := res2.Output.EcToken
  26256. 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)
  26257. } else if res2.Output.MdtrtCertType == "02" {
  26258. 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)
  26259. } else {
  26260. 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)
  26261. }
  26262. var dat2 map[string]interface{}
  26263. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26264. fmt.Println(dat2)
  26265. } else {
  26266. fmt.Println(err)
  26267. }
  26268. userJSONBytes3, _ := json.Marshal(dat2)
  26269. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26270. utils.ErrorLog("解析失败:%v", err)
  26271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26272. return
  26273. }
  26274. saveLog(result2, src_resquest, "2207", "结算")
  26275. } else {
  26276. c.ServeSuccessJSON(map[string]interface{}{
  26277. "failed_code": -10,
  26278. "msg": res2.ErrMsg,
  26279. })
  26280. return
  26281. }
  26282. } else {
  26283. if miConfig.Code == "H15049901371" {
  26284. //赤峰地区国家医保医疗类别
  26285. //职工透析:医疗类别选特殊情况门诊990502
  26286. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26287. var med_type string
  26288. if his.Insutype == "390" {
  26289. if reg_type == 14 {
  26290. med_type = "9933"
  26291. } else if reg_type == 11 {
  26292. med_type = "11"
  26293. }
  26294. } else if his.Insutype == "310" {
  26295. if reg_type == 14 {
  26296. med_type = "990502"
  26297. } else if reg_type == 11 {
  26298. med_type = "11"
  26299. }
  26300. }
  26301. 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)
  26302. } else {
  26303. if his.IdCardType == 4 {
  26304. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26305. var token string
  26306. token = psn_info.VerifyNumber
  26307. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, token, admin_user_id)
  26308. } else {
  26309. if his.IdCardType == 1 {
  26310. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26311. bas := strings.Split(psn_info.CardInfo, "|")
  26312. basNumber := bas[2]
  26313. cert_no = basNumber
  26314. }
  26315. 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)
  26316. }
  26317. }
  26318. //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)
  26319. var dat map[string]interface{}
  26320. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26321. fmt.Println(dat)
  26322. } else {
  26323. fmt.Println(err)
  26324. }
  26325. saveLog(result2, src_resquest, "2207", "结算")
  26326. userJSONBytes, _ := json.Marshal(dat)
  26327. if miConfig.Code == "H15049901371" {
  26328. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26329. utils.ErrorLog("解析失败:%v", err)
  26330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26331. return
  26332. }
  26333. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26334. res.Output = resSeven10265.Output
  26335. res.ErrMsg = resSeven10265.ErrMsg
  26336. res.Cainfo = resSeven10265.Cainfo
  26337. res.WarnMsg = resSeven10265.WarnMsg
  26338. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26339. res.Infcode = infocode
  26340. } else {
  26341. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26342. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26343. utils.ErrorLog("解析失败:%v", err)
  26344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26345. return
  26346. }
  26347. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26348. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26349. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26350. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26351. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26352. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26353. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26354. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26355. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26356. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26357. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26358. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26359. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26360. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26361. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26362. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26363. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26364. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26365. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26366. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26367. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26368. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26369. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26370. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26371. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26372. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26373. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26374. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26375. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26376. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26377. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26378. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26379. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26380. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26381. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26382. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26383. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26384. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26385. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26386. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26387. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26388. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26389. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26390. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26391. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26392. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26393. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26394. res.Cainfo = gzresSeven10265Two.Cainfo
  26395. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26396. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26397. //res.Infcode = infocode
  26398. } else {
  26399. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26400. utils.ErrorLog("解析失败:%v", err)
  26401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26402. return
  26403. }
  26404. }
  26405. }
  26406. }
  26407. if res.Infcode == -1 {
  26408. errlog := &models.HisOrderError{
  26409. UserOrgId: adminUser.CurrentOrgId,
  26410. Ctime: time.Now().Unix(),
  26411. Mtime: time.Now().Unix(),
  26412. Number: chrg_bchno,
  26413. ErrMsg: res.ErrMsg,
  26414. Status: 1,
  26415. PatientId: id,
  26416. RecordTime: recordDateTime,
  26417. Stage: 6,
  26418. }
  26419. service.CreateErrMsgLog(errlog)
  26420. c.ServeSuccessJSON(map[string]interface{}{
  26421. "failed_code": -10,
  26422. "msg": res.ErrMsg,
  26423. })
  26424. return
  26425. } else {
  26426. sickConfig, _ := service.FindSickById(his.SickType)
  26427. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  26428. order.OrderStatus = 2
  26429. order.Status = 1
  26430. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  26431. order.SetlId = res.Output.Setlinfo.SetlID
  26432. order.PsnNo = res.Output.Setlinfo.PsnNo
  26433. order.PsnName = res.Output.Setlinfo.PsnName
  26434. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26435. order.Certno = res.Output.Setlinfo.Certno
  26436. order.Gend = res.Output.Setlinfo.Gend
  26437. order.Naty = res.Output.Setlinfo.Naty
  26438. order.Age = res.Output.Setlinfo.Age
  26439. order.Insutype = res.Output.Setlinfo.Insutype
  26440. order.PsnType = res.Output.Setlinfo.PsnType
  26441. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26442. order.SetlTime = res.Output.Setlinfo.SetlTime
  26443. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26444. if res.Output.Setlinfo.MedType == "140101" {
  26445. order.MedType = "14"
  26446. } else {
  26447. if res.Output.Setlinfo.MedType == "110104" {
  26448. order.MedType = "11"
  26449. } else {
  26450. order.MedType = res.Output.Setlinfo.MedType
  26451. }
  26452. }
  26453. if reg_type == 1112 {
  26454. order.MedType = "1112"
  26455. }
  26456. if reg_type == 1111 {
  26457. order.MedType = "1111"
  26458. }
  26459. order.ClrType = res.Output.Setlinfo.ClrType
  26460. if adminUser.CurrentOrgId == 10480 {
  26461. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26462. order.ClrType = "11"
  26463. } else {
  26464. order.ClrType = "9903"
  26465. }
  26466. }
  26467. if adminUser.CurrentOrgId == 10721 {
  26468. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  26469. order.ClrType = "11"
  26470. } else {
  26471. order.ClrType = "9903"
  26472. }
  26473. }
  26474. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26475. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26476. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26477. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26478. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26479. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26480. order.HifpPay = res.Output.Setlinfo.HifpPay
  26481. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26482. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26483. order.HifesPay = res.Output.Setlinfo.HifesPay
  26484. order.HifobPay = res.Output.Setlinfo.HifobPay
  26485. order.MafPay = res.Output.Setlinfo.MafPay
  26486. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26487. order.OthPay = res.Output.Setlinfo.OthPay
  26488. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26489. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26490. order.AcctPay = res.Output.Setlinfo.AcctPay
  26491. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26492. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26493. order.Balc = res.Output.Setlinfo.Balc
  26494. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26495. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26496. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26497. //order.ClrType = res.Output.Setlinfo.ClrType
  26498. order.ClrWay = res.Output.Setlinfo.ClrWay
  26499. order.Creator = order.Creator
  26500. order.Modify = roles.AdminUserId
  26501. order.RequestLog = src_resquest
  26502. order.FaPiaoNumber = fapiao_number
  26503. order.FaPiaoCode = fapiao_code
  26504. order.SickName = sickConfig.ClassName
  26505. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26506. //detailStr := string(setlDetail)
  26507. //order.SetlDetail = detailStr
  26508. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26509. err = service.UpDateOrder(order)
  26510. if err == nil {
  26511. //判断是否使用了押金
  26512. if dec_way == "true" {
  26513. tmpstring := strconv.FormatInt(order.ID, 10)
  26514. order.Decimal = decimal
  26515. service.UpDateOrder(order)
  26516. //扣押金
  26517. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  26518. if errmsg != nil {
  26519. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  26520. return
  26521. }
  26522. }
  26523. c.ServeSuccessJSON(map[string]interface{}{
  26524. "msg": "结算成功",
  26525. })
  26526. } else {
  26527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26528. return
  26529. }
  26530. }
  26531. } else {
  26532. adminUser := c.GetAdminUserInfo()
  26533. errlog := &models.HisOrderError{
  26534. UserOrgId: adminUser.CurrentOrgId,
  26535. Ctime: time.Now().Unix(),
  26536. Mtime: time.Now().Unix(),
  26537. ErrMsg: res.ErrMsg,
  26538. Status: 1,
  26539. PatientId: id,
  26540. RecordTime: recordDateTime,
  26541. Stage: 4,
  26542. }
  26543. service.CreateErrMsgLog(errlog)
  26544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  26545. return
  26546. }
  26547. } else {
  26548. adminUser := c.GetAdminUserInfo()
  26549. errlog := &models.HisOrderError{
  26550. UserOrgId: adminUser.CurrentOrgId,
  26551. Ctime: time.Now().Unix(),
  26552. Mtime: time.Now().Unix(),
  26553. ErrMsg: res.ErrMsg,
  26554. Status: 1,
  26555. PatientId: id,
  26556. RecordTime: recordDateTime,
  26557. Stage: 4,
  26558. }
  26559. service.CreateErrMsgLog(errlog)
  26560. c.ServeSuccessJSON(map[string]interface{}{
  26561. "failed_code": -10,
  26562. "msg": res.ErrMsg,
  26563. })
  26564. return
  26565. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  26566. //return
  26567. }
  26568. }
  26569. }
  26570. } else if tempOrder.ID > 0 {
  26571. if tempOrder.IsPre == 1 {
  26572. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  26573. var rf []*ResultFive
  26574. json.Unmarshal([]byte(his.Iinfo), &rf)
  26575. chrg_bchno := tempOrder.Number
  26576. cert_no := his.Certno
  26577. var insutypes []string
  26578. var insutype string
  26579. var is390 int = 0
  26580. var is310 int = 0
  26581. for _, item := range rf {
  26582. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26583. insutypes = append(insutypes, item.Insutype)
  26584. }
  26585. }
  26586. if len(insutypes) == 1 {
  26587. insutype = insutypes[0]
  26588. } else {
  26589. for _, i := range insutypes {
  26590. if i == "390" {
  26591. is390 = 1
  26592. }
  26593. if i == "310" {
  26594. is310 = 1
  26595. }
  26596. }
  26597. }
  26598. if is390 == 1 {
  26599. insutype = "390"
  26600. }
  26601. if is310 == 1 {
  26602. insutype = "310"
  26603. }
  26604. if len(insutypes) == 0 {
  26605. insutype = "310"
  26606. }
  26607. if len(insutypes) == 2 {
  26608. insutype = strconv.FormatInt(his.SocialType, 10)
  26609. }
  26610. //insutype = "390"
  26611. if his.IdCardType == 1 {
  26612. // cert_no = his.MedicalInsuranceNumber
  26613. cert_no = his.Certno
  26614. } else {
  26615. cert_no = his.Certno
  26616. }
  26617. var res ResultSeven
  26618. var ahres ResultSevenAH
  26619. var resSeven10265 ResultSeven10265
  26620. var gzresSeven10265Two GZResultSeven10265Two
  26621. var src_resquest string
  26622. var result2 string
  26623. if miConfig.MdtrtareaAdmvs == "450721" {
  26624. res2 := c.GetoleInfo()
  26625. if res2.Infcode == 0 {
  26626. var result string
  26627. var request_log string
  26628. var result_log string
  26629. if res2.Output.MdtrtCertType == "02" {
  26630. 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)
  26631. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26632. } else if res2.Output.MdtrtCertType == "01" {
  26633. 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)
  26634. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26635. } else {
  26636. 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)
  26637. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26638. }
  26639. var dat map[string]interface{}
  26640. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26641. fmt.Println(dat)
  26642. } else {
  26643. fmt.Println(err)
  26644. }
  26645. userJSONBytes, _ := json.Marshal(dat)
  26646. var res5 ResultTwo
  26647. //var resTwo10265 ResultTwo10265
  26648. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26649. utils.ErrorLog("解析失败:%v", err)
  26650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26651. return
  26652. }
  26653. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  26654. if res5.Infcode == -1 {
  26655. c.ServeSuccessJSON(map[string]interface{}{
  26656. "failed_code": -10,
  26657. "msg": res5.ErrMsg,
  26658. })
  26659. return
  26660. }
  26661. var insutypes []string
  26662. var insutype string
  26663. var is390 int = 0
  26664. var is310 int = 0
  26665. for _, item := range res5.Output.Iinfo {
  26666. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26667. insutypes = append(insutypes, item.Insutype)
  26668. }
  26669. }
  26670. if len(insutypes) == 1 {
  26671. insutype = insutypes[0]
  26672. } else {
  26673. for _, i := range insutypes {
  26674. if i == "390" {
  26675. is390 = 1
  26676. }
  26677. if i == "310" {
  26678. is310 = 1
  26679. }
  26680. }
  26681. }
  26682. if is390 == 1 {
  26683. insutype = "390"
  26684. }
  26685. if is310 == 1 {
  26686. insutype = "310"
  26687. }
  26688. if len(insutypes) == 0 {
  26689. insutype = "310"
  26690. }
  26691. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26692. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26693. infoStr := string(Iinfos)
  26694. idetinfoStr := string(Idetinfos)
  26695. psn := &models.HisPsn{
  26696. PsnNo: res5.Output.Baseinfo.PsnNo,
  26697. PatientId: id,
  26698. Certno: res5.Output.Baseinfo.Certno,
  26699. Gend: res5.Output.Baseinfo.Gend,
  26700. Naty: res5.Output.Baseinfo.Naty,
  26701. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26702. PsnName: res5.Output.Baseinfo.PsnName,
  26703. Idetinfo: idetinfoStr,
  26704. Insuinfo: infoStr,
  26705. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26706. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26707. VerifyNumber: res2.Output.EcToken,
  26708. }
  26709. service.CreateHisPsn(psn)
  26710. if res2.Output.MdtrtCertType == "01" {
  26711. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26712. token := res2.Output.EcToken
  26713. 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)
  26714. } else if res2.Output.MdtrtCertType == "02" {
  26715. 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)
  26716. } else {
  26717. 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)
  26718. }
  26719. var dat2 map[string]interface{}
  26720. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26721. fmt.Println(dat2)
  26722. } else {
  26723. fmt.Println(err)
  26724. }
  26725. userJSONBytes3, _ := json.Marshal(dat2)
  26726. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26727. utils.ErrorLog("解析失败:%v", err)
  26728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26729. return
  26730. }
  26731. saveLog(result2, src_resquest, "2207", "结算")
  26732. } else {
  26733. c.ServeSuccessJSON(map[string]interface{}{
  26734. "failed_code": -10,
  26735. "msg": res2.ErrMsg,
  26736. })
  26737. return
  26738. }
  26739. } else if miConfig.MdtrtareaAdmvs == "421300" {
  26740. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26741. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26742. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26743. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26744. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26745. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26746. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26747. resp, requestErr := http.Get(api)
  26748. if requestErr != nil {
  26749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26750. return
  26751. }
  26752. body, ioErr := ioutil.ReadAll(resp.Body)
  26753. if ioErr != nil {
  26754. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26756. return
  26757. }
  26758. var respJSON map[string]interface{}
  26759. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26762. return
  26763. }
  26764. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26765. result, _ := json.Marshal(respJSON)
  26766. fmt.Println("log")
  26767. fmt.Println(string(result))
  26768. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26769. utils.ErrorLog("解析失败:%v", err)
  26770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26771. return
  26772. }
  26773. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26774. if reg_type == 11 && his.Insutype == "390" {
  26775. reg_type = 110104
  26776. }
  26777. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26778. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26779. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26780. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26781. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26782. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26783. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26784. resp, requestErr := http.Get(api)
  26785. if requestErr != nil {
  26786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26787. return
  26788. }
  26789. body, ioErr := ioutil.ReadAll(resp.Body)
  26790. if ioErr != nil {
  26791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26793. return
  26794. }
  26795. var respJSON map[string]interface{}
  26796. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26799. return
  26800. }
  26801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26802. result, _ := json.Marshal(respJSON)
  26803. fmt.Println("log")
  26804. fmt.Println(string(result))
  26805. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26806. utils.ErrorLog("解析失败:%v", err)
  26807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26808. return
  26809. }
  26810. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26811. if reg_type == 11 && his.Insutype == "390" {
  26812. reg_type = 110104
  26813. }
  26814. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26815. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26816. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26817. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26818. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26819. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26820. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26821. resp, requestErr := http.Get(api)
  26822. if requestErr != nil {
  26823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26824. return
  26825. }
  26826. body, ioErr := ioutil.ReadAll(resp.Body)
  26827. if ioErr != nil {
  26828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26830. return
  26831. }
  26832. var respJSON map[string]interface{}
  26833. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26836. return
  26837. }
  26838. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26839. result, _ := json.Marshal(respJSON)
  26840. fmt.Println("log")
  26841. fmt.Println(string(result))
  26842. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26843. utils.ErrorLog("解析失败:%v", err)
  26844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26845. return
  26846. }
  26847. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26848. if reg_type == 11 && his.Insutype == "390" {
  26849. reg_type = 110104
  26850. }
  26851. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26852. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26853. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26854. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26855. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26856. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26857. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26858. resp, requestErr := http.Get(api)
  26859. if requestErr != nil {
  26860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26861. return
  26862. }
  26863. body, ioErr := ioutil.ReadAll(resp.Body)
  26864. if ioErr != nil {
  26865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26867. return
  26868. }
  26869. var respJSON map[string]interface{}
  26870. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26873. return
  26874. }
  26875. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26876. result, _ := json.Marshal(respJSON)
  26877. fmt.Println("log")
  26878. fmt.Println(string(result))
  26879. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26880. utils.ErrorLog("解析失败:%v", err)
  26881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26882. return
  26883. }
  26884. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26885. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  26886. if result3101.Infcode == "0" {
  26887. if len(result3101.Output.Result) > 0 {
  26888. var errMsgs []string
  26889. for _, item := range result3101.Output.Result {
  26890. errMsgs = append(errMsgs, item.VolaCont)
  26891. }
  26892. c.ServeSuccessJSON(map[string]interface{}{
  26893. "failed_code": -10,
  26894. "msg": errMsgs,
  26895. })
  26896. return
  26897. } else {
  26898. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26899. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26900. bas := strings.Split(psn_info.CardInfo, "|")
  26901. if his.IdCardType == 1 {
  26902. cert_no = bas[2]
  26903. } else if his.IdCardType == 3 {
  26904. cert_no = his.Certno
  26905. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26906. } else if his.IdCardType == 4 {
  26907. cert_no = his.Certno
  26908. psn_info.VerifyNumber = psn_info.VerifyNumber
  26909. }
  26910. //江苏地区国家医保医疗类别
  26911. //职工透析:医疗类别选特殊情况门诊9933
  26912. //居民血透门慢: 医疗类别选门诊慢病1402
  26913. //var med_type string
  26914. //if his.Insutype == "310" {
  26915. // if reg_type == 14 {
  26916. // med_type = "9933"
  26917. // } else if reg_type == 11 {
  26918. // med_type = "11"
  26919. //
  26920. // }
  26921. //} else if his.Insutype == "390" {
  26922. // if reg_type == 14 {
  26923. // med_type = "1402"
  26924. // } else if reg_type == 11 {
  26925. // med_type = "11"
  26926. // }
  26927. //}
  26928. var api string
  26929. if miConfig.MdtrtareaAdmvs == "320921" {
  26930. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26931. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26932. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26933. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26934. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26935. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26936. "&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
  26937. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26938. } else {
  26939. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26940. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26941. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26942. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26943. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26944. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26945. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26946. "&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
  26947. }
  26948. resp, requestErr := http.Get(api)
  26949. if requestErr != nil {
  26950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26951. return
  26952. }
  26953. body, ioErr := ioutil.ReadAll(resp.Body)
  26954. if ioErr != nil {
  26955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26957. return
  26958. }
  26959. var respJSON map[string]interface{}
  26960. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26963. return
  26964. }
  26965. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26966. result, _ := json.Marshal(respJSON)
  26967. fmt.Println("log")
  26968. fmt.Println(string(result))
  26969. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26970. utils.ErrorLog("解析失败:%v", err)
  26971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26972. return
  26973. }
  26974. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26975. res.Output = resSeven10265.Output
  26976. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26977. res.ErrMsg = resSeven10265.ErrMsg
  26978. res.Cainfo = resSeven10265.Cainfo
  26979. res.WarnMsg = resSeven10265.WarnMsg
  26980. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26981. res.Infcode = infocode
  26982. }
  26983. }
  26984. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26985. psn_info, _ := service.GetPsnByPatientId(id)
  26986. var verify_number string
  26987. if psn_info.IdCardType == 4 {
  26988. verify_number = psn_info.VerifyNumber
  26989. } else if psn_info.IdCardType == 1 {
  26990. bas := strings.Split(psn_info.CardInfo, "|")
  26991. cardNumber := bas[2]
  26992. verify_number = cardNumber
  26993. } else {
  26994. verify_number = psn_info.Certno
  26995. psn_info.IdCardType = 2
  26996. }
  26997. var api string
  26998. new_chrg_bchno := chrg_bchno
  26999. if adminUser.CurrentOrgId == 10265 {
  27000. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27001. new_chrg_bchno = "0000"
  27002. }
  27003. }
  27004. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27005. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27006. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27007. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27008. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27009. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27010. "&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
  27011. resp, requestErr := http.Get(api)
  27012. if requestErr != nil {
  27013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27014. return
  27015. }
  27016. body, ioErr := ioutil.ReadAll(resp.Body)
  27017. if ioErr != nil {
  27018. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27020. return
  27021. }
  27022. var respJSON map[string]interface{}
  27023. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27026. return
  27027. }
  27028. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27029. result, _ := json.Marshal(respJSON)
  27030. fmt.Println("log")
  27031. fmt.Println(string(result))
  27032. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27033. utils.ErrorLog("解析失败:%v", err)
  27034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27035. return
  27036. }
  27037. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27038. res.Output = resSeven10265.Output
  27039. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27040. res.ErrMsg = resSeven10265.ErrMsg
  27041. res.Cainfo = resSeven10265.Cainfo
  27042. res.WarnMsg = resSeven10265.WarnMsg
  27043. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27044. res.Infcode = infocode
  27045. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27046. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27047. var cert_no string
  27048. if his.IdCardType == 1 {
  27049. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27050. } else {
  27051. cert_no = psn_info.VerifyNumber
  27052. }
  27053. 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)
  27054. var dat map[string]interface{}
  27055. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27056. fmt.Println(dat)
  27057. } else {
  27058. fmt.Println(err)
  27059. }
  27060. saveLog(result2, src_resquest, "2207", "结算")
  27061. userJSONBytes, _ := json.Marshal(dat)
  27062. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27063. utils.ErrorLog("解析失败:%v", err)
  27064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27065. return
  27066. }
  27067. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27068. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27069. var cert_no string
  27070. var card_sn string
  27071. if his.IdCardType == 1 {
  27072. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27073. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27074. bas := strings.Split(psn_info.CardInfo, "|")
  27075. card_sn = bas[3]
  27076. } else if his.IdCardType == 2 {
  27077. cert_no = his.IdCardNo
  27078. } else {
  27079. cert_no = psn_info.VerifyNumber
  27080. }
  27081. var rf []*ResultFive
  27082. json.Unmarshal([]byte(his.Iinfo), &rf)
  27083. var psn_type string
  27084. for _, item := range rf {
  27085. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27086. psn_type = item.PsnType
  27087. }
  27088. }
  27089. 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)
  27090. var dat map[string]interface{}
  27091. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27092. fmt.Println(dat)
  27093. } else {
  27094. fmt.Println(err)
  27095. }
  27096. saveLog(result2, src_resquest, "2207", "结算")
  27097. userJSONBytes, _ := json.Marshal(dat)
  27098. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27099. utils.ErrorLog("解析失败:%v", err)
  27100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27101. return
  27102. }
  27103. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27104. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27105. var cert_no string
  27106. var card_sn string
  27107. if his.IdCardType == 1 {
  27108. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27109. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27110. //bas := strings.Split(psn_info.CardInfo, "|")
  27111. card_sn = ""
  27112. } else if his.IdCardType == 2 {
  27113. cert_no = his.IdCardNo
  27114. } else {
  27115. cert_no = psn_info.VerifyNumber
  27116. }
  27117. var rf []*ResultFive
  27118. json.Unmarshal([]byte(his.Iinfo), &rf)
  27119. var psn_type string
  27120. for _, item := range rf {
  27121. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27122. psn_type = item.PsnType
  27123. }
  27124. }
  27125. 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)
  27126. var dat map[string]interface{}
  27127. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27128. fmt.Println(dat)
  27129. } else {
  27130. fmt.Println(err)
  27131. }
  27132. saveLog(result2, src_resquest, "2207", "结算")
  27133. userJSONBytes, _ := json.Marshal(dat)
  27134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27135. utils.ErrorLog("解析失败:%v", err)
  27136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27137. return
  27138. }
  27139. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27140. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27141. if his.IdCardType == 1 {
  27142. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27143. bas := strings.Split(psn_info.CardInfo, "|")
  27144. cert_no = bas[2]
  27145. } else if his.IdCardType == 3 {
  27146. cert_no = his.Certno
  27147. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27148. } else if his.IdCardType == 4 {
  27149. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27150. cert_no = psn_info.VerifyNumber
  27151. psn_info.VerifyNumber = psn_info.VerifyNumber
  27152. } else {
  27153. cert_no = his.Certno
  27154. psn_info.VerifyNumber = his.Certno
  27155. }
  27156. var api string
  27157. var med_type string
  27158. if his.Insutype == "390" {
  27159. if reg_type == 992102 {
  27160. med_type = "992102"
  27161. }
  27162. if reg_type == 140104 {
  27163. med_type = "140104"
  27164. }
  27165. if reg_type == 140201 {
  27166. med_type = "140201"
  27167. }
  27168. if reg_type == 14 {
  27169. med_type = "14"
  27170. }
  27171. } else if his.Insutype == "310" {
  27172. if reg_type == 992102 {
  27173. med_type = "992102"
  27174. }
  27175. if reg_type == 140104 {
  27176. med_type = "140104"
  27177. }
  27178. if reg_type == 140201 {
  27179. med_type = "140201"
  27180. }
  27181. if reg_type == 14 {
  27182. med_type = "14"
  27183. }
  27184. }
  27185. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27186. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27187. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27188. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27189. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27190. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27191. "&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
  27192. resp, requestErr := http.Get(api)
  27193. if requestErr != nil {
  27194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27195. return
  27196. }
  27197. body, ioErr := ioutil.ReadAll(resp.Body)
  27198. if ioErr != nil {
  27199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27201. return
  27202. }
  27203. var respJSON map[string]interface{}
  27204. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27207. return
  27208. }
  27209. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27210. if status == "0" {
  27211. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27212. c.ServeSuccessJSON(map[string]interface{}{
  27213. "failed_code": -10,
  27214. "msg": err_msg,
  27215. })
  27216. return
  27217. }
  27218. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27219. result, _ := json.Marshal(respJSON)
  27220. fmt.Println("log")
  27221. fmt.Println(string(result))
  27222. if err := json.Unmarshal(result, &ahres); err != nil {
  27223. utils.ErrorLog("解析失败:%v", err)
  27224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27225. return
  27226. }
  27227. res.InfRefmsgid = ahres.InfRefmsgid
  27228. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27229. // 创建对应的Time类型
  27230. t := time.UnixMilli(timestamp)
  27231. // 格式化成指定的日期字符串
  27232. str := t.Format("2006-01-02 15:04:05")
  27233. res.Output.Setlinfo.SetlTime = str
  27234. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27235. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27236. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27237. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27238. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27239. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27240. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27241. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27242. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27243. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27244. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27245. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27246. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27247. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27248. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27249. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27250. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27251. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27252. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27253. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27254. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27255. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27256. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27257. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27258. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27259. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27260. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27261. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27262. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27263. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27264. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27265. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27266. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27267. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27268. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27269. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27270. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27271. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27272. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27273. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27274. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27275. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27276. res.Output.Setldetail = ahres.Output.Setldetail
  27277. res.ErrMsg = ahres.ErrMsg
  27278. res.Cainfo = ahres.Cainfo
  27279. res.WarnMsg = ahres.WarnMsg
  27280. res.Infcode = ahres.Infcode
  27281. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27282. res.Output.Setlinfo.ClrType = "11"
  27283. } else {
  27284. res.Output.Setlinfo.ClrType = "9903"
  27285. }
  27286. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27287. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27288. if his.IdCardType == 1 {
  27289. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27290. bas := strings.Split(psn_info.CardInfo, "|")
  27291. cert_no = bas[2]
  27292. } else if his.IdCardType == 3 {
  27293. cert_no = his.Certno
  27294. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27295. } else if his.IdCardType == 4 {
  27296. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27297. cert_no = his.Certno
  27298. psn_info.VerifyNumber = psn_info.VerifyNumber
  27299. } else {
  27300. cert_no = his.Certno
  27301. psn_info.VerifyNumber = his.Certno
  27302. }
  27303. var api string
  27304. var med_type string
  27305. if his.Insutype == "390" {
  27306. if reg_type == 992102 {
  27307. med_type = "992102"
  27308. }
  27309. if reg_type == 140104 {
  27310. med_type = "140104"
  27311. }
  27312. if reg_type == 14 {
  27313. med_type = "14"
  27314. }
  27315. if reg_type == 140201 {
  27316. med_type = "140201"
  27317. }
  27318. } else if his.Insutype == "310" {
  27319. if reg_type == 992102 {
  27320. med_type = "992102"
  27321. }
  27322. if reg_type == 14 {
  27323. med_type = "14"
  27324. }
  27325. if reg_type == 140104 {
  27326. med_type = "140104"
  27327. }
  27328. if reg_type == 140201 {
  27329. med_type = "140201"
  27330. }
  27331. }
  27332. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27333. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27334. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27335. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27336. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27337. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27338. "&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
  27339. resp, requestErr := http.Get(api)
  27340. if requestErr != nil {
  27341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27342. return
  27343. }
  27344. body, ioErr := ioutil.ReadAll(resp.Body)
  27345. if ioErr != nil {
  27346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27348. return
  27349. }
  27350. var respJSON map[string]interface{}
  27351. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27354. return
  27355. }
  27356. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27357. if status == "0" {
  27358. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27359. c.ServeSuccessJSON(map[string]interface{}{
  27360. "failed_code": -10,
  27361. "msg": err_msg,
  27362. })
  27363. return
  27364. }
  27365. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27366. result, _ := json.Marshal(respJSON)
  27367. fmt.Println("log")
  27368. fmt.Println(string(result))
  27369. if err := json.Unmarshal(result, &ahres); err != nil {
  27370. utils.ErrorLog("解析失败:%v", err)
  27371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27372. return
  27373. }
  27374. res.InfRefmsgid = ahres.InfRefmsgid
  27375. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27376. // 创建对应的Time类型
  27377. t := time.UnixMilli(timestamp)
  27378. // 格式化成指定的日期字符串
  27379. str := t.Format("2006-01-02 15:04:05")
  27380. res.Output.Setlinfo.SetlTime = str
  27381. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27382. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27383. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27384. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27385. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27386. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27387. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27388. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27389. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27390. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27391. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27392. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27393. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27394. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27395. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27396. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27397. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27398. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27399. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27400. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27401. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27402. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27403. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27404. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27405. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27406. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27407. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27408. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27409. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27410. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27411. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27412. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27413. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27414. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27415. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27416. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27417. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27418. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27419. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27420. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27421. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27422. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27423. res.Output.Setldetail = ahres.Output.Setldetail
  27424. res.ErrMsg = ahres.ErrMsg
  27425. res.Cainfo = ahres.Cainfo
  27426. res.WarnMsg = ahres.WarnMsg
  27427. res.Infcode = ahres.Infcode
  27428. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27429. res.Output.Setlinfo.ClrType = "11"
  27430. } else {
  27431. res.Output.Setlinfo.ClrType = "9903"
  27432. }
  27433. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27434. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27435. var cert_no string
  27436. if his.IdCardType == 1 {
  27437. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27438. } else if his.IdCardType == 2 {
  27439. cert_no = his.IdCardNo
  27440. } else {
  27441. cert_no = psn_info.VerifyNumber
  27442. }
  27443. 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, "")
  27444. var dat map[string]interface{}
  27445. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27446. fmt.Println(dat)
  27447. } else {
  27448. fmt.Println(err)
  27449. }
  27450. saveLog(result2, src_resquest, "2207", "结算")
  27451. userJSONBytes, _ := json.Marshal(dat)
  27452. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27453. utils.ErrorLog("解析失败:%v", err)
  27454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27455. return
  27456. }
  27457. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27458. psn_info, _ := service.GetPsnByPatientId(id)
  27459. var verify_number string
  27460. if psn_info.IdCardType == 4 {
  27461. verify_number = psn_info.VerifyNumber
  27462. } else if psn_info.IdCardType == 1 {
  27463. bas := strings.Split(psn_info.CardInfo, "|")
  27464. cardNumber := bas[2]
  27465. verify_number = cardNumber
  27466. } else {
  27467. verify_number = psn_info.Certno
  27468. psn_info.IdCardType = 2
  27469. }
  27470. var api string
  27471. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27472. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27473. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27474. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27475. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27476. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27477. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  27478. resp, requestErr := http.Get(api)
  27479. if requestErr != nil {
  27480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27481. return
  27482. }
  27483. body, ioErr := ioutil.ReadAll(resp.Body)
  27484. if ioErr != nil {
  27485. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27487. return
  27488. }
  27489. var respJSON map[string]interface{}
  27490. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27493. return
  27494. }
  27495. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27496. result, _ := json.Marshal(respJSON)
  27497. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27498. utils.ErrorLog("解析失败:%v", err)
  27499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27500. return
  27501. }
  27502. } else {
  27503. var src_resquest string
  27504. if miConfig.Code == "H15049901371" {
  27505. //赤峰地区国家医保医疗类别
  27506. //职工透析:医疗类别选特殊情况门诊990502
  27507. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27508. var med_type string
  27509. if his.Insutype == "390" {
  27510. if reg_type == 14 {
  27511. med_type = "9933"
  27512. } else if reg_type == 11 {
  27513. med_type = "11"
  27514. }
  27515. } else if his.Insutype == "310" {
  27516. if reg_type == 14 {
  27517. med_type = "990502"
  27518. } else if reg_type == 11 {
  27519. med_type = "11"
  27520. }
  27521. }
  27522. 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)
  27523. } else {
  27524. if his.IdCardType == 4 {
  27525. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27526. token := psn_info.VerifyNumber
  27527. 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)
  27528. } else {
  27529. 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)
  27530. }
  27531. }
  27532. var dat map[string]interface{}
  27533. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27534. fmt.Println(dat)
  27535. } else {
  27536. fmt.Println(err)
  27537. }
  27538. saveLog(result2, src_resquest, "2207", "结算")
  27539. userJSONBytes, _ := json.Marshal(dat)
  27540. if miConfig.Code == "H15049901371" {
  27541. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27542. utils.ErrorLog("解析失败:%v", err)
  27543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27544. return
  27545. }
  27546. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27547. res.Output = resSeven10265.Output
  27548. res.ErrMsg = resSeven10265.ErrMsg
  27549. res.Cainfo = resSeven10265.Cainfo
  27550. res.WarnMsg = resSeven10265.WarnMsg
  27551. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27552. res.Infcode = infocode
  27553. } else {
  27554. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27555. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27556. utils.ErrorLog("解析失败:%v", err)
  27557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27558. return
  27559. }
  27560. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27561. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27562. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27563. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27564. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27565. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27566. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27567. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27568. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27569. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27570. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27571. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27572. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27573. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27574. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27575. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27576. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27577. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27578. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27579. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27580. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27581. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27582. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27583. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27584. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27585. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27586. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27587. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27588. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27589. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27590. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27591. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27592. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27593. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27594. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27595. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27596. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27597. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27598. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27599. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27600. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27601. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27602. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27603. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27604. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27605. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27606. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27607. res.Cainfo = gzresSeven10265Two.Cainfo
  27608. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27609. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27610. //res.Infcode = infocode
  27611. } else {
  27612. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27613. utils.ErrorLog("解析失败:%v", err)
  27614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27615. return
  27616. }
  27617. }
  27618. }
  27619. }
  27620. if res.Infcode == -1 {
  27621. errlog := &models.HisOrderError{
  27622. UserOrgId: adminUser.CurrentOrgId,
  27623. Ctime: time.Now().Unix(),
  27624. Mtime: time.Now().Unix(),
  27625. Number: chrg_bchno,
  27626. ErrMsg: res.ErrMsg,
  27627. Status: 1,
  27628. PatientId: id,
  27629. RecordTime: recordDateTime,
  27630. Stage: 6,
  27631. }
  27632. service.CreateErrMsgLog(errlog)
  27633. c.ServeSuccessJSON(map[string]interface{}{
  27634. "failed_code": -10,
  27635. "msg": res.ErrMsg,
  27636. })
  27637. return
  27638. } else {
  27639. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27640. order.OrderStatus = 2
  27641. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27642. order.SetlId = res.Output.Setlinfo.SetlID
  27643. order.PsnNo = res.Output.Setlinfo.PsnNo
  27644. order.PsnName = res.Output.Setlinfo.PsnName
  27645. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27646. order.Certno = res.Output.Setlinfo.Certno
  27647. order.Gend = res.Output.Setlinfo.Gend
  27648. order.Naty = res.Output.Setlinfo.Naty
  27649. order.Age = res.Output.Setlinfo.Age
  27650. order.Insutype = res.Output.Setlinfo.Insutype
  27651. order.PsnType = res.Output.Setlinfo.PsnType
  27652. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27653. order.SetlTime = res.Output.Setlinfo.SetlTime
  27654. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27655. order.PayWays = pay_ways
  27656. order.AcctUsedFlag = acct_used_flag
  27657. order.WechatPay = wechat_pay
  27658. order.AliPay = ali_pay
  27659. order.JifenPay = jifen_pay
  27660. order.BandCardPay = band_card_pay
  27661. order.CashPay = cash_pay
  27662. order.OthDesc = oth_desc
  27663. //order.MedType = res.Output.Setlinfo.MedType
  27664. if reg_type == 1112 {
  27665. order.MedType = "1112"
  27666. }
  27667. if reg_type == 1111 {
  27668. order.MedType = "1111"
  27669. }
  27670. order.ClrType = res.Output.Setlinfo.ClrType
  27671. if adminUser.CurrentOrgId == 10480 {
  27672. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27673. order.ClrType = "11"
  27674. } else {
  27675. order.ClrType = "9903"
  27676. }
  27677. }
  27678. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27679. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27680. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27681. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27682. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27683. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27684. order.HifpPay = res.Output.Setlinfo.HifpPay
  27685. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27686. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27687. order.HifesPay = res.Output.Setlinfo.HifesPay
  27688. order.HifobPay = res.Output.Setlinfo.HifobPay
  27689. order.MafPay = res.Output.Setlinfo.MafPay
  27690. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27691. order.OthPay = res.Output.Setlinfo.OthPay
  27692. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27693. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27694. order.AcctPay = res.Output.Setlinfo.AcctPay
  27695. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27696. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27697. order.Balc = res.Output.Setlinfo.Balc
  27698. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27699. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27700. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27701. order.ClrWay = res.Output.Setlinfo.ClrWay
  27702. order.Creator = order.Creator
  27703. order.Modify = roles.AdminUserId
  27704. order.RequestLog = src_resquest
  27705. order.Diagnosis = diagnosis_id
  27706. order.FaPiaoNumber = fapiao_number
  27707. order.FaPiaoCode = fapiao_code
  27708. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27709. detailStr := string(setlDetail)
  27710. order.SetlDetail = detailStr
  27711. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27712. err = service.UpDateOrder(order)
  27713. if err == nil {
  27714. //判断是否使用了押金
  27715. if dec_way == "true" {
  27716. tmpstring := strconv.FormatInt(order.ID, 10)
  27717. //扣押金
  27718. order.Decimal = decimal
  27719. service.UpDateOrder(order)
  27720. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27721. if errmsg != nil {
  27722. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27723. return
  27724. }
  27725. }
  27726. c.ServeSuccessJSON(map[string]interface{}{
  27727. "msg": "结算成功",
  27728. })
  27729. } else {
  27730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27731. return
  27732. }
  27733. }
  27734. }
  27735. }
  27736. }
  27737. // 上传明细-预结算-
  27738. func (c *HisApiController) GetPreUploadInfo() {
  27739. id, _ := c.GetInt64("id")
  27740. record_time := c.GetString("record_time")
  27741. his_patient_id, _ := c.GetInt64("his_patient_id")
  27742. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  27743. admin_user_id, _ := c.GetInt64("admin_user_id")
  27744. diagnosis_id := c.GetString("diagnosis")
  27745. sick_type, _ := c.GetInt64("sick_type")
  27746. reg_type, _ := c.GetInt64("p_type")
  27747. begin_time := c.GetString("begin_time")
  27748. acct_used_flag := c.GetString("acct_used_flag")
  27749. id_str := c.GetString("ids")
  27750. ids_arr := strings.Split(id_str, ",")
  27751. timeLayout := "2006-01-02"
  27752. loc, _ := time.LoadLocation("Local")
  27753. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27754. if err != nil {
  27755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27756. return
  27757. }
  27758. recordDateTime := theTime.Unix()
  27759. adminUser := c.GetAdminUserInfo()
  27760. diagnosis_ids := strings.Split(diagnosis_id, ",")
  27761. var config []*models.HisXtDiagnoseConfig
  27762. for _, item := range diagnosis_ids {
  27763. id, _ := strconv.ParseInt(item, 10, 64)
  27764. if id > 0 {
  27765. diagnosisConfig, _ := service.FindDiagnoseById(id)
  27766. config = append(config, &diagnosisConfig)
  27767. }
  27768. }
  27769. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27770. sickConfig, _ := service.FindSickById(sick_type)
  27771. var prescriptions []*models.HisPrescription
  27772. var start_time int64
  27773. var end_time int64
  27774. var isSuccess bool = true
  27775. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27776. fmt.Println(his_patient_id)
  27777. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27778. timestamp := time.Now().Unix()
  27779. tempTime := time.Unix(timestamp, 0)
  27780. timeFormat := tempTime.Format("20060102150405")
  27781. chrgBchno := rand.Intn(100000) + 10000
  27782. new_chrg_bchno := ""
  27783. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  27784. new_chrg_bchno = chrg_bchno
  27785. if adminUser.CurrentOrgId == 10265 {
  27786. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27787. new_chrg_bchno = "0000"
  27788. }
  27789. }
  27790. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27791. var patientPrescription models.HisPrescriptionInfo
  27792. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27793. if patientPrescription.ID == 0 {
  27794. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  27795. }
  27796. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27797. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27798. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27799. strconv.FormatInt(his.PatientId, 10)
  27800. var res2406 Result2406
  27801. //安徽单病种处理
  27802. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  27803. data := make(map[string]interface{})
  27804. client := &http.Client{}
  27805. data["psn_no"] = his.PsnNo
  27806. data["mdtrt_id"] = his.Number
  27807. data["operator"] = roles.UserName
  27808. data["cert_no"] = his.IdCardNo
  27809. data["org_name"] = miConfig.OrgName
  27810. data["psn_name"] = his.Name
  27811. data["ipt_otp_no"] = his.IptOtpNo
  27812. data["ipt_psn_sp_flag_type"] = "0901"
  27813. data["ipt_psn_sp_flag"] = "1"
  27814. data["fixmedins_code"] = miConfig.Code
  27815. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27816. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27817. data["url"] = miConfig.Url
  27818. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27819. bytesData, _ := json.Marshal(data)
  27820. var req *http.Request
  27821. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27822. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27823. resp, _ := client.Do(req)
  27824. defer resp.Body.Close()
  27825. body, ioErr := ioutil.ReadAll(resp.Body)
  27826. if ioErr != nil {
  27827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27829. return
  27830. }
  27831. var respJSON map[string]interface{}
  27832. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27835. return
  27836. }
  27837. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27838. if status == "0" {
  27839. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27840. c.ServeSuccessJSON(map[string]interface{}{
  27841. "failed_code": -10,
  27842. "msg": err_msg,
  27843. })
  27844. return
  27845. }
  27846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27847. userJSONBytes, _ := json.Marshal(respJSON)
  27848. fmt.Println("log")
  27849. fmt.Println(string(userJSONBytes))
  27850. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  27851. utils.ErrorLog("解析失败:%v", err)
  27852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27853. return
  27854. }
  27855. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  27856. data := make(map[string]interface{})
  27857. client := &http.Client{}
  27858. data["psn_no"] = his.PsnNo
  27859. data["mdtrt_id"] = his.Number
  27860. data["operator"] = roles.UserName
  27861. data["cert_no"] = his.IdCardNo
  27862. data["org_name"] = miConfig.OrgName
  27863. data["psn_name"] = his.Name
  27864. data["ipt_otp_no"] = his.IptOtpNo
  27865. data["ipt_psn_sp_flag_type"] = "0901"
  27866. data["ipt_psn_sp_flag"] = "1"
  27867. data["fixmedins_code"] = miConfig.Code
  27868. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27869. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27870. data["url"] = miConfig.Url
  27871. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27872. bytesData, _ := json.Marshal(data)
  27873. var req *http.Request
  27874. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27875. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27876. resp, _ := client.Do(req)
  27877. defer resp.Body.Close()
  27878. body, ioErr := ioutil.ReadAll(resp.Body)
  27879. if ioErr != nil {
  27880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27882. return
  27883. }
  27884. var respJSON map[string]interface{}
  27885. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27888. return
  27889. }
  27890. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27891. if status == "0" {
  27892. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27893. c.ServeSuccessJSON(map[string]interface{}{
  27894. "failed_code": -10,
  27895. "msg": err_msg,
  27896. })
  27897. return
  27898. }
  27899. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27900. userJSONBytes, _ := json.Marshal(respJSON)
  27901. fmt.Println("log")
  27902. fmt.Println(string(userJSONBytes))
  27903. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  27904. utils.ErrorLog("解析失败:%v", err)
  27905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27906. return
  27907. }
  27908. }
  27909. if res2406.Infcode != 0 {
  27910. adminUser := c.GetAdminUserInfo()
  27911. errlog := &models.HisOrderError{
  27912. UserOrgId: adminUser.CurrentOrgId,
  27913. Ctime: time.Now().Unix(),
  27914. Mtime: time.Now().Unix(),
  27915. ErrMsg: res2406.ErrMsg,
  27916. Status: 1,
  27917. PatientId: id,
  27918. RecordTime: recordDateTime,
  27919. Stage: 3,
  27920. }
  27921. service.CreateErrMsgLog(errlog)
  27922. c.ServeSuccessJSON(map[string]interface{}{
  27923. "failed_code": -10,
  27924. "msg": res2406.ErrMsg,
  27925. })
  27926. return
  27927. }
  27928. var res2 ResultSix
  27929. var res3 GZResultSix
  27930. var resSix10265 ResultSix10265
  27931. //var time_stamp string
  27932. if miConfig.MdtrtareaAdmvs == "421300" {
  27933. data := make(map[string]interface{})
  27934. client := &http.Client{}
  27935. data["psn_no"] = his.PsnNo
  27936. data["mdtrt_id"] = his.Number
  27937. data["department"] = department.Name
  27938. data["org_name"] = miConfig.OrgName
  27939. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27940. data["doctor_id"] = doctor_info.DoctorNumber
  27941. data["doctor_name"] = roles.UserName
  27942. data["fixmedins_code"] = miConfig.Code
  27943. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27944. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27945. data["secret_key"] = miConfig.SecretKey
  27946. data["sick_code"] = sickConfig.CountryCode
  27947. data["sick_name"] = sickConfig.ClassName
  27948. data["begin_time"] = begin_time
  27949. data["dept"] = strconv.FormatInt(department.ID, 10)
  27950. data["config"] = config
  27951. data["opter"] = roles.UserName
  27952. fmt.Println(data)
  27953. bytesData, _ := json.Marshal(data)
  27954. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  27955. resp, _ := client.Do(req)
  27956. defer resp.Body.Close()
  27957. body, ioErr := ioutil.ReadAll(resp.Body)
  27958. if ioErr != nil {
  27959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27961. return
  27962. }
  27963. var respJSON map[string]interface{}
  27964. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27967. return
  27968. }
  27969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27970. userJSONBytes, _ := json.Marshal(respJSON)
  27971. fmt.Println("log")
  27972. fmt.Println(string(userJSONBytes))
  27973. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27974. utils.ErrorLog("解析失败:%v", err)
  27975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27976. return
  27977. }
  27978. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27979. data := make(map[string]interface{})
  27980. client := &http.Client{}
  27981. data["psn_no"] = his.PsnNo
  27982. data["mdtrt_id"] = his.Number
  27983. data["department"] = department.Name
  27984. data["org_name"] = miConfig.OrgName
  27985. if reg_type == 11 && his.Insutype == "390" {
  27986. data["med_type"] = "110104"
  27987. } else {
  27988. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27989. }
  27990. data["doctor_id"] = doctor_info.DoctorNumber
  27991. data["doctor_name"] = roles.UserName
  27992. data["fixmedins_code"] = miConfig.Code
  27993. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27994. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27995. data["secret_key"] = miConfig.SecretKey
  27996. data["sick_code"] = sickConfig.CountryCode
  27997. data["sick_name"] = sickConfig.ClassName
  27998. data["begin_time"] = begin_time
  27999. data["dept"] = strconv.FormatInt(department.ID, 10)
  28000. data["config"] = config
  28001. data["opter"] = roles.UserName
  28002. fmt.Println(data)
  28003. bytesData, _ := json.Marshal(data)
  28004. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28005. resp, _ := client.Do(req)
  28006. defer resp.Body.Close()
  28007. body, ioErr := ioutil.ReadAll(resp.Body)
  28008. if ioErr != nil {
  28009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28011. return
  28012. }
  28013. var respJSON map[string]interface{}
  28014. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28017. return
  28018. }
  28019. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28020. userJSONBytes, _ := json.Marshal(respJSON)
  28021. fmt.Println("log")
  28022. fmt.Println(string(userJSONBytes))
  28023. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28024. utils.ErrorLog("解析失败:%v", err)
  28025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28026. return
  28027. }
  28028. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28029. data := make(map[string]interface{})
  28030. client := &http.Client{}
  28031. data["psn_no"] = his.PsnNo
  28032. data["mdtrt_id"] = his.Number
  28033. data["department"] = department.Name
  28034. data["org_name"] = miConfig.OrgName
  28035. if reg_type == 11 && his.Insutype == "390" {
  28036. data["med_type"] = "110104"
  28037. } else {
  28038. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28039. }
  28040. data["doctor_id"] = doctor_info.DoctorNumber
  28041. data["doctor_name"] = roles.UserName
  28042. data["fixmedins_code"] = miConfig.Code
  28043. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28044. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28045. data["secret_key"] = miConfig.SecretKey
  28046. data["sick_code"] = sickConfig.CountryCode
  28047. data["sick_name"] = sickConfig.ClassName
  28048. data["begin_time"] = begin_time
  28049. data["dept"] = strconv.FormatInt(department.ID, 10)
  28050. data["config"] = config
  28051. data["opter"] = roles.UserName
  28052. fmt.Println(data)
  28053. bytesData, _ := json.Marshal(data)
  28054. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28055. resp, _ := client.Do(req)
  28056. defer resp.Body.Close()
  28057. body, ioErr := ioutil.ReadAll(resp.Body)
  28058. if ioErr != nil {
  28059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28061. return
  28062. }
  28063. var respJSON map[string]interface{}
  28064. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28067. return
  28068. }
  28069. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28070. userJSONBytes, _ := json.Marshal(respJSON)
  28071. fmt.Println("log")
  28072. fmt.Println(string(userJSONBytes))
  28073. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28074. utils.ErrorLog("解析失败:%v", err)
  28075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28076. return
  28077. }
  28078. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28079. data := make(map[string]interface{})
  28080. client := &http.Client{}
  28081. data["psn_no"] = his.PsnNo
  28082. data["mdtrt_id"] = his.Number
  28083. data["department"] = department.Name
  28084. data["org_name"] = miConfig.OrgName
  28085. if reg_type == 11 && his.Insutype == "390" {
  28086. data["med_type"] = "110104"
  28087. } else {
  28088. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28089. }
  28090. data["doctor_id"] = doctor_info.DoctorNumber
  28091. data["doctor_name"] = roles.UserName
  28092. data["fixmedins_code"] = miConfig.Code
  28093. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28094. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28095. data["secret_key"] = miConfig.SecretKey
  28096. data["sick_code"] = sickConfig.CountryCode
  28097. data["sick_name"] = sickConfig.ClassName
  28098. data["begin_time"] = begin_time
  28099. data["dept"] = strconv.FormatInt(department.ID, 10)
  28100. data["config"] = config
  28101. data["opter"] = roles.UserName
  28102. fmt.Println(data)
  28103. bytesData, _ := json.Marshal(data)
  28104. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28105. resp, _ := client.Do(req)
  28106. defer resp.Body.Close()
  28107. body, ioErr := ioutil.ReadAll(resp.Body)
  28108. if ioErr != nil {
  28109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28111. return
  28112. }
  28113. var respJSON map[string]interface{}
  28114. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28115. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28117. return
  28118. }
  28119. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28120. userJSONBytes, _ := json.Marshal(respJSON)
  28121. fmt.Println("log")
  28122. fmt.Println(string(userJSONBytes))
  28123. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28124. utils.ErrorLog("解析失败:%v", err)
  28125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28126. return
  28127. }
  28128. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28129. data := make(map[string]interface{})
  28130. client := &http.Client{}
  28131. data["psn_no"] = his.PsnNo
  28132. data["mdtrt_id"] = his.Number
  28133. data["doctor"] = roles.UserName
  28134. data["department"] = department.Name
  28135. data["org_name"] = miConfig.OrgName
  28136. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28137. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28138. data["fixmedins_code"] = miConfig.Code
  28139. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28140. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28141. data["secret_key"] = miConfig.SecretKey
  28142. data["sick_code"] = sickConfig.CountryCode
  28143. data["sick_name"] = sickConfig.ClassName
  28144. data["begin_time"] = begin_time
  28145. data["dept"] = strconv.FormatInt(department.ID, 10)
  28146. data["config"] = config
  28147. data["url"] = miConfig.Url
  28148. data["ak"] = miConfig.AccessKey
  28149. data["cainfo"] = miConfig.Cainfo
  28150. bytesData, _ := json.Marshal(data)
  28151. var req *http.Request
  28152. if miConfig.MdtrtareaAdmvs == "320921" {
  28153. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28154. } else {
  28155. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28156. }
  28157. resp, _ := client.Do(req)
  28158. defer resp.Body.Close()
  28159. body, ioErr := ioutil.ReadAll(resp.Body)
  28160. if ioErr != nil {
  28161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28163. return
  28164. }
  28165. var respJSON map[string]interface{}
  28166. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28169. return
  28170. }
  28171. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28172. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28173. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28175. userJSONBytes, _ := json.Marshal(respJSON)
  28176. fmt.Println("log")
  28177. fmt.Println(string(userJSONBytes))
  28178. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28179. utils.ErrorLog("解析失败:%v", err)
  28180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28181. return
  28182. }
  28183. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28184. res2.Output = resSix10265.Output
  28185. res2.ErrMsg = resSix10265.ErrMsg
  28186. res2.Cainfo = resSix10265.Cainfo
  28187. res2.WarnMsg = resSix10265.WarnMsg
  28188. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28189. res2.Infcode = infocode
  28190. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28191. data := make(map[string]interface{})
  28192. client := &http.Client{}
  28193. data["psn_no"] = his.PsnNo
  28194. data["mdtrt_id"] = his.Number
  28195. data["doctor"] = roles.UserName
  28196. data["department"] = department.Name
  28197. data["org_name"] = miConfig.OrgName
  28198. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28199. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28200. data["fixmedins_code"] = miConfig.Code
  28201. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28202. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28203. data["secret_key"] = miConfig.SecretKey
  28204. data["sick_code"] = sickConfig.CountryCode
  28205. data["sick_name"] = sickConfig.ClassName
  28206. data["begin_time"] = begin_time
  28207. data["dept"] = strconv.FormatInt(department.ID, 10)
  28208. data["config"] = config
  28209. //data["url"] = miConfig.Url
  28210. //data["ak"] = miConfig.AccessKey
  28211. data["cainfo"] = miConfig.Cainfo
  28212. fmt.Println(data)
  28213. bytesData, _ := json.Marshal(data)
  28214. var req *http.Request
  28215. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  28216. resp, _ := client.Do(req)
  28217. defer resp.Body.Close()
  28218. body, ioErr := ioutil.ReadAll(resp.Body)
  28219. if ioErr != nil {
  28220. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28222. return
  28223. }
  28224. var respJSON map[string]interface{}
  28225. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28228. return
  28229. }
  28230. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28231. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28232. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28233. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28234. userJSONBytes, _ := json.Marshal(respJSON)
  28235. fmt.Println("log")
  28236. fmt.Println(string(userJSONBytes))
  28237. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28238. utils.ErrorLog("解析失败:%v", err)
  28239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28240. return
  28241. }
  28242. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28243. res2.Output = resSix10265.Output
  28244. res2.ErrMsg = resSix10265.ErrMsg
  28245. res2.Cainfo = resSix10265.Cainfo
  28246. res2.WarnMsg = resSix10265.WarnMsg
  28247. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28248. res2.Infcode = infocode
  28249. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28250. 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)
  28251. saveLog(result, requestLog, "2203", "上传就诊信息")
  28252. var respJSON2 map[string]interface{}
  28253. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28256. return
  28257. }
  28258. userJSONBytes2, _ := json.Marshal(respJSON2)
  28259. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28260. utils.ErrorLog("解析失败:%v", err)
  28261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28262. return
  28263. }
  28264. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28265. var result string
  28266. var requestLog string
  28267. 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, "")
  28268. saveLog(result, requestLog, "2203", "上传就诊信息")
  28269. var respJSON2 map[string]interface{}
  28270. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28273. return
  28274. }
  28275. userJSONBytes2, _ := json.Marshal(respJSON2)
  28276. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28277. utils.ErrorLog("解析失败:%v", err)
  28278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28279. return
  28280. }
  28281. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28282. var result string
  28283. var requestLog string
  28284. 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, "")
  28285. saveLog(result, requestLog, "2203", "上传就诊信息")
  28286. var respJSON2 map[string]interface{}
  28287. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28290. return
  28291. }
  28292. userJSONBytes2, _ := json.Marshal(respJSON2)
  28293. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28294. utils.ErrorLog("解析失败:%v", err)
  28295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28296. return
  28297. }
  28298. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28299. data := make(map[string]interface{})
  28300. client := &http.Client{}
  28301. data["psn_no"] = his.PsnNo
  28302. data["mdtrt_id"] = his.Number
  28303. data["operator"] = roles.UserName
  28304. data["department"] = department.Name
  28305. data["org_name"] = miConfig.OrgName
  28306. var med_type string
  28307. if his.Insutype == "390" {
  28308. if reg_type == 992102 {
  28309. med_type = "992102"
  28310. data["sick_code"] = "ZDZ940"
  28311. data["sick_name"] = "慢性肾衰竭"
  28312. }
  28313. if reg_type == 140104 {
  28314. med_type = "140104"
  28315. data["sick_code"] = sickConfig.CountryCode
  28316. data["sick_name"] = sickConfig.ClassName
  28317. }
  28318. if reg_type == 14 {
  28319. med_type = "140104"
  28320. data["sick_code"] = sickConfig.CountryCode
  28321. data["sick_name"] = sickConfig.ClassName
  28322. }
  28323. } else if his.Insutype == "310" {
  28324. if reg_type == 992102 {
  28325. med_type = "992102"
  28326. data["sick_code"] = "ZDZ940"
  28327. data["sick_name"] = "慢性肾衰竭"
  28328. }
  28329. if reg_type == 140104 {
  28330. med_type = "140104"
  28331. data["sick_code"] = sickConfig.CountryCode
  28332. data["sick_name"] = sickConfig.ClassName
  28333. }
  28334. if reg_type == 14 {
  28335. med_type = "14"
  28336. data["sick_code"] = sickConfig.CountryCode
  28337. data["sick_name"] = sickConfig.ClassName
  28338. }
  28339. }
  28340. data["med_type"] = med_type
  28341. data["doctor_number"] = doctor_info.DoctorNumber
  28342. data["doctor_name"] = doctor_info.UserName
  28343. data["fixmedins_code"] = miConfig.Code
  28344. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28345. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28346. data["secret_key"] = miConfig.SecretKey
  28347. data["begin_time"] = begin_time
  28348. data["dept"] = strconv.FormatInt(department.ID, 10)
  28349. data["config"] = config
  28350. data["url"] = miConfig.Url
  28351. data["ak"] = miConfig.AccessKey
  28352. data["cainfo"] = miConfig.Cainfo
  28353. bytesData, _ := json.Marshal(data)
  28354. var req *http.Request
  28355. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28356. resp, _ := client.Do(req)
  28357. defer resp.Body.Close()
  28358. body, ioErr := ioutil.ReadAll(resp.Body)
  28359. if ioErr != nil {
  28360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28362. return
  28363. }
  28364. var respJSON map[string]interface{}
  28365. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28368. return
  28369. }
  28370. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28371. if status == "0" {
  28372. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28373. c.ServeSuccessJSON(map[string]interface{}{
  28374. "failed_code": -10,
  28375. "msg": err_msg,
  28376. })
  28377. return
  28378. }
  28379. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28380. userJSONBytes, _ := json.Marshal(respJSON)
  28381. fmt.Println("log")
  28382. fmt.Println(string(userJSONBytes))
  28383. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28384. utils.ErrorLog("解析失败:%v", err)
  28385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28386. return
  28387. }
  28388. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28389. data := make(map[string]interface{})
  28390. client := &http.Client{}
  28391. data["psn_no"] = his.PsnNo
  28392. data["mdtrt_id"] = his.Number
  28393. data["operator"] = roles.UserName
  28394. data["department"] = department.Name
  28395. data["org_name"] = miConfig.OrgName
  28396. var med_type string
  28397. if his.Insutype == "390" {
  28398. if reg_type == 992102 {
  28399. med_type = "992102"
  28400. data["sick_code"] = sickConfig.CountryCode
  28401. data["sick_name"] = sickConfig.ClassName
  28402. }
  28403. if reg_type == 140104 {
  28404. med_type = "140104"
  28405. data["sick_code"] = sickConfig.CountryCode
  28406. data["sick_name"] = sickConfig.ClassName
  28407. }
  28408. if reg_type == 140201 {
  28409. med_type = "140201"
  28410. data["sick_code"] = sickConfig.CountryCode
  28411. data["sick_name"] = sickConfig.ClassName
  28412. }
  28413. if reg_type == 14 {
  28414. med_type = "14"
  28415. data["sick_code"] = sickConfig.CountryCode
  28416. data["sick_name"] = sickConfig.ClassName
  28417. }
  28418. } else if his.Insutype == "310" {
  28419. if reg_type == 992102 {
  28420. med_type = "992102"
  28421. data["sick_code"] = sickConfig.CountryCode
  28422. data["sick_name"] = sickConfig.ClassName
  28423. }
  28424. if reg_type == 140104 {
  28425. med_type = "140104"
  28426. data["sick_code"] = sickConfig.CountryCode
  28427. data["sick_name"] = sickConfig.ClassName
  28428. }
  28429. if reg_type == 140201 {
  28430. med_type = "140201"
  28431. data["sick_code"] = sickConfig.CountryCode
  28432. data["sick_name"] = sickConfig.ClassName
  28433. }
  28434. if reg_type == 14 {
  28435. med_type = "14"
  28436. data["sick_code"] = sickConfig.CountryCode
  28437. data["sick_name"] = sickConfig.ClassName
  28438. }
  28439. }
  28440. data["med_type"] = med_type
  28441. data["doctor_number"] = doctor_info.DoctorNumber
  28442. data["doctor_name"] = doctor_info.UserName
  28443. data["fixmedins_code"] = miConfig.Code
  28444. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28445. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28446. data["secret_key"] = miConfig.SecretKey
  28447. data["begin_time"] = begin_time
  28448. data["dept"] = strconv.FormatInt(department.ID, 10)
  28449. data["config"] = config
  28450. data["url"] = miConfig.Url
  28451. data["ak"] = miConfig.AccessKey
  28452. data["cainfo"] = miConfig.Cainfo
  28453. bytesData, _ := json.Marshal(data)
  28454. var req *http.Request
  28455. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28456. resp, _ := client.Do(req)
  28457. defer resp.Body.Close()
  28458. body, ioErr := ioutil.ReadAll(resp.Body)
  28459. if ioErr != nil {
  28460. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28462. return
  28463. }
  28464. var respJSON map[string]interface{}
  28465. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28468. return
  28469. }
  28470. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28471. if status == "0" {
  28472. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28473. c.ServeSuccessJSON(map[string]interface{}{
  28474. "failed_code": -10,
  28475. "msg": err_msg,
  28476. })
  28477. return
  28478. }
  28479. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28480. userJSONBytes, _ := json.Marshal(respJSON)
  28481. fmt.Println("log")
  28482. fmt.Println(string(userJSONBytes))
  28483. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28484. utils.ErrorLog("解析失败:%v", err)
  28485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28486. return
  28487. }
  28488. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28489. var result string
  28490. var requestLog string
  28491. 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, "")
  28492. saveLog(result, requestLog, "2203", "上传就诊信息")
  28493. var respJSON2 map[string]interface{}
  28494. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28495. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28497. return
  28498. }
  28499. userJSONBytes2, _ := json.Marshal(respJSON2)
  28500. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28501. utils.ErrorLog("解析失败:%v", err)
  28502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28503. return
  28504. }
  28505. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28506. data := make(map[string]interface{})
  28507. client := &http.Client{}
  28508. data["psn_no"] = his.PsnNo
  28509. data["mdtrt_id"] = his.Number
  28510. data["doctor"] = roles.UserName
  28511. data["department"] = department.Name
  28512. data["org_name"] = miConfig.OrgName
  28513. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28514. data["doctor_id"] = doctor_info.DoctorNumber
  28515. data["fixmedins_code"] = miConfig.Code
  28516. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28517. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28518. data["secret_key"] = miConfig.SecretKey
  28519. data["sick_code"] = sickConfig.CountryCode
  28520. data["sick_name"] = sickConfig.ClassName
  28521. data["begin_time"] = begin_time
  28522. data["new_doctor_name"] = doctor_info.UserName
  28523. data["dept"] = strconv.FormatInt(department.ID, 10)
  28524. data["config"] = config
  28525. bytesData, _ := json.Marshal(data)
  28526. var req *http.Request
  28527. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  28528. resp, _ := client.Do(req)
  28529. defer resp.Body.Close()
  28530. body, ioErr := ioutil.ReadAll(resp.Body)
  28531. if ioErr != nil {
  28532. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28534. return
  28535. }
  28536. var respJSON map[string]interface{}
  28537. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28540. return
  28541. }
  28542. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28543. userJSONBytes, _ := json.Marshal(respJSON)
  28544. fmt.Println("log")
  28545. fmt.Println(string(userJSONBytes))
  28546. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28547. utils.ErrorLog("解析失败:%v", err)
  28548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28549. return
  28550. }
  28551. } else {
  28552. var result string
  28553. var requestLog string
  28554. if miConfig.MdtrtareaAdmvs == "440781" { //
  28555. 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)
  28556. } else {
  28557. if miConfig.Code == "H15049901371" {
  28558. //赤峰地区国家医保医疗类别
  28559. //职工透析:医疗类别选特殊情况门诊990502
  28560. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28561. var med_type string
  28562. if his.Insutype == "390" {
  28563. if reg_type == 14 {
  28564. med_type = "9933"
  28565. } else if reg_type == 11 {
  28566. med_type = "11"
  28567. }
  28568. } else if his.Insutype == "310" {
  28569. if reg_type == 14 {
  28570. med_type = "990502"
  28571. } else if reg_type == 11 {
  28572. med_type = "11"
  28573. }
  28574. }
  28575. 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)
  28576. } else {
  28577. 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)
  28578. }
  28579. saveLog(result, requestLog, "2203", "上传就诊信息")
  28580. var respJSON2 map[string]interface{}
  28581. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28584. return
  28585. }
  28586. userJSONBytes2, _ := json.Marshal(respJSON2)
  28587. if miConfig.Code == "H15049901371" {
  28588. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  28589. utils.ErrorLog("解析失败:%v", err)
  28590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28591. return
  28592. }
  28593. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28594. res2.Output = resSix10265.Output
  28595. res2.ErrMsg = resSix10265.ErrMsg
  28596. res2.Cainfo = resSix10265.Cainfo
  28597. res2.WarnMsg = resSix10265.WarnMsg
  28598. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28599. res2.Infcode = infocode
  28600. } else {
  28601. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28602. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  28603. utils.ErrorLog("解析失败:%v", err)
  28604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28605. return
  28606. }
  28607. res2.Infcode = res3.Infcode
  28608. } else {
  28609. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28610. utils.ErrorLog("解析失败:%v", err)
  28611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28612. return
  28613. }
  28614. }
  28615. }
  28616. }
  28617. }
  28618. if res2.Infcode == -1 {
  28619. adminUser := c.GetAdminUserInfo()
  28620. errlog := &models.HisOrderError{
  28621. UserOrgId: adminUser.CurrentOrgId,
  28622. Ctime: time.Now().Unix(),
  28623. Mtime: time.Now().Unix(),
  28624. ErrMsg: res2.ErrMsg,
  28625. Status: 1,
  28626. PatientId: id,
  28627. RecordTime: recordDateTime,
  28628. Stage: 3,
  28629. }
  28630. service.CreateErrMsgLog(errlog)
  28631. c.ServeSuccessJSON(map[string]interface{}{
  28632. "failed_code": -10,
  28633. "msg": res2.ErrMsg,
  28634. })
  28635. return
  28636. }
  28637. if res2.Infcode != 0 {
  28638. adminUser := c.GetAdminUserInfo()
  28639. errlog := &models.HisOrderError{
  28640. UserOrgId: adminUser.CurrentOrgId,
  28641. Ctime: time.Now().Unix(),
  28642. Mtime: time.Now().Unix(),
  28643. ErrMsg: res2.ErrMsg,
  28644. Status: 1,
  28645. PatientId: id,
  28646. RecordTime: recordDateTime,
  28647. Stage: 3,
  28648. }
  28649. service.CreateErrMsgLog(errlog)
  28650. c.ServeSuccessJSON(map[string]interface{}{
  28651. "failed_code": -10,
  28652. "msg": res2.ErrMsg,
  28653. })
  28654. return
  28655. } else {
  28656. his.Diagnosis = diagnosis_id
  28657. his.SickType = sickConfig.ID
  28658. his.PType = fmt.Sprintf("%d", reg_type)
  28659. service.UpdateHisPatientThree(&his)
  28660. data := make(map[string]interface{})
  28661. if settle_accounts_type == 1 { //日结
  28662. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  28663. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  28664. } else {
  28665. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  28666. }
  28667. data["pre"] = prescriptions
  28668. } else { //月结
  28669. start_time_str := c.GetString("start_time")
  28670. end_time_str := c.GetString("end_time")
  28671. timeLayout := "2006-01-02"
  28672. loc, _ := time.LoadLocation("Local")
  28673. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  28674. if err != nil {
  28675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28676. return
  28677. }
  28678. recordStartTime := theStartTime.Unix()
  28679. start_time = recordStartTime
  28680. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  28681. if err != nil {
  28682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28683. return
  28684. }
  28685. recordEndTime := theEndTime.Unix()
  28686. end_time = recordEndTime
  28687. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  28688. data["pre"] = prescriptions
  28689. }
  28690. client := &http.Client{}
  28691. data["psn_no"] = his.PsnNo
  28692. data["mdtrt_id"] = his.Number
  28693. data["chrg_bchno"] = new_chrg_bchno
  28694. data["org_name"] = miConfig.OrgName
  28695. data["doctor"] = doctor_info.UserName
  28696. data["doctor_id"] = doctor_info.DoctorNumber
  28697. data["dept"] = department.Name
  28698. data["fixmedins_code"] = miConfig.Code
  28699. data["opter"] = roles.UserName
  28700. data["dept_code"] = department.Number
  28701. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28702. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28703. data["secret_key"] = miConfig.SecretKey
  28704. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  28705. data["url"] = miConfig.Url
  28706. data["ak"] = miConfig.AccessKey
  28707. data["new_doctor_name"] = patientPrescription.Doctor
  28708. if his.Insutype == "390" {
  28709. if reg_type == 992102 {
  28710. data["diag_code"] = "ZDZ940"
  28711. }
  28712. if reg_type == 140104 {
  28713. data["diag_code"] = sickConfig.CountryCode
  28714. }
  28715. if reg_type == 140201 {
  28716. data["diag_code"] = sickConfig.CountryCode
  28717. }
  28718. if reg_type == 14 {
  28719. data["diag_code"] = sickConfig.CountryCode
  28720. }
  28721. } else if his.Insutype == "310" {
  28722. if miConfig.MdtrtareaAdmvs == "341203" {
  28723. if reg_type == 992102 {
  28724. data["diag_code"] = "ZDZ940"
  28725. }
  28726. if reg_type != 992102 {
  28727. data["diag_code"] = sickConfig.CountryCode
  28728. }
  28729. } else {
  28730. data["diag_code"] = sickConfig.CountryCode
  28731. }
  28732. }
  28733. data["cainfo"] = miConfig.Cainfo
  28734. data["opter"] = roles.UserName
  28735. var ids []int64
  28736. for _, item := range prescriptions {
  28737. ids = append(ids, item.ID)
  28738. }
  28739. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28740. if config.IsOpen == 1 { //对接了医保,走医保流程
  28741. var res ResultFour
  28742. var resFour10265 ResultFour10265
  28743. if miConfig.MdtrtareaAdmvs == "421300" {
  28744. bytesData, _ := json.Marshal(data)
  28745. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28746. resp, _ := client.Do(req)
  28747. defer resp.Body.Close()
  28748. body, ioErr := ioutil.ReadAll(resp.Body)
  28749. if ioErr != nil {
  28750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28752. return
  28753. }
  28754. var respJSON map[string]interface{}
  28755. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28758. return
  28759. }
  28760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28761. userJSONBytes, _ := json.Marshal(respJSON)
  28762. fmt.Println("log")
  28763. fmt.Println(string(userJSONBytes))
  28764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28765. utils.ErrorLog("解析失败:%v", err)
  28766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28767. return
  28768. }
  28769. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28770. bytesData, _ := json.Marshal(data)
  28771. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28772. resp, _ := client.Do(req)
  28773. defer resp.Body.Close()
  28774. body, ioErr := ioutil.ReadAll(resp.Body)
  28775. if ioErr != nil {
  28776. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28778. return
  28779. }
  28780. var respJSON map[string]interface{}
  28781. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28784. return
  28785. }
  28786. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28787. userJSONBytes, _ := json.Marshal(respJSON)
  28788. fmt.Println("log")
  28789. fmt.Println(string(userJSONBytes))
  28790. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28791. utils.ErrorLog("解析失败:%v", err)
  28792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28793. return
  28794. }
  28795. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28796. bytesData, _ := json.Marshal(data)
  28797. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28798. resp, _ := client.Do(req)
  28799. defer resp.Body.Close()
  28800. body, ioErr := ioutil.ReadAll(resp.Body)
  28801. if ioErr != nil {
  28802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28804. return
  28805. }
  28806. var respJSON map[string]interface{}
  28807. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28810. return
  28811. }
  28812. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28813. userJSONBytes, _ := json.Marshal(respJSON)
  28814. fmt.Println("log")
  28815. fmt.Println(string(userJSONBytes))
  28816. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28817. utils.ErrorLog("解析失败:%v", err)
  28818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28819. return
  28820. }
  28821. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28822. bytesData, _ := json.Marshal(data)
  28823. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28824. resp, _ := client.Do(req)
  28825. defer resp.Body.Close()
  28826. body, ioErr := ioutil.ReadAll(resp.Body)
  28827. if ioErr != nil {
  28828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28830. return
  28831. }
  28832. var respJSON map[string]interface{}
  28833. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28836. return
  28837. }
  28838. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28839. userJSONBytes, _ := json.Marshal(respJSON)
  28840. fmt.Println("log")
  28841. fmt.Println(string(userJSONBytes))
  28842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28843. utils.ErrorLog("解析失败:%v", err)
  28844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28845. return
  28846. }
  28847. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28848. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  28849. if result3101.Infcode == "0" {
  28850. if len(result3101.Output.Result) > 0 {
  28851. var errMsgs []string
  28852. for _, item := range result3101.Output.Result {
  28853. errMsgs = append(errMsgs, item.VolaCont)
  28854. }
  28855. c.ServeSuccessJSON(map[string]interface{}{
  28856. "failed_code": -10,
  28857. "msg": errMsgs,
  28858. })
  28859. return
  28860. } else {
  28861. if miConfig.MdtrtareaAdmvs == "320921" {
  28862. data["doctor_id"] = "D320923012139"
  28863. } else {
  28864. data["doctor_id"] = "D371621008686"
  28865. }
  28866. bytesData, _ := json.Marshal(data)
  28867. var req *http.Request
  28868. if miConfig.MdtrtareaAdmvs == "320921" {
  28869. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28870. } else {
  28871. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28872. }
  28873. resp, _ := client.Do(req)
  28874. defer resp.Body.Close()
  28875. body, ioErr := ioutil.ReadAll(resp.Body)
  28876. if ioErr != nil {
  28877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28879. return
  28880. }
  28881. var respJSON map[string]interface{}
  28882. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28885. return
  28886. }
  28887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28888. userJSONBytes, _ := json.Marshal(respJSON)
  28889. fmt.Println("log")
  28890. fmt.Println(string(userJSONBytes))
  28891. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  28892. utils.ErrorLog("解析失败:%v", err)
  28893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28894. return
  28895. }
  28896. res.InfRefmsgid = resFour10265.InfRefmsgid
  28897. res.Output = resFour10265.Output
  28898. res.ErrMsg = resFour10265.ErrMsg
  28899. res.Cainfo = resFour10265.Cainfo
  28900. res.WarnMsg = resFour10265.WarnMsg
  28901. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  28902. res.Infcode = infocode
  28903. }
  28904. }
  28905. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28906. var pagesize int = 5
  28907. var start int = 1
  28908. var stop int
  28909. var pagecount int
  28910. var curpage int
  28911. data["doctor_id"] = doctor_info.DoctorNumber
  28912. var res2 ResultFour
  28913. //var result res.
  28914. //总页数,向上取整,注意除之前要先转换类型为float64
  28915. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  28916. for curpage = 1; curpage <= pagecount; curpage++ {
  28917. if curpage == 1 {
  28918. start = 1
  28919. } else {
  28920. start = (curpage-1)*pagesize + 1
  28921. }
  28922. stop = curpage * pagesize
  28923. if stop > len(prescriptions) {
  28924. stop = len(prescriptions)
  28925. }
  28926. //var requestLog string
  28927. data["pre"] = prescriptions[start-1 : stop]
  28928. fmt.Println(data["pre"])
  28929. bytesData, _ := json.Marshal(data)
  28930. var req *http.Request
  28931. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  28932. resp, _ := client.Do(req)
  28933. defer resp.Body.Close()
  28934. body, ioErr := ioutil.ReadAll(resp.Body)
  28935. if ioErr != nil {
  28936. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28938. return
  28939. }
  28940. var respJSON map[string]interface{}
  28941. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28942. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28944. return
  28945. }
  28946. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28947. userJSONBytes, _ := json.Marshal(respJSON)
  28948. fmt.Println("log")
  28949. fmt.Println(string(userJSONBytes))
  28950. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  28951. utils.ErrorLog("解析失败:%v", err)
  28952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28953. return
  28954. }
  28955. res.InfRefmsgid = resFour10265.InfRefmsgid
  28956. res.Output = resFour10265.Output
  28957. res.ErrMsg = resFour10265.ErrMsg
  28958. res.Cainfo = resFour10265.Cainfo
  28959. res.WarnMsg = resFour10265.WarnMsg
  28960. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  28961. res.Infcode = infocode
  28962. if infocode == 0 {
  28963. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  28964. } else {
  28965. isSuccess = false
  28966. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  28967. res.Infcode = -1
  28968. res.ErrMsg = resFour10265.ErrMsg
  28969. errlog := &models.HisOrderError{
  28970. UserOrgId: adminUser.CurrentOrgId,
  28971. Ctime: time.Now().Unix(),
  28972. Mtime: time.Now().Unix(),
  28973. Number: chrg_bchno,
  28974. ErrMsg: "",
  28975. Status: 1,
  28976. PatientId: id,
  28977. RecordTime: recordDateTime,
  28978. Stage: 4,
  28979. }
  28980. service.CreateErrMsgLog(errlog)
  28981. }
  28982. }
  28983. if isSuccess {
  28984. res.Infcode = 0
  28985. res.Output.Result = res2.Output.Result
  28986. } else {
  28987. order := &models.HisOrder{
  28988. UserOrgId: adminUser.CurrentOrgId,
  28989. HisPatientId: his.ID,
  28990. PatientId: his.PatientId,
  28991. SettleAccountsDate: recordDateTime,
  28992. Ctime: time.Now().Unix(),
  28993. Mtime: time.Now().Unix(),
  28994. MdtrtId: his.Number,
  28995. PsnNo: his.PsnNo,
  28996. MedType: strconv.FormatInt(reg_type, 10),
  28997. Status: 1,
  28998. Number: chrg_bchno,
  28999. Infcode: res.Infcode,
  29000. WarnMsg: res.WarnMsg,
  29001. Cainfo: res.Cainfo,
  29002. ErrMsg: res.ErrMsg,
  29003. RespondTime: res.RefmsgTime,
  29004. InfRefmsgid: res.InfRefmsgid,
  29005. OrderStatus: 1,
  29006. IsMedicineInsurance: 1,
  29007. SettleType: settle_accounts_type,
  29008. SettleStartTime: start_time,
  29009. SettleEndTime: end_time,
  29010. Creator: roles.AdminUserId,
  29011. Modify: roles.AdminUserId,
  29012. PType: 2,
  29013. Diagnosis: diagnosis_id,
  29014. }
  29015. err = service.CreateOrder(order)
  29016. if err != nil {
  29017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29018. return
  29019. }
  29020. c.ServeSuccessJSON(map[string]interface{}{
  29021. "failed_code": -10,
  29022. "msg": res2.ErrMsg,
  29023. })
  29024. return
  29025. }
  29026. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29027. 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)
  29028. var dat map[string]interface{}
  29029. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29030. fmt.Println(dat)
  29031. } else {
  29032. fmt.Println(err)
  29033. }
  29034. saveLog(result, request_log, "2204", "上传费用明细")
  29035. userJSONBytes, _ := json.Marshal(dat)
  29036. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29037. utils.ErrorLog("解析失败:%v", err)
  29038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29039. return
  29040. }
  29041. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29042. 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, "", "")
  29043. var dat map[string]interface{}
  29044. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29045. fmt.Println(dat)
  29046. } else {
  29047. fmt.Println(err)
  29048. }
  29049. saveLog(result, request_log, "2204", "上传费用明细")
  29050. userJSONBytes, _ := json.Marshal(dat)
  29051. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29052. utils.ErrorLog("解析失败:%v", err)
  29053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29054. return
  29055. }
  29056. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29057. 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, "", "")
  29058. var dat map[string]interface{}
  29059. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29060. fmt.Println(dat)
  29061. } else {
  29062. fmt.Println(err)
  29063. }
  29064. saveLog(result, request_log, "2204", "上传费用明细")
  29065. userJSONBytes, _ := json.Marshal(dat)
  29066. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29067. utils.ErrorLog("解析失败:%v", err)
  29068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29069. return
  29070. }
  29071. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29072. bytesData, _ := json.Marshal(data)
  29073. var req *http.Request
  29074. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29075. resp, _ := client.Do(req)
  29076. defer resp.Body.Close()
  29077. body, ioErr := ioutil.ReadAll(resp.Body)
  29078. if ioErr != nil {
  29079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29081. return
  29082. }
  29083. var respJSON map[string]interface{}
  29084. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29087. return
  29088. }
  29089. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29090. if status == "0" {
  29091. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29092. c.ServeSuccessJSON(map[string]interface{}{
  29093. "failed_code": -10,
  29094. "msg": err_msg,
  29095. })
  29096. return
  29097. }
  29098. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29099. userJSONBytes, _ := json.Marshal(respJSON)
  29100. fmt.Println("log")
  29101. fmt.Println(string(userJSONBytes))
  29102. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29103. utils.ErrorLog("解析失败:%v", err)
  29104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29105. return
  29106. }
  29107. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29108. bytesData, _ := json.Marshal(data)
  29109. var req *http.Request
  29110. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29111. resp, _ := client.Do(req)
  29112. defer resp.Body.Close()
  29113. body, ioErr := ioutil.ReadAll(resp.Body)
  29114. if ioErr != nil {
  29115. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29117. return
  29118. }
  29119. var respJSON map[string]interface{}
  29120. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29121. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29123. return
  29124. }
  29125. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29126. if status == "0" {
  29127. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29128. c.ServeSuccessJSON(map[string]interface{}{
  29129. "failed_code": -10,
  29130. "msg": err_msg,
  29131. })
  29132. return
  29133. }
  29134. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29135. userJSONBytes, _ := json.Marshal(respJSON)
  29136. fmt.Println("log")
  29137. fmt.Println(string(userJSONBytes))
  29138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29139. utils.ErrorLog("解析失败:%v", err)
  29140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29141. return
  29142. }
  29143. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29144. 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, "", "")
  29145. var dat map[string]interface{}
  29146. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29147. fmt.Println(dat)
  29148. } else {
  29149. fmt.Println(err)
  29150. }
  29151. saveLog(result, request_log, "2204", "上传费用明细")
  29152. userJSONBytes, _ := json.Marshal(dat)
  29153. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29154. utils.ErrorLog("解析失败:%v", err)
  29155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29156. return
  29157. }
  29158. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29159. bytesData, _ := json.Marshal(data)
  29160. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  29161. resp, _ := client.Do(req)
  29162. defer resp.Body.Close()
  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(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. userJSONBytes, _ := json.Marshal(respJSON)
  29177. fmt.Println("log")
  29178. fmt.Println(string(userJSONBytes))
  29179. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29180. utils.ErrorLog("解析失败:%v", err)
  29181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29182. return
  29183. }
  29184. } else {
  29185. if miConfig.MdtrtareaAdmvs == "441202" {
  29186. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29187. if result3101.Infcode == 0 {
  29188. if len(result3101.Output.Result) > 0 {
  29189. var errMsgs []string
  29190. for _, item := range result3101.Output.Result {
  29191. errMsgs = append(errMsgs, item.VolaCont)
  29192. }
  29193. c.ServeSuccessJSON(map[string]interface{}{
  29194. "failed_code": -10,
  29195. "msg": errMsgs,
  29196. })
  29197. return
  29198. } else {
  29199. 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)
  29200. var dat map[string]interface{}
  29201. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29202. fmt.Println(dat)
  29203. } else {
  29204. fmt.Println(err)
  29205. }
  29206. saveLog(result, request_log, "2204", "上传费用明细")
  29207. userJSONBytes, _ := json.Marshal(dat)
  29208. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29209. utils.ErrorLog("解析失败:%v", err)
  29210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29211. return
  29212. }
  29213. }
  29214. } else {
  29215. c.ServeSuccessJSON(map[string]interface{}{
  29216. "failed_code": -10,
  29217. "msg": result3101.ErrMsg,
  29218. })
  29219. return
  29220. }
  29221. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29222. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29223. if result3101.Infcode == 0 {
  29224. if len(result3101.Output.Result) > 0 {
  29225. var errMsgs []string
  29226. for _, item := range result3101.Output.Result {
  29227. errMsgs = append(errMsgs, item.VolaCont)
  29228. }
  29229. c.ServeSuccessJSON(map[string]interface{}{
  29230. "failed_code": -10,
  29231. "msg": errMsgs,
  29232. })
  29233. return
  29234. } else {
  29235. 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)
  29236. var dat map[string]interface{}
  29237. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29238. fmt.Println(dat)
  29239. } else {
  29240. fmt.Println(err)
  29241. }
  29242. saveLog(result, request_log, "2204", "上传费用明细")
  29243. userJSONBytes, _ := json.Marshal(dat)
  29244. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29245. utils.ErrorLog("解析失败:%v", err)
  29246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29247. return
  29248. }
  29249. }
  29250. } else {
  29251. c.ServeSuccessJSON(map[string]interface{}{
  29252. "failed_code": -10,
  29253. "msg": result3101.ErrMsg,
  29254. })
  29255. return
  29256. }
  29257. } else {
  29258. if miConfig.Code == "H15049901371" {
  29259. 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)
  29260. var dat map[string]interface{}
  29261. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29262. fmt.Println(dat)
  29263. } else {
  29264. fmt.Println(err)
  29265. }
  29266. saveLog(result, request_log, "2204", "上传费用明细")
  29267. userJSONBytes, _ := json.Marshal(dat)
  29268. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29269. utils.ErrorLog("解析失败:%v", err)
  29270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29271. return
  29272. }
  29273. res.InfRefmsgid = resFour10265.InfRefmsgid
  29274. res.Output = resFour10265.Output
  29275. res.ErrMsg = resFour10265.ErrMsg
  29276. res.Cainfo = resFour10265.Cainfo
  29277. res.WarnMsg = resFour10265.WarnMsg
  29278. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29279. res.Infcode = infocode
  29280. } else {
  29281. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" {
  29282. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29283. if result3101.Infcode == 0 {
  29284. if len(result3101.Output.Result) > 0 {
  29285. var errMsgs []string
  29286. for _, item := range result3101.Output.Result {
  29287. errMsgs = append(errMsgs, item.VolaCont)
  29288. }
  29289. c.ServeSuccessJSON(map[string]interface{}{
  29290. "failed_code": -10,
  29291. "msg": errMsgs,
  29292. })
  29293. return
  29294. } else {
  29295. 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)
  29296. var dat map[string]interface{}
  29297. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29298. fmt.Println(dat)
  29299. } else {
  29300. fmt.Println(err)
  29301. }
  29302. saveLog(result, request_log, "2204", "上传费用明细")
  29303. userJSONBytes, _ := json.Marshal(dat)
  29304. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29305. utils.ErrorLog("解析失败:%v", err)
  29306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29307. return
  29308. }
  29309. }
  29310. } else {
  29311. c.ServeSuccessJSON(map[string]interface{}{
  29312. "failed_code": -10,
  29313. "msg": result3101.ErrMsg,
  29314. })
  29315. return
  29316. }
  29317. } else {
  29318. 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)
  29319. var dat map[string]interface{}
  29320. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29321. fmt.Println(dat)
  29322. } else {
  29323. fmt.Println(err)
  29324. }
  29325. saveLog(result, request_log, "2204", "上传费用明细")
  29326. userJSONBytes, _ := json.Marshal(dat)
  29327. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29328. utils.ErrorLog("解析失败:%v", err)
  29329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29330. return
  29331. }
  29332. }
  29333. }
  29334. }
  29335. }
  29336. var total_two float64
  29337. if res.Infcode == -1 {
  29338. errlog := &models.HisOrderError{
  29339. UserOrgId: adminUser.CurrentOrgId,
  29340. Ctime: time.Now().Unix(),
  29341. Mtime: time.Now().Unix(),
  29342. Number: chrg_bchno,
  29343. ErrMsg: res.ErrMsg,
  29344. Status: 1,
  29345. PatientId: id,
  29346. RecordTime: recordDateTime,
  29347. Stage: 4,
  29348. }
  29349. service.CreateErrMsgLog(errlog)
  29350. c.ServeSuccessJSON(map[string]interface{}{
  29351. "failed_code": -10,
  29352. "msg": res.ErrMsg,
  29353. })
  29354. return
  29355. }
  29356. if res.Infcode == 0 {
  29357. order := &models.HisOrder{
  29358. UserOrgId: adminUser.CurrentOrgId,
  29359. HisPatientId: his.ID,
  29360. PatientId: his.PatientId,
  29361. SettleAccountsDate: recordDateTime,
  29362. Ctime: time.Now().Unix(),
  29363. Mtime: time.Now().Unix(),
  29364. MdtrtId: his.Number,
  29365. PsnNo: his.PsnNo,
  29366. MedType: strconv.FormatInt(reg_type, 10),
  29367. Status: 1,
  29368. Number: chrg_bchno,
  29369. Infcode: res.Infcode,
  29370. WarnMsg: res.WarnMsg,
  29371. Cainfo: res.Cainfo,
  29372. ErrMsg: res.ErrMsg,
  29373. RespondTime: res.RefmsgTime,
  29374. InfRefmsgid: res.InfRefmsgid,
  29375. OrderStatus: 1,
  29376. IsMedicineInsurance: 1,
  29377. SettleType: settle_accounts_type,
  29378. SettleStartTime: start_time,
  29379. SettleEndTime: end_time,
  29380. Creator: roles.AdminUserId,
  29381. Modify: roles.AdminUserId,
  29382. PType: 2,
  29383. Diagnosis: diagnosis_id,
  29384. }
  29385. err = service.CreateOrder(order)
  29386. if err != nil {
  29387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29388. return
  29389. }
  29390. for _, item := range res.Output.Result {
  29391. temp := strings.Split(item.FeedetlSn, "-")
  29392. var advice_id int64 = 0
  29393. var project_id int64 = 0
  29394. var types int64 = 0
  29395. id, _ := strconv.ParseInt(temp[2], 10, 64)
  29396. types, _ = strconv.ParseInt(temp[1], 10, 64)
  29397. if temp[1] == "1" {
  29398. advice_id = id
  29399. project_id = 0
  29400. } else if temp[1] == "2" {
  29401. advice_id = 0
  29402. project_id = id
  29403. }
  29404. total_two = total_two + item.DetItemFeeSumamt
  29405. info := &models.HisOrderInfo{
  29406. OrderNumber: order.Number,
  29407. FeedetlSn: item.FeedetlSn,
  29408. UploadDate: time.Now().Unix(),
  29409. AdviceId: advice_id,
  29410. DetItemFeeSumamt: item.DetItemFeeSumamt,
  29411. Cnt: item.Cnt,
  29412. Pric: float64(item.Pric),
  29413. PatientId: his.PatientId,
  29414. PricUplmtAmt: item.PricUplmtAmt,
  29415. SelfpayProp: item.SelfpayProp,
  29416. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  29417. OverlmtAmt: item.OverlmtAmt,
  29418. PreselfpayAmt: item.PreselfpayAmt,
  29419. BasMednFlag: item.BasMednFlag,
  29420. MedChrgitmType: item.MedChrgitmType,
  29421. HiNegoDrugFlag: item.HiNegoDrugFlag,
  29422. Status: 1,
  29423. Memo: item.Memo,
  29424. Mtime: time.Now().Unix(),
  29425. InscpScpAmt: item.InscpScpAmt,
  29426. DrtReimFlag: item.DrtReimFlag,
  29427. Ctime: time.Now().Unix(),
  29428. ListSpItemFlag: item.ListSpItemFlag,
  29429. ChldMedcFlag: item.ChldMedcFlag,
  29430. LmtUsedFlag: item.LmtUsedFlag,
  29431. ChrgitmLv: item.ChrgitmLv,
  29432. UserOrgId: adminUser.CurrentOrgId,
  29433. HisPatientId: his.ID,
  29434. OrderId: order.ID,
  29435. ProjectId: project_id,
  29436. Type: types,
  29437. }
  29438. service.CreateOrderInfo(info)
  29439. }
  29440. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  29441. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  29442. var total float64
  29443. for _, item := range prescriptions {
  29444. if item.Type == 1 { //药品
  29445. for _, subItem := range item.HisDoctorAdviceInfo {
  29446. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29447. total_one := price * subItem.PrescribingNumber
  29448. fmt.Println("subItem")
  29449. fmt.Println(subItem.Price)
  29450. fmt.Println("price")
  29451. fmt.Println(price)
  29452. fmt.Println("total_one")
  29453. fmt.Println(total_one)
  29454. total = total + total_one
  29455. fmt.Println(total)
  29456. }
  29457. }
  29458. if item.Type == 2 { //项目
  29459. for _, subItem := range item.HisPrescriptionProject {
  29460. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  29461. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29462. total_one := price * cnt
  29463. total = total + total_one
  29464. }
  29465. }
  29466. }
  29467. allTotal := fmt.Sprintf("%.2f", total)
  29468. if res.Infcode == 0 {
  29469. var rf []*ResultFive
  29470. json.Unmarshal([]byte(his.Iinfo), &rf)
  29471. chrg_bchno := chrg_bchno
  29472. cert_no := his.Certno
  29473. var insutypes []string
  29474. var insutype string
  29475. var is390 int = 0
  29476. var is310 int = 0
  29477. for _, item := range rf {
  29478. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29479. insutypes = append(insutypes, item.Insutype)
  29480. }
  29481. }
  29482. if len(insutypes) == 1 {
  29483. insutype = insutypes[0]
  29484. } else {
  29485. for _, i := range insutypes {
  29486. if i == "390" {
  29487. is390 = 1
  29488. }
  29489. if i == "310" {
  29490. is310 = 1
  29491. }
  29492. }
  29493. }
  29494. if is390 == 1 {
  29495. insutype = "390"
  29496. }
  29497. if is310 == 1 {
  29498. insutype = "310"
  29499. }
  29500. if len(insutypes) == 0 {
  29501. insutype = "390"
  29502. }
  29503. if len(insutypes) == 2 {
  29504. insutype = strconv.FormatInt(his.SocialType, 10)
  29505. }
  29506. //insutype = "390"
  29507. if his.IdCardType == 1 {
  29508. cert_no = his.MedicalInsuranceNumber
  29509. } else {
  29510. cert_no = his.Certno
  29511. }
  29512. var res ResultSeven
  29513. var ahres ResultSevenAH
  29514. var resSeven10265 ResultSeven10265
  29515. var resSeven10265Two ResultSeven10265Two
  29516. var gzresSeven10265Two GZResultSeven10265Two
  29517. if miConfig.MdtrtareaAdmvs == "421300" {
  29518. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  29519. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29520. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29521. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29522. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29523. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29524. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29525. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29526. resp, requestErr := http.Get(api)
  29527. if requestErr != nil {
  29528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29529. return
  29530. }
  29531. body, ioErr := ioutil.ReadAll(resp.Body)
  29532. if ioErr != nil {
  29533. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29535. return
  29536. }
  29537. var respJSON map[string]interface{}
  29538. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29541. return
  29542. }
  29543. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29544. result, _ := json.Marshal(respJSON)
  29545. fmt.Println("log")
  29546. fmt.Println(string(result))
  29547. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29548. utils.ErrorLog("解析失败:%v", err)
  29549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29550. return
  29551. }
  29552. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29553. if reg_type == 11 && his.Insutype == "390" {
  29554. reg_type = 110104
  29555. }
  29556. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29557. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29558. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29559. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29560. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29561. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29562. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29563. resp, requestErr := http.Get(api)
  29564. if requestErr != nil {
  29565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29566. return
  29567. }
  29568. body, ioErr := ioutil.ReadAll(resp.Body)
  29569. if ioErr != nil {
  29570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29572. return
  29573. }
  29574. var respJSON map[string]interface{}
  29575. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29578. return
  29579. }
  29580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29581. result, _ := json.Marshal(respJSON)
  29582. fmt.Println("log")
  29583. fmt.Println(string(result))
  29584. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29585. utils.ErrorLog("解析失败:%v", err)
  29586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29587. return
  29588. }
  29589. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29590. if reg_type == 11 && his.Insutype == "390" {
  29591. reg_type = 110104
  29592. }
  29593. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29594. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29595. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29596. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29597. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29598. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29599. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29600. resp, requestErr := http.Get(api)
  29601. if requestErr != nil {
  29602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29603. return
  29604. }
  29605. body, ioErr := ioutil.ReadAll(resp.Body)
  29606. if ioErr != nil {
  29607. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29609. return
  29610. }
  29611. var respJSON map[string]interface{}
  29612. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29613. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29615. return
  29616. }
  29617. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29618. result, _ := json.Marshal(respJSON)
  29619. fmt.Println("log")
  29620. fmt.Println(string(result))
  29621. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29622. utils.ErrorLog("解析失败:%v", err)
  29623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29624. return
  29625. }
  29626. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29627. if reg_type == 11 && his.Insutype == "390" {
  29628. reg_type = 110104
  29629. }
  29630. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29631. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29632. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29633. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29634. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29635. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29636. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29637. resp, requestErr := http.Get(api)
  29638. if requestErr != nil {
  29639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29640. return
  29641. }
  29642. body, ioErr := ioutil.ReadAll(resp.Body)
  29643. if ioErr != nil {
  29644. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29646. return
  29647. }
  29648. var respJSON map[string]interface{}
  29649. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29652. return
  29653. }
  29654. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29655. result, _ := json.Marshal(respJSON)
  29656. fmt.Println("log")
  29657. fmt.Println(string(result))
  29658. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29659. utils.ErrorLog("解析失败:%v", err)
  29660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29661. return
  29662. }
  29663. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29664. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29665. if result3101.Infcode == "0" {
  29666. if len(result3101.Output.Result) > 0 {
  29667. var errMsgs []string
  29668. for _, item := range result3101.Output.Result {
  29669. errMsgs = append(errMsgs, item.VolaCont)
  29670. }
  29671. c.ServeSuccessJSON(map[string]interface{}{
  29672. "failed_code": -10,
  29673. "msg": errMsgs,
  29674. })
  29675. return
  29676. } else {
  29677. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29678. if his.IdCardType != 4 {
  29679. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29680. bas := strings.Split(psn_info.CardInfo, "|")
  29681. if his.IdCardType == 1 {
  29682. cert_no = bas[2]
  29683. } else {
  29684. cert_no = bas[1]
  29685. }
  29686. } else {
  29687. cert_no = his.Certno
  29688. }
  29689. //江苏地区国家医保医疗类别
  29690. //职工透析:医疗类别选特殊情况门诊9933
  29691. //居民血透门慢: 医疗类别选门诊慢病1402
  29692. //var med_type string
  29693. //if his.Insutype == "310" {
  29694. // if reg_type == 14 {
  29695. // med_type = "9933"
  29696. // } else if reg_type == 11 {
  29697. // med_type = "11"
  29698. //
  29699. // }
  29700. //} else if his.Insutype == "390" {
  29701. // if reg_type == 14 {
  29702. // med_type = "1402"
  29703. // } else if reg_type == 11 {
  29704. // med_type = "11"
  29705. // }
  29706. //}
  29707. var api string
  29708. if miConfig.MdtrtareaAdmvs == "320921" {
  29709. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29710. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29711. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29712. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29713. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29714. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29715. "&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
  29716. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29717. } else {
  29718. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29719. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29720. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29721. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29722. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29723. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29724. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29725. "&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
  29726. }
  29727. resp, requestErr := http.Get(api)
  29728. if requestErr != nil {
  29729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29730. return
  29731. }
  29732. body, ioErr := ioutil.ReadAll(resp.Body)
  29733. if ioErr != nil {
  29734. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29736. return
  29737. }
  29738. var respJSON map[string]interface{}
  29739. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29742. return
  29743. }
  29744. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29745. result, _ := json.Marshal(respJSON)
  29746. fmt.Println("log")
  29747. fmt.Println(string(result))
  29748. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  29749. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29750. utils.ErrorLog("解析失败:%v", err)
  29751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29752. return
  29753. }
  29754. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29755. res.Output = resSeven10265.Output
  29756. res.ErrMsg = resSeven10265.ErrMsg
  29757. res.Cainfo = resSeven10265.Cainfo
  29758. res.WarnMsg = resSeven10265.WarnMsg
  29759. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29760. res.Infcode = infocode
  29761. } else {
  29762. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  29763. utils.ErrorLog("解析失败:%v", err)
  29764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29765. return
  29766. }
  29767. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  29768. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  29769. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  29770. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  29771. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29772. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  29773. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  29774. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  29775. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  29776. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  29777. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  29778. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29779. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  29780. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  29781. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29782. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29783. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  29784. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  29785. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  29786. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  29787. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  29788. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29789. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  29790. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  29791. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  29792. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  29793. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  29794. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  29795. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  29796. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  29797. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29798. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  29799. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  29800. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  29801. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29802. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29803. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29804. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29805. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  29806. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29807. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  29808. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  29809. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  29810. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  29811. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  29812. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  29813. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  29814. res.ErrMsg = resSeven10265Two.ErrMsg
  29815. res.Cainfo = resSeven10265Two.Cainfo
  29816. res.WarnMsg = resSeven10265Two.WarnMsg
  29817. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29818. res.Infcode = infocode
  29819. }
  29820. }
  29821. }
  29822. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29823. psn_info, _ := service.GetPsnByPatientId(id)
  29824. var verify_number string
  29825. if psn_info.IdCardType == 4 {
  29826. verify_number = psn_info.VerifyNumber
  29827. } else if psn_info.IdCardType == 1 {
  29828. bas := strings.Split(psn_info.CardInfo, "|")
  29829. cardNumber := bas[2]
  29830. verify_number = cardNumber
  29831. } else {
  29832. psn_info.IdCardType = 2
  29833. verify_number = psn_info.Certno
  29834. }
  29835. var api string
  29836. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29837. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  29838. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29839. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29840. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29841. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29842. "&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
  29843. resp, requestErr := http.Get(api)
  29844. if requestErr != nil {
  29845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29846. return
  29847. }
  29848. body, ioErr := ioutil.ReadAll(resp.Body)
  29849. if ioErr != nil {
  29850. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29852. return
  29853. }
  29854. var respJSON map[string]interface{}
  29855. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29856. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29858. return
  29859. }
  29860. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29861. result, _ := json.Marshal(respJSON)
  29862. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29863. utils.ErrorLog("解析失败:%v", err)
  29864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29865. return
  29866. }
  29867. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29868. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  29869. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  29870. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29871. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  29872. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  29873. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  29874. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  29875. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  29876. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  29877. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  29878. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  29879. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  29880. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29881. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  29882. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  29883. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  29884. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  29885. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  29886. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  29887. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29888. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  29889. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  29890. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  29891. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  29892. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  29893. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  29894. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  29895. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  29896. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  29897. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  29898. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  29899. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  29900. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  29901. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29902. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  29903. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  29904. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  29905. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  29906. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  29907. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  29908. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  29909. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  29910. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  29911. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  29912. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  29913. res.ErrMsg = resSeven10265.ErrMsg
  29914. res.Cainfo = resSeven10265.Cainfo
  29915. res.WarnMsg = resSeven10265.WarnMsg
  29916. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29917. res.Infcode = infocode
  29918. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29919. acct_used_flag := "1"
  29920. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  29921. var result string
  29922. var request_log string
  29923. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  29924. 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)
  29925. } else {
  29926. 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)
  29927. }
  29928. var dat map[string]interface{}
  29929. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29930. fmt.Println(dat)
  29931. } else {
  29932. fmt.Println(err)
  29933. }
  29934. saveLog(result, request_log, "2206", "预结算")
  29935. userJSONBytes, _ := json.Marshal(dat)
  29936. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29937. utils.ErrorLog("解析失败:%v", err)
  29938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29939. return
  29940. }
  29941. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29942. var result string
  29943. var request_log string
  29944. if his.IdCardType == 2 {
  29945. 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, "")
  29946. } else if his.IdCardType == 1 {
  29947. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29948. bas := strings.Split(psn_info.CardInfo, "|")
  29949. basNumber := bas[2]
  29950. card_sn := bas[3]
  29951. var rf []*ResultFive
  29952. json.Unmarshal([]byte(his.Iinfo), &rf)
  29953. var psn_type string
  29954. for _, item := range rf {
  29955. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29956. psn_type = item.PsnType
  29957. }
  29958. }
  29959. 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)
  29960. } else {
  29961. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29962. //bas := strings.Split(psn_info.CardInfo, "|")
  29963. //basNumber := bas[2]
  29964. //card_sn := bas[3]
  29965. var rf []*ResultFive
  29966. json.Unmarshal([]byte(his.Iinfo), &rf)
  29967. var psn_type string
  29968. for _, item := range rf {
  29969. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29970. psn_type = item.PsnType
  29971. }
  29972. }
  29973. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29974. 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)
  29975. }
  29976. var dat map[string]interface{}
  29977. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29978. fmt.Println(dat)
  29979. } else {
  29980. fmt.Println(err)
  29981. }
  29982. saveLog(result, request_log, "2206", "预结算")
  29983. userJSONBytes, _ := json.Marshal(dat)
  29984. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29985. utils.ErrorLog("解析失败:%v", err)
  29986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29987. return
  29988. }
  29989. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29990. var result string
  29991. var request_log string
  29992. if his.IdCardType == 2 {
  29993. result, request_log = service.Jxyb2206(his.PsnNo, his.Number, chrg_bchno, his.IdCardNo, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, his.IdCardNo, "")
  29994. } else if his.IdCardType == 1 {
  29995. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29996. bas := strings.Split(psn_info.CardInfo, "|")
  29997. basNumber := bas[0]
  29998. card_sn := ""
  29999. var rf []*ResultFive
  30000. json.Unmarshal([]byte(his.Iinfo), &rf)
  30001. var psn_type string
  30002. for _, item := range rf {
  30003. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30004. psn_type = item.PsnType
  30005. }
  30006. }
  30007. 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)
  30008. } else {
  30009. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30010. //bas := strings.Split(psn_info.CardInfo, "|")
  30011. //basNumber := bas[2]
  30012. //card_sn := bas[3]
  30013. var rf []*ResultFive
  30014. json.Unmarshal([]byte(his.Iinfo), &rf)
  30015. var psn_type string
  30016. for _, item := range rf {
  30017. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30018. psn_type = item.PsnType
  30019. }
  30020. }
  30021. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30022. 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)
  30023. }
  30024. var dat map[string]interface{}
  30025. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30026. fmt.Println(dat)
  30027. } else {
  30028. fmt.Println(err)
  30029. }
  30030. saveLog(result, request_log, "2206", "预结算")
  30031. userJSONBytes, _ := json.Marshal(dat)
  30032. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30033. utils.ErrorLog("解析失败:%v", err)
  30034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30035. return
  30036. }
  30037. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30038. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30039. if his.IdCardType == 4 {
  30040. psn_info.VerifyNumber = psn_info.VerifyNumber
  30041. cert_no = psn_info.VerifyNumber
  30042. } else if his.IdCardType == 2 {
  30043. cert_no = psn_info.Certno
  30044. psn_info.VerifyNumber = psn_info.Certno
  30045. } else {
  30046. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30047. bas := strings.Split(psn_info.CardInfo, "|")
  30048. if his.IdCardType == 1 {
  30049. cert_no = bas[2]
  30050. } else {
  30051. cert_no = bas[1]
  30052. }
  30053. }
  30054. var api string
  30055. var med_type string
  30056. if his.Insutype == "390" {
  30057. if reg_type == 992102 {
  30058. med_type = "992102"
  30059. }
  30060. if reg_type == 140104 {
  30061. med_type = "140104"
  30062. }
  30063. if reg_type == 140201 {
  30064. med_type = "140201"
  30065. }
  30066. if reg_type == 14 {
  30067. med_type = "140104"
  30068. }
  30069. } else if his.Insutype == "310" {
  30070. if reg_type == 992102 {
  30071. med_type = "992102"
  30072. }
  30073. if reg_type == 140104 {
  30074. med_type = "140104"
  30075. }
  30076. if reg_type == 140201 {
  30077. med_type = "140201"
  30078. }
  30079. if reg_type == 14 {
  30080. med_type = "140104"
  30081. }
  30082. }
  30083. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30084. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30085. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30086. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30087. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30088. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30089. "&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
  30090. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30091. resp, requestErr := http.Get(api)
  30092. if requestErr != nil {
  30093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30094. return
  30095. }
  30096. body, ioErr := ioutil.ReadAll(resp.Body)
  30097. if ioErr != nil {
  30098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30100. return
  30101. }
  30102. var respJSON map[string]interface{}
  30103. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30106. return
  30107. }
  30108. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30109. if status == "0" {
  30110. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30111. c.ServeSuccessJSON(map[string]interface{}{
  30112. "failed_code": -10,
  30113. "msg": err_msg,
  30114. })
  30115. return
  30116. }
  30117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30118. result, _ := json.Marshal(respJSON)
  30119. fmt.Println("log")
  30120. fmt.Println(string(result))
  30121. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30122. utils.ErrorLog("解析失败:%v", err)
  30123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30124. return
  30125. }
  30126. res.InfRefmsgid = ahres.InfRefmsgid
  30127. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30128. // 创建对应的Time类型
  30129. t := time.UnixMilli(timestamp)
  30130. // 格式化成指定的日期字符串
  30131. str := t.Format("2006-01-02 15:04:05")
  30132. res.Output.Setlinfo.SetlTime = str
  30133. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30134. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30135. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30136. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30137. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30138. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30139. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30140. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30141. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30142. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30143. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30144. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30145. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30146. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30147. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30148. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30149. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30150. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30151. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30152. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30153. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30154. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30155. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30156. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30157. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30158. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30159. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30160. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30161. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30162. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30163. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30164. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30165. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30166. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30167. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30168. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30169. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30170. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30171. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30172. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30173. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30174. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30175. //res.Output.Setldetail = ahres.Output.Setldetail
  30176. res.ErrMsg = ahres.ErrMsg
  30177. res.Cainfo = ahres.Cainfo
  30178. res.WarnMsg = ahres.WarnMsg
  30179. res.Infcode = ahres.Infcode
  30180. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30181. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30182. if his.IdCardType == 4 {
  30183. psn_info.VerifyNumber = psn_info.VerifyNumber
  30184. cert_no = psn_info.Certno
  30185. } else if his.IdCardType == 2 {
  30186. cert_no = psn_info.Certno
  30187. psn_info.VerifyNumber = psn_info.Certno
  30188. } else {
  30189. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30190. bas := strings.Split(psn_info.CardInfo, "|")
  30191. if his.IdCardType == 1 {
  30192. cert_no = bas[2]
  30193. } else {
  30194. cert_no = bas[1]
  30195. }
  30196. }
  30197. var api string
  30198. var med_type string
  30199. if his.Insutype == "390" {
  30200. if reg_type == 992102 {
  30201. med_type = "992102"
  30202. }
  30203. if reg_type == 140104 {
  30204. med_type = "140104"
  30205. }
  30206. if reg_type == 140201 {
  30207. med_type = "140201"
  30208. }
  30209. if reg_type == 14 {
  30210. med_type = "14"
  30211. }
  30212. } else if his.Insutype == "310" {
  30213. if reg_type == 992102 {
  30214. med_type = "992102"
  30215. }
  30216. if reg_type == 140104 {
  30217. med_type = "140104"
  30218. }
  30219. if reg_type == 140201 {
  30220. med_type = "140201"
  30221. }
  30222. if reg_type == 14 {
  30223. med_type = "14"
  30224. }
  30225. }
  30226. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30227. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30228. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30229. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30230. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30231. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30232. "&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
  30233. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30234. resp, requestErr := http.Get(api)
  30235. if requestErr != nil {
  30236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30237. return
  30238. }
  30239. body, ioErr := ioutil.ReadAll(resp.Body)
  30240. if ioErr != nil {
  30241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30243. return
  30244. }
  30245. var respJSON map[string]interface{}
  30246. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30249. return
  30250. }
  30251. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30252. if status == "0" {
  30253. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30254. c.ServeSuccessJSON(map[string]interface{}{
  30255. "failed_code": -10,
  30256. "msg": err_msg,
  30257. })
  30258. return
  30259. }
  30260. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30261. result, _ := json.Marshal(respJSON)
  30262. fmt.Println("log")
  30263. fmt.Println(string(result))
  30264. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30265. utils.ErrorLog("解析失败:%v", err)
  30266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30267. return
  30268. }
  30269. res.InfRefmsgid = ahres.InfRefmsgid
  30270. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30271. // 创建对应的Time类型
  30272. t := time.UnixMilli(timestamp)
  30273. // 格式化成指定的日期字符串
  30274. str := t.Format("2006-01-02 15:04:05")
  30275. res.Output.Setlinfo.SetlTime = str
  30276. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30277. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30278. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30279. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30280. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30281. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30282. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30283. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30284. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30285. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30286. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30287. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30288. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30289. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30290. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30291. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30292. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30293. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30294. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30295. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30296. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30297. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30298. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30299. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30300. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30301. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30302. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30303. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30304. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30305. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30306. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30307. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30308. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30309. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30310. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30311. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30312. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30313. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30314. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30315. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30316. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30317. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30318. //res.Output.Setldetail = ahres.Output.Setldetail
  30319. res.ErrMsg = ahres.ErrMsg
  30320. res.Cainfo = ahres.Cainfo
  30321. res.WarnMsg = ahres.WarnMsg
  30322. res.Infcode = ahres.Infcode
  30323. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30324. var result string
  30325. var request_log string
  30326. if his.IdCardType == 2 {
  30327. 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")
  30328. } else if his.IdCardType == 1 {
  30329. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30330. bas := strings.Split(psn_info.CardInfo, "|")
  30331. basNumber := bas[2]
  30332. card_sn := bas[3]
  30333. 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")
  30334. } else {
  30335. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30336. 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")
  30337. }
  30338. var dat map[string]interface{}
  30339. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30340. fmt.Println(dat)
  30341. } else {
  30342. fmt.Println(err)
  30343. }
  30344. saveLog(result, request_log, "2206", "预结算")
  30345. userJSONBytes, _ := json.Marshal(dat)
  30346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30347. utils.ErrorLog("解析失败:%v", err)
  30348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30349. return
  30350. }
  30351. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30352. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30353. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30354. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30355. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30356. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30357. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30358. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30359. resp, requestErr := http.Get(api)
  30360. if requestErr != nil {
  30361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30362. return
  30363. }
  30364. body, ioErr := ioutil.ReadAll(resp.Body)
  30365. if ioErr != nil {
  30366. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30368. return
  30369. }
  30370. var respJSON map[string]interface{}
  30371. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30374. return
  30375. }
  30376. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30377. result, _ := json.Marshal(respJSON)
  30378. fmt.Println("log")
  30379. fmt.Println(string(result))
  30380. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30381. utils.ErrorLog("解析失败:%v", err)
  30382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30383. return
  30384. }
  30385. } else {
  30386. if miConfig.MdtrtareaAdmvs == "441202" {
  30387. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30388. if result3101.Infcode == 0 {
  30389. if len(result3101.Output.Result) > 0 {
  30390. var errMsgs []string
  30391. for _, item := range result3101.Output.Result {
  30392. errMsgs = append(errMsgs, item.VolaCont)
  30393. }
  30394. c.ServeSuccessJSON(map[string]interface{}{
  30395. "failed_code": -10,
  30396. "msg": errMsgs,
  30397. })
  30398. return
  30399. } else {
  30400. var result string
  30401. var request_log string
  30402. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30403. allTotal = fmt.Sprintf("%.2f", total_two)
  30404. if his.IdCardType == 4 {
  30405. 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)
  30406. } else {
  30407. 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)
  30408. }
  30409. var dat map[string]interface{}
  30410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30411. fmt.Println(dat)
  30412. } else {
  30413. fmt.Println(err)
  30414. }
  30415. saveLog(result, request_log, "2206", "预结算")
  30416. //userJSONBytes, _ := json.Marshal(dat)
  30417. //
  30418. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30419. // utils.ErrorLog("解析失败:%v", err)
  30420. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30421. // return
  30422. //}
  30423. userJSONBytes, _ := json.Marshal(dat)
  30424. if miConfig.Code == "H15049901371" {
  30425. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30426. utils.ErrorLog("解析失败:%v", err)
  30427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30428. return
  30429. }
  30430. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30431. res.Output = resSeven10265.Output
  30432. res.ErrMsg = resSeven10265.ErrMsg
  30433. res.Cainfo = resSeven10265.Cainfo
  30434. res.WarnMsg = resSeven10265.WarnMsg
  30435. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30436. res.Infcode = infocode
  30437. } else {
  30438. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30439. utils.ErrorLog("解析失败:%v", err)
  30440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30441. return
  30442. }
  30443. }
  30444. }
  30445. } else {
  30446. c.ServeSuccessJSON(map[string]interface{}{
  30447. "failed_code": -10,
  30448. "msg": result3101.ErrMsg,
  30449. })
  30450. return
  30451. }
  30452. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30453. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30454. if result3101.Infcode == 0 {
  30455. if len(result3101.Output.Result) > 0 {
  30456. var errMsgs []string
  30457. for _, item := range result3101.Output.Result {
  30458. errMsgs = append(errMsgs, item.VolaCont)
  30459. }
  30460. c.ServeSuccessJSON(map[string]interface{}{
  30461. "failed_code": -10,
  30462. "msg": errMsgs,
  30463. })
  30464. return
  30465. } else {
  30466. var result string
  30467. var request_log string
  30468. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30469. allTotal = fmt.Sprintf("%.2f", total_two)
  30470. if his.IdCardType == 4 {
  30471. 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)
  30472. } else {
  30473. 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)
  30474. }
  30475. var dat map[string]interface{}
  30476. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30477. fmt.Println(dat)
  30478. } else {
  30479. fmt.Println(err)
  30480. }
  30481. saveLog(result, request_log, "2206", "预结算")
  30482. //userJSONBytes, _ := json.Marshal(dat)
  30483. //
  30484. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30485. // utils.ErrorLog("解析失败:%v", err)
  30486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30487. // return
  30488. //}
  30489. userJSONBytes, _ := json.Marshal(dat)
  30490. if miConfig.Code == "H15049901371" {
  30491. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30492. utils.ErrorLog("解析失败:%v", err)
  30493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30494. return
  30495. }
  30496. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30497. res.Output = resSeven10265.Output
  30498. res.ErrMsg = resSeven10265.ErrMsg
  30499. res.Cainfo = resSeven10265.Cainfo
  30500. res.WarnMsg = resSeven10265.WarnMsg
  30501. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30502. res.Infcode = infocode
  30503. } else {
  30504. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30505. utils.ErrorLog("解析失败:%v", err)
  30506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30507. return
  30508. }
  30509. }
  30510. }
  30511. } else {
  30512. c.ServeSuccessJSON(map[string]interface{}{
  30513. "failed_code": -10,
  30514. "msg": result3101.ErrMsg,
  30515. })
  30516. return
  30517. }
  30518. } else {
  30519. var result string
  30520. var request_log string
  30521. var dat map[string]interface{}
  30522. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30523. allTotal = fmt.Sprintf("%.2f", total_two)
  30524. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  30525. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30526. if result3101.Infcode == 0 {
  30527. if len(result3101.Output.Result) > 0 {
  30528. var errMsgs []string
  30529. for _, item := range result3101.Output.Result {
  30530. errMsgs = append(errMsgs, item.VolaCont)
  30531. }
  30532. c.ServeSuccessJSON(map[string]interface{}{
  30533. "failed_code": -10,
  30534. "msg": errMsgs,
  30535. })
  30536. return
  30537. } else {
  30538. var result string
  30539. var request_log string
  30540. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30541. allTotal = fmt.Sprintf("%.2f", total_two)
  30542. if his.IdCardType == 4 {
  30543. 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)
  30544. } else {
  30545. 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)
  30546. }
  30547. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30548. fmt.Println(dat)
  30549. } else {
  30550. fmt.Println(err)
  30551. }
  30552. saveLog(result, request_log, "2206", "预结算")
  30553. }
  30554. } else {
  30555. c.ServeSuccessJSON(map[string]interface{}{
  30556. "failed_code": -10,
  30557. "msg": result3101.ErrMsg,
  30558. })
  30559. return
  30560. }
  30561. } else {
  30562. if his.IdCardType == 4 {
  30563. 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)
  30564. } else {
  30565. 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)
  30566. }
  30567. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30568. fmt.Println(dat)
  30569. } else {
  30570. fmt.Println(err)
  30571. }
  30572. saveLog(result, request_log, "2206", "预结算")
  30573. }
  30574. //userJSONBytes, _ := json.Marshal(dat)
  30575. //
  30576. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30577. // utils.ErrorLog("解析失败:%v", err)
  30578. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30579. // return
  30580. //}
  30581. userJSONBytes, _ := json.Marshal(dat)
  30582. if miConfig.Code == "H15049901371" {
  30583. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30584. utils.ErrorLog("解析失败:%v", err)
  30585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30586. return
  30587. }
  30588. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30589. res.Output = resSeven10265.Output
  30590. res.ErrMsg = resSeven10265.ErrMsg
  30591. res.Cainfo = resSeven10265.Cainfo
  30592. res.WarnMsg = resSeven10265.WarnMsg
  30593. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30594. res.Infcode = infocode
  30595. } else {
  30596. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30597. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  30598. utils.ErrorLog("解析失败:%v", err)
  30599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30600. return
  30601. }
  30602. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  30603. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  30604. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  30605. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30606. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  30607. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  30608. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  30609. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30610. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  30611. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30612. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30613. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30614. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30615. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30616. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30617. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  30618. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  30619. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  30620. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  30621. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  30622. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30623. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  30624. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  30625. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  30626. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  30627. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  30628. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  30629. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  30630. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  30631. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30632. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  30633. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  30634. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  30635. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30636. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30637. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30638. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30639. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  30640. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30641. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  30642. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  30643. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  30644. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  30645. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  30646. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  30647. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  30648. res.ErrMsg = gzresSeven10265Two.ErrMsg
  30649. res.Cainfo = gzresSeven10265Two.Cainfo
  30650. res.WarnMsg = gzresSeven10265Two.WarnMsg
  30651. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30652. //res.Infcode = infocode
  30653. } else {
  30654. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30655. utils.ErrorLog("解析失败:%v", err)
  30656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30657. return
  30658. }
  30659. }
  30660. }
  30661. }
  30662. }
  30663. utils.ErrorLog("解析失败:%v", res.Infcode)
  30664. if res.Infcode == -1 {
  30665. errlog := &models.HisOrderError{
  30666. UserOrgId: adminUser.CurrentOrgId,
  30667. Ctime: time.Now().Unix(),
  30668. Mtime: time.Now().Unix(),
  30669. Number: chrg_bchno,
  30670. ErrMsg: res.ErrMsg,
  30671. Status: 1,
  30672. PatientId: id,
  30673. RecordTime: recordDateTime,
  30674. Stage: 20,
  30675. }
  30676. service.CreateErrMsgLog(errlog)
  30677. c.ServeSuccessJSON(map[string]interface{}{
  30678. "failed_code": -10,
  30679. "msg": res.ErrMsg,
  30680. })
  30681. return
  30682. }
  30683. if res.Infcode != 0 {
  30684. errlog := &models.HisOrderError{
  30685. UserOrgId: adminUser.CurrentOrgId,
  30686. Ctime: time.Now().Unix(),
  30687. Mtime: time.Now().Unix(),
  30688. Number: chrg_bchno,
  30689. ErrMsg: res.ErrMsg,
  30690. Status: 1,
  30691. PatientId: id,
  30692. RecordTime: recordDateTime,
  30693. Stage: 20,
  30694. }
  30695. service.CreateErrMsgLog(errlog)
  30696. c.ServeSuccessJSON(map[string]interface{}{
  30697. "failed_code": -10,
  30698. "msg": res.ErrMsg,
  30699. })
  30700. return
  30701. } else {
  30702. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  30703. order.OrderStatus = 1
  30704. order.IsPre = 1
  30705. order.Status = 1
  30706. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  30707. order.SetlId = res.Output.Setlinfo.SetlID
  30708. order.PsnNo = res.Output.Setlinfo.PsnNo
  30709. order.PsnName = res.Output.Setlinfo.PsnName
  30710. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  30711. order.Certno = res.Output.Setlinfo.Certno
  30712. order.Gend = res.Output.Setlinfo.Gend
  30713. order.Naty = res.Output.Setlinfo.Naty
  30714. order.Age = res.Output.Setlinfo.Age
  30715. order.Insutype = res.Output.Setlinfo.Insutype
  30716. order.PsnType = res.Output.Setlinfo.PsnType
  30717. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  30718. order.SetlTime = res.Output.Setlinfo.SetlTime
  30719. order.AcctUsedFlag = acct_used_flag
  30720. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  30721. if res.Output.Setlinfo.MedType == "140101" {
  30722. order.MedType = "14"
  30723. } else {
  30724. if res.Output.Setlinfo.MedType == "110104" {
  30725. order.MedType = "11"
  30726. } else {
  30727. order.MedType = res.Output.Setlinfo.MedType
  30728. }
  30729. }
  30730. if res.Output.Setlinfo.MedType == "992102" {
  30731. order.MedType = "992102"
  30732. }
  30733. if res.Output.Setlinfo.MedType == "140104" {
  30734. order.MedType = "140104"
  30735. }
  30736. if res.Output.Setlinfo.MedType == "140201" {
  30737. order.MedType = "140201"
  30738. }
  30739. if res.Output.Setlinfo.MedType == "14" {
  30740. order.MedType = "14"
  30741. }
  30742. if reg_type == 1112 {
  30743. order.MedType = "1112"
  30744. }
  30745. if reg_type == 1111 {
  30746. order.MedType = "1111"
  30747. }
  30748. order.ClrType = res.Output.Setlinfo.ClrType
  30749. if adminUser.CurrentOrgId == 10480 {
  30750. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  30751. order.ClrType = "11"
  30752. } else {
  30753. order.ClrType = "9903"
  30754. }
  30755. }
  30756. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  30757. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  30758. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  30759. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  30760. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  30761. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  30762. order.HifpPay = res.Output.Setlinfo.HifpPay
  30763. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  30764. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  30765. order.HifesPay = res.Output.Setlinfo.HifesPay
  30766. order.HifobPay = res.Output.Setlinfo.HifobPay
  30767. order.MafPay = res.Output.Setlinfo.MafPay
  30768. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  30769. order.OthPay = res.Output.Setlinfo.OthPay
  30770. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  30771. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  30772. order.AcctPay = res.Output.Setlinfo.AcctPay
  30773. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  30774. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  30775. order.Balc = res.Output.Setlinfo.Balc
  30776. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  30777. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  30778. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  30779. order.ClrWay = res.Output.Setlinfo.ClrWay
  30780. order.Creator = order.Creator
  30781. order.Modify = roles.AdminUserId
  30782. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  30783. //detailStr := string(setlDetail)
  30784. //order.SetlDetail = detailStr
  30785. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  30786. err = service.UpDateOrder(order)
  30787. if err == nil {
  30788. c.ServeSuccessJSON(map[string]interface{}{
  30789. "msg": "预结算成功",
  30790. })
  30791. } else {
  30792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  30793. return
  30794. }
  30795. }
  30796. } else {
  30797. adminUser := c.GetAdminUserInfo()
  30798. errlog := &models.HisOrderError{
  30799. UserOrgId: adminUser.CurrentOrgId,
  30800. Ctime: time.Now().Unix(),
  30801. Mtime: time.Now().Unix(),
  30802. ErrMsg: res.ErrMsg,
  30803. Status: 1,
  30804. PatientId: id,
  30805. RecordTime: recordDateTime,
  30806. Stage: 4,
  30807. }
  30808. service.CreateErrMsgLog(errlog)
  30809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  30810. return
  30811. }
  30812. } else {
  30813. if miConfig.MdtrtareaAdmvs == "150499" {
  30814. order := &models.HisOrder{
  30815. UserOrgId: adminUser.CurrentOrgId,
  30816. HisPatientId: his.ID,
  30817. PatientId: his.PatientId,
  30818. SettleAccountsDate: recordDateTime,
  30819. Ctime: time.Now().Unix(),
  30820. Mtime: time.Now().Unix(),
  30821. MdtrtId: his.Number,
  30822. PsnNo: his.PsnNo,
  30823. MedType: strconv.FormatInt(reg_type, 10),
  30824. Status: 1,
  30825. Number: chrg_bchno,
  30826. Infcode: res.Infcode,
  30827. WarnMsg: res.WarnMsg,
  30828. Cainfo: res.Cainfo,
  30829. ErrMsg: res.ErrMsg,
  30830. RespondTime: res.RefmsgTime,
  30831. InfRefmsgid: res.InfRefmsgid,
  30832. OrderStatus: 1,
  30833. IsMedicineInsurance: 1,
  30834. SettleType: settle_accounts_type,
  30835. SettleStartTime: start_time,
  30836. SettleEndTime: end_time,
  30837. Creator: roles.AdminUserId,
  30838. Modify: roles.AdminUserId,
  30839. PType: 2,
  30840. Diagnosis: diagnosis_id,
  30841. }
  30842. err = service.CreateOrder(order)
  30843. if err != nil {
  30844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30845. return
  30846. }
  30847. }
  30848. adminUser := c.GetAdminUserInfo()
  30849. errlog := &models.HisOrderError{
  30850. UserOrgId: adminUser.CurrentOrgId,
  30851. Ctime: time.Now().Unix(),
  30852. Mtime: time.Now().Unix(),
  30853. ErrMsg: res.ErrMsg,
  30854. Status: 1,
  30855. PatientId: id,
  30856. RecordTime: recordDateTime,
  30857. Stage: 4,
  30858. }
  30859. service.CreateErrMsgLog(errlog)
  30860. c.ServeSuccessJSON(map[string]interface{}{
  30861. "failed_code": -10,
  30862. "msg": res.ErrMsg,
  30863. })
  30864. return
  30865. }
  30866. }
  30867. }
  30868. }
  30869. // 退款
  30870. func (c *HisApiController) Refund() {
  30871. order_id, _ := c.GetInt64("order_id")
  30872. admin_user_id, _ := c.GetInt64("admin_user_id")
  30873. adminUser := c.GetAdminUserInfo()
  30874. var order models.HisOrder
  30875. order, _ = service.GetHisOrderByID(order_id)
  30876. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  30877. if fapiao.ID > 0 {
  30878. c.ServeSuccessJSON(map[string]interface{}{
  30879. "failed_code": -10,
  30880. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  30881. })
  30882. return
  30883. }
  30884. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30885. if order.ID == 0 {
  30886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30887. return
  30888. }
  30889. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  30890. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30891. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30892. if config.IsOpen == 1 { //对接了医保,走医保流程
  30893. var res ResultSixteen
  30894. var ahres ResultSevenAH
  30895. var resSixteen10265 ResultSixteen10265
  30896. var resSixteen10265Two ResultSixteen10265Two
  30897. var gz ResultgzSixteen10265Two
  30898. var src_resquest string
  30899. var result string
  30900. if miConfig.MdtrtareaAdmvs == "421300" {
  30901. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  30902. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30903. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30904. resp3, requestErr3 := http.Get(api3)
  30905. if requestErr3 != nil {
  30906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30907. return
  30908. }
  30909. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30910. if ioErr3 != nil {
  30911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30913. return
  30914. }
  30915. var respJSON3 map[string]interface{}
  30916. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30919. return
  30920. }
  30921. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30922. userJSONBytes3, _ := json.Marshal(respJSON3)
  30923. fmt.Println("log")
  30924. fmt.Println(string(userJSONBytes3))
  30925. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30926. utils.ErrorLog("解析失败:%v", err)
  30927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30928. return
  30929. }
  30930. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30931. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  30932. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30933. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30934. resp3, requestErr3 := http.Get(api3)
  30935. if requestErr3 != nil {
  30936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30937. return
  30938. }
  30939. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30940. if ioErr3 != nil {
  30941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30943. return
  30944. }
  30945. var respJSON3 map[string]interface{}
  30946. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30949. return
  30950. }
  30951. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30952. userJSONBytes3, _ := json.Marshal(respJSON3)
  30953. fmt.Println("log")
  30954. fmt.Println(string(userJSONBytes3))
  30955. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30956. utils.ErrorLog("解析失败:%v", err)
  30957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30958. return
  30959. }
  30960. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30961. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  30962. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30963. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30964. resp3, requestErr3 := http.Get(api3)
  30965. if requestErr3 != nil {
  30966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30967. return
  30968. }
  30969. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30970. if ioErr3 != nil {
  30971. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30973. return
  30974. }
  30975. var respJSON3 map[string]interface{}
  30976. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30977. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30979. return
  30980. }
  30981. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30982. userJSONBytes3, _ := json.Marshal(respJSON3)
  30983. fmt.Println("log")
  30984. fmt.Println(string(userJSONBytes3))
  30985. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30986. utils.ErrorLog("解析失败:%v", err)
  30987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30988. return
  30989. }
  30990. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30991. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  30992. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30993. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30994. resp3, requestErr3 := http.Get(api3)
  30995. if requestErr3 != nil {
  30996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30997. return
  30998. }
  30999. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31000. if ioErr3 != nil {
  31001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31003. return
  31004. }
  31005. var respJSON3 map[string]interface{}
  31006. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31009. return
  31010. }
  31011. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31012. userJSONBytes3, _ := json.Marshal(respJSON3)
  31013. fmt.Println("log")
  31014. fmt.Println(string(userJSONBytes3))
  31015. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31016. utils.ErrorLog("解析失败:%v", err)
  31017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31018. return
  31019. }
  31020. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31021. var api3 string
  31022. if miConfig.MdtrtareaAdmvs == "320921" {
  31023. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31024. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31025. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31026. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31027. } else {
  31028. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31029. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31030. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31031. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31032. }
  31033. resp3, requestErr3 := http.Get(api3)
  31034. if requestErr3 != nil {
  31035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31036. return
  31037. }
  31038. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31039. if ioErr3 != nil {
  31040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31042. return
  31043. }
  31044. var respJSON3 map[string]interface{}
  31045. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31048. return
  31049. }
  31050. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31051. userJSONBytes3, _ := json.Marshal(respJSON3)
  31052. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31053. utils.ErrorLog("解析失败:%v", err)
  31054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31055. return
  31056. }
  31057. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31058. res.Output = resSixteen10265.Output
  31059. res.ErrMsg = resSixteen10265.ErrMsg
  31060. res.Cainfo = resSixteen10265.Cainfo
  31061. res.WarnMsg = resSixteen10265.WarnMsg
  31062. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31063. res.Infcode = infocode
  31064. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31065. var api3 string
  31066. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  31067. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31068. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31069. resp3, requestErr3 := http.Get(api3)
  31070. if requestErr3 != nil {
  31071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31072. return
  31073. }
  31074. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31075. if ioErr3 != nil {
  31076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31078. return
  31079. }
  31080. var respJSON3 map[string]interface{}
  31081. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31084. return
  31085. }
  31086. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31087. userJSONBytes3, _ := json.Marshal(respJSON3)
  31088. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31089. utils.ErrorLog("解析失败:%v", err)
  31090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31091. return
  31092. }
  31093. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31094. res.Output = resSixteen10265.Output
  31095. res.ErrMsg = resSixteen10265.ErrMsg
  31096. res.Cainfo = resSixteen10265.Cainfo
  31097. res.WarnMsg = resSixteen10265.WarnMsg
  31098. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31099. res.Infcode = infocode
  31100. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31101. 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)
  31102. var dat map[string]interface{}
  31103. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31104. fmt.Println(dat)
  31105. } else {
  31106. fmt.Println(err)
  31107. }
  31108. saveLog(result, src_resquest, "2208", "退费")
  31109. userJSONBytes, _ := json.Marshal(dat)
  31110. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31111. utils.ErrorLog("解析失败:%v", err)
  31112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31113. return
  31114. }
  31115. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31116. 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, "")
  31117. var dat map[string]interface{}
  31118. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31119. fmt.Println(dat)
  31120. } else {
  31121. fmt.Println(err)
  31122. }
  31123. saveLog(result, src_resquest, "2208", "退费")
  31124. userJSONBytes, _ := json.Marshal(dat)
  31125. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31126. utils.ErrorLog("解析失败:%v", err)
  31127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31128. return
  31129. }
  31130. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31131. 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, "")
  31132. var dat map[string]interface{}
  31133. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31134. fmt.Println(dat)
  31135. } else {
  31136. fmt.Println(err)
  31137. }
  31138. saveLog(result, src_resquest, "2208", "退费")
  31139. userJSONBytes, _ := json.Marshal(dat)
  31140. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31141. utils.ErrorLog("解析失败:%v", err)
  31142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31143. return
  31144. }
  31145. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31146. var api3 string
  31147. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31148. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31149. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31150. resp3, requestErr3 := http.Get(api3)
  31151. if requestErr3 != nil {
  31152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31153. return
  31154. }
  31155. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31156. if ioErr3 != nil {
  31157. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31159. return
  31160. }
  31161. var respJSON3 map[string]interface{}
  31162. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31163. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31165. return
  31166. }
  31167. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31168. if status == "0" {
  31169. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31170. c.ServeSuccessJSON(map[string]interface{}{
  31171. "failed_code": -10,
  31172. "msg": err_msg,
  31173. })
  31174. return
  31175. }
  31176. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31177. userJSONBytes3, _ := json.Marshal(respJSON3)
  31178. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31179. // utils.ErrorLog("解析失败:%v", err)
  31180. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31181. // return
  31182. //}
  31183. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31184. utils.ErrorLog("解析失败:%v", err)
  31185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31186. return
  31187. }
  31188. res.InfRefmsgid = ahres.InfRefmsgid
  31189. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31190. // 创建对应的Time类型
  31191. t := time.UnixMilli(timestamp)
  31192. // 格式化成指定的日期字符串
  31193. str := t.Format("2006-01-02 15:04:05")
  31194. res.Output.Setlinfo.SetlTime = str
  31195. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31196. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31197. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31198. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31199. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31200. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31201. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31202. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31203. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31204. //
  31205. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31206. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31207. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31208. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31209. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31210. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31211. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31212. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31213. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31214. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31215. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31216. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31217. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31218. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31219. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31220. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31221. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31222. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31223. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31224. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31225. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31226. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31227. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31228. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31229. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31230. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31231. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31232. //res.Output.Setldetail = ahres.Output.Setldetail
  31233. res.ErrMsg = ahres.ErrMsg
  31234. res.Cainfo = ahres.Cainfo
  31235. res.WarnMsg = ahres.WarnMsg
  31236. res.Infcode = ahres.Infcode
  31237. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31238. var api3 string
  31239. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31240. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31241. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31242. resp3, requestErr3 := http.Get(api3)
  31243. if requestErr3 != nil {
  31244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31245. return
  31246. }
  31247. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31248. if ioErr3 != nil {
  31249. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31251. return
  31252. }
  31253. var respJSON3 map[string]interface{}
  31254. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31257. return
  31258. }
  31259. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31260. if status == "0" {
  31261. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31262. c.ServeSuccessJSON(map[string]interface{}{
  31263. "failed_code": -10,
  31264. "msg": err_msg,
  31265. })
  31266. return
  31267. }
  31268. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31269. userJSONBytes3, _ := json.Marshal(respJSON3)
  31270. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31271. // utils.ErrorLog("解析失败:%v", err)
  31272. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31273. // return
  31274. //}
  31275. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31276. utils.ErrorLog("解析失败:%v", err)
  31277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31278. return
  31279. }
  31280. res.InfRefmsgid = ahres.InfRefmsgid
  31281. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31282. // 创建对应的Time类型
  31283. t := time.UnixMilli(timestamp)
  31284. // 格式化成指定的日期字符串
  31285. str := t.Format("2006-01-02 15:04:05")
  31286. res.Output.Setlinfo.SetlTime = str
  31287. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31288. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31289. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31290. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31291. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31292. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31293. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31294. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31295. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31296. //
  31297. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31298. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31299. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31300. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31301. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31302. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31303. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31304. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31305. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31306. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31307. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31308. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31309. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31310. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31311. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31312. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31313. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31314. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31315. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31316. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31317. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31318. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31319. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31320. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31321. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31322. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31323. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31324. //res.Output.Setldetail = ahres.Output.Setldetail
  31325. res.ErrMsg = ahres.ErrMsg
  31326. res.Cainfo = ahres.Cainfo
  31327. res.WarnMsg = ahres.WarnMsg
  31328. res.Infcode = ahres.Infcode
  31329. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31330. 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, "")
  31331. var dat map[string]interface{}
  31332. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31333. fmt.Println(dat)
  31334. } else {
  31335. fmt.Println(err)
  31336. }
  31337. saveLog(result, src_resquest, "2208", "退费")
  31338. userJSONBytes, _ := json.Marshal(dat)
  31339. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31340. utils.ErrorLog("解析失败:%v", err)
  31341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31342. return
  31343. }
  31344. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31345. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  31346. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31347. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31348. resp3, requestErr3 := http.Get(api3)
  31349. if requestErr3 != nil {
  31350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31351. return
  31352. }
  31353. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31354. if ioErr3 != nil {
  31355. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31357. return
  31358. }
  31359. var respJSON3 map[string]interface{}
  31360. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31361. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31363. return
  31364. }
  31365. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31366. userJSONBytes3, _ := json.Marshal(respJSON3)
  31367. fmt.Println("log")
  31368. fmt.Println(string(userJSONBytes3))
  31369. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31370. utils.ErrorLog("解析失败:%v", err)
  31371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31372. return
  31373. }
  31374. } else {
  31375. if miConfig.Code == "H15049901371" {
  31376. 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)
  31377. var dat map[string]interface{}
  31378. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31379. fmt.Println(dat)
  31380. } else {
  31381. fmt.Println(err)
  31382. }
  31383. saveLog(result, src_resquest, "2208", "退费")
  31384. if strings.Contains(result, "Post") {
  31385. res.Infcode = -1
  31386. res.ErrMsg = result
  31387. }
  31388. userJSONBytes, _ := json.Marshal(dat)
  31389. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  31390. utils.ErrorLog("解析失败:%v", err)
  31391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31392. return
  31393. }
  31394. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31395. res.Output = resSixteen10265.Output
  31396. res.ErrMsg = resSixteen10265.ErrMsg
  31397. res.Cainfo = resSixteen10265.Cainfo
  31398. res.WarnMsg = resSixteen10265.WarnMsg
  31399. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31400. res.Infcode = infocode
  31401. } else {
  31402. 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)
  31403. var dat map[string]interface{}
  31404. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31405. fmt.Println(dat)
  31406. } else {
  31407. fmt.Println(err)
  31408. }
  31409. saveLog(result, src_resquest, "2208", "退费")
  31410. userJSONBytes, _ := json.Marshal(dat)
  31411. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31412. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  31413. utils.ErrorLog("解析失败:%v", err)
  31414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31415. return
  31416. }
  31417. res.Infcode = gz.Infcode
  31418. } else {
  31419. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31420. utils.ErrorLog("解析失败:%v", err)
  31421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31422. return
  31423. }
  31424. }
  31425. if strings.Contains(result, "Post") {
  31426. res.Infcode = -1
  31427. res.ErrMsg = result
  31428. }
  31429. }
  31430. }
  31431. if res.Infcode == -1 {
  31432. c.ServeSuccessJSON(map[string]interface{}{
  31433. "failed_code": -10,
  31434. "msg": res.ErrMsg,
  31435. })
  31436. return
  31437. }
  31438. if res.Infcode != -1 {
  31439. var res2 ResultSix
  31440. var resSix10265 ResultSix10265
  31441. if miConfig.MdtrtareaAdmvs == "421300" {
  31442. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31443. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31444. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31445. resp3, requestErr3 := http.Get(api3)
  31446. if requestErr3 != nil {
  31447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31448. return
  31449. }
  31450. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31451. if ioErr3 != nil {
  31452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31454. return
  31455. }
  31456. var respJSON3 map[string]interface{}
  31457. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31460. return
  31461. }
  31462. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31463. userJSONBytes3, _ := json.Marshal(respJSON3)
  31464. fmt.Println("log")
  31465. fmt.Println(string(userJSONBytes3))
  31466. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31467. utils.ErrorLog("解析失败:%v", err)
  31468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31469. return
  31470. }
  31471. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31472. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31473. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31474. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31475. resp3, requestErr3 := http.Get(api3)
  31476. if requestErr3 != nil {
  31477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31478. return
  31479. }
  31480. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31481. if ioErr3 != nil {
  31482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31484. return
  31485. }
  31486. var respJSON3 map[string]interface{}
  31487. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31490. return
  31491. }
  31492. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31493. userJSONBytes3, _ := json.Marshal(respJSON3)
  31494. fmt.Println("log")
  31495. fmt.Println(string(userJSONBytes3))
  31496. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31497. utils.ErrorLog("解析失败:%v", err)
  31498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31499. return
  31500. }
  31501. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31502. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31503. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31504. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31505. resp3, requestErr3 := http.Get(api3)
  31506. if requestErr3 != nil {
  31507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31508. return
  31509. }
  31510. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31511. if ioErr3 != nil {
  31512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31514. return
  31515. }
  31516. var respJSON3 map[string]interface{}
  31517. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31520. return
  31521. }
  31522. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31523. userJSONBytes3, _ := json.Marshal(respJSON3)
  31524. fmt.Println("log")
  31525. fmt.Println(string(userJSONBytes3))
  31526. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31527. utils.ErrorLog("解析失败:%v", err)
  31528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31529. return
  31530. }
  31531. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31532. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31533. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31534. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31535. resp3, requestErr3 := http.Get(api3)
  31536. if requestErr3 != nil {
  31537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31538. return
  31539. }
  31540. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31541. if ioErr3 != nil {
  31542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31544. return
  31545. }
  31546. var respJSON3 map[string]interface{}
  31547. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31550. return
  31551. }
  31552. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31553. userJSONBytes3, _ := json.Marshal(respJSON3)
  31554. fmt.Println("log")
  31555. fmt.Println(string(userJSONBytes3))
  31556. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31557. utils.ErrorLog("解析失败:%v", err)
  31558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31559. return
  31560. }
  31561. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31562. var api3 string
  31563. if miConfig.MdtrtareaAdmvs == "320921" {
  31564. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31565. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31566. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31567. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31568. } else {
  31569. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31570. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31571. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31572. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31573. }
  31574. resp3, requestErr3 := http.Get(api3)
  31575. if requestErr3 != nil {
  31576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31577. return
  31578. }
  31579. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31580. if ioErr3 != nil {
  31581. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31583. return
  31584. }
  31585. var respJSON3 map[string]interface{}
  31586. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31587. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31589. return
  31590. }
  31591. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31592. userJSONBytes3, _ := json.Marshal(respJSON3)
  31593. fmt.Println("log")
  31594. fmt.Println(string(userJSONBytes3))
  31595. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31596. utils.ErrorLog("解析失败:%v", err)
  31597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31598. return
  31599. }
  31600. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31601. res2.Output = resSix10265.Output
  31602. res2.ErrMsg = resSix10265.ErrMsg
  31603. res2.Cainfo = resSix10265.Cainfo
  31604. res2.WarnMsg = resSix10265.WarnMsg
  31605. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31606. res2.Infcode = infocode
  31607. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31608. var api3 string
  31609. new_chrg_bchno := order.Number
  31610. if adminUser.CurrentOrgId == 10265 {
  31611. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  31612. new_chrg_bchno = "0000"
  31613. }
  31614. }
  31615. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  31616. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31617. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31618. resp3, requestErr3 := http.Get(api3)
  31619. if requestErr3 != nil {
  31620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31621. return
  31622. }
  31623. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31624. if ioErr3 != nil {
  31625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31627. return
  31628. }
  31629. var respJSON3 map[string]interface{}
  31630. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31633. return
  31634. }
  31635. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31636. userJSONBytes3, _ := json.Marshal(respJSON3)
  31637. fmt.Println("log")
  31638. fmt.Println(string(userJSONBytes3))
  31639. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31640. utils.ErrorLog("解析失败:%v", err)
  31641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31642. return
  31643. }
  31644. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31645. res2.Output = resSix10265.Output
  31646. res2.ErrMsg = resSix10265.ErrMsg
  31647. res2.Cainfo = resSix10265.Cainfo
  31648. res2.WarnMsg = resSix10265.WarnMsg
  31649. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31650. res2.Infcode = infocode
  31651. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31652. 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)
  31653. var dat map[string]interface{}
  31654. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31655. fmt.Println(dat)
  31656. } else {
  31657. fmt.Println(err)
  31658. }
  31659. saveLog(result2, src_request, "2205", "撤销明细")
  31660. userJSONBytes, _ := json.Marshal(dat)
  31661. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31662. utils.ErrorLog("解析失败:%v", err)
  31663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31664. return
  31665. }
  31666. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31667. 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, "")
  31668. var dat map[string]interface{}
  31669. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31670. fmt.Println(dat)
  31671. } else {
  31672. fmt.Println(err)
  31673. }
  31674. saveLog(result2, src_request, "2205", "撤销明细")
  31675. userJSONBytes, _ := json.Marshal(dat)
  31676. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31677. utils.ErrorLog("解析失败:%v", err)
  31678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31679. return
  31680. }
  31681. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31682. 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, "")
  31683. var dat map[string]interface{}
  31684. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31685. fmt.Println(dat)
  31686. } else {
  31687. fmt.Println(err)
  31688. }
  31689. saveLog(result2, src_request, "2205", "撤销明细")
  31690. userJSONBytes, _ := json.Marshal(dat)
  31691. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31692. utils.ErrorLog("解析失败:%v", err)
  31693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31694. return
  31695. }
  31696. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31697. var api3 string
  31698. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31699. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31700. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31701. resp3, requestErr3 := http.Get(api3)
  31702. if requestErr3 != nil {
  31703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31704. return
  31705. }
  31706. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31707. if ioErr3 != nil {
  31708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31710. return
  31711. }
  31712. var respJSON3 map[string]interface{}
  31713. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31716. return
  31717. }
  31718. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31719. if status == "0" {
  31720. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31721. c.ServeSuccessJSON(map[string]interface{}{
  31722. "failed_code": -10,
  31723. "msg": err_msg,
  31724. })
  31725. return
  31726. }
  31727. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31728. userJSONBytes3, _ := json.Marshal(respJSON3)
  31729. fmt.Println("log")
  31730. fmt.Println(string(userJSONBytes3))
  31731. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31732. utils.ErrorLog("解析失败:%v", err)
  31733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31734. return
  31735. }
  31736. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31737. 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, "")
  31738. var dat map[string]interface{}
  31739. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31740. fmt.Println(dat)
  31741. } else {
  31742. fmt.Println(err)
  31743. }
  31744. saveLog(result2, src_request, "2205", "撤销明细")
  31745. userJSONBytes, _ := json.Marshal(dat)
  31746. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31747. utils.ErrorLog("解析失败:%v", err)
  31748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31749. return
  31750. }
  31751. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31752. 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, "")
  31753. var dat map[string]interface{}
  31754. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31755. fmt.Println(dat)
  31756. } else {
  31757. fmt.Println(err)
  31758. }
  31759. saveLog(result2, src_request, "2205", "撤销明细")
  31760. userJSONBytes, _ := json.Marshal(dat)
  31761. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31762. utils.ErrorLog("解析失败:%v", err)
  31763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31764. return
  31765. }
  31766. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31767. var api3 string
  31768. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31769. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31770. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31771. resp3, requestErr3 := http.Get(api3)
  31772. if requestErr3 != nil {
  31773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31774. return
  31775. }
  31776. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31777. if ioErr3 != nil {
  31778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31780. return
  31781. }
  31782. var respJSON3 map[string]interface{}
  31783. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31786. return
  31787. }
  31788. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31789. if status == "0" {
  31790. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31791. c.ServeSuccessJSON(map[string]interface{}{
  31792. "failed_code": -10,
  31793. "msg": err_msg,
  31794. })
  31795. return
  31796. }
  31797. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31798. userJSONBytes3, _ := json.Marshal(respJSON3)
  31799. fmt.Println("log")
  31800. fmt.Println(string(userJSONBytes3))
  31801. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31802. utils.ErrorLog("解析失败:%v", err)
  31803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31804. return
  31805. }
  31806. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31807. 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, "")
  31808. var dat map[string]interface{}
  31809. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31810. fmt.Println(dat)
  31811. } else {
  31812. fmt.Println(err)
  31813. }
  31814. saveLog(result2, src_request, "2205", "撤销明细")
  31815. userJSONBytes, _ := json.Marshal(dat)
  31816. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31817. utils.ErrorLog("解析失败:%v", err)
  31818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31819. return
  31820. }
  31821. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31822. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  31823. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31824. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31825. resp3, requestErr3 := http.Get(api3)
  31826. if requestErr3 != nil {
  31827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31828. return
  31829. }
  31830. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31831. if ioErr3 != nil {
  31832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31834. return
  31835. }
  31836. var respJSON3 map[string]interface{}
  31837. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31840. return
  31841. }
  31842. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31843. userJSONBytes3, _ := json.Marshal(respJSON3)
  31844. fmt.Println("log")
  31845. fmt.Println(string(userJSONBytes3))
  31846. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31847. utils.ErrorLog("解析失败:%v", err)
  31848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31849. return
  31850. }
  31851. } else {
  31852. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31853. res2.Infcode = 0
  31854. } else {
  31855. 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)
  31856. var dat map[string]interface{}
  31857. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31858. fmt.Println(dat)
  31859. } else {
  31860. fmt.Println(err)
  31861. }
  31862. saveLog(result2, src_request, "2205", "撤销明细")
  31863. userJSONBytes, _ := json.Marshal(dat)
  31864. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31865. utils.ErrorLog("解析失败:%v", err)
  31866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31867. return
  31868. }
  31869. }
  31870. }
  31871. if res2.Infcode == -1 {
  31872. c.ServeSuccessJSON(map[string]interface{}{
  31873. "failed_code": -10,
  31874. "msg": res2.ErrMsg,
  31875. })
  31876. return
  31877. }
  31878. if res2.Infcode == 0 {
  31879. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  31880. if err == nil {
  31881. //当押金不为零时产生退费记录
  31882. if order.Decimal != 0 {
  31883. tmp := strconv.FormatInt(order.ID, 10)
  31884. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  31885. if err != nil {
  31886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31887. return
  31888. }
  31889. }
  31890. c.ServeSuccessJSON(map[string]interface{}{
  31891. "msg": "退费成功",
  31892. })
  31893. } else {
  31894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31895. return
  31896. }
  31897. } else {
  31898. c.ServeSuccessJSON(map[string]interface{}{
  31899. "failed_code": -10,
  31900. "msg": res2.ErrMsg,
  31901. })
  31902. }
  31903. } else {
  31904. c.ServeSuccessJSON(map[string]interface{}{
  31905. "failed_code": -10,
  31906. "msg": res.ErrMsg,
  31907. })
  31908. }
  31909. }
  31910. }
  31911. func (c *HisApiController) RefundNumber() {
  31912. record_time := c.GetString("record_time")
  31913. //patient_id, _ := c.GetInt64("patient_id")
  31914. admin_user_id, _ := c.GetInt64("admin_user_id")
  31915. his_patient_id, _ := c.GetInt64("id")
  31916. timeLayout := "2006-01-02"
  31917. loc, _ := time.LoadLocation("Local")
  31918. adminUser := c.GetAdminUserInfo()
  31919. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  31920. fmt.Println(err)
  31921. if err != nil {
  31922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31923. return
  31924. }
  31925. recordDateTime := theTime.Unix()
  31926. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  31927. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  31928. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  31929. //order, _ := service.GetHisOrderByID(order_id)
  31930. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31931. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31932. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31933. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  31934. if count > 0 {
  31935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  31936. return
  31937. }
  31938. if config.IsOpen == 1 { //对接了医保,走医保流程
  31939. var res2 ResultSix
  31940. var res3 GZResultSix
  31941. var resSix10265 ResultSix10265
  31942. if miConfig.MdtrtareaAdmvs == "421300" {
  31943. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  31944. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31945. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31946. resp3, requestErr3 := http.Get(api3)
  31947. if requestErr3 != nil {
  31948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31949. return
  31950. }
  31951. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31952. if ioErr3 != nil {
  31953. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31955. return
  31956. }
  31957. var respJSON3 map[string]interface{}
  31958. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31961. return
  31962. }
  31963. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31964. userJSONBytes3, _ := json.Marshal(respJSON3)
  31965. fmt.Println("log")
  31966. fmt.Println(string(userJSONBytes3))
  31967. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31968. utils.ErrorLog("解析失败:%v", err)
  31969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31970. return
  31971. }
  31972. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31973. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  31974. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31975. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31976. resp3, requestErr3 := http.Get(api3)
  31977. if requestErr3 != nil {
  31978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31979. return
  31980. }
  31981. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31982. if ioErr3 != nil {
  31983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31985. return
  31986. }
  31987. var respJSON3 map[string]interface{}
  31988. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31991. return
  31992. }
  31993. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31994. userJSONBytes3, _ := json.Marshal(respJSON3)
  31995. fmt.Println("log")
  31996. fmt.Println(string(userJSONBytes3))
  31997. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31998. utils.ErrorLog("解析失败:%v", err)
  31999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32000. return
  32001. }
  32002. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32003. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32004. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32005. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32006. resp3, requestErr3 := http.Get(api3)
  32007. if requestErr3 != nil {
  32008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32009. return
  32010. }
  32011. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32012. if ioErr3 != nil {
  32013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32015. return
  32016. }
  32017. var respJSON3 map[string]interface{}
  32018. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32021. return
  32022. }
  32023. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32024. userJSONBytes3, _ := json.Marshal(respJSON3)
  32025. fmt.Println("log")
  32026. fmt.Println(string(userJSONBytes3))
  32027. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32028. utils.ErrorLog("解析失败:%v", err)
  32029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32030. return
  32031. }
  32032. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32033. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32034. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32035. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32036. resp3, requestErr3 := http.Get(api3)
  32037. if requestErr3 != nil {
  32038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32039. return
  32040. }
  32041. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32042. if ioErr3 != nil {
  32043. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32045. return
  32046. }
  32047. var respJSON3 map[string]interface{}
  32048. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32049. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32051. return
  32052. }
  32053. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32054. userJSONBytes3, _ := json.Marshal(respJSON3)
  32055. fmt.Println("log")
  32056. fmt.Println(string(userJSONBytes3))
  32057. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32058. utils.ErrorLog("解析失败:%v", err)
  32059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32060. return
  32061. }
  32062. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32063. var api3 string
  32064. if miConfig.MdtrtareaAdmvs == "320921" {
  32065. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32066. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32067. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32068. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32069. } else {
  32070. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32071. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32072. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32073. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32074. }
  32075. resp3, requestErr3 := http.Get(api3)
  32076. if requestErr3 != nil {
  32077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32078. return
  32079. }
  32080. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32081. if ioErr3 != nil {
  32082. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32084. return
  32085. }
  32086. var respJSON3 map[string]interface{}
  32087. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32090. return
  32091. }
  32092. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32093. userJSONBytes3, _ := json.Marshal(respJSON3)
  32094. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32095. utils.ErrorLog("解析失败:%v", err)
  32096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32097. return
  32098. }
  32099. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32100. res2.Output = resSix10265.Output
  32101. res2.ErrMsg = resSix10265.ErrMsg
  32102. res2.Cainfo = resSix10265.Cainfo
  32103. res2.WarnMsg = resSix10265.WarnMsg
  32104. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32105. res2.Infcode = infocode
  32106. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32107. var api3 string
  32108. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  32109. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32110. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32111. resp3, requestErr3 := http.Get(api3)
  32112. if requestErr3 != nil {
  32113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32114. return
  32115. }
  32116. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32117. if ioErr3 != nil {
  32118. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32120. return
  32121. }
  32122. var respJSON3 map[string]interface{}
  32123. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32126. return
  32127. }
  32128. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32129. userJSONBytes3, _ := json.Marshal(respJSON3)
  32130. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32131. utils.ErrorLog("解析失败:%v", err)
  32132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32133. return
  32134. }
  32135. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32136. res2.Output = resSix10265.Output
  32137. res2.ErrMsg = resSix10265.ErrMsg
  32138. res2.Cainfo = resSix10265.Cainfo
  32139. res2.WarnMsg = resSix10265.WarnMsg
  32140. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32141. res2.Infcode = infocode
  32142. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32143. 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)
  32144. var dat map[string]interface{}
  32145. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32146. fmt.Println(dat)
  32147. } else {
  32148. fmt.Println(err)
  32149. }
  32150. saveLog(result, request, "2202", "退号")
  32151. userJSONBytes, _ := json.Marshal(dat)
  32152. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32153. utils.ErrorLog("解析失败:%v", err)
  32154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32155. return
  32156. }
  32157. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32158. 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, "")
  32159. var dat map[string]interface{}
  32160. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32161. fmt.Println(dat)
  32162. } else {
  32163. fmt.Println(err)
  32164. }
  32165. saveLog(result, request, "2202", "退号")
  32166. userJSONBytes, _ := json.Marshal(dat)
  32167. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32168. utils.ErrorLog("解析失败:%v", err)
  32169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32170. return
  32171. }
  32172. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32173. 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, "")
  32174. var dat map[string]interface{}
  32175. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32176. fmt.Println(dat)
  32177. } else {
  32178. fmt.Println(err)
  32179. }
  32180. saveLog(result, request, "2202", "退号")
  32181. userJSONBytes, _ := json.Marshal(dat)
  32182. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32183. utils.ErrorLog("解析失败:%v", err)
  32184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32185. return
  32186. }
  32187. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32188. var api3 string
  32189. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32190. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32191. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32192. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32193. resp3, requestErr3 := http.Get(api3)
  32194. if requestErr3 != nil {
  32195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32196. return
  32197. }
  32198. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32199. if ioErr3 != nil {
  32200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32202. return
  32203. }
  32204. var respJSON3 map[string]interface{}
  32205. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32208. return
  32209. }
  32210. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32211. if status == "0" {
  32212. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32213. c.ServeSuccessJSON(map[string]interface{}{
  32214. "failed_code": -10,
  32215. "msg": err_msg,
  32216. })
  32217. return
  32218. }
  32219. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32220. userJSONBytes3, _ := json.Marshal(respJSON3)
  32221. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32222. utils.ErrorLog("解析失败:%v", err)
  32223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32224. return
  32225. }
  32226. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32227. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32228. var api3 string
  32229. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32230. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32231. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32232. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32233. resp3, requestErr3 := http.Get(api3)
  32234. if requestErr3 != nil {
  32235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32236. return
  32237. }
  32238. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32239. if ioErr3 != nil {
  32240. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32242. return
  32243. }
  32244. var respJSON3 map[string]interface{}
  32245. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32246. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32248. return
  32249. }
  32250. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32251. if status == "0" {
  32252. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32253. c.ServeSuccessJSON(map[string]interface{}{
  32254. "failed_code": -10,
  32255. "msg": err_msg,
  32256. })
  32257. return
  32258. }
  32259. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32260. userJSONBytes3, _ := json.Marshal(respJSON3)
  32261. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32262. utils.ErrorLog("解析失败:%v", err)
  32263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32264. return
  32265. }
  32266. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32267. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32268. 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, "")
  32269. var dat map[string]interface{}
  32270. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32271. fmt.Println(dat)
  32272. } else {
  32273. fmt.Println(err)
  32274. }
  32275. saveLog(result, request, "2202", "退号")
  32276. userJSONBytes, _ := json.Marshal(dat)
  32277. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32278. utils.ErrorLog("解析失败:%v", err)
  32279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32280. return
  32281. }
  32282. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32283. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  32284. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32285. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32286. resp3, requestErr3 := http.Get(api3)
  32287. if requestErr3 != nil {
  32288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32289. return
  32290. }
  32291. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32292. if ioErr3 != nil {
  32293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32295. return
  32296. }
  32297. var respJSON3 map[string]interface{}
  32298. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32301. return
  32302. }
  32303. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32304. userJSONBytes3, _ := json.Marshal(respJSON3)
  32305. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32306. utils.ErrorLog("解析失败:%v", err)
  32307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32308. return
  32309. }
  32310. } else {
  32311. var api3 string
  32312. if miConfig.Code == "H15049901371" {
  32313. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  32314. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32315. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32316. } else {
  32317. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  32318. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32319. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32320. }
  32321. resp3, requestErr3 := http.Get(api3)
  32322. if requestErr3 != nil {
  32323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32324. return
  32325. }
  32326. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32327. if ioErr3 != nil {
  32328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32330. return
  32331. }
  32332. var respJSON3 map[string]interface{}
  32333. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32336. return
  32337. }
  32338. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32339. userJSONBytes3, _ := json.Marshal(respJSON3)
  32340. if miConfig.Code == "H15049901371" {
  32341. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32342. utils.ErrorLog("解析失败:%v", err)
  32343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32344. return
  32345. }
  32346. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32347. res2.Output = resSix10265.Output
  32348. res2.ErrMsg = resSix10265.ErrMsg
  32349. res2.Cainfo = resSix10265.Cainfo
  32350. res2.WarnMsg = resSix10265.WarnMsg
  32351. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32352. res2.Infcode = infocode
  32353. } else {
  32354. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32355. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  32356. utils.ErrorLog("解析失败:%v", err)
  32357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32358. return
  32359. }
  32360. res2.Infcode = res3.Infcode
  32361. } else {
  32362. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32363. utils.ErrorLog("解析失败:%v", err)
  32364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32365. return
  32366. }
  32367. }
  32368. }
  32369. }
  32370. if res2.Infcode == -1 {
  32371. c.ServeSuccessJSON(map[string]interface{}{
  32372. "failed_code": -10,
  32373. "msg": res2.ErrMsg,
  32374. })
  32375. return
  32376. }
  32377. if res2.Infcode == 0 {
  32378. if err == nil {
  32379. c.ServeSuccessJSON(map[string]interface{}{
  32380. "msg": "退号成功",
  32381. })
  32382. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  32383. } else {
  32384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32385. return
  32386. }
  32387. }
  32388. } else {
  32389. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  32390. //if err == nil {
  32391. // c.ServeSuccessJSON(map[string]interface{}{
  32392. // "msg": "退费成功",
  32393. // })
  32394. //} else {
  32395. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32396. // return
  32397. //}
  32398. }
  32399. }
  32400. func (c *HisApiController) RefundDetail() {
  32401. order_id, _ := c.GetInt64("order_id")
  32402. admin_user_id, _ := c.GetInt64("admin_user_id")
  32403. //his_patient_id, _ := c.GetInt64("his_patient_id")
  32404. number := c.GetString("number")
  32405. record_time := c.GetString("record_time")
  32406. patient_id, _ := c.GetInt64("patient_id")
  32407. //med_type, _ := c.GetInt64("med_type")
  32408. timeLayout := "2006-01-02"
  32409. loc, _ := time.LoadLocation("Local")
  32410. adminUser := c.GetAdminUserInfo()
  32411. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32412. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32413. fmt.Println(err)
  32414. if err != nil {
  32415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32416. return
  32417. }
  32418. recordDateTime := theTime.Unix()
  32419. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  32420. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32421. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32422. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32423. var order models.HisOrder
  32424. order, _ = service.GetHisOrderByID(order_id)
  32425. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32426. if config.IsOpen == 1 { //对接了医保,走医保流程
  32427. var res2 ResultSix
  32428. if miConfig.MdtrtareaAdmvs == "421300" {
  32429. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32430. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32431. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32432. resp3, requestErr3 := http.Get(api3)
  32433. if requestErr3 != nil {
  32434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32435. return
  32436. }
  32437. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32438. if ioErr3 != nil {
  32439. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32441. return
  32442. }
  32443. var respJSON3 map[string]interface{}
  32444. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32447. return
  32448. }
  32449. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32450. userJSONBytes3, _ := json.Marshal(respJSON3)
  32451. fmt.Println("log")
  32452. fmt.Println(string(userJSONBytes3))
  32453. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32454. utils.ErrorLog("解析失败:%v", err)
  32455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32456. return
  32457. }
  32458. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32459. if err == nil {
  32460. c.ServeSuccessJSON(map[string]interface{}{
  32461. "msg": "撤销明细成功",
  32462. })
  32463. return
  32464. } else {
  32465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32466. return
  32467. }
  32468. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32469. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32470. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32471. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32472. resp3, requestErr3 := http.Get(api3)
  32473. if requestErr3 != nil {
  32474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32475. return
  32476. }
  32477. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32478. if ioErr3 != nil {
  32479. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32481. return
  32482. }
  32483. var respJSON3 map[string]interface{}
  32484. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32485. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32487. return
  32488. }
  32489. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32490. userJSONBytes3, _ := json.Marshal(respJSON3)
  32491. fmt.Println("log")
  32492. fmt.Println(string(userJSONBytes3))
  32493. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32494. utils.ErrorLog("解析失败:%v", err)
  32495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32496. return
  32497. }
  32498. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32499. if err == nil {
  32500. c.ServeSuccessJSON(map[string]interface{}{
  32501. "msg": "撤销明细成功",
  32502. })
  32503. return
  32504. } else {
  32505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32506. return
  32507. }
  32508. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32509. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32510. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32511. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32512. resp3, requestErr3 := http.Get(api3)
  32513. if requestErr3 != nil {
  32514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32515. return
  32516. }
  32517. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32518. if ioErr3 != nil {
  32519. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32521. return
  32522. }
  32523. var respJSON3 map[string]interface{}
  32524. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32527. return
  32528. }
  32529. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32530. userJSONBytes3, _ := json.Marshal(respJSON3)
  32531. fmt.Println("log")
  32532. fmt.Println(string(userJSONBytes3))
  32533. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32534. utils.ErrorLog("解析失败:%v", err)
  32535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32536. return
  32537. }
  32538. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32539. if err == nil {
  32540. c.ServeSuccessJSON(map[string]interface{}{
  32541. "msg": "撤销明细成功",
  32542. })
  32543. return
  32544. } else {
  32545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32546. return
  32547. }
  32548. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32549. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32550. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32551. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32552. resp3, requestErr3 := http.Get(api3)
  32553. if requestErr3 != nil {
  32554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32555. return
  32556. }
  32557. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32558. if ioErr3 != nil {
  32559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32561. return
  32562. }
  32563. var respJSON3 map[string]interface{}
  32564. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32567. return
  32568. }
  32569. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32570. userJSONBytes3, _ := json.Marshal(respJSON3)
  32571. fmt.Println("log")
  32572. fmt.Println(string(userJSONBytes3))
  32573. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32574. utils.ErrorLog("解析失败:%v", err)
  32575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32576. return
  32577. }
  32578. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32579. if err == nil {
  32580. c.ServeSuccessJSON(map[string]interface{}{
  32581. "msg": "撤销明细成功",
  32582. })
  32583. return
  32584. } else {
  32585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32586. return
  32587. }
  32588. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32589. var resSix10265 ResultSix10265
  32590. var api3 string
  32591. if miConfig.MdtrtareaAdmvs == "320921" {
  32592. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32593. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32594. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32595. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32596. } else {
  32597. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32598. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32599. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32600. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32601. }
  32602. resp3, requestErr3 := http.Get(api3)
  32603. utils.ErrorLog("接口: %v", requestErr3)
  32604. if requestErr3 != nil {
  32605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32606. return
  32607. }
  32608. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32609. if ioErr3 != nil {
  32610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32612. return
  32613. }
  32614. var respJSON3 map[string]interface{}
  32615. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32618. return
  32619. }
  32620. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32621. userJSONBytes3, _ := json.Marshal(respJSON3)
  32622. fmt.Println("log")
  32623. fmt.Println(string(userJSONBytes3))
  32624. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32625. utils.ErrorLog("解析失败:%v", err)
  32626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32627. return
  32628. }
  32629. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32630. res2.Output = resSix10265.Output
  32631. res2.ErrMsg = resSix10265.ErrMsg
  32632. res2.Cainfo = resSix10265.Cainfo
  32633. res2.WarnMsg = resSix10265.WarnMsg
  32634. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32635. res2.Infcode = infocode
  32636. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32637. if err == nil {
  32638. c.ServeSuccessJSON(map[string]interface{}{
  32639. "msg": "撤销明细成功",
  32640. })
  32641. return
  32642. } else {
  32643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32644. return
  32645. }
  32646. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32647. var api3 string
  32648. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32649. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32650. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32651. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32652. resp3, requestErr3 := http.Get(api3)
  32653. utils.ErrorLog("接口: %v", requestErr3)
  32654. if requestErr3 != nil {
  32655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32656. return
  32657. }
  32658. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32659. if ioErr3 != nil {
  32660. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32662. return
  32663. }
  32664. var respJSON3 map[string]interface{}
  32665. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32668. return
  32669. }
  32670. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32671. if status == "0" {
  32672. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32673. c.ServeSuccessJSON(map[string]interface{}{
  32674. "failed_code": -10,
  32675. "msg": err_msg,
  32676. })
  32677. return
  32678. }
  32679. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32680. userJSONBytes3, _ := json.Marshal(respJSON3)
  32681. fmt.Println("log")
  32682. fmt.Println(string(userJSONBytes3))
  32683. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32684. utils.ErrorLog("解析失败:%v", err)
  32685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32686. return
  32687. }
  32688. fmt.Println(res2.Infcode)
  32689. if res2.Infcode == -1 {
  32690. c.ServeSuccessJSON(map[string]interface{}{
  32691. "failed_code": -10,
  32692. "msg": res2.ErrMsg,
  32693. })
  32694. return
  32695. }
  32696. if res2.Infcode == 0 {
  32697. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32698. if err == nil {
  32699. c.ServeSuccessJSON(map[string]interface{}{
  32700. "msg": "撤销明细成功",
  32701. })
  32702. return
  32703. } else {
  32704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32705. return
  32706. }
  32707. } else {
  32708. c.ServeSuccessJSON(map[string]interface{}{
  32709. "failed_code": -10,
  32710. "msg": res2.ErrMsg,
  32711. })
  32712. }
  32713. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32714. if err == nil {
  32715. c.ServeSuccessJSON(map[string]interface{}{
  32716. "msg": "撤销明细成功",
  32717. })
  32718. return
  32719. } else {
  32720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32721. return
  32722. }
  32723. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32724. var api3 string
  32725. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32726. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32727. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32728. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32729. resp3, requestErr3 := http.Get(api3)
  32730. utils.ErrorLog("接口: %v", requestErr3)
  32731. if requestErr3 != nil {
  32732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32733. return
  32734. }
  32735. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32736. if ioErr3 != nil {
  32737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32739. return
  32740. }
  32741. var respJSON3 map[string]interface{}
  32742. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32745. return
  32746. }
  32747. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32748. if status == "0" {
  32749. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32750. c.ServeSuccessJSON(map[string]interface{}{
  32751. "failed_code": -10,
  32752. "msg": err_msg,
  32753. })
  32754. return
  32755. }
  32756. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32757. userJSONBytes3, _ := json.Marshal(respJSON3)
  32758. fmt.Println("log")
  32759. fmt.Println(string(userJSONBytes3))
  32760. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32761. utils.ErrorLog("解析失败:%v", err)
  32762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32763. return
  32764. }
  32765. fmt.Println(res2.Infcode)
  32766. if res2.Infcode == -1 {
  32767. c.ServeSuccessJSON(map[string]interface{}{
  32768. "failed_code": -10,
  32769. "msg": res2.ErrMsg,
  32770. })
  32771. return
  32772. }
  32773. if res2.Infcode == 0 {
  32774. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32775. if err == nil {
  32776. c.ServeSuccessJSON(map[string]interface{}{
  32777. "msg": "撤销明细成功",
  32778. })
  32779. return
  32780. } else {
  32781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32782. return
  32783. }
  32784. } else {
  32785. c.ServeSuccessJSON(map[string]interface{}{
  32786. "failed_code": -10,
  32787. "msg": res2.ErrMsg,
  32788. })
  32789. }
  32790. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32791. if err == nil {
  32792. c.ServeSuccessJSON(map[string]interface{}{
  32793. "msg": "撤销明细成功",
  32794. })
  32795. return
  32796. } else {
  32797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32798. return
  32799. }
  32800. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32801. var resSix10265 ResultSix10265
  32802. new_chrg_bchno := order.Number
  32803. if adminUser.CurrentOrgId == 10265 {
  32804. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  32805. new_chrg_bchno = "0000"
  32806. }
  32807. }
  32808. var api3 string
  32809. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  32810. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32811. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32812. resp3, requestErr3 := http.Get(api3)
  32813. if requestErr3 != nil {
  32814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32815. return
  32816. }
  32817. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32818. if ioErr3 != nil {
  32819. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32821. return
  32822. }
  32823. var respJSON3 map[string]interface{}
  32824. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32827. return
  32828. }
  32829. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32830. userJSONBytes3, _ := json.Marshal(respJSON3)
  32831. fmt.Println("log")
  32832. fmt.Println(string(userJSONBytes3))
  32833. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32834. utils.ErrorLog("解析失败:%v", err)
  32835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32836. return
  32837. }
  32838. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32839. res2.Output = resSix10265.Output
  32840. res2.ErrMsg = resSix10265.ErrMsg
  32841. res2.Cainfo = resSix10265.Cainfo
  32842. res2.WarnMsg = resSix10265.WarnMsg
  32843. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32844. res2.Infcode = infocode
  32845. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32846. if err == nil {
  32847. c.ServeSuccessJSON(map[string]interface{}{
  32848. "msg": "撤销明细成功",
  32849. })
  32850. return
  32851. } else {
  32852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32853. return
  32854. }
  32855. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32856. 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)
  32857. var dat map[string]interface{}
  32858. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32859. fmt.Println(dat)
  32860. } else {
  32861. fmt.Println(err)
  32862. }
  32863. saveLog(result2, src_request, "2205", "撤销明细")
  32864. userJSONBytes, _ := json.Marshal(dat)
  32865. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32866. utils.ErrorLog("解析失败:%v", err)
  32867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32868. return
  32869. }
  32870. if res2.Infcode == 0 {
  32871. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32872. if err == nil {
  32873. c.ServeSuccessJSON(map[string]interface{}{
  32874. "msg": "撤销明细成功",
  32875. })
  32876. return
  32877. } else {
  32878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32879. return
  32880. }
  32881. } else {
  32882. c.ServeSuccessJSON(map[string]interface{}{
  32883. "failed_code": -10,
  32884. "msg": res2.ErrMsg,
  32885. })
  32886. }
  32887. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32888. 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, "")
  32889. var dat map[string]interface{}
  32890. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32891. fmt.Println(dat)
  32892. } else {
  32893. fmt.Println(err)
  32894. }
  32895. saveLog(result2, src_request, "2205", "撤销明细")
  32896. userJSONBytes, _ := json.Marshal(dat)
  32897. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32898. utils.ErrorLog("解析失败:%v", err)
  32899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32900. return
  32901. }
  32902. if res2.Infcode == 0 {
  32903. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32904. if err == nil {
  32905. c.ServeSuccessJSON(map[string]interface{}{
  32906. "msg": "撤销明细成功",
  32907. })
  32908. return
  32909. } else {
  32910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32911. return
  32912. }
  32913. } else {
  32914. c.ServeSuccessJSON(map[string]interface{}{
  32915. "failed_code": -10,
  32916. "msg": res2.ErrMsg,
  32917. })
  32918. }
  32919. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32920. 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, "")
  32921. var dat map[string]interface{}
  32922. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32923. fmt.Println(dat)
  32924. } else {
  32925. fmt.Println(err)
  32926. }
  32927. saveLog(result2, src_request, "2205", "撤销明细")
  32928. userJSONBytes, _ := json.Marshal(dat)
  32929. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32930. utils.ErrorLog("解析失败:%v", err)
  32931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32932. return
  32933. }
  32934. if res2.Infcode == 0 {
  32935. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32936. if err == nil {
  32937. c.ServeSuccessJSON(map[string]interface{}{
  32938. "msg": "撤销明细成功",
  32939. })
  32940. return
  32941. } else {
  32942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32943. return
  32944. }
  32945. } else {
  32946. c.ServeSuccessJSON(map[string]interface{}{
  32947. "failed_code": -10,
  32948. "msg": res2.ErrMsg,
  32949. })
  32950. }
  32951. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32952. 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, "")
  32953. var dat map[string]interface{}
  32954. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32955. fmt.Println(dat)
  32956. } else {
  32957. fmt.Println(err)
  32958. }
  32959. saveLog(result2, src_request, "2205", "撤销明细")
  32960. userJSONBytes, _ := json.Marshal(dat)
  32961. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32962. utils.ErrorLog("解析失败:%v", err)
  32963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32964. return
  32965. }
  32966. if res2.Infcode == 0 {
  32967. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32968. if err == nil {
  32969. c.ServeSuccessJSON(map[string]interface{}{
  32970. "msg": "撤销明细成功",
  32971. })
  32972. return
  32973. } else {
  32974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32975. return
  32976. }
  32977. } else {
  32978. c.ServeSuccessJSON(map[string]interface{}{
  32979. "failed_code": -10,
  32980. "msg": res2.ErrMsg,
  32981. })
  32982. }
  32983. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32984. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  32985. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32986. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32987. resp2, requestErr2 := http.Get(api2)
  32988. if requestErr2 != nil {
  32989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32990. return
  32991. }
  32992. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  32993. if ioErr2 != nil {
  32994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  32995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32996. return
  32997. }
  32998. var respJSON2 map[string]interface{}
  32999. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33002. return
  33003. }
  33004. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33005. userJSONBytes3, _ := json.Marshal(respJSON2)
  33006. fmt.Println("log")
  33007. fmt.Println(string(userJSONBytes3))
  33008. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33009. utils.ErrorLog("解析失败:%v", err)
  33010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33011. return
  33012. }
  33013. if res2.Infcode == 0 {
  33014. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33015. if err == nil {
  33016. c.ServeSuccessJSON(map[string]interface{}{
  33017. "msg": "撤销明细成功",
  33018. })
  33019. return
  33020. } else {
  33021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33022. return
  33023. }
  33024. } else {
  33025. c.ServeSuccessJSON(map[string]interface{}{
  33026. "failed_code": -10,
  33027. "msg": res2.ErrMsg,
  33028. })
  33029. }
  33030. } else {
  33031. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  33032. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33033. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33034. resp2, requestErr2 := http.Get(api2)
  33035. if requestErr2 != nil {
  33036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33037. return
  33038. }
  33039. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33040. if ioErr2 != nil {
  33041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33043. return
  33044. }
  33045. var respJSON2 map[string]interface{}
  33046. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33047. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33049. return
  33050. }
  33051. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33052. userJSONBytes3, _ := json.Marshal(respJSON2)
  33053. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33054. utils.ErrorLog("解析失败:%v", err)
  33055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33056. return
  33057. }
  33058. if res2.Infcode == -1 {
  33059. c.ServeSuccessJSON(map[string]interface{}{
  33060. "failed_code": -10,
  33061. "msg": res2.ErrMsg,
  33062. })
  33063. return
  33064. } else {
  33065. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33066. if err == nil {
  33067. c.ServeSuccessJSON(map[string]interface{}{
  33068. "msg": "撤销明细成功",
  33069. })
  33070. return
  33071. } else {
  33072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33073. return
  33074. }
  33075. }
  33076. }
  33077. } else {
  33078. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33079. if err == nil {
  33080. c.ServeSuccessJSON(map[string]interface{}{
  33081. "msg": "退费成功",
  33082. })
  33083. } else {
  33084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33085. return
  33086. }
  33087. }
  33088. }
  33089. // 对账
  33090. func (c *HisApiController) GetCheckAccount() {
  33091. start_time := c.GetString("start_time")
  33092. end_time := c.GetString("end_time")
  33093. insutype := c.GetString("insutype")
  33094. clr_type := c.GetString("clr_type")
  33095. clr_org := c.GetString("clr_optins")
  33096. admin_user_id, _ := c.GetInt64("admin_user_id")
  33097. adminUser := c.GetAdminUserInfo()
  33098. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33099. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33100. if len(clr_org) == 0 {
  33101. clr_org = miConfig.InsuplcAdmdvs
  33102. }
  33103. timeLayout := "2006-01-02"
  33104. loc, _ := time.LoadLocation("Local")
  33105. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33106. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33107. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33108. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33109. fixmedins_setl_cnt := int64(len(orders))
  33110. var medfee_sumamt float64
  33111. var acct_pay float64
  33112. var fund_pay_sumamt float64
  33113. for _, item := range orders {
  33114. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33115. acct_pay = acct_pay + item.AcctPay
  33116. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33117. }
  33118. var user_name string
  33119. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33120. if role.ID == 0 {
  33121. user_name = "xxx"
  33122. } else {
  33123. user_name = role.UserName
  33124. }
  33125. var res ResultEight
  33126. var res10188 ResultEightFor10188
  33127. if config.IsOpen == 1 {
  33128. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33129. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  33130. "insutype=" + insutype +
  33131. "&clr_type=" + clr_type +
  33132. "&setl_optins=" + clr_org +
  33133. "&stmt_begndate=" + start_time +
  33134. "&stm_enddate=" + end_time +
  33135. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33136. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33137. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33138. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33139. "&fixmedins_code=" + miConfig.Code +
  33140. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33141. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33142. "&secret_key=" + miConfig.SecretKey +
  33143. "&org_name=" + miConfig.OrgName +
  33144. "&doctor=" + user_name +
  33145. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33146. fmt.Println(api)
  33147. resp, requestErr := http.Get(api)
  33148. if requestErr != nil {
  33149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33150. return
  33151. }
  33152. body, ioErr := ioutil.ReadAll(resp.Body)
  33153. fmt.Println(body)
  33154. if ioErr != nil {
  33155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33157. return
  33158. }
  33159. var respJSON map[string]interface{}
  33160. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33163. return
  33164. }
  33165. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33166. userJSONBytes, _ := json.Marshal(respJSON)
  33167. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33168. utils.ErrorLog("解析失败:%v", err)
  33169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33170. return
  33171. }
  33172. res.InfRefmsgid = res10188.InfRefmsgid
  33173. res.Output = res10188.Output
  33174. res.ErrMsg = res10188.ErrMsg
  33175. res.Cainfo = res10188.Cainfo
  33176. res.WarnMsg = res10188.WarnMsg
  33177. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33178. res.Infcode = infocode
  33179. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33180. if clr_type != "9903" {
  33181. clr_type = "99" // 就诊 ID(来自2201接口返回)
  33182. }
  33183. if clr_type == "9903" {
  33184. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  33185. }
  33186. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  33187. "insutype=" + insutype +
  33188. "&clr_type=" + clr_type +
  33189. "&setl_optins=" + clr_org +
  33190. "&stmt_begndate=" + start_time +
  33191. "&stm_enddate=" + end_time +
  33192. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33193. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33194. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33195. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33196. "&fixmedins_code=" + miConfig.Code +
  33197. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33198. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33199. "&secret_key=" + miConfig.SecretKey +
  33200. "&org_name=" + miConfig.OrgName +
  33201. "&doctor=" + user_name
  33202. resp, requestErr := http.Get(api)
  33203. if requestErr != nil {
  33204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33205. return
  33206. }
  33207. body, ioErr := ioutil.ReadAll(resp.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. result, _ := json.Marshal(respJSON)
  33221. fmt.Println("log")
  33222. fmt.Println(string(result))
  33223. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  33224. utils.ErrorLog("解析失败:%v", err)
  33225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33226. return
  33227. }
  33228. res.InfRefmsgid = res10188.InfRefmsgid
  33229. res.Output = res10188.Output
  33230. res.ErrMsg = res10188.ErrMsg
  33231. res.Cainfo = res10188.Cainfo
  33232. res.WarnMsg = res10188.WarnMsg
  33233. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33234. res.Infcode = infocode
  33235. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33236. var baseParams models.BaseParams
  33237. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33238. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33239. baseParams.SecretKey = miConfig.SecretKey
  33240. baseParams.OrgName = miConfig.OrgName
  33241. baseParams.FixmedinsCode = miConfig.Code
  33242. baseParams.EncKey = miConfig.EncKey
  33243. baseParams.AppSecret = miConfig.AppSecret
  33244. baseParams.SignKey = miConfig.SignKey
  33245. baseParams.AppID = miConfig.Code
  33246. baseParams.Doctor = role.UserName
  33247. baseParams.RequestUrl = miConfig.Url
  33248. businessParams := models.BusinessParams{
  33249. Insutype: insutype,
  33250. ClrType: clr_type,
  33251. SetlOptins: clr_org,
  33252. StmtBegndate: start_time,
  33253. StmtEnddate: end_time,
  33254. MedfeeSumamt: medfee_sumamt,
  33255. FundPaySumamt: fund_pay_sumamt,
  33256. AcctPay: acct_pay,
  33257. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33258. }
  33259. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33260. fmt.Println(requestLog)
  33261. fmt.Println(result)
  33262. fmt.Println(err_msg)
  33263. var dat map[string]interface{}
  33264. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33265. fmt.Println(dat)
  33266. } else {
  33267. fmt.Println(err)
  33268. }
  33269. userJSONBytes, _ := json.Marshal(dat)
  33270. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33271. utils.ErrorLog("解析失败:%v", err)
  33272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33273. return
  33274. }
  33275. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33276. var baseParams models.BaseParams
  33277. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33278. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33279. baseParams.SecretKey = miConfig.SecretKey
  33280. baseParams.OrgName = miConfig.OrgName
  33281. baseParams.FixmedinsCode = miConfig.Code
  33282. baseParams.EncKey = miConfig.EncKey
  33283. baseParams.AppSecret = miConfig.AppSecret
  33284. baseParams.SignKey = miConfig.SignKey
  33285. baseParams.AppID = miConfig.Code
  33286. baseParams.Doctor = role.UserName
  33287. baseParams.RequestUrl = miConfig.Url
  33288. baseParams.AccessKey = miConfig.AccessKey
  33289. businessParams := models.BusinessParams{
  33290. Insutype: insutype,
  33291. ClrType: clr_type,
  33292. SetlOptins: "430822",
  33293. StmtBegndate: start_time,
  33294. StmtEnddate: end_time,
  33295. MedfeeSumamt: medfee_sumamt,
  33296. FundPaySumamt: fund_pay_sumamt,
  33297. AcctPay: acct_pay,
  33298. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33299. }
  33300. 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)
  33301. fmt.Println(requestLog)
  33302. fmt.Println(result)
  33303. var dat map[string]interface{}
  33304. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33305. fmt.Println(dat)
  33306. } else {
  33307. fmt.Println(err)
  33308. }
  33309. userJSONBytes, _ := json.Marshal(dat)
  33310. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33311. utils.ErrorLog("解析失败:%v", err)
  33312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33313. return
  33314. }
  33315. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33316. var baseParams models.BaseParams
  33317. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33318. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33319. baseParams.SecretKey = miConfig.SecretKey
  33320. baseParams.OrgName = miConfig.OrgName
  33321. baseParams.FixmedinsCode = miConfig.Code
  33322. baseParams.EncKey = miConfig.EncKey
  33323. baseParams.AppSecret = miConfig.AppSecret
  33324. baseParams.SignKey = miConfig.SignKey
  33325. baseParams.AppID = miConfig.Code
  33326. baseParams.Doctor = role.UserName
  33327. baseParams.RequestUrl = miConfig.Url
  33328. businessParams := models.BusinessParams{
  33329. Insutype: insutype,
  33330. ClrType: clr_type,
  33331. SetlOptins: clr_org,
  33332. StmtBegndate: start_time,
  33333. StmtEnddate: end_time,
  33334. MedfeeSumamt: medfee_sumamt,
  33335. FundPaySumamt: fund_pay_sumamt,
  33336. AcctPay: acct_pay,
  33337. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33338. }
  33339. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33340. fmt.Println(requestLog)
  33341. fmt.Println(result)
  33342. fmt.Println(err_msg)
  33343. var dat map[string]interface{}
  33344. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33345. fmt.Println(dat)
  33346. } else {
  33347. fmt.Println(err)
  33348. }
  33349. userJSONBytes, _ := json.Marshal(dat)
  33350. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33351. utils.ErrorLog("解析失败:%v", err)
  33352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33353. return
  33354. }
  33355. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33356. if len(clr_type) == 0 {
  33357. clr_type = "11"
  33358. }
  33359. api := miConfig.Url + "gdyb/ten?" +
  33360. "insutype=" + insutype +
  33361. "&clr_type=" + clr_type +
  33362. "&setl_optins=" + clr_org +
  33363. "&stmt_begndate=" + start_time +
  33364. "&stm_enddate=" + end_time +
  33365. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33366. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33367. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33368. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33369. "&fixmedins_code=" + miConfig.Code +
  33370. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33371. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33372. "&secret_key=" + miConfig.SecretKey +
  33373. "&org_name=" + miConfig.OrgName +
  33374. "&doctor=" + user_name
  33375. fmt.Println(api)
  33376. resp, requestErr := http.Get(api)
  33377. if requestErr != nil {
  33378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33379. return
  33380. }
  33381. body, ioErr := ioutil.ReadAll(resp.Body)
  33382. fmt.Println(body)
  33383. if ioErr != nil {
  33384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33386. return
  33387. }
  33388. var respJSON map[string]interface{}
  33389. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33392. return
  33393. }
  33394. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33395. userJSONBytes, _ := json.Marshal(respJSON)
  33396. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33397. utils.ErrorLog("解析失败:%v", err)
  33398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33399. return
  33400. }
  33401. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33402. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33403. //fixmedins_setl_cnt := int64(len(orders_two))
  33404. //var medfee_sumamt float64
  33405. //var acct_pay float64
  33406. //var fund_pay_sumamt float64
  33407. //for _, item := range orders_two {
  33408. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33409. // acct_pay = acct_pay + item.AcctPay
  33410. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33411. //}
  33412. var baseParams models.BaseParams
  33413. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33414. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33415. baseParams.SecretKey = miConfig.SecretKey
  33416. baseParams.OrgName = miConfig.OrgName
  33417. baseParams.FixmedinsCode = miConfig.Code
  33418. baseParams.EncKey = miConfig.EncKey
  33419. baseParams.AppSecret = miConfig.AppSecret
  33420. baseParams.SignKey = miConfig.SignKey
  33421. baseParams.AppID = miConfig.Code
  33422. baseParams.Doctor = role.UserName
  33423. baseParams.RequestUrl = miConfig.Url
  33424. if clr_type == "9903" {
  33425. clr_type = "9994"
  33426. }
  33427. businessParams := models.BusinessParams{
  33428. Insutype: insutype,
  33429. ClrType: clr_type,
  33430. SetlOptins: "360302",
  33431. StmtBegndate: start_time,
  33432. StmtEnddate: end_time,
  33433. MedfeeSumamt: 0,
  33434. FundPaySumamt: 0,
  33435. AcctPay: 0,
  33436. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33437. }
  33438. 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))
  33439. fmt.Println(requestLog)
  33440. fmt.Println(result)
  33441. var dat map[string]interface{}
  33442. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33443. fmt.Println(dat)
  33444. } else {
  33445. fmt.Println(err)
  33446. }
  33447. userJSONBytes, _ := json.Marshal(dat)
  33448. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33449. utils.ErrorLog("解析失败:%v", err)
  33450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33451. return
  33452. }
  33453. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33454. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33455. fixmedins_setl_cnt := int64(len(orders_two))
  33456. var medfee_sumamt float64
  33457. var acct_pay float64
  33458. var fund_pay_sumamt float64
  33459. for _, item := range orders_two {
  33460. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33461. acct_pay = acct_pay + item.AcctPay
  33462. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33463. }
  33464. var baseParams models.BaseParams
  33465. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33466. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33467. baseParams.SecretKey = miConfig.SecretKey
  33468. baseParams.OrgName = miConfig.OrgName
  33469. baseParams.FixmedinsCode = miConfig.Code
  33470. baseParams.EncKey = miConfig.EncKey
  33471. baseParams.AppSecret = miConfig.AppSecret
  33472. baseParams.SignKey = miConfig.SignKey
  33473. baseParams.AppID = miConfig.Code
  33474. baseParams.Doctor = role.UserName
  33475. baseParams.RequestUrl = miConfig.Url
  33476. if clr_type == "9903" {
  33477. clr_type = "9994"
  33478. }
  33479. businessParams := models.BusinessParams{
  33480. Insutype: insutype,
  33481. ClrType: clr_type,
  33482. SetlOptins: "361025",
  33483. StmtBegndate: start_time,
  33484. StmtEnddate: end_time,
  33485. MedfeeSumamt: 0,
  33486. FundPaySumamt: 0,
  33487. AcctPay: 0,
  33488. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33489. }
  33490. 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))
  33491. fmt.Println(requestLog)
  33492. fmt.Println(result)
  33493. var dat map[string]interface{}
  33494. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33495. fmt.Println(dat)
  33496. } else {
  33497. fmt.Println(err)
  33498. }
  33499. userJSONBytes, _ := json.Marshal(dat)
  33500. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33501. utils.ErrorLog("解析失败:%v", err)
  33502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33503. return
  33504. }
  33505. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33506. var api string
  33507. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33508. "&clr_type=" + clr_type +
  33509. "&setl_optins=" + clr_org +
  33510. "&stmt_begndate=" + start_time +
  33511. "&stm_enddate=" + end_time +
  33512. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33513. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33514. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33515. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33516. "&fixmedins_code=" + miConfig.Code +
  33517. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33518. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33519. "&secret_key=" + miConfig.SecretKey +
  33520. "&org_name=" + miConfig.OrgName +
  33521. "&doctor=" + user_name + "&url=" + miConfig.Url
  33522. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33523. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33524. resp, requestErr := http.Get(api)
  33525. if requestErr != nil {
  33526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33527. return
  33528. }
  33529. body, ioErr := ioutil.ReadAll(resp.Body)
  33530. if ioErr != nil {
  33531. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33533. return
  33534. }
  33535. var respJSON map[string]interface{}
  33536. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33539. return
  33540. }
  33541. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33542. if status == "0" {
  33543. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33544. c.ServeSuccessJSON(map[string]interface{}{
  33545. "failed_code": -10,
  33546. "msg": err_msg,
  33547. })
  33548. return
  33549. }
  33550. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33551. userJSONBytes, _ := json.Marshal(respJSON)
  33552. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33553. utils.ErrorLog("解析失败:%v", err)
  33554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33555. return
  33556. }
  33557. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33558. var api string
  33559. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33560. "&clr_type=" + clr_type +
  33561. "&setl_optins=" + clr_org +
  33562. "&stmt_begndate=" + start_time +
  33563. "&stm_enddate=" + end_time +
  33564. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33565. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33566. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33567. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33568. "&fixmedins_code=" + miConfig.Code +
  33569. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33570. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33571. "&secret_key=" + miConfig.SecretKey +
  33572. "&org_name=" + miConfig.OrgName +
  33573. "&doctor=" + user_name + "&url=" + miConfig.Url
  33574. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33575. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33576. resp, requestErr := http.Get(api)
  33577. if requestErr != nil {
  33578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33579. return
  33580. }
  33581. body, ioErr := ioutil.ReadAll(resp.Body)
  33582. if ioErr != nil {
  33583. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33585. return
  33586. }
  33587. var respJSON map[string]interface{}
  33588. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33591. return
  33592. }
  33593. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33594. if status == "0" {
  33595. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33596. c.ServeSuccessJSON(map[string]interface{}{
  33597. "failed_code": -10,
  33598. "msg": err_msg,
  33599. })
  33600. return
  33601. }
  33602. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33603. userJSONBytes, _ := json.Marshal(respJSON)
  33604. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33605. utils.ErrorLog("解析失败:%v", err)
  33606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33607. return
  33608. }
  33609. } else {
  33610. if len(clr_type) == 0 {
  33611. clr_type = "11"
  33612. }
  33613. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33614. "insutype=" + insutype +
  33615. "&clr_type=" + clr_type +
  33616. "&setl_optins=" + clr_org +
  33617. "&stmt_begndate=" + start_time +
  33618. "&stm_enddate=" + end_time +
  33619. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33620. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33621. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33622. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33623. "&fixmedins_code=" + miConfig.Code +
  33624. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33625. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33626. "&secret_key=" + miConfig.SecretKey +
  33627. "&org_name=" + miConfig.OrgName +
  33628. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33629. fmt.Println(api)
  33630. resp, requestErr := http.Get(api)
  33631. if requestErr != nil {
  33632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33633. return
  33634. }
  33635. body, ioErr := ioutil.ReadAll(resp.Body)
  33636. fmt.Println(body)
  33637. if ioErr != nil {
  33638. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33640. return
  33641. }
  33642. var respJSON map[string]interface{}
  33643. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33644. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33646. return
  33647. }
  33648. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33649. userJSONBytes, _ := json.Marshal(respJSON)
  33650. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33651. utils.ErrorLog("解析失败:%v", err)
  33652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33653. return
  33654. }
  33655. }
  33656. if res.Infcode == 0 {
  33657. if res.Output.Stmtinfo.StmtRslt == "0" {
  33658. micc := &models.MedicalInsuranceCostCompare{
  33659. StartTime: startime.Unix(),
  33660. EndTime: endtime.Unix(),
  33661. Insutype: insutype,
  33662. CheckType: 1,
  33663. Num: fixmedins_setl_cnt,
  33664. Mtime: time.Now().Unix(),
  33665. Status: 1,
  33666. UserOrgId: adminUser.CurrentOrgId,
  33667. CostTotal: medfee_sumamt,
  33668. FuncTotal: fund_pay_sumamt,
  33669. PsnPay: acct_pay,
  33670. Creator: admin_user_id,
  33671. Ctime: time.Now().Unix(),
  33672. ClrType: clr_type,
  33673. }
  33674. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  33675. if err == nil {
  33676. c.ServeSuccessJSON(map[string]interface{}{
  33677. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33678. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33679. })
  33680. } else {
  33681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33682. }
  33683. } else {
  33684. c.ServeSuccessJSON(map[string]interface{}{
  33685. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33686. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33687. })
  33688. }
  33689. } else {
  33690. c.ServeSuccessJSON(map[string]interface{}{
  33691. "failed_code": -10,
  33692. "msg": res.ErrMsg,
  33693. })
  33694. }
  33695. }
  33696. }
  33697. func (c *HisApiController) Check310() {
  33698. adminUser := c.GetAdminUserInfo()
  33699. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33700. var user_name string
  33701. user_name = "高慧裕"
  33702. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33703. "insutype=" + "310" +
  33704. "&clr_type=" + "" +
  33705. "&setl_optins=" + "441202" +
  33706. "&stmt_begndate=" + "2022-03-01" +
  33707. "&stm_enddate=" + "2022-03-31" +
  33708. "&medfee_sumamt=" + "194930.12" +
  33709. "&fund_pay_sumamt=" + "188741.46" +
  33710. "&acct_pay=" + "0" +
  33711. "&fixmedins_setl_cnt=" + "452" +
  33712. "&fixmedins_code=" + miConfig.Code +
  33713. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33714. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33715. "&secret_key=" + miConfig.SecretKey +
  33716. "&org_name=" + miConfig.OrgName +
  33717. "&doctor=" + user_name
  33718. fmt.Println(api)
  33719. resp, requestErr := http.Get(api)
  33720. if requestErr != nil {
  33721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33722. return
  33723. }
  33724. body, ioErr := ioutil.ReadAll(resp.Body)
  33725. fmt.Println(body)
  33726. if ioErr != nil {
  33727. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33729. return
  33730. }
  33731. var respJSON map[string]interface{}
  33732. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33733. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33735. return
  33736. }
  33737. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33738. userJSONBytes, _ := json.Marshal(respJSON)
  33739. var res ResultEight
  33740. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33741. utils.ErrorLog("解析失败:%v", err)
  33742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33743. return
  33744. }
  33745. }
  33746. func (c *HisApiController) Check390() {
  33747. adminUser := c.GetAdminUserInfo()
  33748. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33749. var user_name string
  33750. user_name = "高慧裕"
  33751. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33752. "insutype=" + "390" +
  33753. "&clr_type=" + "" +
  33754. "&setl_optins=" + "441202" +
  33755. "&stmt_begndate=" + "2022-03-01" +
  33756. "&stm_enddate=" + "2022-03-31" +
  33757. "&medfee_sumamt=" + "1068448.89" +
  33758. "&fund_pay_sumamt=" + "1014677.62" +
  33759. "&acct_pay=" + "0" +
  33760. "&fixmedins_setl_cnt=" + "1950" +
  33761. "&fixmedins_code=" + miConfig.Code +
  33762. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33763. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33764. "&secret_key=" + miConfig.SecretKey +
  33765. "&org_name=" + miConfig.OrgName +
  33766. "&doctor=" + user_name
  33767. fmt.Println(api)
  33768. resp, requestErr := http.Get(api)
  33769. if requestErr != nil {
  33770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33771. return
  33772. }
  33773. body, ioErr := ioutil.ReadAll(resp.Body)
  33774. fmt.Println(body)
  33775. if ioErr != nil {
  33776. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33778. return
  33779. }
  33780. var respJSON map[string]interface{}
  33781. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33784. return
  33785. }
  33786. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33787. userJSONBytes, _ := json.Marshal(respJSON)
  33788. var res ResultEight
  33789. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33790. utils.ErrorLog("解析失败:%v", err)
  33791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33792. return
  33793. }
  33794. }
  33795. // 对账明细
  33796. func (c *HisApiController) GetCheckDetailAccount() {
  33797. start_time := c.GetString("start_time")
  33798. end_time := c.GetString("end_time")
  33799. admin_user_id, _ := c.GetInt64("admin_user_id")
  33800. adminUser := c.GetAdminUserInfo()
  33801. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33802. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33803. timeLayout := "2006-01-02"
  33804. loc, _ := time.LoadLocation("Local")
  33805. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33806. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33807. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  33808. rand.Seed(time.Now().UnixNano())
  33809. num := rand.Intn(30000)
  33810. Mkdir(miConfig.OrgName)
  33811. file := strconv.FormatInt(int64(num), 10)
  33812. file_name := file + ".txt"
  33813. zip_name := file + ".zip"
  33814. zip_path := miConfig.OrgName + "/" + zip_name
  33815. file_path := miConfig.OrgName + "/" + file_name
  33816. decimal.DivisionPrecision = 2
  33817. var medfee_sumamt float64
  33818. var psn_cash_pay float64
  33819. var fund_pay_sumamt float64
  33820. fixmedins_setl_cnt := int64(len(orders))
  33821. for _, item := range orders {
  33822. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33823. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  33824. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33825. }
  33826. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  33827. defer f.Close()
  33828. if err != nil {
  33829. fmt.Println(err.Error())
  33830. } else {
  33831. for _, item := range orders {
  33832. var refd_setl_flag string
  33833. if item.OrderStatus == 2 {
  33834. refd_setl_flag = "0"
  33835. var str string
  33836. str = item.SetlId + " " +
  33837. item.MdtrtId + " " +
  33838. item.PsnNo + " " +
  33839. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33840. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33841. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  33842. _, err = f.Write([]byte(str))
  33843. }
  33844. if item.OrderStatus == 3 {
  33845. var str string
  33846. str = item.SetlId + " " +
  33847. item.MdtrtId + " " +
  33848. item.PsnNo + " " +
  33849. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33850. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33851. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  33852. _, err = f.Write([]byte(str))
  33853. var str2 string
  33854. str2 = item.SetlId + " " +
  33855. item.MdtrtId + " " +
  33856. item.PsnNo + " " +
  33857. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  33858. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  33859. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  33860. _, err = f.Write([]byte(str2))
  33861. }
  33862. }
  33863. }
  33864. Zip(file_path, zip_path)
  33865. fmt.Println(ReadFile(zip_path))
  33866. fmt.Println(string(ReadFile(zip_path)))
  33867. if config.IsOpen == 1 {
  33868. var user_name string
  33869. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33870. if role.ID == 0 {
  33871. user_name = "管理员"
  33872. } else {
  33873. user_name = role.UserName
  33874. }
  33875. baseParams := models.BaseParams{
  33876. SecretKey: miConfig.SecretKey,
  33877. FixmedinsCode: miConfig.Code,
  33878. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  33879. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  33880. OrgName: miConfig.OrgName,
  33881. Doctor: user_name,
  33882. }
  33883. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  33884. var dat map[string]interface{}
  33885. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33886. fmt.Println(dat)
  33887. } else {
  33888. fmt.Println(err)
  33889. }
  33890. userJSONBytes, _ := json.Marshal(dat)
  33891. var res ResultNine
  33892. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33893. utils.ErrorLog("解析失败:%v", err)
  33894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33895. return
  33896. }
  33897. if res.Infcode == 0 {
  33898. fileNo := res.Output.FileQuryNo
  33899. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  33900. "file_qury_no=" + fileNo +
  33901. "&setl_optins=" + "定点医保中心" +
  33902. "&stmt_begndate=" + start_time +
  33903. "&stm_enddate=" + end_time +
  33904. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33905. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33906. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  33907. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33908. "&fixmedins_code=" + miConfig.Code +
  33909. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33910. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33911. "&secret_key=" + miConfig.SecretKey +
  33912. "&org_name=" + miConfig.OrgName +
  33913. "&doctor=" + user_name
  33914. resp, requestErr := http.Get(api)
  33915. if requestErr != nil {
  33916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33917. return
  33918. }
  33919. body, ioErr := ioutil.ReadAll(resp.Body)
  33920. if ioErr != nil {
  33921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33923. return
  33924. }
  33925. var respJSON map[string]interface{}
  33926. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33929. return
  33930. }
  33931. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33932. userJSONBytes, _ := json.Marshal(respJSON)
  33933. var res ResultTen
  33934. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33935. utils.ErrorLog("解析失败:%v", err)
  33936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33937. return
  33938. }
  33939. if res.Infcode == 0 {
  33940. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  33941. micc := &models.MedicalInsuranceCostCompare{
  33942. StartTime: startime.Unix(),
  33943. EndTime: endtime.Unix(),
  33944. Insutype: "0",
  33945. CheckType: 2,
  33946. Num: fixmedins_setl_cnt,
  33947. Mtime: time.Now().Unix(),
  33948. Status: 1,
  33949. UserOrgId: adminUser.CurrentOrgId,
  33950. CostTotal: medfee_sumamt,
  33951. FuncTotal: fund_pay_sumamt,
  33952. PsnPay: psn_cash_pay,
  33953. Creator: admin_user_id,
  33954. Ctime: time.Now().Unix(),
  33955. }
  33956. service.CreateMedicalInsuranceCostCompareRecord(micc)
  33957. c.ServeSuccessJSON(map[string]interface{}{
  33958. "msg": "明细对账成功",
  33959. })
  33960. }
  33961. } else {
  33962. }
  33963. }
  33964. }
  33965. type CustomOrderInfo struct {
  33966. Name string
  33967. Spec string
  33968. Unit string
  33969. Count float64
  33970. Price float64
  33971. Total float64
  33972. }
  33973. func (c *HisApiController) GetBatchSettleAccounts() {
  33974. admin_user_id, _ := c.GetInt64("admin_user_id")
  33975. order_ids := c.GetString("order_ids")
  33976. order_ids_arr := strings.Split(order_ids, ",")
  33977. data3 := []map[string]interface{}{}
  33978. for _, item := range order_ids_arr {
  33979. id, _ := strconv.ParseInt(item, 10, 64)
  33980. order_id := id
  33981. adminUser := c.GetAdminUserInfo()
  33982. order, _ := service.GetHisOrderByID(order_id)
  33983. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  33984. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  33985. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  33986. orderInfos = append(orderInfos, orderInfos_two...)
  33987. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  33988. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  33989. var diagnosis_ids []string
  33990. if his.ID > 0 {
  33991. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  33992. } else {
  33993. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  33994. }
  33995. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  33996. var dia_config []*models.HisXtDiagnoseConfig
  33997. var name string
  33998. for _, item := range diagnosis_ids {
  33999. id, _ := strconv.ParseInt(item, 10, 64)
  34000. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34001. dia_config = append(dia_config, &diagnosisConfig)
  34002. if len(name) == 0 {
  34003. name = diagnosisConfig.ClassName
  34004. }
  34005. //} else {
  34006. // name = name + "," + diagnosisConfig.ClassName
  34007. //}
  34008. }
  34009. var bedCostTotal float64 = 0 //床位总费
  34010. var bedCostSelfTotal float64 = 0 //床位自费
  34011. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34012. var bedSelfTotal float64 = 0 //床位部分项目自费
  34013. var bedInscpTotal float64 = 0 //床位部分项目自费
  34014. var operationCostTotal float64 = 0 //手术费
  34015. var operationCostSelfTotal float64 = 0 //手术费
  34016. var operationCostPartSelfTotal float64 = 0 //手术费
  34017. var operationSelfTotal float64 = 0 //床位部分项目自费
  34018. var operationInscpTotal float64 = 0 //床位部分项目自费
  34019. var otherCostTotal float64 = 0 //其他费用
  34020. var otherCostSelfTotal float64 = 0 //其他费用
  34021. var otherCostPartSelfTotal float64 = 0 //其他费用
  34022. var otherSelfTotal float64 = 0 //床位部分项目自费
  34023. var otherInscpTotal float64 = 0 //床位部分项目自费
  34024. var materialCostTotal float64 = 0 //材料费
  34025. var materialCostSelfTotal float64 = 0 //材料费
  34026. var materialCostPartSelfTotal float64 = 0 //材料费
  34027. var materialSelfTotal float64 = 0 //床位部分项目自费
  34028. var materialInscpTotal float64 = 0 //床位部分项目自费
  34029. var westernMedicineCostTotal float64 = 0 //西药费
  34030. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34031. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34032. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34033. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34034. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34035. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34036. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34037. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34038. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34039. var checkCostTotal float64 = 0 //检查费
  34040. var checkCostSelfTotal float64 = 0 //检查费
  34041. var checkCostPartSelfTotal float64 = 0 //检查费
  34042. var checkSelfTotal float64 = 0 //床位部分项目自费
  34043. var checkInscpTotal float64 = 0 //床位部分项目自费
  34044. var laboratoryCostTotal float64 = 0 //化验费
  34045. var laboratoryCostSelfTotal float64 = 0 //化验费
  34046. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34047. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34048. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34049. var treatCostTotal float64 = 0 //治疗费用
  34050. var treatCostSelfTotal float64 = 0 //治疗费用
  34051. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34052. var treatSelfTotal float64 = 0 //床位部分项目自费
  34053. var treatInscpTotal float64 = 0 //床位部分项目自费
  34054. decimal.DivisionPrecision = 2
  34055. for _, item := range orderInfos {
  34056. if item.MedChrgitmType == "01" { //床位费
  34057. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34058. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34059. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34060. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34061. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34062. }
  34063. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34064. if item.MedChrgitmType == "03" { //检查费
  34065. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34066. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34067. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34068. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34069. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34070. }
  34071. } else {
  34072. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34073. fmt.Println("------------")
  34074. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34075. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34076. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34077. }
  34078. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34079. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34080. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34081. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34082. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34083. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34084. }
  34085. }
  34086. if item.MedChrgitmType == "04" { //化验费
  34087. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34088. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34089. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34090. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34091. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34092. }
  34093. if item.MedChrgitmType == "05" { //治疗费
  34094. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34095. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34096. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34097. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34098. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34099. }
  34100. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34101. fmt.Println("------------")
  34102. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34103. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34104. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34105. }
  34106. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34107. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34108. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34109. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34110. }
  34111. //if item.MedChrgitmType == "06" { //手术费
  34112. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34113. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34114. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34115. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34116. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34117. //
  34118. //}
  34119. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34120. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34121. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34122. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34123. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34124. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34125. }
  34126. if item.MedChrgitmType == "09" { //西药费
  34127. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34128. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34129. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34130. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34131. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34132. }
  34133. if item.MedChrgitmType == "11" { //中成费
  34134. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34135. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34136. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34137. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34138. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34139. }
  34140. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  34141. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34142. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34143. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34144. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34145. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34146. }
  34147. }
  34148. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34149. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34150. var user_name string
  34151. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34152. if role.ID == 0 {
  34153. user_name = "管理员"
  34154. } else {
  34155. user_name = role.UserName
  34156. }
  34157. baseParams := models.BaseParams{
  34158. SecretKey: miConfig.SecretKey,
  34159. FixmedinsCode: miConfig.Code,
  34160. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34161. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34162. OrgName: miConfig.OrgName,
  34163. Doctor: user_name,
  34164. RequestUrl: miConfig.Url,
  34165. AccessKey: miConfig.AccessKey,
  34166. }
  34167. businessParams := models.BusinessParams{
  34168. PsnNo: order.PsnNo,
  34169. MdtrtId: order.MdtrtId,
  34170. SetlId: order.SetlId,
  34171. }
  34172. var res ResultEleven
  34173. var resEleven10265 ResultEleven10265
  34174. if config.IsOpen == 1 {
  34175. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34176. result := service.Gdyb5203(baseParams, businessParams)
  34177. service.Gdyb5204(baseParams, businessParams)
  34178. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  34179. var dat map[string]interface{}
  34180. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34181. fmt.Println(dat)
  34182. } else {
  34183. fmt.Println(err)
  34184. }
  34185. userJSONBytes, _ := json.Marshal(dat)
  34186. if miConfig.Code == "H15049901371" {
  34187. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  34188. utils.ErrorLog("解析失败:%v", err)
  34189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34190. return
  34191. }
  34192. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34193. res.Output = resEleven10265.Output
  34194. res.ErrMsg = resEleven10265.ErrMsg
  34195. res.Cainfo = resEleven10265.Cainfo
  34196. res.WarnMsg = resEleven10265.WarnMsg
  34197. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34198. res.Infcode = infocode
  34199. } else {
  34200. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34201. utils.ErrorLog("解析失败:%v", err)
  34202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34203. return
  34204. }
  34205. }
  34206. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34207. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34208. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34209. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34210. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34211. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34212. var doctor_name string
  34213. if roles.ID == 0 {
  34214. doctor_name = "管理员"
  34215. } else {
  34216. doctor_name = roles.UserName
  34217. }
  34218. yiliao_leibie := ""
  34219. switch order.MedType {
  34220. case "11":
  34221. yiliao_leibie = "普通门诊"
  34222. break
  34223. case "12":
  34224. yiliao_leibie = "门诊挂号"
  34225. break
  34226. case "13":
  34227. yiliao_leibie = "急诊"
  34228. break
  34229. case "14":
  34230. yiliao_leibie = "门诊特殊病"
  34231. break
  34232. case "15":
  34233. yiliao_leibie = "门诊统筹"
  34234. break
  34235. case "16":
  34236. yiliao_leibie = "门诊慢性病"
  34237. break
  34238. case "21":
  34239. yiliao_leibie = "普通住院"
  34240. break
  34241. }
  34242. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34243. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  34244. if res.Infcode == 0 {
  34245. data2 := map[string]interface{}{
  34246. "diagnosis": name,
  34247. "order_infos": orderInfos,
  34248. "number": order.MdtrtId,
  34249. "date": order.SettleAccountsDate,
  34250. "charge_admin": charge_admin,
  34251. "printor_admin": printor_admin,
  34252. "info": res.Output.Setlinfo,
  34253. "order": order,
  34254. "bedCostTotal": bedCostTotal,
  34255. "bedCostSelfTotal": bedCostSelfTotal,
  34256. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34257. "bedSelfTotal": bedSelfTotal,
  34258. "bedInscpTotal": bedInscpTotal,
  34259. "operationCostTotal": operationCostTotal,
  34260. "operationCostSelfTotal": operationCostSelfTotal,
  34261. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34262. "operationSelfTotal": operationSelfTotal,
  34263. "operationInscpTotal": operationInscpTotal,
  34264. "otherCostTotal": otherCostTotal,
  34265. "otherCostSelfTotal": otherCostSelfTotal,
  34266. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34267. "otherSelfTotal": otherSelfTotal,
  34268. "otherInscpTotal": otherInscpTotal,
  34269. "materialCostTotal": materialCostTotal,
  34270. "materialCostSelfTotal": materialCostSelfTotal,
  34271. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34272. "materialSelfTotal": materialSelfTotal,
  34273. "materialInscpTotal": materialInscpTotal,
  34274. "westernMedicineCostTotal": westernMedicineCostTotal,
  34275. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34276. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34277. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34278. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34279. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34280. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34281. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34282. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34283. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34284. "checkCostTotal": checkCostTotal,
  34285. "checkCostSelfTotal": checkCostSelfTotal,
  34286. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34287. "checkSelfTotal": checkSelfTotal,
  34288. "checkInscpTotal": checkInscpTotal,
  34289. "laboratoryCostTotal": laboratoryCostTotal,
  34290. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34291. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34292. "laboratorySelfTotal": laboratorySelfTotal,
  34293. "laboratoryInscpTotal": laboratoryInscpTotal,
  34294. "treatCostTotal": treatCostTotal,
  34295. "treatCostSelfTotal": treatCostSelfTotal,
  34296. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34297. "treatSelfTotal": treatSelfTotal,
  34298. "treatInscpTotal": treatInscpTotal,
  34299. "doctor_info": doctor_info,
  34300. "doctor_code": adminRole_two.DoctorCode,
  34301. "doctor_name": doctor_name,
  34302. "health_card_no": order.PsnNo,
  34303. "department": departments.Name,
  34304. "yiliao_leibie": yiliao_leibie,
  34305. "after_money": order.AccountPrice,
  34306. "patient": patient,
  34307. "org_name": miConfig.OrgName,
  34308. "org_code": miConfig.Code,
  34309. "order_number": order.Number,
  34310. "his_hospital": his_hospital,
  34311. "his": his,
  34312. "dia_config": dia_config,
  34313. "psn_cash_pay": order.PsnCashPay,
  34314. //"check_order_info": cus_slice,
  34315. }
  34316. data3 = append(data3, data2)
  34317. }
  34318. }
  34319. }
  34320. c.ServeSuccessJSON(map[string]interface{}{
  34321. "infos": data3,
  34322. })
  34323. }
  34324. func (c *HisApiController) GetSettleAccounts() {
  34325. //id, _ := c.GetInt64("id")
  34326. //record_time := c.GetString("record_time")
  34327. order_id, _ := c.GetInt64("order_id")
  34328. admin_user_id, _ := c.GetInt64("admin_user_id")
  34329. //timeLayout := "2006-01-02"
  34330. //loc, _ := time.LoadLocation("Local")
  34331. //
  34332. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34333. //if err != nil {
  34334. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34335. // return
  34336. //}Hbyb5203
  34337. //recordDateTime := theTime.Unix()
  34338. adminUser := c.GetAdminUserInfo()
  34339. order, _ := service.GetHisOrderByID(order_id)
  34340. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34341. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34342. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34343. orderInfos = append(orderInfos, orderInfos_two...)
  34344. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34345. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34346. var diagnosis_ids []string
  34347. if his.ID > 0 {
  34348. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34349. } else {
  34350. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34351. }
  34352. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34353. var dia_config []*models.HisXtDiagnoseConfig
  34354. var name string
  34355. for _, item := range diagnosis_ids {
  34356. id, _ := strconv.ParseInt(item, 10, 64)
  34357. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34358. dia_config = append(dia_config, &diagnosisConfig)
  34359. if len(name) == 0 {
  34360. name = diagnosisConfig.ClassName
  34361. } else {
  34362. name = name + "," + diagnosisConfig.ClassName
  34363. }
  34364. }
  34365. if patient.UserOrgId == 10215 {
  34366. name = "慢性肾功能不全(血透治疗)"
  34367. }
  34368. var bedCostTotal float64 = 0 //床位总费
  34369. var bedCostSelfTotal float64 = 0 //床位自费
  34370. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34371. var bedSelfTotal float64 = 0 //床位部分项目自费
  34372. var bedInscpTotal float64 = 0 //床位部分项目自费
  34373. var operationCostTotal float64 = 0 //手术费
  34374. var operationCostSelfTotal float64 = 0 //手术费
  34375. var operationCostPartSelfTotal float64 = 0 //手术费
  34376. var operationSelfTotal float64 = 0 //床位部分项目自费
  34377. var operationInscpTotal float64 = 0 //床位部分项目自费
  34378. var otherCostTotal float64 = 0 //其他费用
  34379. var otherCostSelfTotal float64 = 0 //其他费用
  34380. var otherCostPartSelfTotal float64 = 0 //其他费用
  34381. var otherSelfTotal float64 = 0 //床位部分项目自费
  34382. var otherInscpTotal float64 = 0 //床位部分项目自费
  34383. var materialCostTotal float64 = 0 //材料费
  34384. var materialCostSelfTotal float64 = 0 //材料费
  34385. var materialCostPartSelfTotal float64 = 0 //材料费
  34386. var materialSelfTotal float64 = 0 //床位部分项目自费
  34387. var materialInscpTotal float64 = 0 //床位部分项目自费
  34388. var westernMedicineCostTotal float64 = 0 //西药费
  34389. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34390. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34391. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34392. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34393. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34394. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34395. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34396. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34397. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34398. var checkCostTotal float64 = 0 //检查费
  34399. var checkCostSelfTotal float64 = 0 //检查费
  34400. var checkCostPartSelfTotal float64 = 0 //检查费
  34401. var checkSelfTotal float64 = 0 //床位部分项目自费
  34402. var checkInscpTotal float64 = 0 //床位部分项目自费
  34403. var laboratoryCostTotal float64 = 0 //化验费
  34404. var laboratoryCostSelfTotal float64 = 0 //化验费
  34405. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34406. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34407. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34408. var treatCostTotal float64 = 0 //治疗费用
  34409. var treatCostSelfTotal float64 = 0 //治疗费用
  34410. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34411. var treatSelfTotal float64 = 0 //床位部分项目自费
  34412. var treatInscpTotal float64 = 0 //床位部分项目自费
  34413. var zcCostTotal float64 = 0 //治疗费用
  34414. var zcCostSelfTotal float64 = 0 //治疗费用
  34415. var zcCostPartSelfTotal float64 = 0 //治疗费用
  34416. var zcSelfTotal float64 = 0 //床位部分项目自费
  34417. var zcInscpTotal float64 = 0 //床位部分项目自费
  34418. var huliCostTotal float64 = 0 //治疗费用
  34419. var huliCostSelfTotal float64 = 0 //治疗费用
  34420. var huliCostPartSelfTotal float64 = 0 //治疗费用
  34421. var huliSelfTotal float64 = 0 //床位部分项目自费
  34422. var huliInscpTotal float64 = 0 //床位部分项目自费
  34423. decimal.DivisionPrecision = 2
  34424. for _, item := range orderInfos {
  34425. if item.MedChrgitmType == "01" { //床位费
  34426. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34427. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34428. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34429. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34430. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34431. }
  34432. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34433. if item.MedChrgitmType == "03" { //检查费
  34434. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34435. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34436. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34437. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34438. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34439. }
  34440. } else {
  34441. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34442. fmt.Println("------------")
  34443. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34444. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34445. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34446. }
  34447. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34448. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34449. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34450. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34451. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34452. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34453. }
  34454. }
  34455. if item.MedChrgitmType == "04" { //化验费
  34456. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34457. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34458. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34459. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34460. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34461. }
  34462. if item.MedChrgitmType == "05" { //治疗费
  34463. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34464. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34465. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34466. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34467. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34468. }
  34469. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34470. fmt.Println("------------")
  34471. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34472. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34473. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34474. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34475. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34476. }
  34477. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34478. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34479. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34480. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34481. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34482. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34483. }
  34484. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34485. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34486. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34487. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34488. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34489. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34490. }
  34491. if item.MedChrgitmType == "09" { //西药费
  34492. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34493. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34494. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34495. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34496. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34497. }
  34498. if item.MedChrgitmType == "11" { //中成费
  34499. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34500. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34501. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34502. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34503. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34504. }
  34505. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  34506. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34507. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34508. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34509. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34510. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34511. }
  34512. if item.MedChrgitmType == "02" { //其他费
  34513. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34514. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34515. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34516. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34517. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34518. }
  34519. if item.MedChrgitmType == "07" { //其他费
  34520. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34521. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34522. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34523. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34524. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34525. }
  34526. }
  34527. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34528. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34529. var user_name string
  34530. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34531. if role.ID == 0 {
  34532. user_name = "管理员"
  34533. } else {
  34534. user_name = role.UserName
  34535. }
  34536. baseParams := models.BaseParams{
  34537. SecretKey: miConfig.SecretKey,
  34538. FixmedinsCode: miConfig.Code,
  34539. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34540. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34541. OrgName: miConfig.OrgName,
  34542. Doctor: user_name,
  34543. RequestUrl: miConfig.Url,
  34544. AccessKey: miConfig.AccessKey,
  34545. }
  34546. businessParams := models.BusinessParams{
  34547. PsnNo: order.PsnNo,
  34548. MdtrtId: order.MdtrtId,
  34549. SetlId: order.SetlId,
  34550. }
  34551. var res ResultEleven
  34552. var resah ResultElevenah
  34553. var resEleven10265 ResultEleven10265
  34554. if config.IsOpen == 1 {
  34555. if miConfig.MdtrtareaAdmvs == "421300" {
  34556. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34557. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34558. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34559. resp, requestErr := http.Get(api)
  34560. if requestErr != nil {
  34561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34562. return
  34563. }
  34564. body, ioErr := ioutil.ReadAll(resp.Body)
  34565. if ioErr != nil {
  34566. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34568. return
  34569. }
  34570. var respJSON map[string]interface{}
  34571. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34572. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34574. return
  34575. }
  34576. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34577. result, _ := json.Marshal(respJSON)
  34578. fmt.Println("log")
  34579. fmt.Println(string(result))
  34580. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34581. utils.ErrorLog("解析失败:%v", err)
  34582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34583. return
  34584. }
  34585. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34586. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34587. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34588. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34589. resp, requestErr := http.Get(api)
  34590. if requestErr != nil {
  34591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34592. return
  34593. }
  34594. body, ioErr := ioutil.ReadAll(resp.Body)
  34595. if ioErr != nil {
  34596. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34598. return
  34599. }
  34600. var respJSON map[string]interface{}
  34601. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34604. return
  34605. }
  34606. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34607. result, _ := json.Marshal(respJSON)
  34608. fmt.Println("log")
  34609. fmt.Println(string(result))
  34610. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34611. utils.ErrorLog("解析失败:%v", err)
  34612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34613. return
  34614. }
  34615. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34616. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34617. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34618. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34619. resp, requestErr := http.Get(api)
  34620. if requestErr != nil {
  34621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34622. return
  34623. }
  34624. body, ioErr := ioutil.ReadAll(resp.Body)
  34625. if ioErr != nil {
  34626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34628. return
  34629. }
  34630. var respJSON map[string]interface{}
  34631. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34634. return
  34635. }
  34636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34637. result, _ := json.Marshal(respJSON)
  34638. fmt.Println("log")
  34639. fmt.Println(string(result))
  34640. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34641. utils.ErrorLog("解析失败:%v", err)
  34642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34643. return
  34644. }
  34645. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34646. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34647. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34648. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  34649. resp, requestErr := http.Get(api)
  34650. if requestErr != nil {
  34651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34652. return
  34653. }
  34654. body, ioErr := ioutil.ReadAll(resp.Body)
  34655. if ioErr != nil {
  34656. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34658. return
  34659. }
  34660. var respJSON map[string]interface{}
  34661. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34664. return
  34665. }
  34666. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34667. result, _ := json.Marshal(respJSON)
  34668. fmt.Println("log")
  34669. fmt.Println(string(result))
  34670. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34671. utils.ErrorLog("解析失败:%v", err)
  34672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34673. return
  34674. }
  34675. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34676. var api string
  34677. if miConfig.MdtrtareaAdmvs == "320921" {
  34678. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34679. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34680. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34681. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34682. } else {
  34683. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34684. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34685. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34686. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34687. }
  34688. resp, requestErr := http.Get(api)
  34689. if requestErr != nil {
  34690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34691. return
  34692. }
  34693. body, ioErr := ioutil.ReadAll(resp.Body)
  34694. if ioErr != nil {
  34695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34697. return
  34698. }
  34699. var respJSON map[string]interface{}
  34700. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34703. return
  34704. }
  34705. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34706. result, _ := json.Marshal(respJSON)
  34707. fmt.Println("log")
  34708. fmt.Println(string(result))
  34709. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34710. utils.ErrorLog("解析失败:%v", err)
  34711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34712. return
  34713. }
  34714. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34715. res.Output = resEleven10265.Output
  34716. res.ErrMsg = resEleven10265.ErrMsg
  34717. res.Cainfo = resEleven10265.Cainfo
  34718. res.WarnMsg = resEleven10265.WarnMsg
  34719. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34720. res.Infcode = infocode
  34721. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34722. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  34723. saveLog(result, requestLog, "5203", "结算单")
  34724. var dat map[string]interface{}
  34725. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34726. fmt.Println(dat)
  34727. } else {
  34728. fmt.Println(err)
  34729. }
  34730. userJSONBytes, _ := json.Marshal(dat)
  34731. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34732. utils.ErrorLog("解析失败:%v", err)
  34733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34734. return
  34735. }
  34736. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34737. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34738. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34739. saveLog(result, requestLog, "5203", "结算单")
  34740. var dat map[string]interface{}
  34741. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34742. fmt.Println(dat)
  34743. } else {
  34744. fmt.Println(err)
  34745. }
  34746. userJSONBytes, _ := json.Marshal(dat)
  34747. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34748. utils.ErrorLog("解析失败:%v", err)
  34749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34750. return
  34751. }
  34752. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34753. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34754. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34755. saveLog(result, requestLog, "5203", "结算单")
  34756. var dat map[string]interface{}
  34757. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34758. fmt.Println(dat)
  34759. } else {
  34760. fmt.Println(err)
  34761. }
  34762. userJSONBytes, _ := json.Marshal(dat)
  34763. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34764. utils.ErrorLog("解析失败:%v", err)
  34765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34766. return
  34767. }
  34768. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34769. var api string
  34770. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34771. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34772. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34773. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34774. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34775. resp, requestErr := http.Get(api)
  34776. if requestErr != nil {
  34777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34778. return
  34779. }
  34780. body, ioErr := ioutil.ReadAll(resp.Body)
  34781. if ioErr != nil {
  34782. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34784. return
  34785. }
  34786. var respJSON map[string]interface{}
  34787. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34790. return
  34791. }
  34792. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34793. if status == "0" {
  34794. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34795. c.ServeSuccessJSON(map[string]interface{}{
  34796. "failed_code": -10,
  34797. "msg": err_msg,
  34798. })
  34799. return
  34800. }
  34801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34802. result, _ := json.Marshal(respJSON)
  34803. fmt.Println("log")
  34804. fmt.Println(string(result))
  34805. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  34806. utils.ErrorLog("解析失败:%v", err)
  34807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34808. return
  34809. }
  34810. res.InfRefmsgid = resah.InfRefmsgid
  34811. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34812. // 创建对应的Time类型
  34813. t := time.UnixMilli(timestamp)
  34814. // 格式化成指定的日期字符串
  34815. str := t.Format("2006-01-02 15:04:05")
  34816. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34817. // 创建对应的Time类型
  34818. t3 := time.UnixMilli(timestamp2)
  34819. // 格式化成指定的日期字符串
  34820. str2 := t3.Format("2006-01-02 15:04:05")
  34821. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  34822. // 创建对应的Time类型
  34823. t4 := time.UnixMilli(timestamp3)
  34824. // 格式化成指定的日期字符串
  34825. str3 := t4.Format("2006-01-02 15:04:05")
  34826. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  34827. // 创建对应的Time类型
  34828. t5 := time.UnixMilli(timestamp4)
  34829. // 格式化成指定的日期字符串
  34830. str5 := t5.Format("2006-01-02 15:04:05")
  34831. res.Output.Setlinfo.Brdy = str2
  34832. res.Output.Setlinfo.SetlTime = str
  34833. res.Output.Setlinfo.Begndate = str3
  34834. res.Output.Setlinfo.Enddate = str5
  34835. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  34836. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  34837. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  34838. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  34839. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34840. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34841. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  34842. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  34843. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34844. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  34845. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  34846. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  34847. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  34848. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  34849. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  34850. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  34851. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  34852. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  34853. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34854. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  34855. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  34856. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34857. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  34858. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  34859. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  34860. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  34861. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  34862. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  34863. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  34864. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  34865. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  34866. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  34867. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34868. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  34869. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  34870. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  34871. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  34872. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  34873. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  34874. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  34875. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  34876. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  34877. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  34878. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  34879. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  34880. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  34881. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  34882. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  34883. //res.Output.Setldetail = resah.Output.Setldetail
  34884. res.ErrMsg = resah.ErrMsg
  34885. res.Cainfo = resah.Cainfo
  34886. res.WarnMsg = resah.WarnMsg
  34887. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34888. var api string
  34889. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34890. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34891. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34892. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34893. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34894. resp, requestErr := http.Get(api)
  34895. if requestErr != nil {
  34896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34897. return
  34898. }
  34899. body, ioErr := ioutil.ReadAll(resp.Body)
  34900. if ioErr != nil {
  34901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34903. return
  34904. }
  34905. var respJSON map[string]interface{}
  34906. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34909. return
  34910. }
  34911. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34912. if status == "0" {
  34913. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34914. c.ServeSuccessJSON(map[string]interface{}{
  34915. "failed_code": -10,
  34916. "msg": err_msg,
  34917. })
  34918. return
  34919. }
  34920. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34921. result, _ := json.Marshal(respJSON)
  34922. fmt.Println("log")
  34923. fmt.Println(string(result))
  34924. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  34925. utils.ErrorLog("解析失败:%v", err)
  34926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34927. return
  34928. }
  34929. res.InfRefmsgid = resah.InfRefmsgid
  34930. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34931. // 创建对应的Time类型
  34932. t := time.UnixMilli(timestamp)
  34933. // 格式化成指定的日期字符串
  34934. str := t.Format("2006-01-02 15:04:05")
  34935. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34936. // 创建对应的Time类型
  34937. t3 := time.UnixMilli(timestamp2)
  34938. // 格式化成指定的日期字符串
  34939. str2 := t3.Format("2006-01-02 15:04:05")
  34940. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  34941. // 创建对应的Time类型
  34942. t4 := time.UnixMilli(timestamp3)
  34943. // 格式化成指定的日期字符串
  34944. str3 := t4.Format("2006-01-02 15:04:05")
  34945. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  34946. // 创建对应的Time类型
  34947. t5 := time.UnixMilli(timestamp4)
  34948. // 格式化成指定的日期字符串
  34949. str5 := t5.Format("2006-01-02 15:04:05")
  34950. res.Output.Setlinfo.Brdy = str2
  34951. res.Output.Setlinfo.SetlTime = str
  34952. res.Output.Setlinfo.Begndate = str3
  34953. res.Output.Setlinfo.Enddate = str5
  34954. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  34955. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  34956. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  34957. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  34958. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34959. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34960. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  34961. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  34962. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34963. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  34964. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  34965. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  34966. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  34967. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  34968. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  34969. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  34970. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  34971. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  34972. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34973. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  34974. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  34975. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34976. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  34977. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  34978. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  34979. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  34980. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  34981. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  34982. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  34983. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  34984. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  34985. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  34986. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34987. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  34988. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  34989. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  34990. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  34991. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  34992. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  34993. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  34994. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  34995. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  34996. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  34997. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  34998. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  34999. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35000. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35001. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35002. //res.Output.Setldetail = resah.Output.Setldetail
  35003. res.ErrMsg = resah.ErrMsg
  35004. res.Cainfo = resah.Cainfo
  35005. res.WarnMsg = resah.WarnMsg
  35006. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35007. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  35008. saveLog(result, requestLog, "5203", "结算单")
  35009. var dat map[string]interface{}
  35010. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35011. fmt.Println(dat)
  35012. } else {
  35013. fmt.Println(err)
  35014. }
  35015. userJSONBytes, _ := json.Marshal(dat)
  35016. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35017. utils.ErrorLog("解析失败:%v", err)
  35018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35019. return
  35020. }
  35021. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35022. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35023. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35024. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35025. resp, requestErr := http.Get(api)
  35026. if requestErr != nil {
  35027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35028. return
  35029. }
  35030. body, ioErr := ioutil.ReadAll(resp.Body)
  35031. if ioErr != nil {
  35032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35034. return
  35035. }
  35036. var respJSON map[string]interface{}
  35037. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35040. return
  35041. }
  35042. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35043. result, _ := json.Marshal(respJSON)
  35044. fmt.Println("log")
  35045. fmt.Println(string(result))
  35046. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  35047. utils.ErrorLog("解析失败:%v", err)
  35048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35049. return
  35050. }
  35051. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35052. res.Output = resEleven10265.Output
  35053. res.ErrMsg = resEleven10265.ErrMsg
  35054. res.Cainfo = resEleven10265.Cainfo
  35055. res.WarnMsg = resEleven10265.WarnMsg
  35056. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35057. res.Infcode = infocode
  35058. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35059. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35060. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35061. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35062. resp, requestErr := http.Get(api)
  35063. if requestErr != nil {
  35064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35065. return
  35066. }
  35067. body, ioErr := ioutil.ReadAll(resp.Body)
  35068. if ioErr != nil {
  35069. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35071. return
  35072. }
  35073. var respJSON map[string]interface{}
  35074. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35077. return
  35078. }
  35079. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35080. result, _ := json.Marshal(respJSON)
  35081. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35082. utils.ErrorLog("解析失败:%v", err)
  35083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35084. return
  35085. }
  35086. } else if miConfig.MdtrtareaAdmvs == "450721" {
  35087. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  35088. //return
  35089. } else {
  35090. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35091. if len(his.InsuplcAdmdvs) == 0 {
  35092. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35093. } else {
  35094. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35095. }
  35096. result := service.Gdyb5203(baseParams, businessParams)
  35097. //service.Gdyb5204(baseParams, businessParams)
  35098. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35099. var dat map[string]interface{}
  35100. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35101. fmt.Println(dat)
  35102. } else {
  35103. fmt.Println(err)
  35104. }
  35105. userJSONBytes, _ := json.Marshal(dat)
  35106. if miConfig.Code == "H15049901371" {
  35107. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  35108. utils.ErrorLog("解析失败:%v", err)
  35109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35110. return
  35111. }
  35112. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35113. res.Output = resEleven10265.Output
  35114. res.ErrMsg = resEleven10265.ErrMsg
  35115. res.Cainfo = resEleven10265.Cainfo
  35116. res.WarnMsg = resEleven10265.WarnMsg
  35117. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35118. res.Infcode = infocode
  35119. } else {
  35120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35121. utils.ErrorLog("解析失败:%v", err)
  35122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35123. return
  35124. }
  35125. }
  35126. }
  35127. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35128. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  35129. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  35130. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  35131. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  35132. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35133. var doctor_name string
  35134. if roles.ID == 0 {
  35135. doctor_name = "管理员"
  35136. } else {
  35137. doctor_name = roles.UserName
  35138. }
  35139. yiliao_leibie := ""
  35140. switch order.MedType {
  35141. case "11":
  35142. yiliao_leibie = "普通门诊"
  35143. break
  35144. case "12":
  35145. yiliao_leibie = "门诊挂号"
  35146. break
  35147. case "13":
  35148. yiliao_leibie = "急诊"
  35149. break
  35150. case "14":
  35151. yiliao_leibie = "门诊特殊病"
  35152. break
  35153. case "15":
  35154. yiliao_leibie = "门诊统筹"
  35155. break
  35156. case "16":
  35157. yiliao_leibie = "门诊慢性病"
  35158. break
  35159. case "21":
  35160. yiliao_leibie = "普通住院"
  35161. break
  35162. }
  35163. //var rf []CustomFundPay
  35164. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  35165. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35166. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  35167. if res.Infcode == 0 {
  35168. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10454 || adminUser.CurrentOrgId == 10644 || adminUser.CurrentOrgId == 10653 || adminUser.CurrentOrgId == 10210 {
  35169. c.ServeSuccessJSON(map[string]interface{}{
  35170. "diagnosis": name,
  35171. "order_infos": orderInfos,
  35172. "number": order.MdtrtId,
  35173. "date": order.SettleAccountsDate,
  35174. "charge_admin": charge_admin,
  35175. "printor_admin": printor_admin,
  35176. "info": res.Output.Setlinfo,
  35177. "order": order,
  35178. "bedCostTotal": bedCostTotal,
  35179. "bedCostSelfTotal": bedCostSelfTotal,
  35180. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35181. "bedSelfTotal": bedSelfTotal,
  35182. "bedInscpTotal": bedInscpTotal,
  35183. "operationCostTotal": operationCostTotal,
  35184. "operationCostSelfTotal": operationCostSelfTotal,
  35185. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35186. "operationSelfTotal": operationSelfTotal,
  35187. "operationInscpTotal": operationInscpTotal,
  35188. "otherCostTotal": otherCostTotal,
  35189. "otherCostSelfTotal": otherCostSelfTotal,
  35190. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35191. "otherSelfTotal": otherSelfTotal,
  35192. "otherInscpTotal": otherInscpTotal,
  35193. "materialCostTotal": materialCostTotal,
  35194. "materialCostSelfTotal": materialCostSelfTotal,
  35195. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35196. "materialSelfTotal": materialSelfTotal,
  35197. "materialInscpTotal": materialInscpTotal,
  35198. "westernMedicineCostTotal": westernMedicineCostTotal,
  35199. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35200. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35201. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35202. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35203. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35204. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35205. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35206. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35207. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35208. "checkCostTotal": checkCostTotal,
  35209. "checkCostSelfTotal": checkCostSelfTotal,
  35210. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35211. "checkSelfTotal": checkSelfTotal,
  35212. "checkInscpTotal": checkInscpTotal,
  35213. "laboratoryCostTotal": laboratoryCostTotal,
  35214. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35215. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35216. "laboratorySelfTotal": laboratorySelfTotal,
  35217. "laboratoryInscpTotal": laboratoryInscpTotal,
  35218. "treatCostTotal": treatCostTotal,
  35219. "treatCostSelfTotal": treatCostSelfTotal,
  35220. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35221. "treatSelfTotal": treatSelfTotal,
  35222. "treatInscpTotal": treatInscpTotal,
  35223. "doctor_info": doctor_info,
  35224. "doctor_code": adminRole_two.DoctorCode,
  35225. "doctor_name": doctor_name,
  35226. "health_card_no": order.PsnNo,
  35227. "department": departments.Name,
  35228. "yiliao_leibie": yiliao_leibie,
  35229. "after_money": order.AccountPrice,
  35230. "patient": patient,
  35231. "org_name": miConfig.OrgName,
  35232. "org_code": miConfig.Code,
  35233. "order_number": order.Number,
  35234. "his_hospital": his_hospital,
  35235. "his": his,
  35236. "dia_config": dia_config,
  35237. "psn_cash_pay": order.PsnCashPay,
  35238. "zcCostTotal": zcCostTotal,
  35239. "zcCostSelfTotal": zcCostSelfTotal,
  35240. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35241. "zcSelfTotal": zcSelfTotal,
  35242. "zcInscpTotal": zcInscpTotal,
  35243. "huliCostTotal": huliCostTotal,
  35244. "huliCostSelfTotal": huliCostSelfTotal,
  35245. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35246. "huliSelfTotal": huliSelfTotal,
  35247. "huliInscpTotal": huliInscpTotal,
  35248. //"funds": rf,
  35249. //"check_order_info": cus_slice,
  35250. })
  35251. } else {
  35252. c.ServeSuccessJSON(map[string]interface{}{
  35253. "diagnosis": name,
  35254. "order_infos": orderInfos,
  35255. "number": order.MdtrtId,
  35256. "date": order.SettleAccountsDate,
  35257. "charge_admin": charge_admin,
  35258. "printor_admin": printor_admin,
  35259. "info": order,
  35260. "order": order,
  35261. "bedCostTotal": bedCostTotal,
  35262. "bedCostSelfTotal": bedCostSelfTotal,
  35263. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35264. "bedSelfTotal": bedSelfTotal,
  35265. "bedInscpTotal": bedInscpTotal,
  35266. "operationCostTotal": operationCostTotal,
  35267. "operationCostSelfTotal": operationCostSelfTotal,
  35268. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35269. "operationSelfTotal": operationSelfTotal,
  35270. "operationInscpTotal": operationInscpTotal,
  35271. "otherCostTotal": otherCostTotal,
  35272. "otherCostSelfTotal": otherCostSelfTotal,
  35273. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35274. "otherSelfTotal": otherSelfTotal,
  35275. "otherInscpTotal": otherInscpTotal,
  35276. "materialCostTotal": materialCostTotal,
  35277. "materialCostSelfTotal": materialCostSelfTotal,
  35278. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35279. "materialSelfTotal": materialSelfTotal,
  35280. "materialInscpTotal": materialInscpTotal,
  35281. "westernMedicineCostTotal": westernMedicineCostTotal,
  35282. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35283. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35284. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35285. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35286. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35287. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35288. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35289. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35290. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35291. "checkCostTotal": checkCostTotal,
  35292. "checkCostSelfTotal": checkCostSelfTotal,
  35293. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35294. "checkSelfTotal": checkSelfTotal,
  35295. "checkInscpTotal": checkInscpTotal,
  35296. "laboratoryCostTotal": laboratoryCostTotal,
  35297. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35298. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35299. "laboratorySelfTotal": laboratorySelfTotal,
  35300. "laboratoryInscpTotal": laboratoryInscpTotal,
  35301. "treatCostTotal": treatCostTotal,
  35302. "treatCostSelfTotal": treatCostSelfTotal,
  35303. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35304. "treatSelfTotal": treatSelfTotal,
  35305. "treatInscpTotal": treatInscpTotal,
  35306. "doctor_info": doctor_info,
  35307. "doctor_code": adminRole_two.DoctorCode,
  35308. "doctor_name": doctor_name,
  35309. "health_card_no": order.PsnNo,
  35310. "department": departments.Name,
  35311. "yiliao_leibie": yiliao_leibie,
  35312. "after_money": order.AccountPrice,
  35313. "patient": patient,
  35314. "org_name": miConfig.OrgName,
  35315. "org_code": miConfig.Code,
  35316. "order_number": order.Number,
  35317. "his_hospital": his_hospital,
  35318. "his": his,
  35319. "dia_config": dia_config,
  35320. "psn_cash_pay": order.PsnCashPay,
  35321. "zcCostTotal": zcCostTotal,
  35322. "zcCostSelfTotal": zcCostSelfTotal,
  35323. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35324. "zcSelfTotal": zcSelfTotal,
  35325. "zcInscpTotal": zcInscpTotal,
  35326. "huliCostTotal": huliCostTotal,
  35327. "huliCostSelfTotal": huliCostSelfTotal,
  35328. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35329. "huliSelfTotal": huliSelfTotal,
  35330. "huliInscpTotal": huliInscpTotal,
  35331. //"funds": rf,
  35332. //"check_order_info": cus_slice,
  35333. })
  35334. }
  35335. }
  35336. }
  35337. }
  35338. //func (c *HisApiController) CheckTreatment() {
  35339. // patient_id, _ := c.GetInt64("patient_id")
  35340. // id_card_no := c.GetString("id_card_no")
  35341. // insutype := c.GetString("insutype")
  35342. // med_type := c.GetString("med_type")
  35343. // admin_user_id, _ := c.GetInt64("admin_user_id")
  35344. //
  35345. // adminUser := c.GetAdminUserInfo()
  35346. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35347. //
  35348. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35349. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35350. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35351. //
  35352. // if miConfig.MdtrtareaAdmvs == "421300" {
  35353. // var res ResultTwo
  35354. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  35355. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35356. // "&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)
  35357. // resp, requestErr := http.Get(api)
  35358. // if requestErr != nil {
  35359. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35360. // return
  35361. // }
  35362. //
  35363. // body, ioErr := ioutil.ReadAll(resp.Body)
  35364. // if ioErr != nil {
  35365. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35366. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35367. // return
  35368. // }
  35369. // var respJSON map[string]interface{}
  35370. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35371. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35372. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35373. // return
  35374. // }
  35375. //
  35376. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35377. // result, _ := json.Marshal(respJSON)
  35378. //
  35379. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35380. // utils.ErrorLog("解析失败:%v", err)
  35381. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35382. // return
  35383. // }
  35384. //
  35385. // if res.Infcode == 0 {
  35386. //
  35387. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  35388. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35389. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  35390. // resp, requestErr := http.Get(api)
  35391. // if requestErr != nil {
  35392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35393. // return
  35394. // }
  35395. //
  35396. // body, ioErr := ioutil.ReadAll(resp.Body)
  35397. // if ioErr != nil {
  35398. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35399. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35400. // return
  35401. // }
  35402. // var respJSON map[string]interface{}
  35403. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35404. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35405. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35406. // return
  35407. // }
  35408. // var res Result2001
  35409. //
  35410. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35411. // result2, _ := json.Marshal(respJSON)
  35412. //
  35413. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  35414. // utils.ErrorLog("解析失败:%v", err)
  35415. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35416. // return
  35417. // }
  35418. //
  35419. // if res.Infcode == 0 {
  35420. // c.ServeSuccessJSON(map[string]interface{}{
  35421. // "msg": res.Output.Trtinfo,
  35422. // })
  35423. // }
  35424. //
  35425. // } else {
  35426. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35427. // return
  35428. // }
  35429. //
  35430. // } else {
  35431. //
  35432. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35433. // var dat map[string]interface{}
  35434. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35435. // fmt.Println(dat)
  35436. // } else {
  35437. // fmt.Println(err)
  35438. // }
  35439. // userJSONBytes, _ := json.Marshal(dat)
  35440. // var res ResultTwo
  35441. // var res10265 ResultTwo10265
  35442. // if miConfig.Code == "H15049901371" {
  35443. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35444. // utils.ErrorLog("解析失败:%v", err)
  35445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35446. // return
  35447. // }
  35448. // res.ErrMsg = res10265.ErrMsg
  35449. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35450. // res.Infcode = infocode
  35451. // res.Output = res10265.Output
  35452. // res.InfRefmsgid = res10265.InfRefmsgid
  35453. // } else {
  35454. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35455. // utils.ErrorLog("解析失败:%v", err)
  35456. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35457. // return
  35458. // }
  35459. // }
  35460. //
  35461. // var user_name string
  35462. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  35463. // if role.ID == 0 {
  35464. // user_name = "xxx"
  35465. // } else {
  35466. // user_name = role.UserName
  35467. // }
  35468. //
  35469. // baseParams := models.BaseParams{
  35470. // SecretKey: miConfig.SecretKey,
  35471. // FixmedinsCode: miConfig.Code,
  35472. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35473. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35474. // OrgName: miConfig.OrgName,
  35475. // Doctor: user_name,
  35476. // }
  35477. //
  35478. // if config.IsOpen == 1 {
  35479. // if miConfig.Code == "H15049901371" {
  35480. // if med_type == "14" {
  35481. // if insutype == "390" {
  35482. // med_type = "9933"
  35483. // } else if insutype == "310" {
  35484. // med_type = "990502"
  35485. // }
  35486. // } else if med_type == "11" {
  35487. // med_type = "11"
  35488. // }
  35489. // }
  35490. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  35491. // var dat map[string]interface{}
  35492. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35493. // fmt.Println(dat)
  35494. // } else {
  35495. // fmt.Println(err)
  35496. // }
  35497. // var res Result2001
  35498. // var res10265 Result2001Org10265
  35499. // if miConfig.Code == "H15049901371" {
  35500. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35501. // utils.ErrorLog("解析失败:%v", err)
  35502. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35503. // return
  35504. // }
  35505. // res.ErrMsg = res10265.ErrMsg
  35506. // res.Output = res10265.Output
  35507. // res.InfRefmsgid = res10265.InfRefmsgid
  35508. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35509. // res.Infcode = infocode
  35510. // } else {
  35511. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35512. // utils.ErrorLog("解析失败:%v", err)
  35513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35514. // return
  35515. // }
  35516. // }
  35517. // if res.Infcode == 0 {
  35518. // c.ServeSuccessJSON(map[string]interface{}{
  35519. // "msg": res.Output.Trtinfo,
  35520. // })
  35521. // }
  35522. // }
  35523. // }
  35524. //}
  35525. //func (c *HisApiController) PutRecord() {
  35526. // id, _ := c.GetInt64("id")
  35527. // record_time := c.GetString("record_time")
  35528. // timeLayout := "2006-01-02"
  35529. // loc, _ := time.LoadLocation("Local")
  35530. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35531. // if err != nil {
  35532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35533. // return
  35534. // }
  35535. // recordDateTime := theTime.Unix()
  35536. //
  35537. // adminInfo := c.GetAdminUserInfo()
  35538. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  35539. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35540. //
  35541. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35542. //
  35543. // fmt.Println(miConfig.SecretKey)
  35544. //
  35545. // if patient == nil {
  35546. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35547. // return
  35548. // }
  35549. // if len(patient.IdCardNo) == 0 {
  35550. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  35551. // return
  35552. // }
  35553. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  35554. // if config.IsOpen == 1 {
  35555. // 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
  35556. // resp, requestErr := http.Get(api)
  35557. // if requestErr != nil {
  35558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35559. // return
  35560. // }
  35561. // defer resp.Body.Close()
  35562. // body, ioErr := ioutil.ReadAll(resp.Body)
  35563. // if ioErr != nil {
  35564. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35565. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35566. // return
  35567. // }
  35568. // var respJSON map[string]interface{}
  35569. //
  35570. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35571. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35573. // return
  35574. // }
  35575. //
  35576. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35577. // userJSONBytes, _ := json.Marshal(userJSON)
  35578. // var res ResultTwo
  35579. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35580. // utils.ErrorLog("解析失败:%v", err)
  35581. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35582. // return
  35583. // }
  35584. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35585. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35586. // infoStr := string(Iinfos)
  35587. // idetinfoStr := string(Idetinfos)
  35588. //
  35589. // if res.Infcode == 0 {
  35590. // his := models.VMHisPatient{
  35591. // Status: 1,
  35592. // Ctime: time.Now().Unix(),
  35593. // Mtime: time.Now().Unix(),
  35594. // PsnNo: res.Output.Baseinfo.PsnNo,
  35595. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  35596. // Certno: res.Output.Baseinfo.Certno,
  35597. // PsnName: res.Output.Baseinfo.PsnName,
  35598. // Gend: res.Output.Baseinfo.Gend,
  35599. // Naty: res.Output.Baseinfo.Naty,
  35600. // Brdy: res.Output.Baseinfo.Brdy,
  35601. // Age: res.Output.Baseinfo.Age,
  35602. // Iinfo: infoStr,
  35603. // Idetinfo: idetinfoStr,
  35604. // PatientId: patient.ID,
  35605. // RecordDate: theTime.Unix(),
  35606. // UserOrgId: adminInfo.CurrentOrgId,
  35607. // AdminUserId: adminInfo.AdminUser.Id,
  35608. // IsReturn: 1,
  35609. // }
  35610. //
  35611. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  35612. // //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")
  35613. // //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")
  35614. //
  35615. // //var dat map[string]interface{}
  35616. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35617. // // fmt.Println(dat)
  35618. // //} else {
  35619. // // fmt.Println(err)
  35620. // //}
  35621. //
  35622. // var dat2 map[string]interface{}
  35623. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35624. // fmt.Println(dat2)
  35625. // } else {
  35626. // fmt.Println(err)
  35627. // }
  35628. //
  35629. // } else {
  35630. // adminUser := c.GetAdminUserInfo()
  35631. // errlog := &models.HisOrderError{
  35632. // UserOrgId: adminUser.CurrentOrgId,
  35633. // Ctime: time.Now().Unix(),
  35634. // Mtime: time.Now().Unix(),
  35635. // ErrMsg: res.ErrMsg,
  35636. // Status: 1,
  35637. // PatientId: id,
  35638. // RecordTime: recordDateTime,
  35639. // Stage: 1,
  35640. // }
  35641. // service.CreateErrMsgLog(errlog)
  35642. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  35643. // return
  35644. // }
  35645. // }
  35646. //
  35647. //}
  35648. //func (c *HisApiController) GetUploadDiag() {
  35649. // id, _ := c.GetInt64("id")
  35650. // record_time := c.GetString("record_time")
  35651. //
  35652. // diagnosis_id, _ := c.GetInt64("diagnosis")
  35653. // sick_type, _ := c.GetInt64("sick_type")
  35654. // reg_type, _ := c.GetInt64("reg_type")
  35655. //
  35656. // timeLayout := "2006-01-02"
  35657. // loc, _ := time.LoadLocation("Local")
  35658. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35659. // if err != nil {
  35660. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35661. // return
  35662. // }
  35663. //
  35664. // var patientPrescription models.HisPrescriptionInfo
  35665. // recordDateTime := theTime.Unix()
  35666. // adminInfo := c.GetAdminUserInfo()
  35667. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35668. //
  35669. // if patientPrescription.ID == 0 {
  35670. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35671. // }
  35672. //
  35673. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35674. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  35675. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35676. // sickConfig, _ := service.FindSickById(sick_type)
  35677. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35678. //
  35679. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  35680. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  35681. // "&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 +
  35682. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  35683. // resp2, requestErr2 := http.Get(api2)
  35684. // if requestErr2 != nil {
  35685. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35686. // return
  35687. // }
  35688. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35689. // if ioErr2 != nil {
  35690. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35691. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35692. // return
  35693. // }
  35694. // var respJSON2 map[string]interface{}
  35695. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35696. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35697. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35698. // return
  35699. // }
  35700. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35701. // userJSONBytes2, _ := json.Marshal(respJSON2)
  35702. //
  35703. // var res2 ResultSix
  35704. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35705. // utils.ErrorLog("解析失败:%v", err)
  35706. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35707. // return
  35708. // }
  35709. // if res2.Infcode != 0 {
  35710. // adminUser := c.GetAdminUserInfo()
  35711. // errlog := &models.HisOrderError{
  35712. // UserOrgId: adminUser.CurrentOrgId,
  35713. // Ctime: time.Now().Unix(),
  35714. // Mtime: time.Now().Unix(),
  35715. // ErrMsg: res2.ErrMsg,
  35716. // Status: 1,
  35717. // PatientId: id,
  35718. // RecordTime: recordDateTime,
  35719. // Stage: 3,
  35720. // }
  35721. // service.CreateErrMsgLog(errlog)
  35722. //
  35723. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  35724. // return
  35725. // }
  35726. //
  35727. // c.ServeSuccessJSON(map[string]interface{}{
  35728. // "msg": "上传成功",
  35729. // })
  35730. //
  35731. //}
  35732. type QueryResult struct {
  35733. ID int64
  35734. Name string
  35735. Code string
  35736. List_type_code string
  35737. }
  35738. func (c *HisApiController) GetCheckCode() {
  35739. ids_str := c.GetString("ids")
  35740. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35741. ids_arr := strings.Split(ids_str, ",")
  35742. var queryResult []QueryResult
  35743. ids := make([]int64, 0)
  35744. for _, item := range ids_arr {
  35745. id, _ := strconv.ParseInt(item, 10, 64)
  35746. ids = append(ids, id)
  35747. }
  35748. if record_type == 1 {
  35749. drugs, _ := service.GetBatchDrugList(ids)
  35750. for _, item := range drugs {
  35751. result := QueryResult{
  35752. ID: item.ID,
  35753. Name: item.DrugName,
  35754. Code: item.MedicalInsuranceNumber,
  35755. List_type_code: "101",
  35756. }
  35757. queryResult = append(queryResult, result)
  35758. }
  35759. } else if record_type == 2 {
  35760. goods, _ := service.GetBatchGoodInformationList(ids)
  35761. fmt.Println(goods)
  35762. for _, item := range goods {
  35763. result := QueryResult{
  35764. ID: item.ID,
  35765. Name: item.GoodName,
  35766. Code: item.SocialSecurityDirectoryCode,
  35767. List_type_code: "301",
  35768. }
  35769. queryResult = append(queryResult, result)
  35770. }
  35771. } else if record_type == 3 {
  35772. projects, _ := service.GetBathchMyPorjecgList(ids)
  35773. for _, item := range projects {
  35774. result := QueryResult{
  35775. ID: item.ID,
  35776. Name: item.ProjectName,
  35777. Code: item.MedicalCode,
  35778. List_type_code: "201",
  35779. }
  35780. queryResult = append(queryResult, result)
  35781. }
  35782. }
  35783. admin_user_id, _ := c.GetInt64("admin_user_id")
  35784. adminUser := c.GetAdminUserInfo()
  35785. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35786. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35787. var user_name string
  35788. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35789. if role.ID == 0 {
  35790. user_name = "管理员"
  35791. } else {
  35792. user_name = role.UserName
  35793. }
  35794. baseParams := models.BaseParams{
  35795. SecretKey: miConfig.SecretKey,
  35796. FixmedinsCode: miConfig.Code,
  35797. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35798. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35799. OrgName: miConfig.OrgName,
  35800. Doctor: user_name,
  35801. }
  35802. var result string
  35803. if miConfig.MdtrtareaAdmvs == "430800" {
  35804. for _, item := range queryResult {
  35805. if record_type == 1 {
  35806. 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)
  35807. } else if record_type == 2 {
  35808. fmt.Println(item.Code)
  35809. 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)
  35810. } else if record_type == 3 {
  35811. 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)
  35812. }
  35813. var dat map[string]interface{}
  35814. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35815. fmt.Println(dat)
  35816. } else {
  35817. fmt.Println(err)
  35818. }
  35819. userJSONBytes, _ := json.Marshal(dat)
  35820. var res ResultSix
  35821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35822. utils.ErrorLog("解析失败:%v", err)
  35823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35824. return
  35825. }
  35826. if res.Infcode == 0 {
  35827. if record_type == 1 {
  35828. service.UpdateBaseDrugById(item.ID)
  35829. } else if record_type == 2 {
  35830. service.UpdateGoodInformaitonByDetail(item.ID)
  35831. } else if record_type == 3 {
  35832. service.UpdateProjectById(item.ID)
  35833. }
  35834. c.ServeSuccessJSON(map[string]interface{}{
  35835. "failed_code": 0,
  35836. "msg": "目录对照成功",
  35837. })
  35838. } else {
  35839. c.ServeSuccessJSON(map[string]interface{}{
  35840. "failed_code": -10,
  35841. "msg": res.ErrMsg,
  35842. })
  35843. }
  35844. }
  35845. } else {
  35846. for _, item := range queryResult {
  35847. var result string
  35848. if record_type == 1 {
  35849. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35850. } else if record_type == 2 {
  35851. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35852. } else if record_type == 3 {
  35853. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35854. }
  35855. var dat map[string]interface{}
  35856. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35857. fmt.Println(dat)
  35858. } else {
  35859. fmt.Println(err)
  35860. }
  35861. userJSONBytes, _ := json.Marshal(dat)
  35862. var res ResultSix
  35863. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35864. utils.ErrorLog("解析失败:%v", err)
  35865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35866. return
  35867. }
  35868. if res.Infcode == 0 {
  35869. if record_type == 1 {
  35870. service.UpdateBaseDrugById(item.ID)
  35871. } else if record_type == 2 {
  35872. service.UpdateGoodInformaitonByDetail(item.ID)
  35873. } else if record_type == 3 {
  35874. service.UpdateProjectById(item.ID)
  35875. }
  35876. c.ServeSuccessJSON(map[string]interface{}{
  35877. "failed_code": 0,
  35878. "msg": "目录对照成功",
  35879. })
  35880. } else {
  35881. c.ServeSuccessJSON(map[string]interface{}{
  35882. "failed_code": -10,
  35883. "msg": res.ErrMsg,
  35884. })
  35885. }
  35886. }
  35887. }
  35888. }
  35889. func (c *HisApiController) UnCheckCode() {
  35890. ids_str := c.GetString("ids")
  35891. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35892. admin_user_id, _ := c.GetInt64("admin_user_id")
  35893. ids_arr := strings.Split(ids_str, ",")
  35894. var queryResult []QueryResult
  35895. ids := make([]int64, 0)
  35896. for _, item := range ids_arr {
  35897. id, _ := strconv.ParseInt(item, 10, 64)
  35898. ids = append(ids, id)
  35899. }
  35900. if record_type == 1 {
  35901. drugs, _ := service.GetBatchDrugList(ids)
  35902. for _, item := range drugs {
  35903. result := QueryResult{
  35904. ID: item.ID,
  35905. Name: item.DrugName,
  35906. Code: item.MedicalInsuranceNumber,
  35907. List_type_code: "101",
  35908. }
  35909. queryResult = append(queryResult, result)
  35910. }
  35911. } else if record_type == 2 {
  35912. goods, _ := service.GetBatchGoodInformationList(ids)
  35913. for _, item := range goods {
  35914. result := QueryResult{
  35915. ID: item.ID,
  35916. Name: item.GoodName,
  35917. Code: item.SocialSecurityDirectoryCode,
  35918. List_type_code: "301",
  35919. }
  35920. queryResult = append(queryResult, result)
  35921. }
  35922. } else if record_type == 3 {
  35923. projects, _ := service.GetBathchMyPorjecgList(ids)
  35924. for _, item := range projects {
  35925. result := QueryResult{
  35926. ID: item.ID,
  35927. Name: item.ProjectName,
  35928. Code: item.MedicalCode,
  35929. List_type_code: "201",
  35930. }
  35931. queryResult = append(queryResult, result)
  35932. }
  35933. }
  35934. adminUser := c.GetAdminUserInfo()
  35935. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35936. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35937. var user_name string
  35938. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35939. if role.ID == 0 {
  35940. user_name = "xxx"
  35941. } else {
  35942. user_name = role.UserName
  35943. }
  35944. baseParams := &models.BaseParams{
  35945. SecretKey: miConfig.SecretKey,
  35946. FixmedinsCode: miConfig.Code,
  35947. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35948. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35949. OrgName: miConfig.OrgName,
  35950. Doctor: user_name,
  35951. }
  35952. if config.IsOpen == 1 {
  35953. if miConfig.MdtrtareaAdmvs == "430800" {
  35954. for _, item := range queryResult {
  35955. var result string
  35956. if record_type == 1 {
  35957. 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)
  35958. } else if record_type == 2 {
  35959. fmt.Println(item.Code)
  35960. 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)
  35961. } else if record_type == 3 {
  35962. 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)
  35963. }
  35964. var dat map[string]interface{}
  35965. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35966. fmt.Println(dat)
  35967. } else {
  35968. fmt.Println(err)
  35969. }
  35970. userJSONBytes, _ := json.Marshal(dat)
  35971. var res ResultSix
  35972. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35973. utils.ErrorLog("解析失败:%v", err)
  35974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35975. return
  35976. }
  35977. if res.Infcode == 0 {
  35978. if record_type == 1 {
  35979. service.UpdateBaseDrugById(item.ID)
  35980. } else if record_type == 2 {
  35981. service.UpdateGoodInformaitonByDetail(item.ID)
  35982. } else if record_type == 3 {
  35983. service.UpdateProjectById(item.ID)
  35984. }
  35985. c.ServeSuccessJSON(map[string]interface{}{
  35986. "failed_code": 0,
  35987. "msg": "目录对照成功",
  35988. })
  35989. } else {
  35990. c.ServeSuccessJSON(map[string]interface{}{
  35991. "failed_code": -10,
  35992. "msg": res.ErrMsg,
  35993. })
  35994. }
  35995. }
  35996. } else {
  35997. for _, item := range queryResult {
  35998. var result string
  35999. if record_type == 1 {
  36000. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36001. } else if record_type == 2 {
  36002. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36003. } else if record_type == 3 {
  36004. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36005. }
  36006. var dat2 map[string]interface{}
  36007. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36008. fmt.Println(dat2)
  36009. } else {
  36010. fmt.Println(err)
  36011. }
  36012. userJSONBytes, _ := json.Marshal(dat2)
  36013. var res ResultSix
  36014. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36015. utils.ErrorLog("解析失败:%v", err)
  36016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36017. return
  36018. }
  36019. if res.Infcode == 0 {
  36020. if record_type == 1 {
  36021. service.UpdateDrugByIdDetail(item.ID)
  36022. } else if record_type == 2 {
  36023. service.UpdateGoodInfoById(item.ID)
  36024. } else if record_type == 3 {
  36025. service.UpdateMyProjectById(item.ID)
  36026. }
  36027. c.ServeSuccessJSON(map[string]interface{}{
  36028. "failed_code": 0,
  36029. "msg": "撤销目录对照成功",
  36030. })
  36031. } else {
  36032. c.ServeSuccessJSON(map[string]interface{}{
  36033. "failed_code": -10,
  36034. "msg": res.ErrMsg,
  36035. })
  36036. }
  36037. }
  36038. }
  36039. }
  36040. }
  36041. func (c *HisApiController) GetPatientInfo() {
  36042. id_card_no := c.GetString("id_card_no")
  36043. admin_user_id, _ := c.GetInt64("admin_user_id")
  36044. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  36045. if patient.ID == 0 {
  36046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  36047. return
  36048. }
  36049. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  36050. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  36051. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  36052. var res ResultTwo
  36053. var res10265 ResultTwo10265
  36054. if config.IsOpen == 1 {
  36055. if miConfig.MdtrtareaAdmvs == "150499" {
  36056. //请求内网数据
  36057. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  36058. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36059. "&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
  36060. resp, requestErr := http.Get(api)
  36061. if requestErr != nil {
  36062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36063. return
  36064. }
  36065. body, ioErr := ioutil.ReadAll(resp.Body)
  36066. if ioErr != nil {
  36067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36069. return
  36070. }
  36071. var respJSON map[string]interface{}
  36072. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36075. return
  36076. }
  36077. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36078. result_byte, _ := json.Marshal(respJSON)
  36079. result := string(result_byte)
  36080. var dat map[string]interface{}
  36081. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36082. fmt.Println(dat)
  36083. } else {
  36084. fmt.Println(err)
  36085. }
  36086. userJSONBytes, _ := json.Marshal(dat)
  36087. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36088. utils.ErrorLog("解析失败:%v", err)
  36089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36090. return
  36091. }
  36092. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36093. res.Infcode = Infcode
  36094. res.ErrMsg = res10265.ErrMsg
  36095. res.Output = res10265.Output
  36096. res.InfRefmsgid = res10265.InfRefmsgid
  36097. res.RespondTime = res10265.RespondTime
  36098. res.WarnInfo = res10265.WarnInfo
  36099. } else {
  36100. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  36101. var dat map[string]interface{}
  36102. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36103. fmt.Println(dat)
  36104. } else {
  36105. fmt.Println(err)
  36106. }
  36107. userJSONBytes, _ := json.Marshal(dat)
  36108. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36109. utils.ErrorLog("解析失败:%v", err)
  36110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36111. return
  36112. }
  36113. }
  36114. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36115. // utils.ErrorLog("解析失败:%v", err)
  36116. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36117. // return
  36118. //}
  36119. for index, item := range res.Output.Iinfo {
  36120. if item.PsnInsuStas == "2" {
  36121. fmt.Println("--------")
  36122. res.Output.Iinfo[index].Insutype = "300"
  36123. res.Output.Iinfo[index].PsnInsuStas = "1"
  36124. }
  36125. }
  36126. fmt.Println(res.Output.Iinfo)
  36127. if res.Infcode != 0 {
  36128. c.ServeSuccessJSON(map[string]interface{}{
  36129. "failed_code": -10,
  36130. "msg": res.ErrMsg,
  36131. })
  36132. } else {
  36133. c.ServeSuccessJSON(map[string]interface{}{
  36134. "failed_code": 0,
  36135. "info": res,
  36136. })
  36137. }
  36138. }
  36139. }
  36140. func (c *HisApiController) PsnPutOnRecord() {
  36141. record_type, _ := c.GetInt64("type")
  36142. patient_id, _ := c.GetInt64("patient_id")
  36143. admin_user_id, _ := c.GetInt64("admin_user_id")
  36144. start_time := c.GetString("start_time")
  36145. end_time := c.GetString("end_time")
  36146. adminUser := c.GetAdminUserInfo()
  36147. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36148. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36149. var patients []*models.Patients
  36150. if record_type == 1 { //全部备案
  36151. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  36152. patients = append(patients, patient...)
  36153. } else { //单个备案
  36154. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36155. patients = append(patients, patient)
  36156. }
  36157. var user_name string
  36158. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36159. if role.ID == 0 {
  36160. user_name = "xxx"
  36161. } else {
  36162. user_name = role.UserName
  36163. }
  36164. if config.IsOpen == 1 {
  36165. for _, item := range patients {
  36166. 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
  36167. resp, requestErr := http.Get(api)
  36168. if requestErr != nil {
  36169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36170. return
  36171. }
  36172. defer resp.Body.Close()
  36173. body, ioErr := ioutil.ReadAll(resp.Body)
  36174. if ioErr != nil {
  36175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36177. return
  36178. }
  36179. var respJSON map[string]interface{}
  36180. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36183. return
  36184. }
  36185. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36186. userJSONBytes, _ := json.Marshal(userJSON)
  36187. var res ResultTwo
  36188. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36189. utils.ErrorLog("解析失败:%v", err)
  36190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36191. return
  36192. }
  36193. if res.Infcode == 0 {
  36194. 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)
  36195. var dat map[string]interface{}
  36196. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36197. fmt.Println(dat)
  36198. } else {
  36199. fmt.Println(err)
  36200. }
  36201. userJSONBytes, _ := json.Marshal(dat)
  36202. var res2 ResultThirteen
  36203. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36204. utils.ErrorLog("解析失败:%v", err)
  36205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36206. return
  36207. }
  36208. if res2.Infcode == 0 {
  36209. psnResult := &models.GdybPsnRecord{
  36210. UserOrgId: adminUser.CurrentOrgId,
  36211. PatientId: item.ID,
  36212. PsnNo: res.Output.Baseinfo.PsnNo,
  36213. Ctime: time.Now().Unix(),
  36214. Mtime: time.Now().Unix(),
  36215. Status: 1,
  36216. IsCancel: 1,
  36217. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36218. }
  36219. service.CreatePsnRecord(psnResult)
  36220. } else {
  36221. c.ServeSuccessJSON(map[string]interface{}{
  36222. "failed_code": -10,
  36223. "msg": res2.ErrMsg,
  36224. })
  36225. return
  36226. }
  36227. }
  36228. }
  36229. }
  36230. }
  36231. func (c *HisApiController) PsnUnPutOnRecord() {
  36232. id, _ := c.GetInt64("id")
  36233. //record_type, _ := c.GetInt64("type")
  36234. admin_user_id, _ := c.GetInt64("admin_user_id")
  36235. adminUser := c.GetAdminUserInfo()
  36236. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36237. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36238. var user_name string
  36239. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36240. if role.ID == 0 {
  36241. user_name = "xxx"
  36242. } else {
  36243. user_name = role.UserName
  36244. }
  36245. psn_record, _ := service.GetPsnRecordById(id)
  36246. if psn_record.ID == 0 {
  36247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36248. return
  36249. }
  36250. if config.IsOpen == 1 {
  36251. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36252. var dat map[string]interface{}
  36253. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36254. fmt.Println(dat)
  36255. } else {
  36256. fmt.Println(err)
  36257. }
  36258. userJSONBytes, _ := json.Marshal(dat)
  36259. var res ResultFourteen
  36260. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36261. utils.ErrorLog("解析失败:%v", err)
  36262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36263. return
  36264. }
  36265. if res.Infcode == 0 {
  36266. psn_record.IsCancel = 2
  36267. service.CreatePsnRecord(&psn_record)
  36268. } else {
  36269. c.ServeSuccessJSON(map[string]interface{}{
  36270. "failed_code": -10,
  36271. "msg": res.ErrMsg,
  36272. })
  36273. return
  36274. }
  36275. }
  36276. }
  36277. func (c *HisApiController) PsnPutNCDSOnRecord() {
  36278. patient_id, _ := c.GetInt64("patient_id")
  36279. insutype_two := c.GetString("insutype")
  36280. psn_no := c.GetString("psn_no")
  36281. doctor_id, _ := c.GetInt64("doctor_id")
  36282. sick_id, _ := c.GetInt64("sick_id")
  36283. department_id, _ := c.GetInt64("department_id")
  36284. start_time := c.GetString("start_time")
  36285. end_time := c.GetString("end_time")
  36286. check_time := c.GetString("check_time")
  36287. hospital_code := c.GetString("hospital_code")
  36288. hospital_name := c.GetString("hospital_name")
  36289. adminUser := c.GetAdminUserInfo()
  36290. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36291. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36292. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36293. sick, _ := service.FindSickById(sick_id)
  36294. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36295. if len(hospital_code) == 0 {
  36296. hospital_code = miConfig.Code
  36297. }
  36298. if len(hospital_name) == 0 {
  36299. hospital_name = miConfig.OrgName
  36300. }
  36301. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36302. var res ResultTwo
  36303. var res10265 ResultTwo10265
  36304. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36305. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  36306. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  36307. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36308. "&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
  36309. resp, requestErr := http.Get(api)
  36310. if requestErr != nil {
  36311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36312. return
  36313. }
  36314. body, ioErr := ioutil.ReadAll(resp.Body)
  36315. if ioErr != nil {
  36316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36318. return
  36319. }
  36320. var respJSON map[string]interface{}
  36321. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36324. return
  36325. }
  36326. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36327. result, _ := json.Marshal(respJSON)
  36328. fmt.Println("log")
  36329. fmt.Println(string(result))
  36330. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36331. utils.ErrorLog("解析失败:%v", err)
  36332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36333. return
  36334. }
  36335. res.ErrMsg = res10265.ErrMsg
  36336. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36337. res.Infcode = infocode
  36338. res.Output = res10265.Output
  36339. res.InfRefmsgid = res10265.InfRefmsgid
  36340. } else {
  36341. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36342. if miConfig.Code == "H15049901371" {
  36343. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36344. utils.ErrorLog("解析失败:%v", err)
  36345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36346. return
  36347. }
  36348. res.ErrMsg = res10265.ErrMsg
  36349. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36350. res.Infcode = infocode
  36351. res.Output = res10265.Output
  36352. res.InfRefmsgid = res10265.InfRefmsgid
  36353. } else {
  36354. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36355. utils.ErrorLog("解析失败:%v", err)
  36356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36357. return
  36358. }
  36359. }
  36360. }
  36361. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36362. infoStr := string(Iinfos)
  36363. var rf []*ResultFive
  36364. json.Unmarshal([]byte(infoStr), &rf)
  36365. var insuplc_admdvs string
  36366. var insutype string
  36367. var is390 int = 0
  36368. var is310 int = 0
  36369. var insutypes []*ResultFive
  36370. for _, item := range rf {
  36371. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36372. insutypes = append(insutypes, item)
  36373. }
  36374. }
  36375. if len(insutypes) == 1 {
  36376. insutype = insutypes[0].Insutype
  36377. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36378. } else {
  36379. for _, i := range insutypes {
  36380. if i.Insutype == "390" {
  36381. is390 = 1
  36382. }
  36383. if i.Insutype == "310" {
  36384. is310 = 1
  36385. }
  36386. }
  36387. }
  36388. if is390 == 1 {
  36389. insutype = "390"
  36390. }
  36391. if is310 == 1 {
  36392. insutype = "310"
  36393. }
  36394. if len(insutypes) == 2 {
  36395. insutype = insutype_two
  36396. }
  36397. if len(insutypes) == 0 {
  36398. insutype = "310"
  36399. }
  36400. insutype = insutype_two
  36401. fmt.Println(insutype)
  36402. for _, item := range rf {
  36403. fmt.Println(item.Insutype)
  36404. fmt.Println(insutype)
  36405. if item.Insutype == insutype {
  36406. fmt.Println(item.Insutype)
  36407. fmt.Println(insutype)
  36408. insuplc_admdvs = item.InsuplcAdmdvs
  36409. }
  36410. }
  36411. fmt.Println(insuplc_admdvs)
  36412. var res2 ResultThirteen
  36413. var res10265_2 ResultThirteen10265
  36414. if config.IsOpen == 1 {
  36415. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36416. } else {
  36417. if miConfig.MdtrtareaAdmvs == "150499" {
  36418. //
  36419. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  36420. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36421. // "&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
  36422. //resp, requestErr := http.Get(api)
  36423. //if requestErr != nil {
  36424. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36425. // return
  36426. //}
  36427. //
  36428. //body, ioErr := ioutil.ReadAll(resp.Body)
  36429. //if ioErr != nil {
  36430. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36431. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36432. // return
  36433. //}
  36434. //var respJSON map[string]interface{}
  36435. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36436. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36437. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36438. // return
  36439. //}
  36440. //
  36441. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36442. //result, _ := json.Marshal(respJSON)
  36443. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  36444. // utils.ErrorLog("解析失败:%v", err)
  36445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36446. // return
  36447. //}
  36448. //infocode = resThree.Infcode
  36449. //result, _ := json.Marshal(respJSON)
  36450. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  36451. // utils.ErrorLog("解析失败:%v", err)
  36452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36453. // return
  36454. //}
  36455. //
  36456. //resThree.ErrMsg = resThree10265.ErrMsg
  36457. //
  36458. //resThree.Output = resThree10265.Output
  36459. //
  36460. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  36461. //
  36462. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  36463. //
  36464. } else {
  36465. 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)
  36466. var dat map[string]interface{}
  36467. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36468. fmt.Println(dat)
  36469. } else {
  36470. fmt.Println(err)
  36471. }
  36472. userJSONBytes, _ := json.Marshal(dat)
  36473. if miConfig.Code == "H15049901371" {
  36474. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  36475. utils.ErrorLog("解析失败:%v", err)
  36476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36477. return
  36478. }
  36479. res2.ErrMsg = res10265_2.ErrMsg
  36480. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  36481. res2.Infcode = infocode
  36482. res2.Output = res10265_2.Output
  36483. res2.InfRefmsgid = res10265_2.InfRefmsgid
  36484. } else {
  36485. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36486. utils.ErrorLog("解析失败:%v", err)
  36487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36488. return
  36489. }
  36490. }
  36491. }
  36492. }
  36493. if res2.Infcode == 0 {
  36494. psnResult := &models.GdybPsnNcdsRecord{
  36495. UserOrgId: adminUser.CurrentOrgId,
  36496. PatientId: patient.ID,
  36497. PsnNo: psn_no,
  36498. DoctorId: doctor.AdminUserId,
  36499. DepartmentId: department_id,
  36500. SickType: sick_id,
  36501. Insutype: insutype,
  36502. Ctime: time.Now().Unix(),
  36503. Mtime: time.Now().Unix(),
  36504. Status: 1,
  36505. IsCancel: 1,
  36506. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36507. }
  36508. service.CreatePsnNCDSRecord(psnResult)
  36509. c.ServeSuccessJSON(map[string]interface{}{
  36510. "failed_code": 0,
  36511. "msg": "备案成功",
  36512. "result": psnResult,
  36513. })
  36514. } else {
  36515. c.ServeSuccessJSON(map[string]interface{}{
  36516. "failed_code": -10,
  36517. "msg": res2.ErrMsg,
  36518. })
  36519. return
  36520. }
  36521. }
  36522. }
  36523. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  36524. id, _ := c.GetInt64("id")
  36525. admin_user_id, _ := c.GetInt64("admin_user_id")
  36526. adminUser := c.GetAdminUserInfo()
  36527. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36528. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36529. //config, _ := service.Ge(adminUser.CurrentOrgId)
  36530. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  36531. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36532. //var user_name string
  36533. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36534. //if role.ID == 0 {
  36535. // user_name = "xxx"
  36536. //} else {
  36537. // user_name = role.UserName
  36538. //}
  36539. psn_record, _ := service.GetPsnNCDSRecordById(id)
  36540. if psn_record.ID == 0 {
  36541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36542. return
  36543. }
  36544. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36545. var res ResultTwo
  36546. var res10265 ResultTwo10265
  36547. if miConfig.Code == "H15049901371" {
  36548. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36549. utils.ErrorLog("解析失败:%v", err)
  36550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36551. return
  36552. }
  36553. res.ErrMsg = res10265.ErrMsg
  36554. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36555. res.Infcode = infocode
  36556. res.Output = res10265.Output
  36557. res.InfRefmsgid = res10265.InfRefmsgid
  36558. } else {
  36559. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36560. utils.ErrorLog("解析失败:%v", err)
  36561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36562. return
  36563. }
  36564. }
  36565. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36566. infoStr := string(Iinfos)
  36567. var rf []*ResultFive
  36568. json.Unmarshal([]byte(infoStr), &rf)
  36569. var insuplc_admdvs string
  36570. var insutype string
  36571. var is390 int = 0
  36572. var is310 int = 0
  36573. var insutypes []*ResultFive
  36574. for _, item := range rf {
  36575. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36576. insutypes = append(insutypes, item)
  36577. }
  36578. }
  36579. if len(insutypes) == 1 {
  36580. insutype = insutypes[0].Insutype
  36581. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36582. } else {
  36583. for _, i := range insutypes {
  36584. if i.Insutype == "390" {
  36585. is390 = 1
  36586. }
  36587. if i.Insutype == "310" {
  36588. is310 = 1
  36589. }
  36590. }
  36591. }
  36592. if is390 == 1 {
  36593. insutype = "390"
  36594. }
  36595. if is310 == 1 {
  36596. insutype = "310"
  36597. }
  36598. if len(insutypes) == 0 {
  36599. insutype = "310"
  36600. }
  36601. insutype = psn_record.Insutype
  36602. for _, item := range rf {
  36603. if item.Insutype == insutype {
  36604. insuplc_admdvs = item.InsuplcAdmdvs
  36605. }
  36606. }
  36607. if config.IsOpen == 1 {
  36608. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36609. var dat map[string]interface{}
  36610. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36611. fmt.Println(dat)
  36612. } else {
  36613. fmt.Println(err)
  36614. }
  36615. userJSONBytes, _ := json.Marshal(dat)
  36616. var res ResultFourteen
  36617. var res10265 ResultFourteen10265
  36618. if miConfig.Code == "H15049901371" {
  36619. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36620. utils.ErrorLog("解析失败:%v", err)
  36621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36622. return
  36623. }
  36624. res.ErrMsg = res10265.ErrMsg
  36625. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36626. res.Infcode = infocode
  36627. res.Output = res10265.Output
  36628. res.InfRefmsgid = res10265.InfRefmsgid
  36629. } else {
  36630. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36631. utils.ErrorLog("解析失败:%v", err)
  36632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36633. return
  36634. }
  36635. }
  36636. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36637. // utils.ErrorLog("解析失败:%v", err)
  36638. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36639. // return
  36640. //}
  36641. if res.Infcode == 0 {
  36642. psn_record.IsCancel = 2
  36643. service.CreatePsnNCDSRecord(&psn_record)
  36644. c.ServeSuccessJSON(map[string]interface{}{
  36645. "failed_code": 0,
  36646. "msg": "撤销备案成功",
  36647. })
  36648. } else {
  36649. c.ServeSuccessJSON(map[string]interface{}{
  36650. "failed_code": -10,
  36651. "msg": res.ErrMsg,
  36652. })
  36653. return
  36654. }
  36655. }
  36656. }
  36657. func (c *HisApiController) TestTest() {
  36658. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  36659. fmt.Println(patient.Iinfo)
  36660. }
  36661. type CustomData struct {
  36662. MsgId string
  36663. PsnNo string
  36664. Info string
  36665. }
  36666. func (c *HisApiController) ReversalData() {
  36667. var customData []*CustomData
  36668. custom := &CustomData{
  36669. MsgId: "H44022900158202103301714472004",
  36670. PsnNo: "44020000001101329945",
  36671. Info: "2207",
  36672. }
  36673. customData = append(customData, custom)
  36674. custom1 := &CustomData{
  36675. MsgId: "H4402290015820210330172057803",
  36676. PsnNo: "44020000001101161813",
  36677. Info: "2207",
  36678. }
  36679. customData = append(customData, custom1)
  36680. custom2 := &CustomData{
  36681. MsgId: "H44022900158202103301705198813",
  36682. PsnNo: "44190000133097375417",
  36683. Info: "2207",
  36684. }
  36685. customData = append(customData, custom2)
  36686. custom3 := &CustomData{
  36687. MsgId: "H44022900158202103301715524756",
  36688. PsnNo: "44020000001100187221",
  36689. Info: "2207",
  36690. }
  36691. customData = append(customData, custom3)
  36692. custom4 := &CustomData{
  36693. MsgId: "H44022900158202103301730376224",
  36694. PsnNo: "44020000001101959155",
  36695. Info: "2207",
  36696. }
  36697. customData = append(customData, custom4)
  36698. custom5 := &CustomData{
  36699. MsgId: "H44022900158202103301748008725",
  36700. PsnNo: "44020000001104246641",
  36701. Info: "2207",
  36702. }
  36703. customData = append(customData, custom5)
  36704. custom6 := &CustomData{
  36705. MsgId: "H44022900158202103301718096755",
  36706. PsnNo: "44020000001102211860",
  36707. Info: "2207",
  36708. }
  36709. customData = append(customData, custom6)
  36710. custom7 := &CustomData{
  36711. MsgId: "H44022900158202103301736551640",
  36712. PsnNo: "44020000001102687718",
  36713. Info: "2207",
  36714. }
  36715. customData = append(customData, custom7)
  36716. custom8 := &CustomData{
  36717. MsgId: "H44022900158202103301743097676",
  36718. PsnNo: "44020000001102127785",
  36719. Info: "2207",
  36720. }
  36721. customData = append(customData, custom8)
  36722. custom9 := &CustomData{
  36723. MsgId: "H44022900158202103301712304203",
  36724. PsnNo: "44020000001101518097",
  36725. Info: "2207",
  36726. }
  36727. customData = append(customData, custom9)
  36728. custom10 := &CustomData{
  36729. MsgId: "H44022900158202103301738448785",
  36730. PsnNo: "44020000001100500813",
  36731. Info: "2207",
  36732. }
  36733. customData = append(customData, custom10)
  36734. custom11 := &CustomData{
  36735. MsgId: "H44022900158202103301732455843",
  36736. PsnNo: "44020000001102690557",
  36737. Info: "2207",
  36738. }
  36739. customData = append(customData, custom11)
  36740. custom12 := &CustomData{
  36741. MsgId: "H44022900158202103301745421708",
  36742. PsnNo: "44020000001102211928",
  36743. Info: "2207",
  36744. }
  36745. customData = append(customData, custom12)
  36746. custom1212 := &CustomData{
  36747. MsgId: "H440229001582021033017351627",
  36748. PsnNo: "44020000001102481733",
  36749. Info: "2207",
  36750. }
  36751. customData = append(customData, custom1212)
  36752. custom13 := &CustomData{
  36753. MsgId: "H44022900158202103301740327951",
  36754. PsnNo: "44020000001103174866",
  36755. Info: "2207",
  36756. }
  36757. customData = append(customData, custom13)
  36758. custom14 := &CustomData{
  36759. MsgId: "H4402290015820210330174922668",
  36760. PsnNo: "44020000001102927272",
  36761. Info: "2207",
  36762. }
  36763. customData = append(customData, custom14)
  36764. custom15 := &CustomData{
  36765. MsgId: "H44022900158202103301752362273",
  36766. PsnNo: "44020000001102942890",
  36767. Info: "2207",
  36768. }
  36769. customData = append(customData, custom15)
  36770. custom16 := &CustomData{
  36771. MsgId: "H44022900158202103301751082917",
  36772. PsnNo: "44020000001101662162",
  36773. Info: "2207",
  36774. }
  36775. customData = append(customData, custom16)
  36776. custom17 := &CustomData{
  36777. MsgId: "H44022900158202103301754147728",
  36778. PsnNo: "44020000000229014511",
  36779. Info: "2207",
  36780. }
  36781. customData = append(customData, custom17)
  36782. adminUser := c.GetAdminUserInfo()
  36783. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36784. for _, item := range customData {
  36785. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  36786. fmt.Println(result)
  36787. }
  36788. }
  36789. func (c *HisApiController) GetAllopatry() {
  36790. year := c.GetString("year")
  36791. month := c.GetString("month")
  36792. admin_user_id, _ := c.GetInt64("admin_user_id")
  36793. adminUser := c.GetAdminUserInfo()
  36794. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36795. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36796. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36797. var dat map[string]interface{}
  36798. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36799. fmt.Println(dat)
  36800. } else {
  36801. fmt.Println(err)
  36802. }
  36803. userJSONBytes, _ := json.Marshal(dat)
  36804. var res models.Result9001
  36805. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36806. utils.ErrorLog("解析失败:%v", err)
  36807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36808. return
  36809. }
  36810. fmt.Println(res.Output.Signinoutb)
  36811. fmt.Println(res.Output.Signinoutb.SignNo)
  36812. fmt.Println(string(userJSONBytes))
  36813. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  36814. var dat3 map[string]interface{}
  36815. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  36816. fmt.Println(dat3)
  36817. } else {
  36818. fmt.Println(err)
  36819. }
  36820. userJSONBytes3, _ := json.Marshal(dat3)
  36821. var res3 models.Result3260
  36822. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  36823. utils.ErrorLog("解析失败:%v", err)
  36824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36825. return
  36826. }
  36827. var curpage int
  36828. var pagesize int = 100
  36829. var start int = 1
  36830. //var stop int
  36831. //pagecount := 10
  36832. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  36833. var res22 []models.Result3260
  36834. for curpage = 1; curpage <= pagecount; curpage++ {
  36835. if curpage == 1 {
  36836. start = 0
  36837. } else {
  36838. start = (curpage-1)*pagesize + 1
  36839. }
  36840. fmt.Println(start)
  36841. //stop = curpage * pagesize
  36842. //if stop > int(res3.Output.Totalrow) {
  36843. // stop =int(res3.Output.Totalrow)
  36844. //}
  36845. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  36846. var dat2 map[string]interface{}
  36847. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36848. fmt.Println(dat)
  36849. } else {
  36850. fmt.Println(err)
  36851. }
  36852. userJSONBytes2, _ := json.Marshal(dat2)
  36853. var res2 models.Result3260
  36854. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36855. utils.ErrorLog("解析失败:%v", err)
  36856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36857. return
  36858. }
  36859. if res2.Infcode == 0 {
  36860. res22 = append(res22, res2)
  36861. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36862. //var dat2 map[string]interface{}
  36863. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  36864. // fmt.Println(dat)
  36865. //} else {
  36866. // fmt.Println(err)
  36867. //}
  36868. //c.ServeSuccessJSON(map[string]interface{}{
  36869. // "list": res2.Output.Data,
  36870. //})
  36871. //continue
  36872. }
  36873. }
  36874. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  36875. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  36876. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  36877. //var dat2 map[string]interface{}
  36878. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36879. // fmt.Println(dat)
  36880. //} else {
  36881. // fmt.Println(err)
  36882. //}
  36883. //userJSONBytes2, _ := json.Marshal(dat2)
  36884. //var res2 models.Result3260
  36885. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36886. // utils.ErrorLog("解析失败:%v", err)
  36887. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36888. // return
  36889. //}
  36890. //if res2.Infcode == 0 {
  36891. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36892. // var dat2 map[string]interface{}
  36893. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  36894. // fmt.Println(dat)
  36895. // } else {
  36896. // fmt.Println(err)
  36897. // }
  36898. // c.ServeSuccessJSON(map[string]interface{}{
  36899. // "list": res2.Output.Data,
  36900. // })
  36901. //}
  36902. }
  36903. func (c *HisApiController) ComfirmAllopatry() {
  36904. year := c.GetString("year")
  36905. month := c.GetString("month")
  36906. admin_user_id, _ := c.GetInt64("admin_user_id")
  36907. adminUser := c.GetAdminUserInfo()
  36908. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36909. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36910. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36911. var dat map[string]interface{}
  36912. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36913. fmt.Println(dat)
  36914. } else {
  36915. fmt.Println(err)
  36916. }
  36917. userJSONBytes, _ := json.Marshal(dat)
  36918. var res models.Result9001
  36919. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36920. utils.ErrorLog("解析失败:%v", err)
  36921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36922. return
  36923. }
  36924. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  36925. var dat2 map[string]interface{}
  36926. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36927. fmt.Println(dat)
  36928. } else {
  36929. fmt.Println(err)
  36930. }
  36931. userJSONBytes2, _ := json.Marshal(dat2)
  36932. var res2 models.Result3260
  36933. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36934. utils.ErrorLog("解析失败:%v", err)
  36935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36936. return
  36937. }
  36938. //if res2.Infcode == 0 {
  36939. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36940. // var dat map[string]interface{}
  36941. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36942. // fmt.Println(dat)
  36943. // } else {
  36944. // fmt.Println(err)
  36945. // }
  36946. // userJSONBytes, _ := json.Marshal(dat)
  36947. // var res3 models.Result3261
  36948. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  36949. // utils.ErrorLog("解析失败:%v", err)
  36950. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36951. // return
  36952. // }
  36953. //
  36954. // if res3.Infcode == 0 {
  36955. // record := &models.HisYidiClearRecord{
  36956. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  36957. // Ctime: time.Now().Unix(),
  36958. // Mtime: time.Now().Unix(),
  36959. // Status: 1,
  36960. // MsgId: msgId,
  36961. // }
  36962. // service.SaveClearRecord(record)
  36963. // c.ServeSuccessJSON(map[string]interface{}{
  36964. // "msg": "提取成功",
  36965. // })
  36966. // }
  36967. //}
  36968. }
  36969. func (c *HisApiController) RefundAllopatry() {
  36970. year := c.GetString("year")
  36971. month := c.GetString("month")
  36972. //id, _ := c.GetInt64("id")
  36973. admin_user_id, _ := c.GetInt64("admin_user_id")
  36974. adminUser := c.GetAdminUserInfo()
  36975. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36976. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36977. //record, _ := service.GetClearRecordById(id)
  36978. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36979. var dat map[string]interface{}
  36980. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  36981. fmt.Println(dat)
  36982. } else {
  36983. fmt.Println(err)
  36984. }
  36985. userJSONBytes, _ := json.Marshal(dat)
  36986. var res models.Result9001
  36987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36988. utils.ErrorLog("解析失败:%v", err)
  36989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36990. return
  36991. }
  36992. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  36993. var dat2 map[string]interface{}
  36994. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36995. fmt.Println(dat)
  36996. } else {
  36997. fmt.Println(err)
  36998. }
  36999. userJSONBytes2, _ := json.Marshal(dat2)
  37000. var empty ResultFourteen
  37001. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  37002. utils.ErrorLog("解析失败:%v", err)
  37003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37004. return
  37005. }
  37006. if empty.Infcode == 0 {
  37007. c.ServeSuccessJSON(map[string]interface{}{
  37008. "msg": "撤销成功",
  37009. })
  37010. return
  37011. }
  37012. }
  37013. func (c *HisApiController) ReversalOtherData() {
  37014. var customData []*CustomData
  37015. custom := &CustomData{
  37016. MsgId: "H44022900158202103301714472004",
  37017. PsnNo: "44020000001101329945",
  37018. Info: "2208",
  37019. }
  37020. customData = append(customData, custom)
  37021. custom1 := &CustomData{
  37022. MsgId: "H4402290015820210330172057803",
  37023. PsnNo: "44020000001101161813",
  37024. Info: "2208",
  37025. }
  37026. customData = append(customData, custom1)
  37027. custom2 := &CustomData{
  37028. MsgId: "H44022900158202103301705198813",
  37029. PsnNo: "44190000133097375417",
  37030. Info: "2208",
  37031. }
  37032. customData = append(customData, custom2)
  37033. custom3 := &CustomData{
  37034. MsgId: "H44022900158202103301715524756",
  37035. PsnNo: "44020000001100187221",
  37036. Info: "2208",
  37037. }
  37038. customData = append(customData, custom3)
  37039. custom4 := &CustomData{
  37040. MsgId: "H44022900158202103301730376224",
  37041. PsnNo: "44020000001101959155",
  37042. Info: "2208",
  37043. }
  37044. customData = append(customData, custom4)
  37045. custom5 := &CustomData{
  37046. MsgId: "H44022900158202103301748008725",
  37047. PsnNo: "44020000001104246641",
  37048. Info: "2208",
  37049. }
  37050. customData = append(customData, custom5)
  37051. custom6 := &CustomData{
  37052. MsgId: "H44022900158202103301718096755",
  37053. PsnNo: "44020000001102211860",
  37054. Info: "2208",
  37055. }
  37056. customData = append(customData, custom6)
  37057. custom7 := &CustomData{
  37058. MsgId: "H44022900158202103301736551640",
  37059. PsnNo: "44020000001102687718",
  37060. Info: "2208",
  37061. }
  37062. customData = append(customData, custom7)
  37063. custom8 := &CustomData{
  37064. MsgId: "H44022900158202103301743097676",
  37065. PsnNo: "44020000001102127785",
  37066. Info: "2208",
  37067. }
  37068. customData = append(customData, custom8)
  37069. custom9 := &CustomData{
  37070. MsgId: "H44022900158202103301712304203",
  37071. PsnNo: "44020000001101518097",
  37072. Info: "2208",
  37073. }
  37074. customData = append(customData, custom9)
  37075. custom10 := &CustomData{
  37076. MsgId: "H44022900158202103301738448785",
  37077. PsnNo: "44020000001100500813",
  37078. Info: "2208",
  37079. }
  37080. customData = append(customData, custom10)
  37081. custom11 := &CustomData{
  37082. MsgId: "H44022900158202103301732455843",
  37083. PsnNo: "44020000001102690557",
  37084. Info: "2208",
  37085. }
  37086. customData = append(customData, custom11)
  37087. custom12 := &CustomData{
  37088. MsgId: "H44022900158202103301745421708",
  37089. PsnNo: "44020000001102211928",
  37090. Info: "2208",
  37091. }
  37092. customData = append(customData, custom12)
  37093. custom1212 := &CustomData{
  37094. MsgId: "H440229001582021033017351627",
  37095. PsnNo: "44020000001102481733",
  37096. Info: "2208",
  37097. }
  37098. customData = append(customData, custom1212)
  37099. custom13 := &CustomData{
  37100. MsgId: "H44022900158202103301740327951",
  37101. PsnNo: "44020000001103174866",
  37102. Info: "2208",
  37103. }
  37104. customData = append(customData, custom13)
  37105. custom14 := &CustomData{
  37106. MsgId: "H4402290015820210330174922668",
  37107. PsnNo: "44020000001102927272",
  37108. Info: "2208",
  37109. }
  37110. customData = append(customData, custom14)
  37111. custom15 := &CustomData{
  37112. MsgId: "H44022900158202103301752362273",
  37113. PsnNo: "44020000001102942890",
  37114. Info: "2208",
  37115. }
  37116. customData = append(customData, custom15)
  37117. custom16 := &CustomData{
  37118. MsgId: "H44022900158202103301751082917",
  37119. PsnNo: "44020000001101662162",
  37120. Info: "2208",
  37121. }
  37122. customData = append(customData, custom16)
  37123. custom17 := &CustomData{
  37124. MsgId: "H44022900158202103301754147728",
  37125. PsnNo: "44020000000229014511",
  37126. Info: "2208",
  37127. }
  37128. customData = append(customData, custom17)
  37129. adminUser := c.GetAdminUserInfo()
  37130. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37131. for _, item := range customData {
  37132. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37133. fmt.Println(result)
  37134. }
  37135. }
  37136. func PathExists(path string) (bool, error) {
  37137. _, err := os.Stat(path)
  37138. if err == nil {
  37139. return true, nil
  37140. }
  37141. if os.IsNotExist(err) {
  37142. return false, nil
  37143. }
  37144. return false, err
  37145. }
  37146. // 创建文件夹
  37147. func Mkdir(dir string) {
  37148. // 创建文件夹
  37149. exist, err := PathExists(dir)
  37150. if err != nil {
  37151. fmt.Println(err.Error())
  37152. } else {
  37153. if exist {
  37154. fmt.Println(dir + "文件夹已存在!")
  37155. } else {
  37156. // 文件夹名称,权限
  37157. err := os.Mkdir(dir, os.ModePerm)
  37158. if err != nil {
  37159. fmt.Println(dir+"文件夹创建失败:", err.Error())
  37160. } else {
  37161. fmt.Println(dir + "文件夹创建成功!")
  37162. }
  37163. }
  37164. }
  37165. }
  37166. // 压缩文件
  37167. func Zip(srcFile string, destZip string) error {
  37168. zipfile, err := os.Create(destZip)
  37169. if err != nil {
  37170. return err
  37171. }
  37172. defer zipfile.Close()
  37173. archive := zip.NewWriter(zipfile)
  37174. defer archive.Close()
  37175. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  37176. if err != nil {
  37177. return err
  37178. }
  37179. header, err := zip.FileInfoHeader(info)
  37180. if err != nil {
  37181. return err
  37182. }
  37183. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  37184. // header.Name = path
  37185. if info.IsDir() {
  37186. header.Name += "/"
  37187. } else {
  37188. header.Method = zip.Deflate
  37189. }
  37190. writer, err := archive.CreateHeader(header)
  37191. if err != nil {
  37192. return err
  37193. }
  37194. if !info.IsDir() {
  37195. file, err := os.Open(path)
  37196. if err != nil {
  37197. return err
  37198. }
  37199. defer file.Close()
  37200. _, err = io.Copy(writer, file)
  37201. }
  37202. return err
  37203. })
  37204. return err
  37205. }
  37206. func ReadFile(filePath string) []byte {
  37207. f, err := os.Open(filePath)
  37208. if err != nil {
  37209. fmt.Println("read file fail", err)
  37210. return nil
  37211. }
  37212. defer f.Close()
  37213. fd, err := ioutil.ReadAll(f)
  37214. if err != nil {
  37215. fmt.Println("read to fd fail", err)
  37216. return nil
  37217. }
  37218. return fd
  37219. }
  37220. func saveLogq(result string, request string, infno string, desc string) {
  37221. dir := "日志"
  37222. utils.Mkdir(dir)
  37223. month := time.Unix(1557042972, 0).Format("1")
  37224. year := time.Now().Format("2006")
  37225. month = time.Now().Format("01")
  37226. day := time.Now().Format("02")
  37227. hour := time.Now().Format("15")
  37228. min := time.Now().Format("04")
  37229. sec := time.Now().Format("05")
  37230. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37231. file := year + month + day + "_log"
  37232. file_name := file + ".txt"
  37233. file_path := "日志" + "/" + file_name
  37234. exist, _ := utils.PathExists(file_path)
  37235. if exist { //存在
  37236. fmt.Println("存在")
  37237. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37238. if err != nil {
  37239. fmt.Println("read fail")
  37240. }
  37241. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37242. n, _ := f.Seek(0, 2)
  37243. _, err = f.WriteAt([]byte(content), n)
  37244. } else { //不存在
  37245. fmt.Println("文件不存在,创建文件")
  37246. f, err := os.Create("日志" + "/" + file_name)
  37247. defer f.Close()
  37248. if err != nil {
  37249. } else {
  37250. _, err = f.Write([]byte("记录日志"))
  37251. }
  37252. }
  37253. }
  37254. func saveLog(result string, request string, infno string, desc string) {
  37255. org_id, _ := beego.AppConfig.Int64("org_id")
  37256. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37257. dir := miConfig.OrgName + "日志"
  37258. utils.Mkdir(dir)
  37259. month := time.Unix(1557042972, 0).Format("1")
  37260. year := time.Now().Format("2006")
  37261. month = time.Now().Format("01")
  37262. day := time.Now().Format("02")
  37263. hour := time.Now().Format("15")
  37264. min := time.Now().Format("04")
  37265. sec := time.Now().Format("05")
  37266. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37267. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  37268. file_name := file + ".txt"
  37269. file_path := miConfig.OrgName + "日志" + "/" + file_name
  37270. exist, _ := utils.PathExists(file_path)
  37271. if exist { //存在
  37272. fmt.Println("存在")
  37273. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37274. if err != nil {
  37275. fmt.Println("read fail")
  37276. }
  37277. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37278. n, _ := f.Seek(0, 2)
  37279. _, err = f.WriteAt([]byte(content), n)
  37280. } else { //不存在
  37281. fmt.Println("文件不存在,创建文件")
  37282. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  37283. defer f.Close()
  37284. if err != nil {
  37285. } else {
  37286. _, err = f.Write([]byte("记录日志"))
  37287. }
  37288. }
  37289. }
  37290. type Charset string
  37291. const (
  37292. UTF8 = Charset("UTF-8")
  37293. GB18030 = Charset("GB18030")
  37294. )
  37295. func ConvertToString(src string, srcCode string, tagCode string) string {
  37296. srcCoder := mahonia.NewDecoder(srcCode)
  37297. srcResult := srcCoder.ConvertString(src)
  37298. tagCoder := mahonia.NewDecoder(tagCode)
  37299. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  37300. result := string(cdata)
  37301. return result
  37302. }
  37303. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  37304. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37305. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37306. var token string
  37307. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37308. var api string
  37309. if miConfig.MdtrtareaAdmvs == "320921" {
  37310. 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 +
  37311. "&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
  37312. fmt.Println(api)
  37313. } else {
  37314. 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 +
  37315. "&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
  37316. }
  37317. resp, requestErr := http.Get(api)
  37318. if requestErr != nil {
  37319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37320. return ""
  37321. }
  37322. body, ioErr := ioutil.ReadAll(resp.Body)
  37323. if ioErr != nil {
  37324. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37326. return ""
  37327. }
  37328. var respJSON map[string]interface{}
  37329. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37332. return ""
  37333. }
  37334. var status string
  37335. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37336. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37337. var res ResultTwo //1101结果
  37338. var res10265 ResultTwo10265 //1101结果
  37339. if status == "0" { //读卡成功
  37340. var card_info string //卡信息
  37341. var busi_card_info string
  37342. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37343. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37344. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37345. fmt.Println(card_info)
  37346. fmt.Println(busi_card_info)
  37347. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37348. result, _ := json.Marshal(respJSON)
  37349. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37350. utils.ErrorLog("解析失败:%v", err)
  37351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37352. return ""
  37353. }
  37354. res.ErrMsg = res10265.ErrMsg
  37355. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37356. res.Infcode = infocode
  37357. res.Output = res10265.Output
  37358. res.InfRefmsgid = res10265.InfRefmsgid
  37359. if res.Infcode == 0 {
  37360. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37361. if err == gorm.ErrRecordNotFound {
  37362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37363. return ""
  37364. } else if err != nil {
  37365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37366. return ""
  37367. } else {
  37368. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37369. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37370. infoStr := string(Iinfos)
  37371. idetinfoStr := string(Idetinfos)
  37372. psn := &models.HisPsn{
  37373. PsnNo: res.Output.Baseinfo.PsnNo,
  37374. PatientId: patient.ID,
  37375. Certno: res.Output.Baseinfo.Certno,
  37376. Gend: res.Output.Baseinfo.Gend,
  37377. Naty: res.Output.Baseinfo.Naty,
  37378. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37379. PsnName: res.Output.Baseinfo.PsnName,
  37380. Idetinfo: idetinfoStr,
  37381. Insuinfo: infoStr,
  37382. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37383. CardInfo: card_info,
  37384. VerifyNumber: token,
  37385. }
  37386. service.CreateHisPsn(psn)
  37387. return token
  37388. }
  37389. }
  37390. } else {
  37391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37392. return ""
  37393. }
  37394. } else { //读卡失败
  37395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37396. return ""
  37397. }
  37398. return token
  37399. }
  37400. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  37401. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37402. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37403. var token string
  37404. var api string
  37405. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  37406. "&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
  37407. fmt.Println(api)
  37408. resp, requestErr := http.Get(api)
  37409. if requestErr != nil {
  37410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37411. return ""
  37412. }
  37413. body, ioErr := ioutil.ReadAll(resp.Body)
  37414. if ioErr != nil {
  37415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37417. return ""
  37418. }
  37419. var respJSON map[string]interface{}
  37420. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37423. return ""
  37424. }
  37425. var status string
  37426. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37427. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37428. var res ResultTwo //1101结果
  37429. if status == "1" { //读卡成功
  37430. var card_info string //卡信息
  37431. var busi_card_info string
  37432. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37433. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37434. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37435. fmt.Println(card_info)
  37436. fmt.Println(busi_card_info)
  37437. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37438. result, _ := json.Marshal(respJSON)
  37439. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37440. utils.ErrorLog("解析失败:%v", err)
  37441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37442. return ""
  37443. }
  37444. if res.Infcode == 0 {
  37445. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37446. if err == gorm.ErrRecordNotFound {
  37447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37448. return ""
  37449. } else if err != nil {
  37450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37451. return ""
  37452. } else {
  37453. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37454. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37455. infoStr := string(Iinfos)
  37456. idetinfoStr := string(Idetinfos)
  37457. psn := &models.HisPsn{
  37458. PsnNo: res.Output.Baseinfo.PsnNo,
  37459. PatientId: patient.ID,
  37460. Certno: res.Output.Baseinfo.Certno,
  37461. Gend: res.Output.Baseinfo.Gend,
  37462. Naty: res.Output.Baseinfo.Naty,
  37463. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37464. PsnName: res.Output.Baseinfo.PsnName,
  37465. Idetinfo: idetinfoStr,
  37466. Insuinfo: infoStr,
  37467. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37468. CardInfo: card_info,
  37469. VerifyNumber: token,
  37470. }
  37471. service.CreateHisPsn(psn)
  37472. return token
  37473. }
  37474. }
  37475. } else {
  37476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37477. return ""
  37478. }
  37479. return token
  37480. }
  37481. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  37482. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37483. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37484. var token string
  37485. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37486. var api string
  37487. if miConfig.MdtrtareaAdmvs == "320921" {
  37488. 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 +
  37489. "&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
  37490. fmt.Println(api)
  37491. } else {
  37492. 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 +
  37493. "&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
  37494. }
  37495. resp, requestErr := http.Get(api)
  37496. if requestErr != nil {
  37497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37498. return ""
  37499. }
  37500. body, ioErr := ioutil.ReadAll(resp.Body)
  37501. if ioErr != nil {
  37502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37504. return ""
  37505. }
  37506. var respJSON map[string]interface{}
  37507. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37510. return ""
  37511. }
  37512. var status string
  37513. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37514. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37515. var res ResultTwo //1101结果
  37516. var res10265 ResultTwo10265 //1101结果
  37517. if status == "0" { //读卡成功
  37518. var card_info string //卡信息
  37519. var busi_card_info string
  37520. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37521. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37522. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37523. fmt.Println(card_info)
  37524. fmt.Println(busi_card_info)
  37525. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37526. result, _ := json.Marshal(respJSON)
  37527. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37528. utils.ErrorLog("解析失败:%v", err)
  37529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37530. return ""
  37531. }
  37532. res.ErrMsg = res10265.ErrMsg
  37533. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37534. res.Infcode = infocode
  37535. res.Output = res10265.Output
  37536. res.InfRefmsgid = res10265.InfRefmsgid
  37537. if res.Infcode == 0 {
  37538. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37539. if err == gorm.ErrRecordNotFound {
  37540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37541. return ""
  37542. } else if err != nil {
  37543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37544. return ""
  37545. } else {
  37546. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37547. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37548. infoStr := string(Iinfos)
  37549. idetinfoStr := string(Idetinfos)
  37550. psn := &models.HisPsn{
  37551. PsnNo: res.Output.Baseinfo.PsnNo,
  37552. PatientId: patient.ID,
  37553. Certno: res.Output.Baseinfo.Certno,
  37554. Gend: res.Output.Baseinfo.Gend,
  37555. Naty: res.Output.Baseinfo.Naty,
  37556. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37557. PsnName: res.Output.Baseinfo.PsnName,
  37558. Idetinfo: idetinfoStr,
  37559. Insuinfo: infoStr,
  37560. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37561. CardInfo: card_info,
  37562. VerifyNumber: token,
  37563. }
  37564. service.CreateHisPsn(psn)
  37565. return token
  37566. }
  37567. }
  37568. } else {
  37569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37570. return ""
  37571. }
  37572. } else { //读卡失败
  37573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37574. return ""
  37575. }
  37576. return token
  37577. }
  37578. func DeleteExtraSpaceTwo(s string) string {
  37579. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37580. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37581. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37582. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37583. s2 := make([]byte, len(s1)) //定义字符数组切片
  37584. copy(s2, s1) //将字符串复制到切片
  37585. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37586. for len(spc_index) > 0 { //找到适配项
  37587. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37588. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37589. }
  37590. return string(s2)
  37591. }
  37592. func Remove0000(s string) string {
  37593. str := make([]rune, 0, len(s))
  37594. for _, v := range []rune(s) {
  37595. if v == 0 {
  37596. continue
  37597. }
  37598. str = append(str, v)
  37599. }
  37600. return string(str)
  37601. }
  37602. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  37603. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  37604. readCard := DllDef.MustFindProc("EcQuery")
  37605. pCardInfo := make([]byte, 8192)
  37606. pBusiCardInfo := make([]byte, 8192)
  37607. data := make(map[string]interface{})
  37608. //pData := make(map[string]interface{})
  37609. inputData := make(map[string]interface{})
  37610. inputData["orgId"] = code
  37611. inputData["businessType"] = "01101"
  37612. inputData["operatorId"] = operator_id
  37613. inputData["operatorName"] = operator_name
  37614. inputData["officeId"] = "001"
  37615. inputData["officeName"] = "血透室"
  37616. //
  37617. data["data"] = inputData
  37618. data["transType"] = "ec.query"
  37619. data["orgId"] = code
  37620. bytesData, _ := json.Marshal(data)
  37621. pCardInfo = bytesData
  37622. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  37623. fmt.Println(ret2)
  37624. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  37625. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  37626. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  37627. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  37628. if ret2 != 0 {
  37629. return "", ""
  37630. }
  37631. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  37632. }
  37633. func DeleteExtraSpace(s string) string {
  37634. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37635. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37636. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37637. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37638. s2 := make([]byte, len(s1)) //定义字符数组切片
  37639. copy(s2, s1) //将字符串复制到切片
  37640. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37641. for len(spc_index) > 0 { //找到适配项
  37642. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37643. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37644. }
  37645. return string(s2)
  37646. }
  37647. // 对账
  37648. func (c *HisApiController) Post3202() {
  37649. start_time := c.GetString("start_time")
  37650. end_time := c.GetString("end_time")
  37651. //insutype := c.GetString("insutype")
  37652. clr_type := c.GetString("clr_type")
  37653. clr_org := c.GetString("clr_optins")
  37654. admin_user_id, _ := c.GetInt64("admin_user_id")
  37655. adminUser := c.GetAdminUserInfo()
  37656. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37657. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37658. if len(clr_org) == 0 {
  37659. clr_org = miConfig.MdtrtareaAdmvs
  37660. }
  37661. timeLayout := "2006-01-02"
  37662. loc, _ := time.LoadLocation("Local")
  37663. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37664. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37665. var orders []*models.HisOrder
  37666. if clr_org == "421300" {
  37667. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37668. } else if clr_org == "420902" {
  37669. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37670. } else {
  37671. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37672. }
  37673. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37674. //fixmedins_setl_cnt := int64(len(orders))
  37675. var medfee_sumamt float64
  37676. var acct_pay float64
  37677. var fund_pay_sumamt float64
  37678. for _, item := range orders {
  37679. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37680. acct_pay = acct_pay + item.AcctPay
  37681. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37682. }
  37683. //var medfee_sumamt_two float64
  37684. //var acct_pay_two float64
  37685. //var fund_pay_sumamt_two float64
  37686. //for _, item := range orders_two {
  37687. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37688. // acct_pay_two = acct_pay_two + item.AcctPay
  37689. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37690. //}
  37691. //var user_name string
  37692. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37693. //if role.ID == 0 {
  37694. // user_name = "xxx"
  37695. //} else {
  37696. // user_name = role.UserName
  37697. //}
  37698. var res ResultSix
  37699. if config.IsOpen == 1 {
  37700. var bps []*models.BusinessParamsTwo
  37701. var bp models.BusinessParamsTwo
  37702. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37703. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37704. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37705. bp.MedfeeSumamt = medfee_sumamt_str
  37706. bp.AcctPay = acct_pay_str
  37707. bp.FundPaySumamt = fund_pay_sumamt_str
  37708. bp.Insutype = ""
  37709. bp.StmtBegndate = start_time
  37710. bp.ClrType = clr_type
  37711. bp.SetlOptins = clr_org
  37712. bp.StmtEnddate = end_time
  37713. bps = append(bps, &bp)
  37714. data := make(map[string]interface{})
  37715. data["bps"] = bps
  37716. data["org_name"] = miConfig.OrgName
  37717. data["doctor"] = role.UserName
  37718. data["fixmedins_code"] = miConfig.Code
  37719. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37720. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37721. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37722. if miConfig.MdtrtareaAdmvs == "421300" {
  37723. client := &http.Client{}
  37724. bytesData, _ := json.Marshal(data)
  37725. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37726. resp, _ := client.Do(req)
  37727. defer resp.Body.Close()
  37728. body, ioErr := ioutil.ReadAll(resp.Body)
  37729. if ioErr != nil {
  37730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37732. return
  37733. }
  37734. var respJSON map[string]interface{}
  37735. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37738. return
  37739. }
  37740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37741. userJSONBytes, _ := json.Marshal(respJSON)
  37742. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37743. utils.ErrorLog("解析失败:%v", err)
  37744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37745. return
  37746. }
  37747. }
  37748. if miConfig.MdtrtareaAdmvs == "420200" {
  37749. client := &http.Client{}
  37750. bytesData, _ := json.Marshal(data)
  37751. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37752. resp, _ := client.Do(req)
  37753. defer resp.Body.Close()
  37754. body, ioErr := ioutil.ReadAll(resp.Body)
  37755. if ioErr != nil {
  37756. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37758. return
  37759. }
  37760. var respJSON map[string]interface{}
  37761. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37764. return
  37765. }
  37766. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37767. userJSONBytes, _ := json.Marshal(respJSON)
  37768. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37769. utils.ErrorLog("解析失败:%v", err)
  37770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37771. return
  37772. }
  37773. }
  37774. if miConfig.MdtrtareaAdmvs == "421182" {
  37775. client := &http.Client{}
  37776. bytesData, _ := json.Marshal(data)
  37777. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37778. resp, _ := client.Do(req)
  37779. defer resp.Body.Close()
  37780. body, ioErr := ioutil.ReadAll(resp.Body)
  37781. if ioErr != nil {
  37782. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37784. return
  37785. }
  37786. var respJSON map[string]interface{}
  37787. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37790. return
  37791. }
  37792. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37793. userJSONBytes, _ := json.Marshal(respJSON)
  37794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37795. utils.ErrorLog("解析失败:%v", err)
  37796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37797. return
  37798. }
  37799. }
  37800. if miConfig.MdtrtareaAdmvs == "420902" {
  37801. client := &http.Client{}
  37802. bytesData, _ := json.Marshal(data)
  37803. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37804. resp, _ := client.Do(req)
  37805. defer resp.Body.Close()
  37806. body, ioErr := ioutil.ReadAll(resp.Body)
  37807. if ioErr != nil {
  37808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37810. return
  37811. }
  37812. var respJSON map[string]interface{}
  37813. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37816. return
  37817. }
  37818. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37819. userJSONBytes, _ := json.Marshal(respJSON)
  37820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37821. utils.ErrorLog("解析失败:%v", err)
  37822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37823. return
  37824. }
  37825. }
  37826. if res.Infcode == 0 {
  37827. c.ServeSuccessJSON(map[string]interface{}{
  37828. "msg": "发起成功",
  37829. })
  37830. } else {
  37831. c.ServeSuccessJSON(map[string]interface{}{
  37832. "failed_code": -10,
  37833. "msg": res.ErrMsg,
  37834. })
  37835. }
  37836. }
  37837. }
  37838. func (c *HisApiController) Post3204a() {
  37839. start_time := c.GetString("start_time")
  37840. end_time := c.GetString("end_time")
  37841. //insutype := c.GetString("insutype")
  37842. clr_type := c.GetString("clr_type")
  37843. clr_org := c.GetString("clr_optins")
  37844. admin_user_id, _ := c.GetInt64("admin_user_id")
  37845. adminUser := c.GetAdminUserInfo()
  37846. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37847. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37848. if len(clr_org) == 0 {
  37849. clr_org = miConfig.MdtrtareaAdmvs
  37850. }
  37851. timeLayout := "2006-01-02"
  37852. loc, _ := time.LoadLocation("Local")
  37853. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37854. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37855. var orders []*models.HisOrder
  37856. if clr_org == "421300" {
  37857. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37858. } else if clr_org == "420902" {
  37859. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37860. } else {
  37861. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37862. }
  37863. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37864. //fixmedins_setl_cnt := int64(len(orders))
  37865. var medfee_sumamt float64
  37866. var acct_pay float64
  37867. var fund_pay_sumamt float64
  37868. for _, item := range orders {
  37869. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37870. acct_pay = acct_pay + item.AcctPay
  37871. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37872. }
  37873. //var medfee_sumamt_two float64
  37874. //var acct_pay_two float64
  37875. //var fund_pay_sumamt_two float64
  37876. //for _, item := range orders_two {
  37877. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37878. // acct_pay_two = acct_pay_two + item.AcctPay
  37879. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37880. //}
  37881. //var user_name string
  37882. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37883. //if role.ID == 0 {
  37884. // user_name = "xxx"
  37885. //} else {
  37886. // user_name = role.UserName
  37887. //}
  37888. var res ResultSix
  37889. if config.IsOpen == 1 {
  37890. var bps []*models.BusinessParamsTwo
  37891. var bp models.BusinessParamsTwo
  37892. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37893. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37894. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37895. bp.MedfeeSumamt = medfee_sumamt_str
  37896. bp.AcctPay = acct_pay_str
  37897. bp.FundPaySumamt = fund_pay_sumamt_str
  37898. bp.Insutype = ""
  37899. bp.StmtBegndate = start_time
  37900. bp.ClrType = clr_type
  37901. bp.SetlOptins = clr_org
  37902. bp.StmtEnddate = end_time
  37903. bps = append(bps, &bp)
  37904. data := make(map[string]interface{})
  37905. data["bps"] = bps
  37906. data["org_name"] = miConfig.OrgName
  37907. data["doctor"] = role.UserName
  37908. data["fixmedins_code"] = miConfig.Code
  37909. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37910. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37911. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37912. if miConfig.MdtrtareaAdmvs == "421300" {
  37913. client := &http.Client{}
  37914. bytesData, _ := json.Marshal(data)
  37915. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  37916. resp, _ := client.Do(req)
  37917. defer resp.Body.Close()
  37918. body, ioErr := ioutil.ReadAll(resp.Body)
  37919. if ioErr != nil {
  37920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37922. return
  37923. }
  37924. var respJSON map[string]interface{}
  37925. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37928. return
  37929. }
  37930. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37931. userJSONBytes, _ := json.Marshal(respJSON)
  37932. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37933. utils.ErrorLog("解析失败:%v", err)
  37934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37935. return
  37936. }
  37937. }
  37938. if miConfig.MdtrtareaAdmvs == "420200" {
  37939. client := &http.Client{}
  37940. bytesData, _ := json.Marshal(data)
  37941. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  37942. resp, _ := client.Do(req)
  37943. defer resp.Body.Close()
  37944. body, ioErr := ioutil.ReadAll(resp.Body)
  37945. if ioErr != nil {
  37946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37948. return
  37949. }
  37950. var respJSON map[string]interface{}
  37951. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37954. return
  37955. }
  37956. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37957. userJSONBytes, _ := json.Marshal(respJSON)
  37958. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37959. utils.ErrorLog("解析失败:%v", err)
  37960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37961. return
  37962. }
  37963. }
  37964. if miConfig.MdtrtareaAdmvs == "421182" {
  37965. client := &http.Client{}
  37966. bytesData, _ := json.Marshal(data)
  37967. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  37968. resp, _ := client.Do(req)
  37969. defer resp.Body.Close()
  37970. body, ioErr := ioutil.ReadAll(resp.Body)
  37971. if ioErr != nil {
  37972. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37974. return
  37975. }
  37976. var respJSON map[string]interface{}
  37977. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37980. return
  37981. }
  37982. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37983. userJSONBytes, _ := json.Marshal(respJSON)
  37984. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37985. utils.ErrorLog("解析失败:%v", err)
  37986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37987. return
  37988. }
  37989. }
  37990. if miConfig.MdtrtareaAdmvs == "420902" {
  37991. client := &http.Client{}
  37992. bytesData, _ := json.Marshal(data)
  37993. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  37994. resp, _ := client.Do(req)
  37995. defer resp.Body.Close()
  37996. body, ioErr := ioutil.ReadAll(resp.Body)
  37997. if ioErr != nil {
  37998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38000. return
  38001. }
  38002. var respJSON map[string]interface{}
  38003. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38006. return
  38007. }
  38008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38009. userJSONBytes, _ := json.Marshal(respJSON)
  38010. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38011. utils.ErrorLog("解析失败:%v", err)
  38012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38013. return
  38014. }
  38015. }
  38016. if res.Infcode == 0 {
  38017. c.ServeSuccessJSON(map[string]interface{}{
  38018. "msg": "撤销成功",
  38019. })
  38020. } else {
  38021. c.ServeSuccessJSON(map[string]interface{}{
  38022. "failed_code": -10,
  38023. "msg": res.ErrMsg,
  38024. })
  38025. }
  38026. }
  38027. }
  38028. func (c *HisApiController) Post3204() {
  38029. admin_user_id, _ := c.GetInt64("admin_user_id")
  38030. id := c.GetString("id")
  38031. adminUser := c.GetAdminUserInfo()
  38032. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38033. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38034. //clr_org := miConfig.MdtrtareaAdmvs
  38035. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38036. var res ResultSix
  38037. if config.IsOpen == 1 {
  38038. data := make(map[string]interface{})
  38039. data["id"] = id
  38040. data["org_name"] = miConfig.OrgName
  38041. data["doctor"] = role.UserName
  38042. data["fixmedins_code"] = miConfig.Code
  38043. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38044. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38045. client := &http.Client{}
  38046. bytesData, _ := json.Marshal(data)
  38047. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  38048. resp, _ := client.Do(req)
  38049. defer resp.Body.Close()
  38050. body, ioErr := ioutil.ReadAll(resp.Body)
  38051. if ioErr != nil {
  38052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38054. return
  38055. }
  38056. var respJSON map[string]interface{}
  38057. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38060. return
  38061. }
  38062. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38063. userJSONBytes, _ := json.Marshal(respJSON)
  38064. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38065. utils.ErrorLog("解析失败:%v", err)
  38066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38067. return
  38068. }
  38069. if res.Infcode == 0 {
  38070. c.ServeSuccessJSON(map[string]interface{}{
  38071. "msg": "发起成功",
  38072. })
  38073. } else {
  38074. c.ServeSuccessJSON(map[string]interface{}{
  38075. "failed_code": -10,
  38076. "msg": res.ErrMsg,
  38077. })
  38078. }
  38079. }
  38080. }
  38081. func (c *HisApiController) Post8404() {
  38082. admin_user_id, _ := c.GetInt64("admin_user_id")
  38083. month := c.GetString("month")
  38084. adminUser := c.GetAdminUserInfo()
  38085. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38086. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38087. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38088. var res ResultSix
  38089. if config.IsOpen == 1 {
  38090. data := make(map[string]interface{})
  38091. data["month"] = month
  38092. data["org_name"] = miConfig.OrgName
  38093. data["doctor"] = role.UserName
  38094. data["fixmedins_code"] = miConfig.Code
  38095. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38096. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38097. client := &http.Client{}
  38098. bytesData, _ := json.Marshal(data)
  38099. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  38100. resp, _ := client.Do(req)
  38101. defer resp.Body.Close()
  38102. body, ioErr := ioutil.ReadAll(resp.Body)
  38103. if ioErr != nil {
  38104. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38106. return
  38107. }
  38108. var respJSON map[string]interface{}
  38109. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38112. return
  38113. }
  38114. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38115. userJSONBytes, _ := json.Marshal(respJSON)
  38116. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38117. utils.ErrorLog("解析失败:%v", err)
  38118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38119. return
  38120. }
  38121. if res.Infcode == 0 {
  38122. c.ServeSuccessJSON(map[string]interface{}{
  38123. "msg": "查询成功",
  38124. })
  38125. } else {
  38126. c.ServeSuccessJSON(map[string]interface{}{
  38127. "failed_code": -10,
  38128. "msg": res.ErrMsg,
  38129. })
  38130. }
  38131. }
  38132. }
  38133. func (c *HisApiController) Post3202b() {
  38134. start_time := c.GetString("start_time")
  38135. end_time := c.GetString("end_time")
  38136. //insutype := c.GetString("insutype")
  38137. clr_type := c.GetString("clr_type")
  38138. clr_org := c.GetString("clr_optins")
  38139. admin_user_id, _ := c.GetInt64("admin_user_id")
  38140. adminUser := c.GetAdminUserInfo()
  38141. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38142. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38143. if len(clr_org) == 0 {
  38144. clr_org = miConfig.MdtrtareaAdmvs
  38145. }
  38146. timeLayout := "2006-01-02"
  38147. loc, _ := time.LoadLocation("Local")
  38148. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38149. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38150. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38151. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38152. //fixmedins_setl_cnt := int64(len(orders))
  38153. var medfee_sumamt float64
  38154. var acct_pay float64
  38155. var fund_pay_sumamt float64
  38156. for _, item := range orders {
  38157. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38158. acct_pay = acct_pay + item.AcctPay
  38159. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38160. }
  38161. //var medfee_sumamt_two float64
  38162. //var acct_pay_two float64
  38163. //var fund_pay_sumamt_two float64
  38164. //for _, item := range orders_two {
  38165. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38166. // acct_pay_two = acct_pay_two + item.AcctPay
  38167. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38168. //}
  38169. //var user_name string
  38170. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38171. //if role.ID == 0 {
  38172. // user_name = "xxx"
  38173. //} else {
  38174. // user_name = role.UserName
  38175. //}
  38176. var res ResultSix
  38177. if config.IsOpen == 1 {
  38178. var bps []*models.BusinessParamsTwo
  38179. var bp models.BusinessParamsTwo
  38180. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38181. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38182. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38183. bp.MedfeeSumamt = medfee_sumamt_str
  38184. bp.AcctPay = acct_pay_str
  38185. bp.FundPaySumamt = fund_pay_sumamt_str
  38186. bp.Insutype = "390"
  38187. bp.StmtBegndate = start_time
  38188. bp.ClrType = clr_type
  38189. bp.SetlOptins = clr_org
  38190. bp.StmtEnddate = end_time
  38191. bps = append(bps, &bp)
  38192. data := make(map[string]interface{})
  38193. data["bps"] = bps
  38194. data["org_name"] = miConfig.OrgName
  38195. data["doctor"] = role.UserName
  38196. data["fixmedins_code"] = miConfig.Code
  38197. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38198. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38199. if miConfig.MdtrtareaAdmvs == "421300" {
  38200. client := &http.Client{}
  38201. bytesData, _ := json.Marshal(data)
  38202. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38203. resp, _ := client.Do(req)
  38204. defer resp.Body.Close()
  38205. body, ioErr := ioutil.ReadAll(resp.Body)
  38206. if ioErr != nil {
  38207. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38209. return
  38210. }
  38211. var respJSON map[string]interface{}
  38212. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38215. return
  38216. }
  38217. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38218. userJSONBytes, _ := json.Marshal(respJSON)
  38219. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38220. utils.ErrorLog("解析失败:%v", err)
  38221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38222. return
  38223. }
  38224. }
  38225. if miConfig.MdtrtareaAdmvs == "420200" {
  38226. client := &http.Client{}
  38227. bytesData, _ := json.Marshal(data)
  38228. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38229. resp, _ := client.Do(req)
  38230. defer resp.Body.Close()
  38231. body, ioErr := ioutil.ReadAll(resp.Body)
  38232. if ioErr != nil {
  38233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38235. return
  38236. }
  38237. var respJSON map[string]interface{}
  38238. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38241. return
  38242. }
  38243. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38244. userJSONBytes, _ := json.Marshal(respJSON)
  38245. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38246. utils.ErrorLog("解析失败:%v", err)
  38247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38248. return
  38249. }
  38250. }
  38251. if miConfig.MdtrtareaAdmvs == "421182" {
  38252. client := &http.Client{}
  38253. bytesData, _ := json.Marshal(data)
  38254. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  38255. resp, _ := client.Do(req)
  38256. defer resp.Body.Close()
  38257. body, ioErr := ioutil.ReadAll(resp.Body)
  38258. if ioErr != nil {
  38259. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38261. return
  38262. }
  38263. var respJSON map[string]interface{}
  38264. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38267. return
  38268. }
  38269. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38270. userJSONBytes, _ := json.Marshal(respJSON)
  38271. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38272. utils.ErrorLog("解析失败:%v", err)
  38273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38274. return
  38275. }
  38276. }
  38277. if res.Infcode == 0 {
  38278. c.ServeSuccessJSON(map[string]interface{}{
  38279. "msg": "发起成功",
  38280. })
  38281. } else {
  38282. c.ServeSuccessJSON(map[string]interface{}{
  38283. "failed_code": -10,
  38284. "msg": res.ErrMsg,
  38285. })
  38286. }
  38287. }
  38288. }
  38289. func (c *HisApiController) Post1608() {
  38290. start_time := c.GetString("start_time")
  38291. end_time := c.GetString("end_time")
  38292. admin_user_id, _ := c.GetInt64("admin_user_id")
  38293. adminUser := c.GetAdminUserInfo()
  38294. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38295. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38296. timeLayout := "2006-01-02"
  38297. loc, _ := time.LoadLocation("Local")
  38298. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38299. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38300. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38301. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38302. fixmedins_setl_cnt := int64(len(orders))
  38303. var medfee_sumamt float64
  38304. var func_smamt float64
  38305. for _, item := range orders {
  38306. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38307. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  38308. }
  38309. times := strings.Split(start_time, "-")
  38310. time_tows := strings.Split(end_time, "-")
  38311. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38312. var res ResultSix
  38313. if config.IsOpen == 1 {
  38314. //var bps []*models.BusinessParamsTwo
  38315. //var bp models.BusinessParamsTwo
  38316. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38317. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  38318. data := make(map[string]interface{})
  38319. data["org_name"] = miConfig.OrgName
  38320. data["doctor"] = role.UserName
  38321. data["func_smamt"] = func_smamt_str
  38322. data["fixmedins_code"] = miConfig.Code
  38323. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38324. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38325. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  38326. data["medfee_sumamt"] = medfee_sumamt_str
  38327. data["start_time"] = times[0] + times[1] + times[2]
  38328. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  38329. if miConfig.MdtrtareaAdmvs == "421300" {
  38330. client := &http.Client{}
  38331. bytesData, _ := json.Marshal(data)
  38332. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38333. resp, _ := client.Do(req)
  38334. defer resp.Body.Close()
  38335. body, ioErr := ioutil.ReadAll(resp.Body)
  38336. if ioErr != nil {
  38337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38339. return
  38340. }
  38341. var respJSON map[string]interface{}
  38342. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38345. return
  38346. }
  38347. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38348. userJSONBytes, _ := json.Marshal(respJSON)
  38349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38350. utils.ErrorLog("解析失败:%v", err)
  38351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38352. return
  38353. }
  38354. }
  38355. if miConfig.MdtrtareaAdmvs == "420200" {
  38356. client := &http.Client{}
  38357. bytesData, _ := json.Marshal(data)
  38358. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38359. resp, _ := client.Do(req)
  38360. defer resp.Body.Close()
  38361. body, ioErr := ioutil.ReadAll(resp.Body)
  38362. if ioErr != nil {
  38363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38365. return
  38366. }
  38367. var respJSON map[string]interface{}
  38368. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38371. return
  38372. }
  38373. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38374. userJSONBytes, _ := json.Marshal(respJSON)
  38375. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38376. utils.ErrorLog("解析失败:%v", err)
  38377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38378. return
  38379. }
  38380. }
  38381. if miConfig.MdtrtareaAdmvs == "421182" {
  38382. client := &http.Client{}
  38383. bytesData, _ := json.Marshal(data)
  38384. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  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. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38400. userJSONBytes, _ := json.Marshal(respJSON)
  38401. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38402. utils.ErrorLog("解析失败:%v", err)
  38403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38404. return
  38405. }
  38406. }
  38407. if res.Infcode == 0 {
  38408. c.ServeSuccessJSON(map[string]interface{}{
  38409. "msg": "发起成功",
  38410. })
  38411. } else {
  38412. c.ServeSuccessJSON(map[string]interface{}{
  38413. "failed_code": -10,
  38414. "msg": res.ErrMsg,
  38415. })
  38416. }
  38417. }
  38418. }
  38419. // 5.11.1.1【5262】结算信息按时间段查询
  38420. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38421. admin_user_id, _ := c.GetInt64("admin_user_id")
  38422. adminUser := c.GetAdminUserInfo()
  38423. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38424. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38425. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38426. var res Result5262
  38427. if config.IsOpen == 1 {
  38428. if miConfig.MdtrtareaAdmvs == "421300" {
  38429. data := make(map[string]interface{})
  38430. data["bps"] = bp
  38431. data["org_name"] = miConfig.OrgName
  38432. data["doctor"] = role.UserName
  38433. data["fixmedins_code"] = miConfig.Code
  38434. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38435. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38436. data["page"] = strconv.FormatInt(page, 10)
  38437. data["limit"] = strconv.FormatInt(limit, 10)
  38438. fmt.Println(data)
  38439. client := &http.Client{}
  38440. bytesData, _ := json.Marshal(data)
  38441. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38442. resp, _ := client.Do(req)
  38443. defer resp.Body.Close()
  38444. body, ioErr := ioutil.ReadAll(resp.Body)
  38445. if ioErr != nil {
  38446. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38448. return
  38449. }
  38450. var respJSON map[string]interface{}
  38451. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38454. return
  38455. }
  38456. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38457. userJSONBytes, _ := json.Marshal(respJSON)
  38458. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38459. utils.ErrorLog("解析失败:%v", err)
  38460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38461. return
  38462. }
  38463. }
  38464. if miConfig.MdtrtareaAdmvs == "420200" {
  38465. data := make(map[string]interface{})
  38466. data["bps"] = bp
  38467. data["org_name"] = miConfig.OrgName
  38468. data["doctor"] = role.UserName
  38469. data["fixmedins_code"] = miConfig.Code
  38470. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38471. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38472. data["page"] = strconv.FormatInt(page, 10)
  38473. data["limit"] = strconv.FormatInt(limit, 10)
  38474. fmt.Println(data)
  38475. client := &http.Client{}
  38476. bytesData, _ := json.Marshal(data)
  38477. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38478. resp, _ := client.Do(req)
  38479. defer resp.Body.Close()
  38480. body, ioErr := ioutil.ReadAll(resp.Body)
  38481. if ioErr != nil {
  38482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38484. return
  38485. }
  38486. var respJSON map[string]interface{}
  38487. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38490. return
  38491. }
  38492. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38493. userJSONBytes, _ := json.Marshal(respJSON)
  38494. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38495. utils.ErrorLog("解析失败:%v", err)
  38496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38497. return
  38498. }
  38499. }
  38500. if miConfig.MdtrtareaAdmvs == "421182" {
  38501. data := make(map[string]interface{})
  38502. data["bps"] = bp
  38503. data["org_name"] = miConfig.OrgName
  38504. data["doctor"] = role.UserName
  38505. data["fixmedins_code"] = miConfig.Code
  38506. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38507. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38508. data["page"] = strconv.FormatInt(page, 10)
  38509. data["limit"] = strconv.FormatInt(limit, 10)
  38510. fmt.Println(data)
  38511. client := &http.Client{}
  38512. bytesData, _ := json.Marshal(data)
  38513. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38514. resp, _ := client.Do(req)
  38515. defer resp.Body.Close()
  38516. body, ioErr := ioutil.ReadAll(resp.Body)
  38517. if ioErr != nil {
  38518. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38520. return
  38521. }
  38522. var respJSON map[string]interface{}
  38523. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38526. return
  38527. }
  38528. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38529. userJSONBytes, _ := json.Marshal(respJSON)
  38530. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38531. utils.ErrorLog("解析失败:%v", err)
  38532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38533. return
  38534. }
  38535. }
  38536. if miConfig.MdtrtareaAdmvs == "420902" {
  38537. data := make(map[string]interface{})
  38538. data["bps"] = bp
  38539. data["org_name"] = miConfig.OrgName
  38540. data["doctor"] = role.UserName
  38541. data["fixmedins_code"] = miConfig.Code
  38542. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38543. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38544. data["page"] = strconv.FormatInt(page, 10)
  38545. data["limit"] = strconv.FormatInt(limit, 10)
  38546. fmt.Println(data)
  38547. client := &http.Client{}
  38548. bytesData, _ := json.Marshal(data)
  38549. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38550. resp, _ := client.Do(req)
  38551. defer resp.Body.Close()
  38552. body, ioErr := ioutil.ReadAll(resp.Body)
  38553. if ioErr != nil {
  38554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38556. return
  38557. }
  38558. var respJSON map[string]interface{}
  38559. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38562. return
  38563. }
  38564. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38565. userJSONBytes, _ := json.Marshal(respJSON)
  38566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38567. utils.ErrorLog("解析失败:%v", err)
  38568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38569. return
  38570. }
  38571. }
  38572. if res.Infcode == 0 {
  38573. c.ServeSuccessJSON(map[string]interface{}{
  38574. "order": res.Output.Result,
  38575. "total": res.Output.PageInfo.RecordCounts,
  38576. })
  38577. } else {
  38578. c.ServeSuccessJSON(map[string]interface{}{
  38579. "failed_code": -10,
  38580. "msg": res.ErrMsg,
  38581. })
  38582. }
  38583. }
  38584. }
  38585. // 5.11.1.2【5267】异地结算信息时间段查询
  38586. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38587. admin_user_id, _ := c.GetInt64("admin_user_id")
  38588. adminUser := c.GetAdminUserInfo()
  38589. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38590. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38591. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38592. var res Result5267
  38593. if config.IsOpen == 1 {
  38594. if miConfig.MdtrtareaAdmvs == "421300" {
  38595. data := make(map[string]interface{})
  38596. data["bps"] = bp
  38597. data["org_name"] = miConfig.OrgName
  38598. data["doctor"] = role.UserName
  38599. data["fixmedins_code"] = miConfig.Code
  38600. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38601. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38602. data["page"] = page
  38603. data["limit"] = limit
  38604. fmt.Println(data)
  38605. client := &http.Client{}
  38606. bytesData, _ := json.Marshal(data)
  38607. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38608. resp, _ := client.Do(req)
  38609. defer resp.Body.Close()
  38610. body, ioErr := ioutil.ReadAll(resp.Body)
  38611. if ioErr != nil {
  38612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38614. return
  38615. }
  38616. var respJSON map[string]interface{}
  38617. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38620. return
  38621. }
  38622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38623. userJSONBytes, _ := json.Marshal(respJSON)
  38624. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38625. utils.ErrorLog("解析失败:%v", err)
  38626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38627. return
  38628. }
  38629. }
  38630. if miConfig.MdtrtareaAdmvs == "420200" {
  38631. data := make(map[string]interface{})
  38632. data["bps"] = bp
  38633. data["org_name"] = miConfig.OrgName
  38634. data["doctor"] = role.UserName
  38635. data["fixmedins_code"] = miConfig.Code
  38636. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38637. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38638. data["page"] = page
  38639. data["limit"] = limit
  38640. fmt.Println(data)
  38641. client := &http.Client{}
  38642. bytesData, _ := json.Marshal(data)
  38643. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38644. resp, _ := client.Do(req)
  38645. defer resp.Body.Close()
  38646. body, ioErr := ioutil.ReadAll(resp.Body)
  38647. if ioErr != nil {
  38648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38650. return
  38651. }
  38652. var respJSON map[string]interface{}
  38653. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38656. return
  38657. }
  38658. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38659. userJSONBytes, _ := json.Marshal(respJSON)
  38660. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38661. utils.ErrorLog("解析失败:%v", err)
  38662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38663. return
  38664. }
  38665. }
  38666. if miConfig.MdtrtareaAdmvs == "421182" {
  38667. data := make(map[string]interface{})
  38668. data["bps"] = bp
  38669. data["org_name"] = miConfig.OrgName
  38670. data["doctor"] = role.UserName
  38671. data["fixmedins_code"] = miConfig.Code
  38672. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38673. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38674. data["page"] = page
  38675. data["limit"] = limit
  38676. fmt.Println(data)
  38677. client := &http.Client{}
  38678. bytesData, _ := json.Marshal(data)
  38679. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  38680. resp, _ := client.Do(req)
  38681. defer resp.Body.Close()
  38682. body, ioErr := ioutil.ReadAll(resp.Body)
  38683. if ioErr != nil {
  38684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38686. return
  38687. }
  38688. var respJSON map[string]interface{}
  38689. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38692. return
  38693. }
  38694. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38695. userJSONBytes, _ := json.Marshal(respJSON)
  38696. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38697. utils.ErrorLog("解析失败:%v", err)
  38698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38699. return
  38700. }
  38701. }
  38702. if res.Infcode == 0 {
  38703. c.ServeSuccessJSON(map[string]interface{}{
  38704. "order": res.Output.Result,
  38705. "total": res.Output.PageInfo.RecordCounts,
  38706. })
  38707. } else {
  38708. c.ServeSuccessJSON(map[string]interface{}{
  38709. "failed_code": -10,
  38710. "msg": res.ErrMsg,
  38711. })
  38712. }
  38713. }
  38714. }
  38715. func (c *HisApiController) Post3501() {
  38716. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38717. data := make(map[string]interface{})
  38718. var struct3501s []models.Struct3501
  38719. var struct3501 models.Struct3501
  38720. struct3501.OrgName = miConfig.OrgName
  38721. struct3501.AccessKey = miConfig.AccessKey
  38722. struct3501.RequestUrl = miConfig.Url
  38723. struct3501.SecretKey = miConfig.SecretKey
  38724. struct3501.ManuDate = "2022-08-17"
  38725. struct3501.FixmedinsBchno = ""
  38726. struct3501.ManuLotnum = ""
  38727. struct3501.RxFlag = "0"
  38728. struct3501.ExpyEnd = "2022-08-17"
  38729. struct3501.Invdate = "2022-08-17"
  38730. struct3501.InvCnt = "20.25"
  38731. struct3501.Memo = ""
  38732. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38733. struct3501.FixmedinsHilistId = miConfig.Code
  38734. struct3501.FixmedinsHilistName = miConfig.OrgName
  38735. struct3501s = append(struct3501s, struct3501)
  38736. data["struct_3501s"] = struct3501s
  38737. client := &http.Client{}
  38738. bytesData, _ := json.Marshal(data)
  38739. var req *http.Request
  38740. if miConfig.MdtrtareaAdmvs == "320921" {
  38741. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38742. } else {
  38743. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38744. }
  38745. resp, _ := client.Do(req)
  38746. defer resp.Body.Close()
  38747. body, ioErr := ioutil.ReadAll(resp.Body)
  38748. if ioErr != nil {
  38749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38751. return
  38752. }
  38753. var respJSON map[string]interface{}
  38754. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38757. return
  38758. }
  38759. var res ResultSix
  38760. var resSix10265 ResultSix10265 //1101结果
  38761. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38762. result, _ := json.Marshal(respJSON)
  38763. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38764. utils.ErrorLog("解析失败:%v", err)
  38765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38766. return
  38767. }
  38768. res.InfRefmsgid = resSix10265.InfRefmsgid
  38769. res.Output = resSix10265.Output
  38770. res.ErrMsg = resSix10265.ErrMsg
  38771. res.Cainfo = resSix10265.Cainfo
  38772. res.WarnMsg = resSix10265.WarnMsg
  38773. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38774. res.Infcode = infocode
  38775. if infocode == 0 {
  38776. c.ServeSuccessJSON(map[string]interface{}{
  38777. "msg": "上传成功",
  38778. })
  38779. return
  38780. } else {
  38781. c.ServeSuccessJSON(map[string]interface{}{
  38782. "failed_code": -10,
  38783. "msg": res.ErrMsg,
  38784. })
  38785. return
  38786. }
  38787. }
  38788. func (c *HisApiController) Post3502() {
  38789. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38790. data := make(map[string]interface{})
  38791. var struct3502s []models.Struct3502
  38792. var struct3502 models.Struct3502
  38793. struct3502.OrgName = miConfig.OrgName
  38794. struct3502.AccessKey = miConfig.AccessKey
  38795. struct3502.RequestUrl = miConfig.Url
  38796. struct3502.SecretKey = miConfig.SecretKey
  38797. struct3502.ManuDate = "2022-08-15"
  38798. struct3502.FixmedinsBchno = ""
  38799. struct3502.ManuLotnum = ""
  38800. struct3502.RxFlag = "0"
  38801. struct3502.ExpyEnd = "2022-08-15"
  38802. struct3502.Invdate = "2022-08-15"
  38803. struct3502.InvCnt = "20.25"
  38804. struct3502.Memo = ""
  38805. struct3502.MedListCodg = "XB01ABD056B002020200517"
  38806. struct3502.FixmedinsHilistId = miConfig.Code
  38807. struct3502.FixmedinsHilistName = miConfig.OrgName
  38808. struct3502s = append(struct3502s, struct3502)
  38809. data["struct_3502s"] = struct3502s
  38810. client := &http.Client{}
  38811. bytesData, _ := json.Marshal(data)
  38812. var req *http.Request
  38813. if miConfig.MdtrtareaAdmvs == "320921" {
  38814. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38815. } else {
  38816. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38817. }
  38818. resp, _ := client.Do(req)
  38819. defer resp.Body.Close()
  38820. body, ioErr := ioutil.ReadAll(resp.Body)
  38821. if ioErr != nil {
  38822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38824. return
  38825. }
  38826. var respJSON map[string]interface{}
  38827. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38830. return
  38831. }
  38832. var res ResultSix
  38833. var resSix10265 ResultSix10265 //1101结果
  38834. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38835. result, _ := json.Marshal(respJSON)
  38836. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38837. utils.ErrorLog("解析失败:%v", err)
  38838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38839. return
  38840. }
  38841. res.InfRefmsgid = resSix10265.InfRefmsgid
  38842. res.Output = resSix10265.Output
  38843. res.ErrMsg = resSix10265.ErrMsg
  38844. res.Cainfo = resSix10265.Cainfo
  38845. res.WarnMsg = resSix10265.WarnMsg
  38846. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38847. res.Infcode = infocode
  38848. if infocode == 0 {
  38849. c.ServeSuccessJSON(map[string]interface{}{
  38850. "msg": "上传成功",
  38851. })
  38852. return
  38853. } else {
  38854. c.ServeSuccessJSON(map[string]interface{}{
  38855. "failed_code": -10,
  38856. "msg": res.ErrMsg,
  38857. })
  38858. return
  38859. }
  38860. }
  38861. func (c *HisApiController) Post3503() {
  38862. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38863. data := make(map[string]interface{})
  38864. var struct3501s []models.Struct3501
  38865. var struct3501 models.Struct3501
  38866. struct3501.OrgName = miConfig.OrgName
  38867. struct3501.AccessKey = miConfig.AccessKey
  38868. struct3501.RequestUrl = miConfig.Url
  38869. struct3501.SecretKey = miConfig.SecretKey
  38870. struct3501.ManuDate = "2022-08-15"
  38871. struct3501.FixmedinsBchno = ""
  38872. struct3501.ManuLotnum = ""
  38873. struct3501.RxFlag = "0"
  38874. struct3501.ExpyEnd = "2022-08-15"
  38875. struct3501.Invdate = "2022-08-15"
  38876. struct3501.InvCnt = "20.25"
  38877. struct3501.Memo = ""
  38878. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38879. struct3501.FixmedinsHilistId = miConfig.Code
  38880. struct3501.FixmedinsHilistName = miConfig.OrgName
  38881. struct3501s = append(struct3501s, struct3501)
  38882. data["struct_3501s"] = struct3501s
  38883. client := &http.Client{}
  38884. bytesData, _ := json.Marshal(data)
  38885. var req *http.Request
  38886. if miConfig.MdtrtareaAdmvs == "320921" {
  38887. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38888. } else {
  38889. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38890. }
  38891. resp, _ := client.Do(req)
  38892. defer resp.Body.Close()
  38893. body, ioErr := ioutil.ReadAll(resp.Body)
  38894. if ioErr != nil {
  38895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38897. return
  38898. }
  38899. var respJSON map[string]interface{}
  38900. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38903. return
  38904. }
  38905. var res ResultSix
  38906. var resSix10265 ResultSix10265 //1101结果
  38907. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38908. result, _ := json.Marshal(respJSON)
  38909. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38910. utils.ErrorLog("解析失败:%v", err)
  38911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38912. return
  38913. }
  38914. res.InfRefmsgid = resSix10265.InfRefmsgid
  38915. res.Output = resSix10265.Output
  38916. res.ErrMsg = resSix10265.ErrMsg
  38917. res.Cainfo = resSix10265.Cainfo
  38918. res.WarnMsg = resSix10265.WarnMsg
  38919. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38920. res.Infcode = infocode
  38921. if infocode == 0 {
  38922. c.ServeSuccessJSON(map[string]interface{}{
  38923. "msg": "上传成功",
  38924. })
  38925. return
  38926. } else {
  38927. c.ServeSuccessJSON(map[string]interface{}{
  38928. "failed_code": -10,
  38929. "msg": res.ErrMsg,
  38930. })
  38931. return
  38932. }
  38933. }
  38934. func (c *HisApiController) Post3504() {
  38935. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38936. data := make(map[string]interface{})
  38937. var struct3501s []models.Struct3501
  38938. var struct3501 models.Struct3501
  38939. struct3501.OrgName = miConfig.OrgName
  38940. struct3501.AccessKey = miConfig.AccessKey
  38941. struct3501.RequestUrl = miConfig.Url
  38942. struct3501.SecretKey = miConfig.SecretKey
  38943. struct3501.ManuDate = "2022-08-15"
  38944. struct3501.FixmedinsBchno = ""
  38945. struct3501.ManuLotnum = ""
  38946. struct3501.RxFlag = "0"
  38947. struct3501.ExpyEnd = "2022-08-15"
  38948. struct3501.Invdate = "2022-08-15"
  38949. struct3501.InvCnt = "20.25"
  38950. struct3501.Memo = ""
  38951. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38952. struct3501.FixmedinsHilistId = miConfig.Code
  38953. struct3501.FixmedinsHilistName = miConfig.OrgName
  38954. struct3501s = append(struct3501s, struct3501)
  38955. data["struct_3501s"] = struct3501s
  38956. client := &http.Client{}
  38957. bytesData, _ := json.Marshal(data)
  38958. var req *http.Request
  38959. if miConfig.MdtrtareaAdmvs == "320921" {
  38960. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38961. } else {
  38962. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38963. }
  38964. resp, _ := client.Do(req)
  38965. defer resp.Body.Close()
  38966. body, ioErr := ioutil.ReadAll(resp.Body)
  38967. if ioErr != nil {
  38968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38970. return
  38971. }
  38972. var respJSON map[string]interface{}
  38973. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38976. return
  38977. }
  38978. var res ResultSix
  38979. var resSix10265 ResultSix10265 //1101结果
  38980. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38981. result, _ := json.Marshal(respJSON)
  38982. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38983. utils.ErrorLog("解析失败:%v", err)
  38984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38985. return
  38986. }
  38987. res.InfRefmsgid = resSix10265.InfRefmsgid
  38988. res.Output = resSix10265.Output
  38989. res.ErrMsg = resSix10265.ErrMsg
  38990. res.Cainfo = resSix10265.Cainfo
  38991. res.WarnMsg = resSix10265.WarnMsg
  38992. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38993. res.Infcode = infocode
  38994. if infocode == 0 {
  38995. c.ServeSuccessJSON(map[string]interface{}{
  38996. "msg": "上传成功",
  38997. })
  38998. return
  38999. } else {
  39000. c.ServeSuccessJSON(map[string]interface{}{
  39001. "failed_code": -10,
  39002. "msg": res.ErrMsg,
  39003. })
  39004. return
  39005. }
  39006. }
  39007. func (c *HisApiController) Post3505() {
  39008. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39009. data := make(map[string]interface{})
  39010. var struct3501s []models.Struct3501
  39011. var struct3501 models.Struct3501
  39012. struct3501.OrgName = miConfig.OrgName
  39013. struct3501.AccessKey = miConfig.AccessKey
  39014. struct3501.RequestUrl = miConfig.Url
  39015. struct3501.SecretKey = miConfig.SecretKey
  39016. struct3501.ManuDate = "2022-08-15"
  39017. struct3501.FixmedinsBchno = ""
  39018. struct3501.ManuLotnum = ""
  39019. struct3501.RxFlag = "0"
  39020. struct3501.ExpyEnd = "2022-08-15"
  39021. struct3501.Invdate = "2022-08-15"
  39022. struct3501.InvCnt = "20.25"
  39023. struct3501.Memo = ""
  39024. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39025. struct3501.FixmedinsHilistId = miConfig.Code
  39026. struct3501.FixmedinsHilistName = miConfig.OrgName
  39027. struct3501s = append(struct3501s, struct3501)
  39028. data["struct_3501s"] = struct3501s
  39029. client := &http.Client{}
  39030. bytesData, _ := json.Marshal(data)
  39031. var req *http.Request
  39032. if miConfig.MdtrtareaAdmvs == "320921" {
  39033. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39034. } else {
  39035. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39036. }
  39037. resp, _ := client.Do(req)
  39038. defer resp.Body.Close()
  39039. body, ioErr := ioutil.ReadAll(resp.Body)
  39040. if ioErr != nil {
  39041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39043. return
  39044. }
  39045. var respJSON map[string]interface{}
  39046. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39047. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39049. return
  39050. }
  39051. var res ResultSix
  39052. var resSix10265 ResultSix10265 //1101结果
  39053. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39054. result, _ := json.Marshal(respJSON)
  39055. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39056. utils.ErrorLog("解析失败:%v", err)
  39057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39058. return
  39059. }
  39060. res.InfRefmsgid = resSix10265.InfRefmsgid
  39061. res.Output = resSix10265.Output
  39062. res.ErrMsg = resSix10265.ErrMsg
  39063. res.Cainfo = resSix10265.Cainfo
  39064. res.WarnMsg = resSix10265.WarnMsg
  39065. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39066. res.Infcode = infocode
  39067. if infocode == 0 {
  39068. c.ServeSuccessJSON(map[string]interface{}{
  39069. "msg": "上传成功",
  39070. })
  39071. return
  39072. } else {
  39073. c.ServeSuccessJSON(map[string]interface{}{
  39074. "failed_code": -10,
  39075. "msg": res.ErrMsg,
  39076. })
  39077. return
  39078. }
  39079. }
  39080. func (c *HisApiController) Post3506() {
  39081. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39082. data := make(map[string]interface{})
  39083. var struct3501s []models.Struct3501
  39084. var struct3501 models.Struct3501
  39085. struct3501.OrgName = miConfig.OrgName
  39086. struct3501.AccessKey = miConfig.AccessKey
  39087. struct3501.RequestUrl = miConfig.Url
  39088. struct3501.SecretKey = miConfig.SecretKey
  39089. struct3501.ManuDate = "2022-08-15"
  39090. struct3501.FixmedinsBchno = ""
  39091. struct3501.ManuLotnum = ""
  39092. struct3501.RxFlag = "0"
  39093. struct3501.ExpyEnd = "2022-08-15"
  39094. struct3501.Invdate = "2022-08-15"
  39095. struct3501.InvCnt = "20.25"
  39096. struct3501.Memo = ""
  39097. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39098. struct3501.FixmedinsHilistId = miConfig.Code
  39099. struct3501.FixmedinsHilistName = miConfig.OrgName
  39100. struct3501s = append(struct3501s, struct3501)
  39101. data["struct_3501s"] = struct3501s
  39102. client := &http.Client{}
  39103. bytesData, _ := json.Marshal(data)
  39104. var req *http.Request
  39105. if miConfig.MdtrtareaAdmvs == "320921" {
  39106. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39107. } else {
  39108. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39109. }
  39110. resp, _ := client.Do(req)
  39111. defer resp.Body.Close()
  39112. body, ioErr := ioutil.ReadAll(resp.Body)
  39113. if ioErr != nil {
  39114. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39116. return
  39117. }
  39118. var respJSON map[string]interface{}
  39119. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39120. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39122. return
  39123. }
  39124. var res ResultSix
  39125. var resSix10265 ResultSix10265 //1101结果
  39126. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39127. result, _ := json.Marshal(respJSON)
  39128. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39129. utils.ErrorLog("解析失败:%v", err)
  39130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39131. return
  39132. }
  39133. res.InfRefmsgid = resSix10265.InfRefmsgid
  39134. res.Output = resSix10265.Output
  39135. res.ErrMsg = resSix10265.ErrMsg
  39136. res.Cainfo = resSix10265.Cainfo
  39137. res.WarnMsg = resSix10265.WarnMsg
  39138. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39139. res.Infcode = infocode
  39140. if infocode == 0 {
  39141. c.ServeSuccessJSON(map[string]interface{}{
  39142. "msg": "上传成功",
  39143. })
  39144. return
  39145. } else {
  39146. c.ServeSuccessJSON(map[string]interface{}{
  39147. "failed_code": -10,
  39148. "msg": res.ErrMsg,
  39149. })
  39150. return
  39151. }
  39152. }
  39153. func (c *HisApiController) Post3507() {
  39154. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39155. data := make(map[string]interface{})
  39156. var struct3501s []models.Struct3501
  39157. var struct3501 models.Struct3501
  39158. struct3501.OrgName = miConfig.OrgName
  39159. struct3501.AccessKey = miConfig.AccessKey
  39160. struct3501.RequestUrl = miConfig.Url
  39161. struct3501.SecretKey = miConfig.SecretKey
  39162. struct3501.ManuDate = "2022-08-15"
  39163. struct3501.FixmedinsBchno = ""
  39164. struct3501.ManuLotnum = ""
  39165. struct3501.RxFlag = "0"
  39166. struct3501.ExpyEnd = "2022-08-15"
  39167. struct3501.Invdate = "2022-08-15"
  39168. struct3501.InvCnt = "20.25"
  39169. struct3501.Memo = ""
  39170. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39171. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  39172. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  39173. struct3501s = append(struct3501s, struct3501)
  39174. data["struct_3501s"] = struct3501s
  39175. client := &http.Client{}
  39176. bytesData, _ := json.Marshal(data)
  39177. var req *http.Request
  39178. if miConfig.MdtrtareaAdmvs == "320921" {
  39179. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39180. } else {
  39181. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39182. }
  39183. resp, _ := client.Do(req)
  39184. defer resp.Body.Close()
  39185. body, ioErr := ioutil.ReadAll(resp.Body)
  39186. if ioErr != nil {
  39187. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39189. return
  39190. }
  39191. var respJSON map[string]interface{}
  39192. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39193. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39195. return
  39196. }
  39197. var res ResultSix
  39198. var resSix10265 ResultSix10265 //1101结果
  39199. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39200. result, _ := json.Marshal(respJSON)
  39201. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39202. utils.ErrorLog("解析失败:%v", err)
  39203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39204. return
  39205. }
  39206. res.InfRefmsgid = resSix10265.InfRefmsgid
  39207. res.Output = resSix10265.Output
  39208. res.ErrMsg = resSix10265.ErrMsg
  39209. res.Cainfo = resSix10265.Cainfo
  39210. res.WarnMsg = resSix10265.WarnMsg
  39211. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39212. res.Infcode = infocode
  39213. if infocode == 0 {
  39214. c.ServeSuccessJSON(map[string]interface{}{
  39215. "msg": "上传成功",
  39216. })
  39217. return
  39218. } else {
  39219. c.ServeSuccessJSON(map[string]interface{}{
  39220. "failed_code": -10,
  39221. "msg": res.ErrMsg,
  39222. })
  39223. return
  39224. }
  39225. }
  39226. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39227. // WebSocket服务器地址
  39228. serverURL := "ws://127.0.0.1:8899"
  39229. // 解析WebSocket服务器地址
  39230. u, err := url.Parse(serverURL)
  39231. if err != nil {
  39232. }
  39233. // 建立WebSocket连接
  39234. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39235. if err != nil {
  39236. }
  39237. defer conn.Close()
  39238. input2 := make(map[string]interface{})
  39239. input := make(map[string]interface{})
  39240. inputData := make(map[string]interface{})
  39241. inputData["orgId"] = code
  39242. inputData["businessType"] = "01101"
  39243. inputData["operatorId"] = operator_id
  39244. inputData["operatorName"] = operator_name
  39245. inputData["officeId"] = "001"
  39246. inputData["officeName"] = "血透室"
  39247. inputData["deviceType"] = ""
  39248. input["data"] = inputData
  39249. input["orgId"] = code
  39250. input["transType"] = "ec.query"
  39251. //if md == ""
  39252. if md[:4] == "4403" {
  39253. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39254. } else if md[:4] == "4401" {
  39255. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39256. } else {
  39257. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39258. }
  39259. input2["indata"] = input
  39260. fmt.Println(input2)
  39261. bytesData, _ := json.Marshal(input2)
  39262. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39263. if err != nil {
  39264. fmt.Println(err)
  39265. }
  39266. // 接收消息
  39267. _, receivedMessage, err := conn.ReadMessage()
  39268. if err != nil {
  39269. fmt.Println(err)
  39270. }
  39271. return "", string(receivedMessage)
  39272. }
  39273. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  39274. // WebSocket服务器地址
  39275. serverURL := "ws://127.0.0.1:8899"
  39276. // 解析WebSocket服务器地址
  39277. u, err := url.Parse(serverURL)
  39278. if err != nil {
  39279. }
  39280. // 建立WebSocket连接
  39281. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39282. if err != nil {
  39283. }
  39284. defer conn.Close()
  39285. input2 := make(map[string]interface{})
  39286. input := make(map[string]interface{})
  39287. inputData := make(map[string]interface{})
  39288. inputData["orgId"] = code
  39289. inputData["businessType"] = "01101"
  39290. inputData["operatorId"] = operator_id
  39291. inputData["operatorName"] = operator_name
  39292. inputData["officeId"] = "001"
  39293. inputData["officeName"] = "血透室"
  39294. inputData["deviceType"] = ""
  39295. input["data"] = inputData
  39296. input["orgId"] = code
  39297. input["transType"] = "ec.query"
  39298. //if md == ""
  39299. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39300. input2["indata"] = input
  39301. fmt.Println(input2)
  39302. bytesData, _ := json.Marshal(input2)
  39303. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39304. if err != nil {
  39305. fmt.Println(err)
  39306. }
  39307. // 接收消息
  39308. _, receivedMessage, err := conn.ReadMessage()
  39309. if err != nil {
  39310. fmt.Println(err)
  39311. }
  39312. return "", string(receivedMessage)
  39313. }
  39314. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  39315. // WebSocket服务器地址
  39316. serverURL := "ws://127.0.0.1:8899"
  39317. // 解析WebSocket服务器地址
  39318. u, err := url.Parse(serverURL)
  39319. if err != nil {
  39320. }
  39321. // 建立WebSocket连接
  39322. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39323. if err != nil {
  39324. }
  39325. defer conn.Close()
  39326. input2 := make(map[string]interface{})
  39327. input := make(map[string]interface{})
  39328. inputData := make(map[string]interface{})
  39329. inputData["orgId"] = code
  39330. inputData["businessType"] = "01301"
  39331. inputData["operatorId"] = operator_id
  39332. inputData["operatorName"] = operator_name
  39333. inputData["officeId"] = "001"
  39334. inputData["officeName"] = "血透室"
  39335. inputData["deviceType"] = ""
  39336. input["data"] = inputData
  39337. input["orgId"] = code
  39338. input["transType"] = "ec.query"
  39339. //if md == ""
  39340. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39341. input2["indata"] = input
  39342. fmt.Println(input2)
  39343. bytesData, _ := json.Marshal(input2)
  39344. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39345. if err != nil {
  39346. fmt.Println(err)
  39347. }
  39348. // 接收消息
  39349. _, receivedMessage, err := conn.ReadMessage()
  39350. if err != nil {
  39351. fmt.Println(err)
  39352. }
  39353. return "", string(receivedMessage)
  39354. }
  39355. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  39356. // WebSocket服务器地址
  39357. serverURL := "ws://127.0.0.1:8899"
  39358. // 解析WebSocket服务器地址
  39359. u, err := url.Parse(serverURL)
  39360. if err != nil {
  39361. }
  39362. // 建立WebSocket连接
  39363. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39364. if err != nil {
  39365. }
  39366. defer conn.Close()
  39367. input2 := make(map[string]interface{})
  39368. input := make(map[string]interface{})
  39369. inputData := make(map[string]interface{})
  39370. inputData["orgId"] = code
  39371. inputData["businessType"] = "01103"
  39372. inputData["operatorId"] = operator_id
  39373. inputData["operatorName"] = operator_name
  39374. inputData["officeId"] = "001"
  39375. inputData["officeName"] = "血透室"
  39376. inputData["deviceType"] = ""
  39377. input["data"] = inputData
  39378. input["orgId"] = code
  39379. input["transType"] = "ec.query"
  39380. //if md ==
  39381. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  39382. input2["indata"] = input
  39383. fmt.Println(input2)
  39384. bytesData, _ := json.Marshal(input2)
  39385. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39386. if err != nil {
  39387. fmt.Println(err)
  39388. }
  39389. // 接收消息
  39390. _, receivedMessage, err := conn.ReadMessage()
  39391. if err != nil {
  39392. fmt.Println(err)
  39393. }
  39394. return "", string(receivedMessage)
  39395. }
  39396. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39397. // WebSocket服务器地址
  39398. serverURL := "ws://127.0.0.1:8899"
  39399. // 解析WebSocket服务器地址
  39400. u, err := url.Parse(serverURL)
  39401. if err != nil {
  39402. }
  39403. // 建立WebSocket连接
  39404. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39405. if err != nil {
  39406. }
  39407. defer conn.Close()
  39408. input2 := make(map[string]interface{})
  39409. input := make(map[string]interface{})
  39410. inputData := make(map[string]interface{})
  39411. inputData["orgId"] = code
  39412. inputData["businessType"] = "01101"
  39413. inputData["operatorId"] = operator_id
  39414. inputData["operatorName"] = operator_name
  39415. inputData["officeId"] = "001"
  39416. inputData["officeName"] = "血透室"
  39417. inputData["deviceType"] = ""
  39418. input["data"] = inputData
  39419. input["orgId"] = code
  39420. input["transType"] = "ec.query"
  39421. //if md == ""
  39422. if md[:4] == "4403" {
  39423. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39424. } else if md[:4] == "4401" {
  39425. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39426. } else {
  39427. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39428. }
  39429. input2["indata"] = input
  39430. fmt.Println(input2)
  39431. bytesData, _ := json.Marshal(input2)
  39432. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39433. if err != nil {
  39434. fmt.Println(err)
  39435. }
  39436. // 接收消息
  39437. _, receivedMessage, err := conn.ReadMessage()
  39438. if err != nil {
  39439. fmt.Println(err)
  39440. }
  39441. return "", string(receivedMessage)
  39442. }
  39443. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  39444. // WebSocket服务器地址
  39445. serverURL := "ws://127.0.0.1:8899"
  39446. // 解析WebSocket服务器地址
  39447. u, err := url.Parse(serverURL)
  39448. if err != nil {
  39449. }
  39450. // 建立WebSocket连接
  39451. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39452. if err != nil {
  39453. }
  39454. defer conn.Close()
  39455. input2 := make(map[string]interface{})
  39456. input := make(map[string]interface{})
  39457. inputData := make(map[string]interface{})
  39458. inputData["orgId"] = code
  39459. inputData["businessType"] = "01301"
  39460. inputData["operatorId"] = operator_id
  39461. inputData["operatorName"] = operator_name
  39462. inputData["officeId"] = "001"
  39463. inputData["officeName"] = "血透室"
  39464. inputData["deviceType"] = ""
  39465. input["data"] = inputData
  39466. input["orgId"] = code
  39467. input["transType"] = "ec.query"
  39468. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39469. input2["indata"] = input
  39470. bytesData, _ := json.Marshal(input2)
  39471. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39472. if err != nil {
  39473. fmt.Println(err)
  39474. }
  39475. // 接收消息
  39476. _, receivedMessage, err := conn.ReadMessage()
  39477. if err != nil {
  39478. fmt.Println(err)
  39479. }
  39480. return "", string(receivedMessage)
  39481. }
  39482. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  39483. newArr = make([]string, 0)
  39484. for i := 0; i < len(arr); i++ {
  39485. repeat := false
  39486. for j := i + 1; j < len(arr); j++ {
  39487. if arr[i] == arr[j] {
  39488. repeat = true
  39489. break
  39490. }
  39491. }
  39492. if !repeat {
  39493. newArr = append(newArr, arr[i])
  39494. }
  39495. }
  39496. return
  39497. }
  39498. func getBirthdateAndAge(idNumber string) (string, int, error) {
  39499. if len(idNumber) != 18 {
  39500. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  39501. }
  39502. // 提取出生日期
  39503. year, err := strconv.Atoi(idNumber[6:10])
  39504. if err != nil {
  39505. return "", 0, err
  39506. }
  39507. month, err := strconv.Atoi(idNumber[10:12])
  39508. if err != nil {
  39509. return "", 0, err
  39510. }
  39511. day, err := strconv.Atoi(idNumber[12:14])
  39512. if err != nil {
  39513. return "", 0, err
  39514. }
  39515. // 格式化生日字符串
  39516. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  39517. birthdateFormatted := birthdate.Format("2006-01-02")
  39518. // 计算年龄
  39519. today := time.Now()
  39520. age := today.Year() - birthdate.Year()
  39521. if today.YearDay() < birthdate.YearDay() {
  39522. age--
  39523. }
  39524. return birthdateFormatted, age, nil
  39525. }
  39526. // 从身份证号码中提取出生年月日
  39527. func getBirthDateFromIDCard(idCard string) (string, error) {
  39528. // 身份证号码长度应为18位
  39529. if len(idCard) != 18 {
  39530. return "", fmt.Errorf("身份证号码长度应为18位")
  39531. }
  39532. // 提取出生日期部分 (YYYYMMDD)
  39533. birthDateStr := idCard[6:14]
  39534. // 解析出生日期
  39535. birthDate, err := time.Parse("20060102", birthDateStr)
  39536. if err != nil {
  39537. return "", fmt.Errorf("解析出生日期失败: %v", err)
  39538. }
  39539. // 格式化出生日期为 YYYY-MM-DD
  39540. formattedDate := birthDate.Format("2006-01-02")
  39541. return formattedDate, nil
  39542. }