his_api_controller.go 1.5MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. //"github.com/tjfoc/gmsm/sm3"
  8. "math"
  9. //"crypto/x509/pkix"
  10. "encoding/json"
  11. "fmt"
  12. "gdyb/controllers"
  13. "gdyb/enums"
  14. "gdyb/models"
  15. "gdyb/service"
  16. "gdyb/utils"
  17. "github.com/astaxie/beego"
  18. "github.com/axgle/mahonia"
  19. "github.com/go-ole/go-ole/oleutil"
  20. "github.com/gorilla/websocket"
  21. "github.com/jinzhu/gorm"
  22. "github.com/shopspring/decimal"
  23. "io"
  24. "io/ioutil"
  25. "math/rand"
  26. "net/http"
  27. "net/url"
  28. "os"
  29. "path/filepath"
  30. "regexp"
  31. "strconv"
  32. "strings"
  33. "syscall"
  34. "time"
  35. "unsafe"
  36. )
  37. type HisApiController struct {
  38. controllers.BaseAuthAPIController
  39. }
  40. func HisManagerApiRegistRouters() {
  41. //挂号
  42. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  43. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  44. //上传就诊信息-上传明细-结算
  45. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  46. //查询
  47. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  48. //对总账
  49. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  50. //对明细
  51. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  52. //退费,退明细
  53. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  54. //退号
  55. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  56. //退明细
  57. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  58. //上传就诊信息-上传明细-预结算
  59. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  60. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  61. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  62. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  63. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  64. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  65. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  66. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  67. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  68. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  69. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  70. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  71. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  72. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  73. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  74. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  75. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  76. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  77. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  78. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  79. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  80. beego.Router("/api/check", &HisApiController{}, "get:Check")
  81. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  82. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  83. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  84. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  85. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  86. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  87. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  88. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  89. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  90. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  91. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  92. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  93. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  94. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  95. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  96. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  97. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  98. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  99. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  100. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  101. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  102. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  103. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  104. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  107. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  108. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  109. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  110. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  111. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  112. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  113. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  114. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  115. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  116. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  117. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  118. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  119. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  120. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  121. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  122. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  123. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  124. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  125. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  126. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  127. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  128. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  129. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  130. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  131. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  132. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  133. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  134. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  135. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  136. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  137. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  138. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  139. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  140. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  141. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  142. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  143. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  144. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  145. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  146. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  147. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  148. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  149. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  150. //库盘和变更
  151. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  152. //删除库盘和变更
  153. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  154. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  155. //药品变更
  156. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  157. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  158. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  159. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  160. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  161. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  162. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  163. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  164. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  165. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  166. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  167. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  168. //beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  169. //beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  170. }
  171. func (c *HisApiController) TestNet() {
  172. c.ServeSuccessJSON(map[string]interface{}{
  173. "msg": "成功",
  174. })
  175. }
  176. func (c *HisApiController) Get3508() {
  177. admin_user_id, _ := c.GetInt64("admin_user_id")
  178. drug_id, _ := c.GetInt64("id")
  179. start_time := c.GetString("start_time")
  180. end_time := c.GetString("end_time")
  181. adminUser := c.GetAdminUserInfo()
  182. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  183. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  184. drug, _ := service.GetDrugByID(drug_id)
  185. var struct3508 models.Struct3508
  186. struct3508.OrgName = miConfig.OrgName
  187. struct3508.FixmedinsCode = miConfig.Code
  188. struct3508.AccessKey = miConfig.AccessKey
  189. struct3508.Opter = curRoles.UserName
  190. struct3508.RequestUrl = miConfig.Url
  191. struct3508.Url = miConfig.Url
  192. struct3508.AppId = miConfig.Cainfo
  193. struct3508.AppSecret = miConfig.AppSecret
  194. struct3508.Enckey = miConfig.EncKey
  195. struct3508.SignKey = miConfig.SignKey
  196. struct3508.SecretKey = miConfig.SecretKey
  197. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  198. struct3508.Begndate = start_time
  199. struct3508.Enddate = end_time
  200. result1, result2, _ := service.FJyb3508(struct3508)
  201. saveLog(result1, result2, "3508", "3508")
  202. var res models.Result3508
  203. var respJSON2 map[string]interface{}
  204. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  207. return
  208. }
  209. userJSONBytes2, _ := json.Marshal(respJSON2)
  210. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  211. utils.ErrorLog("解析失败:%v", err)
  212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  213. return
  214. }
  215. if res.Infcode == -1 {
  216. c.ServeSuccessJSON(map[string]interface{}{
  217. "failed_code": -10,
  218. "msg": res.ErrMsg,
  219. })
  220. } else {
  221. c.ServeSuccessJSON(map[string]interface{}{
  222. "info": res.Output,
  223. })
  224. }
  225. }
  226. func (c *HisApiController) Get3509() {
  227. admin_user_id, _ := c.GetInt64("admin_user_id")
  228. drug_id, _ := c.GetInt64("id")
  229. start_time := c.GetString("start_time")
  230. end_time := c.GetString("end_time")
  231. adminUser := c.GetAdminUserInfo()
  232. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  233. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  234. drug, _ := service.GetDrugByID(drug_id)
  235. var struct3508 models.Struct3509
  236. struct3508.OrgName = miConfig.OrgName
  237. struct3508.FixmedinsCode = miConfig.Code
  238. struct3508.AccessKey = miConfig.AccessKey
  239. struct3508.Opter = curRoles.UserName
  240. struct3508.RequestUrl = miConfig.Url
  241. struct3508.Url = miConfig.Url
  242. struct3508.AppId = miConfig.Cainfo
  243. struct3508.AppSecret = miConfig.AppSecret
  244. struct3508.Enckey = miConfig.EncKey
  245. struct3508.SignKey = miConfig.SignKey
  246. struct3508.SecretKey = miConfig.SecretKey
  247. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  248. struct3508.Begndate = start_time
  249. struct3508.Enddate = end_time
  250. result1, result2, _ := service.FJyb3509(struct3508)
  251. saveLog(result1, result2, "3509", "3509")
  252. var res models.Result3509
  253. var respJSON2 map[string]interface{}
  254. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  257. return
  258. }
  259. userJSONBytes2, _ := json.Marshal(respJSON2)
  260. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  261. utils.ErrorLog("解析失败:%v", err)
  262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  263. return
  264. }
  265. if res.Infcode == -1 {
  266. c.ServeSuccessJSON(map[string]interface{}{
  267. "failed_code": -10,
  268. "msg": res.ErrMsg,
  269. })
  270. } else {
  271. c.ServeSuccessJSON(map[string]interface{}{
  272. "info": res.Output,
  273. })
  274. }
  275. }
  276. func (c *HisApiController) Get3510() {
  277. admin_user_id, _ := c.GetInt64("admin_user_id")
  278. drug_id, _ := c.GetInt64("id")
  279. start_time := c.GetString("start_time")
  280. end_time := c.GetString("end_time")
  281. adminUser := c.GetAdminUserInfo()
  282. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  283. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  284. drug, _ := service.GetDrugByID(drug_id)
  285. var struct3508 models.Struct3510
  286. struct3508.FixmedinsCode = miConfig.Code
  287. struct3508.OrgName = miConfig.OrgName
  288. struct3508.AccessKey = miConfig.AccessKey
  289. struct3508.Opter = curRoles.UserName
  290. struct3508.RequestUrl = miConfig.Url
  291. struct3508.Url = miConfig.Url
  292. struct3508.AppId = miConfig.Cainfo
  293. struct3508.AppSecret = miConfig.AppSecret
  294. struct3508.Enckey = miConfig.EncKey
  295. struct3508.SignKey = miConfig.SignKey
  296. struct3508.SecretKey = miConfig.SecretKey
  297. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  298. struct3508.Begndate = start_time
  299. struct3508.Enddate = end_time
  300. result1, result2, _ := service.FJyb3510(struct3508)
  301. saveLog(result1, result2, "3510", "3510")
  302. var res models.Result3510
  303. var respJSON2 map[string]interface{}
  304. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  307. return
  308. }
  309. userJSONBytes2, _ := json.Marshal(respJSON2)
  310. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  311. utils.ErrorLog("解析失败:%v", err)
  312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  313. return
  314. }
  315. if res.Infcode == -1 {
  316. c.ServeSuccessJSON(map[string]interface{}{
  317. "failed_code": -10,
  318. "msg": res.ErrMsg,
  319. })
  320. } else {
  321. c.ServeSuccessJSON(map[string]interface{}{
  322. "info": res.Output,
  323. })
  324. }
  325. }
  326. func (c *HisApiController) Get3511() {
  327. admin_user_id, _ := c.GetInt64("admin_user_id")
  328. drug_id, _ := c.GetInt64("id")
  329. start_time := c.GetString("start_time")
  330. end_time := c.GetString("end_time")
  331. adminUser := c.GetAdminUserInfo()
  332. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  333. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  334. drug, _ := service.GetDrugByID(drug_id)
  335. var struct3508 models.Struct3511
  336. struct3508.FixmedinsCode = miConfig.Code
  337. struct3508.OrgName = miConfig.OrgName
  338. struct3508.AccessKey = miConfig.AccessKey
  339. struct3508.Opter = curRoles.UserName
  340. struct3508.RequestUrl = miConfig.Url
  341. struct3508.Url = miConfig.Url
  342. struct3508.AppId = miConfig.Cainfo
  343. struct3508.AppSecret = miConfig.AppSecret
  344. struct3508.Enckey = miConfig.EncKey
  345. struct3508.SignKey = miConfig.SignKey
  346. struct3508.SecretKey = miConfig.SecretKey
  347. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  348. struct3508.Begndate = start_time
  349. struct3508.Enddate = end_time
  350. result1, result2, _ := service.FJyb3511(struct3508)
  351. saveLog(result1, result2, "3511", "3511")
  352. var res models.Result3511
  353. var respJSON2 map[string]interface{}
  354. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  357. return
  358. }
  359. userJSONBytes2, _ := json.Marshal(respJSON2)
  360. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  361. utils.ErrorLog("解析失败:%v", err)
  362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  363. return
  364. }
  365. if res.Infcode == -1 {
  366. c.ServeSuccessJSON(map[string]interface{}{
  367. "failed_code": -10,
  368. "msg": res.ErrMsg,
  369. })
  370. } else {
  371. c.ServeSuccessJSON(map[string]interface{}{
  372. "info": res.Output,
  373. })
  374. }
  375. }
  376. func (c *HisApiController) Get3512() {
  377. admin_user_id, _ := c.GetInt64("admin_user_id")
  378. drug_id, _ := c.GetInt64("id")
  379. start_time := c.GetString("start_time")
  380. end_time := c.GetString("end_time")
  381. adminUser := c.GetAdminUserInfo()
  382. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  383. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  384. drug, _ := service.GetDrugByID(drug_id)
  385. var struct3508 models.Struct3512
  386. struct3508.FixmedinsCode = miConfig.Code
  387. struct3508.OrgName = miConfig.OrgName
  388. struct3508.AccessKey = miConfig.AccessKey
  389. struct3508.Opter = curRoles.UserName
  390. struct3508.RequestUrl = miConfig.Url
  391. struct3508.Url = miConfig.Url
  392. struct3508.AppId = miConfig.Cainfo
  393. struct3508.AppSecret = miConfig.AppSecret
  394. struct3508.Enckey = miConfig.EncKey
  395. struct3508.SignKey = miConfig.SignKey
  396. struct3508.SecretKey = miConfig.SecretKey
  397. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  398. struct3508.Begndate = start_time
  399. struct3508.Enddate = end_time
  400. result1, result2, _ := service.FJyb3512(struct3508)
  401. saveLog(result1, result2, "3512", "3512")
  402. var res models.Result3512
  403. var respJSON2 map[string]interface{}
  404. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  407. return
  408. }
  409. userJSONBytes2, _ := json.Marshal(respJSON2)
  410. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  411. utils.ErrorLog("解析失败:%v", err)
  412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  413. return
  414. }
  415. if res.Infcode == -1 {
  416. c.ServeSuccessJSON(map[string]interface{}{
  417. "failed_code": -10,
  418. "msg": res.ErrMsg,
  419. })
  420. } else {
  421. c.ServeSuccessJSON(map[string]interface{}{
  422. "info": res.Output,
  423. })
  424. }
  425. }
  426. func (c *HisApiController) Get3513() {
  427. admin_user_id, _ := c.GetInt64("admin_user_id")
  428. drug_id, _ := c.GetInt64("id")
  429. start_time := c.GetString("start_time")
  430. end_time := c.GetString("end_time")
  431. adminUser := c.GetAdminUserInfo()
  432. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  433. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  434. drug, _ := service.GetDrugByID(drug_id)
  435. var struct3508 models.Struct3513
  436. struct3508.FixmedinsCode = miConfig.Code
  437. struct3508.OrgName = miConfig.OrgName
  438. struct3508.AccessKey = miConfig.AccessKey
  439. struct3508.Opter = curRoles.UserName
  440. struct3508.RequestUrl = miConfig.Url
  441. struct3508.Url = miConfig.Url
  442. struct3508.AppId = miConfig.Cainfo
  443. struct3508.AppSecret = miConfig.AppSecret
  444. struct3508.Enckey = miConfig.EncKey
  445. struct3508.SignKey = miConfig.SignKey
  446. struct3508.SecretKey = miConfig.SecretKey
  447. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  448. struct3508.Begndate = start_time
  449. struct3508.Enddate = end_time
  450. result1, result2, _ := service.FJyb3513(struct3508)
  451. saveLog(result1, result2, "3513", "3513")
  452. var res models.Result3513
  453. var respJSON2 map[string]interface{}
  454. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  457. return
  458. }
  459. userJSONBytes2, _ := json.Marshal(respJSON2)
  460. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  461. utils.ErrorLog("解析失败:%v", err)
  462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  463. return
  464. }
  465. if res.Infcode == -1 {
  466. c.ServeSuccessJSON(map[string]interface{}{
  467. "failed_code": -10,
  468. "msg": res.ErrMsg,
  469. })
  470. } else {
  471. c.ServeSuccessJSON(map[string]interface{}{
  472. "info": res.Output,
  473. })
  474. }
  475. }
  476. func (c *HisApiController) Get35081() {
  477. admin_user_id, _ := c.GetInt64("admin_user_id")
  478. drug_id, _ := c.GetInt64("id")
  479. //start_time := c.GetString("start_time")
  480. //end_time := c.GetString("end_time")
  481. page, _ := c.GetInt("page")
  482. adminUser := c.GetAdminUserInfo()
  483. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  484. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  485. drug, _ := service.GetDrugByID(drug_id)
  486. var struct3508 models.Struct35081
  487. struct3508.FixmedinsCode = miConfig.Code
  488. struct3508.OrgName = miConfig.OrgName
  489. struct3508.AccessKey = miConfig.AccessKey
  490. struct3508.Opter = curRoles.UserName
  491. struct3508.RequestUrl = miConfig.Url
  492. struct3508.Url = miConfig.Url
  493. struct3508.AppId = miConfig.Cainfo
  494. struct3508.AppSecret = miConfig.AppSecret
  495. struct3508.Enckey = miConfig.EncKey
  496. struct3508.SignKey = miConfig.SignKey
  497. struct3508.SecretKey = miConfig.SecretKey
  498. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  499. struct3508.PageNum = page
  500. struct3508.PageSize = 10
  501. result1, result2, _ := service.FJyb35081(struct3508)
  502. saveLog(result1, result2, "35081", "35081")
  503. var res models.Result35081
  504. var respJSON2 map[string]interface{}
  505. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  508. return
  509. }
  510. userJSONBytes2, _ := json.Marshal(respJSON2)
  511. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  512. utils.ErrorLog("解析失败:%v", err)
  513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  514. return
  515. }
  516. if res.Infcode == -1 {
  517. c.ServeSuccessJSON(map[string]interface{}{
  518. "failed_code": -10,
  519. "msg": res.ErrMsg,
  520. })
  521. } else {
  522. c.ServeSuccessJSON(map[string]interface{}{
  523. "info": res.Output,
  524. })
  525. }
  526. }
  527. func (c *HisApiController) Get35082() {
  528. admin_user_id, _ := c.GetInt64("admin_user_id")
  529. drug_id, _ := c.GetInt64("id")
  530. //start_time := c.GetString("start_time")
  531. //end_time := c.GetString("end_time")
  532. page, _ := c.GetInt("page")
  533. adminUser := c.GetAdminUserInfo()
  534. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  535. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  536. drug, _ := service.GetDrugByID(drug_id)
  537. var struct3508 models.Struct35082
  538. struct3508.FixmedinsCode = miConfig.Code
  539. struct3508.OrgName = miConfig.OrgName
  540. struct3508.AccessKey = miConfig.AccessKey
  541. struct3508.Opter = curRoles.UserName
  542. struct3508.RequestUrl = miConfig.Url
  543. struct3508.Url = miConfig.Url
  544. struct3508.AppId = miConfig.Cainfo
  545. struct3508.AppSecret = miConfig.AppSecret
  546. struct3508.Enckey = miConfig.EncKey
  547. struct3508.SignKey = miConfig.SignKey
  548. struct3508.SecretKey = miConfig.SecretKey
  549. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  550. struct3508.PageNum = page
  551. struct3508.PageSize = 10
  552. result1, result2, _ := service.FJyb35082(struct3508)
  553. saveLog(result1, result2, "35082", "35082")
  554. var res models.Result35082
  555. var respJSON2 map[string]interface{}
  556. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  557. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  559. return
  560. }
  561. userJSONBytes2, _ := json.Marshal(respJSON2)
  562. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  563. utils.ErrorLog("解析失败:%v", err)
  564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  565. return
  566. }
  567. if res.Infcode == -1 {
  568. c.ServeSuccessJSON(map[string]interface{}{
  569. "failed_code": -10,
  570. "msg": res.ErrMsg,
  571. })
  572. } else {
  573. c.ServeSuccessJSON(map[string]interface{}{
  574. "info": res.Output,
  575. })
  576. }
  577. }
  578. func (c *HisApiController) FJ3501AND3502() {
  579. ids := c.GetString("ids")
  580. admin_user_id, _ := c.GetInt64("admin_user_id")
  581. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  582. id_arr := strings.Split(ids, ",")
  583. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  584. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  585. //库盘
  586. var errs []string
  587. for _, drug := range drugs {
  588. if drug.IsPc == 0 && drug.IsBg == 0 {
  589. var res2 ResultSix
  590. var res3 ResultSix
  591. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  592. var struct3501 models.Struct3501
  593. struct3501.Code = miConfig.Code
  594. struct3501.OrgName = miConfig.OrgName
  595. struct3501.AccessKey = miConfig.AccessKey
  596. struct3501.Opter = roles.UserName
  597. struct3501.RequestUrl = miConfig.Url
  598. struct3501.Url = miConfig.Url
  599. struct3501.AppId = miConfig.Cainfo
  600. struct3501.AppSecret = miConfig.AppSecret
  601. struct3501.Enckey = miConfig.EncKey
  602. struct3501.SignKey = miConfig.SignKey
  603. struct3501.SecretKey = miConfig.SecretKey
  604. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  605. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  606. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  607. struct3501.RxFlag = "0"
  608. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  609. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  610. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  611. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  612. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  613. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  614. struct3501.FixmedinsBchno = number
  615. struct3501.DrugTracCodg = drug.DrugCode
  616. memo := make(map[string]interface{})
  617. memo["pric"] = drug.Price
  618. bytesData, _ := json.Marshal(memo)
  619. struct3501.Memo = string(bytesData)
  620. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  621. result1, result2, _ := service.FJyb3501(struct3501)
  622. saveLog(result1, result2, "3501", "3501")
  623. //saveLog(result, requestLog, "2201", "挂号")
  624. var respJSON2 map[string]interface{}
  625. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  628. return
  629. }
  630. userJSONBytes2, _ := json.Marshal(respJSON2)
  631. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  632. utils.ErrorLog("解析失败:%v", err)
  633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  634. return
  635. }
  636. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  637. data := make(map[string]interface{})
  638. data["struct_3501s"] = struct3501
  639. client := &http.Client{}
  640. bytesData, _ := json.Marshal(data)
  641. var req *http.Request
  642. if miConfig.MdtrtareaAdmvs == "320921" {
  643. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  644. } else {
  645. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  646. }
  647. resp, _ := client.Do(req)
  648. defer resp.Body.Close()
  649. body, ioErr := ioutil.ReadAll(resp.Body)
  650. if ioErr != nil {
  651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  652. }
  653. var respJSON map[string]interface{}
  654. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  657. return
  658. }
  659. var resSix10265 ResultSix10265 //1101结果
  660. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  661. result, _ := json.Marshal(respJSON)
  662. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  663. utils.ErrorLog("解析失败:%v", err)
  664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  665. return
  666. }
  667. res2.InfRefmsgid = resSix10265.InfRefmsgid
  668. res2.Output = resSix10265.Output
  669. res2.ErrMsg = resSix10265.ErrMsg
  670. res2.Cainfo = resSix10265.Cainfo
  671. res2.WarnMsg = resSix10265.WarnMsg
  672. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  673. res2.Infcode = infocode
  674. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  675. data := make(map[string]interface{})
  676. data["struct_3501s"] = struct3501
  677. client := &http.Client{}
  678. bytesData, _ := json.Marshal(data)
  679. var req *http.Request
  680. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  681. resp, _ := client.Do(req)
  682. defer resp.Body.Close()
  683. body, ioErr := ioutil.ReadAll(resp.Body)
  684. if ioErr != nil {
  685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  686. }
  687. var respJSON map[string]interface{}
  688. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  691. return
  692. }
  693. var resSix10265 ResultSix10265 //1101结果
  694. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  695. result, _ := json.Marshal(respJSON)
  696. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  697. utils.ErrorLog("解析失败:%v", err)
  698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  699. return
  700. }
  701. res2.InfRefmsgid = resSix10265.InfRefmsgid
  702. res2.Output = resSix10265.Output
  703. res2.ErrMsg = resSix10265.ErrMsg
  704. res2.Cainfo = resSix10265.Cainfo
  705. res2.WarnMsg = resSix10265.WarnMsg
  706. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  707. res2.Infcode = infocode
  708. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  709. data := make(map[string]interface{})
  710. data["struct_3501s"] = struct3501
  711. client := &http.Client{}
  712. bytesData, _ := json.Marshal(data)
  713. var req *http.Request
  714. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  715. resp, _ := client.Do(req)
  716. defer resp.Body.Close()
  717. body, ioErr := ioutil.ReadAll(resp.Body)
  718. if ioErr != nil {
  719. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  720. }
  721. var respJSON map[string]interface{}
  722. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  725. return
  726. }
  727. var resSix10265 ResultSix10265 //1101结果
  728. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  729. result, _ := json.Marshal(respJSON)
  730. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  731. utils.ErrorLog("解析失败:%v", err)
  732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  733. return
  734. }
  735. res2.InfRefmsgid = resSix10265.InfRefmsgid
  736. res2.Output = resSix10265.Output
  737. res2.ErrMsg = resSix10265.ErrMsg
  738. res2.Cainfo = resSix10265.Cainfo
  739. res2.WarnMsg = resSix10265.WarnMsg
  740. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  741. res2.Infcode = infocode
  742. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") { //广东
  743. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  744. saveLog(result1, result2, "3501", "3501")
  745. //saveLog(result, requestLog, "2201", "挂号")
  746. var respJSON2 map[string]interface{}
  747. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  750. return
  751. }
  752. userJSONBytes2, _ := json.Marshal(respJSON2)
  753. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  754. utils.ErrorLog("解析失败:%v", err)
  755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  756. return
  757. }
  758. }
  759. if res2.Infcode != -1 {
  760. drug.IsPc = 1
  761. drug.Bchno = number
  762. drug.PcDate = time.Now().Unix()
  763. err := service.SaveW(drug)
  764. if err == nil {
  765. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  766. var struct3502 models.Struct3502
  767. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  768. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  769. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  770. struct3502.FixmedinsCode = miConfig.Code
  771. struct3502.Code = miConfig.Code
  772. struct3502.RxFlag = "0"
  773. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  774. struct3502.OrgName = miConfig.OrgName
  775. struct3502.Opter = roles.UserName
  776. struct3502.AccessKey = miConfig.AccessKey
  777. struct3502.RequestUrl = miConfig.Url
  778. struct3502.SecretKey = miConfig.SecretKey
  779. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  780. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  781. struct3502.Url = miConfig.Url
  782. struct3502.AppId = miConfig.Cainfo
  783. struct3502.AppSecret = miConfig.AppSecret
  784. struct3502.Enckey = miConfig.EncKey
  785. struct3502.SignKey = miConfig.SignKey
  786. struct3502.SecretKey = miConfig.SecretKey
  787. struct3502.DrugTracCodg = drug.DrugCode
  788. struct3502.Memo = ""
  789. struct3502.InvChgType = "108"
  790. struct3502.FixmedinsBchno = bg_number
  791. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  792. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  793. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  794. result11, result22, _ := service.FJyb3502(struct3502)
  795. saveLog(result11, result22, "3502", "3502")
  796. var respJSON3 map[string]interface{}
  797. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  798. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  800. return
  801. }
  802. userJSONBytes3, _ := json.Marshal(respJSON3)
  803. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  804. utils.ErrorLog("解析失败:%v", err)
  805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  806. return
  807. }
  808. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  809. data := make(map[string]interface{})
  810. data["struct_3502s"] = struct3502
  811. client := &http.Client{}
  812. bytesData, _ := json.Marshal(data)
  813. var req *http.Request
  814. if miConfig.MdtrtareaAdmvs == "320921" {
  815. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  816. } else {
  817. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  818. }
  819. resp, _ := client.Do(req)
  820. defer resp.Body.Close()
  821. body, ioErr := ioutil.ReadAll(resp.Body)
  822. if ioErr != nil {
  823. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  824. }
  825. var respJSON map[string]interface{}
  826. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  829. return
  830. }
  831. var resSix10265 ResultSix10265 //1101结果
  832. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  833. result, _ := json.Marshal(respJSON)
  834. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  835. utils.ErrorLog("解析失败:%v", err)
  836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  837. return
  838. }
  839. res3.InfRefmsgid = resSix10265.InfRefmsgid
  840. res3.Output = resSix10265.Output
  841. res3.ErrMsg = resSix10265.ErrMsg
  842. res3.Cainfo = resSix10265.Cainfo
  843. res3.WarnMsg = resSix10265.WarnMsg
  844. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  845. res3.Infcode = infocode
  846. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  847. data := make(map[string]interface{})
  848. data["struct_3502s"] = struct3502
  849. client := &http.Client{}
  850. bytesData, _ := json.Marshal(data)
  851. var req *http.Request
  852. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  853. resp, _ := client.Do(req)
  854. defer resp.Body.Close()
  855. body, ioErr := ioutil.ReadAll(resp.Body)
  856. if ioErr != nil {
  857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  858. }
  859. var respJSON map[string]interface{}
  860. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  863. return
  864. }
  865. var resSix10265 ResultSix10265 //1101结果
  866. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  867. result, _ := json.Marshal(respJSON)
  868. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  869. utils.ErrorLog("解析失败:%v", err)
  870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  871. return
  872. }
  873. res3.InfRefmsgid = resSix10265.InfRefmsgid
  874. res3.Output = resSix10265.Output
  875. res3.ErrMsg = resSix10265.ErrMsg
  876. res3.Cainfo = resSix10265.Cainfo
  877. res3.WarnMsg = resSix10265.WarnMsg
  878. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  879. res3.Infcode = infocode
  880. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  881. data := make(map[string]interface{})
  882. data["struct_3501s"] = struct3501
  883. client := &http.Client{}
  884. bytesData, _ := json.Marshal(data)
  885. var req *http.Request
  886. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  887. resp, _ := client.Do(req)
  888. defer resp.Body.Close()
  889. body, ioErr := ioutil.ReadAll(resp.Body)
  890. if ioErr != nil {
  891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  892. }
  893. var respJSON map[string]interface{}
  894. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  897. return
  898. }
  899. var resSix10265 ResultSix10265 //1101结果
  900. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  901. result, _ := json.Marshal(respJSON)
  902. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  903. utils.ErrorLog("解析失败:%v", err)
  904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  905. return
  906. }
  907. res2.InfRefmsgid = resSix10265.InfRefmsgid
  908. res2.Output = resSix10265.Output
  909. res2.ErrMsg = resSix10265.ErrMsg
  910. res2.Cainfo = resSix10265.Cainfo
  911. res2.WarnMsg = resSix10265.WarnMsg
  912. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  913. res2.Infcode = infocode
  914. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  915. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  916. saveLog(result11, result22, "3502", "3502")
  917. var respJSON3 map[string]interface{}
  918. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  921. return
  922. }
  923. userJSONBytes3, _ := json.Marshal(respJSON3)
  924. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  925. utils.ErrorLog("解析失败:%v", err)
  926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  927. return
  928. }
  929. }
  930. if res3.Infcode == -1 {
  931. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  932. c.ServeSuccessJSON(map[string]interface{}{
  933. "failed_code": -10,
  934. "msg": res3.ErrMsg,
  935. })
  936. } else {
  937. drug.IsBg = 1
  938. drug.BgBchno = bg_number
  939. service.SaveW(drug)
  940. }
  941. }
  942. } else {
  943. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  944. }
  945. }
  946. //变更
  947. if drug.IsPc == 1 && drug.IsBg == 0 {
  948. var res3 ResultSix
  949. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  950. var struct3502 models.Struct3502
  951. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  952. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  953. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  954. struct3502.FixmedinsCode = miConfig.Code
  955. struct3502.Code = miConfig.Code
  956. struct3502.Opter = roles.UserName
  957. struct3502.RxFlag = "0"
  958. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  959. struct3502.OrgName = miConfig.OrgName
  960. struct3502.AccessKey = miConfig.AccessKey
  961. struct3502.RequestUrl = miConfig.Url
  962. struct3502.SecretKey = miConfig.SecretKey
  963. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  964. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  965. struct3502.InvChgType = "108"
  966. struct3502.DrugTracCodg = drug.DrugCode
  967. struct3502.Url = miConfig.Url
  968. struct3502.AppId = miConfig.Cainfo
  969. struct3502.AppSecret = miConfig.AppSecret
  970. struct3502.Enckey = miConfig.EncKey
  971. struct3502.SignKey = miConfig.SignKey
  972. struct3502.SecretKey = miConfig.SecretKey
  973. struct3502.FixmedinsBchno = bg_number
  974. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  975. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  976. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  977. result1, result2, _ := service.FJyb3502(struct3502)
  978. saveLog(result1, result2, "3502", "3502")
  979. var respJSON3 map[string]interface{}
  980. if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  983. return
  984. }
  985. userJSONBytes3, _ := json.Marshal(respJSON3)
  986. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  987. utils.ErrorLog("解析失败:%v", err)
  988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  989. return
  990. }
  991. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  992. data := make(map[string]interface{})
  993. data["struct_3502s"] = struct3502
  994. client := &http.Client{}
  995. bytesData, _ := json.Marshal(data)
  996. var req *http.Request
  997. if miConfig.MdtrtareaAdmvs == "320921" {
  998. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  999. } else {
  1000. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1001. }
  1002. resp, _ := client.Do(req)
  1003. defer resp.Body.Close()
  1004. body, ioErr := ioutil.ReadAll(resp.Body)
  1005. if ioErr != nil {
  1006. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1007. }
  1008. var respJSON map[string]interface{}
  1009. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1010. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1012. return
  1013. }
  1014. var resSix10265 ResultSix10265 //1101结果
  1015. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1016. result, _ := json.Marshal(respJSON)
  1017. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1018. utils.ErrorLog("解析失败:%v", err)
  1019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1020. return
  1021. }
  1022. res3.InfRefmsgid = resSix10265.InfRefmsgid
  1023. res3.Output = resSix10265.Output
  1024. res3.ErrMsg = resSix10265.ErrMsg
  1025. res3.Cainfo = resSix10265.Cainfo
  1026. res3.WarnMsg = resSix10265.WarnMsg
  1027. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1028. res3.Infcode = infocode
  1029. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1030. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1031. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  1032. }
  1033. if res3.Infcode == -1 {
  1034. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1035. } else {
  1036. drug.IsBg = 1
  1037. drug.BgBchno = bg_number
  1038. service.SaveW(drug)
  1039. }
  1040. }
  1041. }
  1042. if len(errs) == 0 {
  1043. c.ServeSuccessJSON(map[string]interface{}{
  1044. "msg": "盘存变更成功",
  1045. })
  1046. } else {
  1047. c.ServeSuccessJSON(map[string]interface{}{
  1048. "failed_code": -10,
  1049. "msg": errs,
  1050. })
  1051. }
  1052. }
  1053. func (c *HisApiController) DeletePCandBG() {
  1054. ids := c.GetString("ids")
  1055. id_arr := strings.Split(ids, ",")
  1056. admin_user_id, _ := c.GetInt64("admin_user_id")
  1057. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1058. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1059. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1060. var err []string
  1061. for _, item := range drugs {
  1062. if item.IsPc == 1 && item.IsBg == 1 {
  1063. var res FJ3507Result
  1064. var res2 FJ3507Result
  1065. var struct3507 models.Struct3507
  1066. struct3507.FixmedinsBchno = item.Bchno
  1067. struct3507.InvDataType = "1"
  1068. struct3507.Opter = roles.UserName
  1069. struct3507.OrgName = miConfig.OrgName
  1070. struct3507.AccessKey = miConfig.AccessKey
  1071. struct3507.RequestUrl = miConfig.Url
  1072. struct3507.FixmedinsCode = miConfig.Code
  1073. struct3507.Code = miConfig.Code
  1074. struct3507.SecretKey = miConfig.SecretKey
  1075. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1076. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1077. struct3507.Url = miConfig.Url
  1078. struct3507.AppId = miConfig.Cainfo
  1079. struct3507.AppSecret = miConfig.AppSecret
  1080. struct3507.Enckey = miConfig.EncKey
  1081. struct3507.SignKey = miConfig.SignKey
  1082. struct3507.SecretKey = miConfig.SecretKey
  1083. if miConfig.MdtrtareaAdmvs == "350500" {
  1084. result, result1, _ := service.FJyb3507(struct3507)
  1085. saveLog(result, result1, "3507", "3507")
  1086. var respJSON2 map[string]interface{}
  1087. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1090. return
  1091. }
  1092. userJSONBytes2, _ := json.Marshal(respJSON2)
  1093. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1094. utils.ErrorLog("解析失败:%v", err)
  1095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1096. return
  1097. }
  1098. } else {
  1099. data := make(map[string]interface{})
  1100. data["struct_3507s"] = struct3507
  1101. client := &http.Client{}
  1102. bytesData, _ := json.Marshal(data)
  1103. var req *http.Request
  1104. if miConfig.MdtrtareaAdmvs == "320921" {
  1105. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1106. } else {
  1107. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1108. }
  1109. resp, _ := client.Do(req)
  1110. defer resp.Body.Close()
  1111. body, ioErr := ioutil.ReadAll(resp.Body)
  1112. if ioErr != nil {
  1113. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1114. }
  1115. var respJSON map[string]interface{}
  1116. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1117. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1119. return
  1120. }
  1121. var resSix10265 ResultSix10265 //1101结果
  1122. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1123. result, _ := json.Marshal(respJSON)
  1124. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1125. utils.ErrorLog("解析失败:%v", err)
  1126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1127. return
  1128. }
  1129. res.InfRefmsgid = resSix10265.InfRefmsgid
  1130. //res.Output = resSix10265.Output
  1131. res.ErrMsg = resSix10265.ErrMsg
  1132. res.Cainfo = resSix10265.Cainfo
  1133. res.WarnMsg = resSix10265.WarnMsg
  1134. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1135. res.Infcode = infocode
  1136. }
  1137. if res.Infcode == 0 {
  1138. item.IsPc = 0
  1139. err2 := service.SaveW(item)
  1140. if err2 == nil {
  1141. var struct3507_2 models.Struct3507
  1142. struct3507_2.OrgName = miConfig.OrgName
  1143. struct3507_2.AccessKey = miConfig.AccessKey
  1144. struct3507_2.RequestUrl = miConfig.Url
  1145. struct3507_2.Opter = roles.UserName
  1146. struct3507_2.FixmedinsCode = miConfig.Code
  1147. struct3507_2.Code = miConfig.Code
  1148. struct3507_2.SecretKey = miConfig.SecretKey
  1149. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1150. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1151. struct3507_2.Url = miConfig.Url
  1152. struct3507_2.AppId = miConfig.Cainfo
  1153. struct3507_2.AppSecret = miConfig.AppSecret
  1154. struct3507_2.Enckey = miConfig.EncKey
  1155. struct3507_2.SignKey = miConfig.SignKey
  1156. struct3507_2.SecretKey = miConfig.SecretKey
  1157. struct3507_2.FixmedinsBchno = item.BgBchno
  1158. struct3507_2.InvDataType = "2"
  1159. if miConfig.MdtrtareaAdmvs == "350500" {
  1160. result11, result22, _ := service.FJyb3507(struct3507_2)
  1161. saveLog(result11, result22, "3507", "3507")
  1162. var respJSON3 map[string]interface{}
  1163. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1166. return
  1167. }
  1168. userJSONBytes3, _ := json.Marshal(respJSON3)
  1169. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1170. utils.ErrorLog("解析失败:%v", err)
  1171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1172. return
  1173. }
  1174. } else {
  1175. data := make(map[string]interface{})
  1176. data["struct_3507s"] = struct3507_2
  1177. client := &http.Client{}
  1178. bytesData, _ := json.Marshal(data)
  1179. var req *http.Request
  1180. if miConfig.MdtrtareaAdmvs == "320921" {
  1181. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1182. } else {
  1183. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1184. }
  1185. resp, _ := client.Do(req)
  1186. defer resp.Body.Close()
  1187. body, ioErr := ioutil.ReadAll(resp.Body)
  1188. if ioErr != nil {
  1189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1190. }
  1191. var respJSON map[string]interface{}
  1192. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1193. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1195. return
  1196. }
  1197. var resSix10265 ResultSix10265 //1101结果
  1198. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1199. result, _ := json.Marshal(respJSON)
  1200. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1201. utils.ErrorLog("解析失败:%v", err)
  1202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1203. return
  1204. }
  1205. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1206. //res2.Output = resSix10265.Output
  1207. res2.ErrMsg = resSix10265.ErrMsg
  1208. res2.Cainfo = resSix10265.Cainfo
  1209. res2.WarnMsg = resSix10265.WarnMsg
  1210. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1211. res2.Infcode = infocode
  1212. }
  1213. if res2.Infcode != -1 {
  1214. item.IsBg = 0
  1215. item.Bchno = ""
  1216. item.BgBchno = ""
  1217. item.PcDate = 0
  1218. service.SaveW(item)
  1219. } else {
  1220. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1221. }
  1222. }
  1223. } else {
  1224. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1225. }
  1226. }
  1227. if item.IsPc == 1 && item.IsBg == 0 {
  1228. var res FJ3507Result
  1229. var struct3507 models.Struct3507
  1230. struct3507.FixmedinsBchno = item.Bchno
  1231. struct3507.InvDataType = "1"
  1232. struct3507.Opter = roles.UserName
  1233. struct3507.FixmedinsCode = miConfig.Code
  1234. struct3507.Code = miConfig.Code
  1235. struct3507.OrgName = miConfig.OrgName
  1236. struct3507.AccessKey = miConfig.AccessKey
  1237. struct3507.RequestUrl = miConfig.Url
  1238. struct3507.SecretKey = miConfig.SecretKey
  1239. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1240. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1241. struct3507.Url = miConfig.Url
  1242. struct3507.AppId = miConfig.Cainfo
  1243. struct3507.AppSecret = miConfig.AppSecret
  1244. struct3507.Enckey = miConfig.EncKey
  1245. struct3507.SignKey = miConfig.SignKey
  1246. struct3507.SecretKey = miConfig.SecretKey
  1247. //result, result1, _ := service.FJyb3507(struct3507)
  1248. //saveLog(result, result1, "3507", "3507")
  1249. if miConfig.MdtrtareaAdmvs == "350500" {
  1250. result, result1, _ := service.FJyb3507(struct3507)
  1251. saveLog(result, result1, "3507", "3507")
  1252. var respJSON2 map[string]interface{}
  1253. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1256. return
  1257. }
  1258. userJSONBytes2, _ := json.Marshal(respJSON2)
  1259. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1260. utils.ErrorLog("解析失败:%v", err)
  1261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1262. return
  1263. }
  1264. } else {
  1265. data := make(map[string]interface{})
  1266. data["struct_3507s"] = struct3507
  1267. client := &http.Client{}
  1268. bytesData, _ := json.Marshal(data)
  1269. var req *http.Request
  1270. if miConfig.MdtrtareaAdmvs == "320921" {
  1271. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1272. } else {
  1273. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1274. }
  1275. resp, _ := client.Do(req)
  1276. defer resp.Body.Close()
  1277. body, ioErr := ioutil.ReadAll(resp.Body)
  1278. if ioErr != nil {
  1279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1280. }
  1281. var respJSON map[string]interface{}
  1282. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1283. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1285. return
  1286. }
  1287. var resSix10265 ResultSix10265 //1101结果
  1288. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1289. result, _ := json.Marshal(respJSON)
  1290. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1291. utils.ErrorLog("解析失败:%v", err)
  1292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1293. return
  1294. }
  1295. res.InfRefmsgid = resSix10265.InfRefmsgid
  1296. //res.Output = resSix10265.Output
  1297. res.ErrMsg = resSix10265.ErrMsg
  1298. res.Cainfo = resSix10265.Cainfo
  1299. res.WarnMsg = resSix10265.WarnMsg
  1300. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1301. res.Infcode = infocode
  1302. }
  1303. if res.Infcode == 0 {
  1304. item.IsPc = 0
  1305. item.Bchno = ""
  1306. item.BgBchno = ""
  1307. item.PcDate = 0
  1308. service.SaveW(item)
  1309. } else {
  1310. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1311. }
  1312. }
  1313. if item.IsPc == 0 && item.IsBg == 1 {
  1314. var res FJ3507Result
  1315. var struct3507 models.Struct3507
  1316. struct3507.FixmedinsBchno = item.BgBchno
  1317. struct3507.InvDataType = "2"
  1318. struct3507.Opter = roles.UserName
  1319. struct3507.FixmedinsCode = miConfig.Code
  1320. struct3507.OrgName = miConfig.OrgName
  1321. struct3507.AccessKey = miConfig.AccessKey
  1322. struct3507.RequestUrl = miConfig.Url
  1323. struct3507.SecretKey = miConfig.SecretKey
  1324. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1325. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1326. struct3507.Url = miConfig.Url
  1327. struct3507.AppId = miConfig.Cainfo
  1328. struct3507.AppSecret = miConfig.AppSecret
  1329. struct3507.Enckey = miConfig.EncKey
  1330. struct3507.SignKey = miConfig.SignKey
  1331. struct3507.SecretKey = miConfig.SecretKey
  1332. //result, result1, _ := service.FJyb3507(struct3507)
  1333. //saveLog(result, result1, "3507", "3507")
  1334. if miConfig.MdtrtareaAdmvs == "350500" {
  1335. result, result1, _ := service.FJyb3507(struct3507)
  1336. saveLog(result, result1, "3507", "3507")
  1337. var respJSON2 map[string]interface{}
  1338. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1341. return
  1342. }
  1343. userJSONBytes2, _ := json.Marshal(respJSON2)
  1344. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1345. utils.ErrorLog("解析失败:%v", err)
  1346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1347. return
  1348. }
  1349. } else {
  1350. data := make(map[string]interface{})
  1351. data["struct_3507s"] = struct3507
  1352. client := &http.Client{}
  1353. bytesData, _ := json.Marshal(data)
  1354. var req *http.Request
  1355. if miConfig.MdtrtareaAdmvs == "320921" {
  1356. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1357. } else {
  1358. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1359. }
  1360. resp, _ := client.Do(req)
  1361. defer resp.Body.Close()
  1362. body, ioErr := ioutil.ReadAll(resp.Body)
  1363. if ioErr != nil {
  1364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1365. }
  1366. var respJSON map[string]interface{}
  1367. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1370. return
  1371. }
  1372. var resSix10265 ResultSix10265 //1101结果
  1373. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1374. result, _ := json.Marshal(respJSON)
  1375. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1376. utils.ErrorLog("解析失败:%v", err)
  1377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1378. return
  1379. }
  1380. res.InfRefmsgid = resSix10265.InfRefmsgid
  1381. //res.Output = resSix10265.Output
  1382. res.ErrMsg = resSix10265.ErrMsg
  1383. res.Cainfo = resSix10265.Cainfo
  1384. res.WarnMsg = resSix10265.WarnMsg
  1385. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1386. res.Infcode = infocode
  1387. }
  1388. if res.Infcode == 0 {
  1389. item.IsBg = 0
  1390. item.Bchno = ""
  1391. item.BgBchno = ""
  1392. item.PcDate = 0
  1393. service.SaveW(item)
  1394. } else {
  1395. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1396. }
  1397. }
  1398. }
  1399. if len(err) == 0 {
  1400. c.ServeSuccessJSON(map[string]interface{}{
  1401. "msg": "删除盘存变更成功",
  1402. })
  1403. } else {
  1404. c.ServeSuccessJSON(map[string]interface{}{
  1405. "failed_code": -10,
  1406. "msg": err,
  1407. })
  1408. }
  1409. }
  1410. func (c *HisApiController) DeleteXSandBG() {
  1411. ids := c.GetString("ids")
  1412. id_arr := strings.Split(ids, ",")
  1413. admin_user_id, _ := c.GetInt64("admin_user_id")
  1414. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1415. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1416. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1417. var err []string
  1418. for _, item := range flows {
  1419. if item.IsSale == 1 && item.IsChange == 1 {
  1420. var res FJ3507Result
  1421. var res2 FJ3507Result
  1422. var struct3507 models.Struct3507
  1423. struct3507.FixmedinsBchno = item.Bchno
  1424. struct3507.InvDataType = "4"
  1425. struct3507.Opter = roles.UserName
  1426. struct3507.OrgName = miConfig.OrgName
  1427. struct3507.AccessKey = miConfig.AccessKey
  1428. struct3507.RequestUrl = miConfig.Url
  1429. struct3507.FixmedinsCode = miConfig.Code
  1430. struct3507.SecretKey = miConfig.SecretKey
  1431. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1432. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1433. struct3507.Url = miConfig.Url
  1434. struct3507.AppId = miConfig.Cainfo
  1435. struct3507.AppSecret = miConfig.AppSecret
  1436. struct3507.Enckey = miConfig.EncKey
  1437. struct3507.SignKey = miConfig.SignKey
  1438. struct3507.SecretKey = miConfig.SecretKey
  1439. //result, result1, _ := service.FJyb3507(struct3507)
  1440. //saveLog(result, result1, "3507", "3507")
  1441. if miConfig.MdtrtareaAdmvs == "350500" {
  1442. result, result1, _ := service.FJyb3507(struct3507)
  1443. saveLog(result, result1, "3507", "3507")
  1444. var respJSON2 map[string]interface{}
  1445. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1448. return
  1449. }
  1450. userJSONBytes2, _ := json.Marshal(respJSON2)
  1451. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1452. utils.ErrorLog("解析失败:%v", err)
  1453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1454. return
  1455. }
  1456. } else {
  1457. data := make(map[string]interface{})
  1458. data["struct_3507s"] = struct3507
  1459. client := &http.Client{}
  1460. bytesData, _ := json.Marshal(data)
  1461. var req *http.Request
  1462. if miConfig.MdtrtareaAdmvs == "320921" {
  1463. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1464. } else {
  1465. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1466. }
  1467. resp, _ := client.Do(req)
  1468. defer resp.Body.Close()
  1469. body, ioErr := ioutil.ReadAll(resp.Body)
  1470. if ioErr != nil {
  1471. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1472. }
  1473. var respJSON map[string]interface{}
  1474. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1477. return
  1478. }
  1479. var resSix10265 ResultSix10265 //1101结果
  1480. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1481. result, _ := json.Marshal(respJSON)
  1482. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1483. utils.ErrorLog("解析失败:%v", err)
  1484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1485. return
  1486. }
  1487. res.InfRefmsgid = resSix10265.InfRefmsgid
  1488. //res.Output = resSix10265.Output
  1489. res.ErrMsg = resSix10265.ErrMsg
  1490. res.Cainfo = resSix10265.Cainfo
  1491. res.WarnMsg = resSix10265.WarnMsg
  1492. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1493. res.Infcode = infocode
  1494. }
  1495. if res.Infcode == 0 {
  1496. item.IsSale = 0
  1497. item.SaleDate = ""
  1498. item.Bchno = ""
  1499. err2 := service.SaveDF(item)
  1500. if err2 == nil {
  1501. var struct3507_2 models.Struct3507
  1502. struct3507_2.OrgName = miConfig.OrgName
  1503. struct3507_2.AccessKey = miConfig.AccessKey
  1504. struct3507_2.RequestUrl = miConfig.Url
  1505. struct3507_2.Opter = roles.UserName
  1506. struct3507_2.FixmedinsCode = miConfig.Code
  1507. struct3507_2.Code = miConfig.Code
  1508. struct3507_2.SecretKey = miConfig.SecretKey
  1509. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1510. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1511. struct3507_2.Url = miConfig.Url
  1512. struct3507_2.AppId = miConfig.Cainfo
  1513. struct3507_2.AppSecret = miConfig.AppSecret
  1514. struct3507_2.Enckey = miConfig.EncKey
  1515. struct3507_2.SignKey = miConfig.SignKey
  1516. struct3507_2.SecretKey = miConfig.SecretKey
  1517. struct3507_2.FixmedinsBchno = item.BgBchno
  1518. struct3507_2.InvDataType = "2"
  1519. if miConfig.MdtrtareaAdmvs == "350500" {
  1520. result11, result22, _ := service.FJyb3507(struct3507_2)
  1521. saveLog(result11, result22, "3507", "3507")
  1522. var respJSON3 map[string]interface{}
  1523. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1526. return
  1527. }
  1528. userJSONBytes3, _ := json.Marshal(respJSON3)
  1529. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1530. utils.ErrorLog("解析失败:%v", err)
  1531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1532. return
  1533. }
  1534. } else {
  1535. data := make(map[string]interface{})
  1536. data["struct_3507s"] = struct3507_2
  1537. client := &http.Client{}
  1538. bytesData, _ := json.Marshal(data)
  1539. var req *http.Request
  1540. if miConfig.MdtrtareaAdmvs == "320921" {
  1541. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1542. } else {
  1543. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1544. }
  1545. resp, _ := client.Do(req)
  1546. defer resp.Body.Close()
  1547. body, ioErr := ioutil.ReadAll(resp.Body)
  1548. if ioErr != nil {
  1549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1550. }
  1551. var respJSON map[string]interface{}
  1552. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1555. return
  1556. }
  1557. var resSix10265 ResultSix10265 //1101结果
  1558. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1559. result, _ := json.Marshal(respJSON)
  1560. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1561. utils.ErrorLog("解析失败:%v", err)
  1562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1563. return
  1564. }
  1565. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1566. //res.Output = resSix10265.Output
  1567. res2.ErrMsg = resSix10265.ErrMsg
  1568. res2.Cainfo = resSix10265.Cainfo
  1569. res2.WarnMsg = resSix10265.WarnMsg
  1570. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1571. res2.Infcode = infocode
  1572. }
  1573. if res2.Infcode == 0 {
  1574. item.IsChange = 0
  1575. item.BgBchno = ""
  1576. service.SaveDF2(item)
  1577. } else {
  1578. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1579. }
  1580. }
  1581. } else {
  1582. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1583. }
  1584. }
  1585. if item.IsSale == 2 && item.IsChange == 1 {
  1586. var res FJ3507Result
  1587. var res2 FJ3507Result
  1588. var struct3507 models.Struct3507
  1589. struct3507.FixmedinsBchno = item.Bchno
  1590. struct3507.InvDataType = "4"
  1591. struct3507.Opter = roles.UserName
  1592. struct3507.OrgName = miConfig.OrgName
  1593. struct3507.AccessKey = miConfig.AccessKey
  1594. struct3507.RequestUrl = miConfig.Url
  1595. struct3507.FixmedinsCode = miConfig.Code
  1596. struct3507.Code = miConfig.Code
  1597. struct3507.SecretKey = miConfig.SecretKey
  1598. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1599. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1600. struct3507.Url = miConfig.Url
  1601. struct3507.AppId = miConfig.Cainfo
  1602. struct3507.AppSecret = miConfig.AppSecret
  1603. struct3507.Enckey = miConfig.EncKey
  1604. struct3507.SignKey = miConfig.SignKey
  1605. struct3507.SecretKey = miConfig.SecretKey
  1606. //result, result1, _ := service.FJyb3507(struct3507)
  1607. //saveLog(result, result1, "3507", "3507")
  1608. //
  1609. //var respJSON2 map[string]interface{}
  1610. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1611. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1612. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1613. // return
  1614. //}
  1615. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1616. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1617. // utils.ErrorLog("解析失败:%v", err)
  1618. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1619. // return
  1620. //}
  1621. if miConfig.MdtrtareaAdmvs == "350500" {
  1622. result, result1, _ := service.FJyb3507(struct3507)
  1623. saveLog(result, result1, "3507", "3507")
  1624. var respJSON2 map[string]interface{}
  1625. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1628. return
  1629. }
  1630. userJSONBytes2, _ := json.Marshal(respJSON2)
  1631. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1632. utils.ErrorLog("解析失败:%v", err)
  1633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1634. return
  1635. }
  1636. } else {
  1637. data := make(map[string]interface{})
  1638. data["struct_3507s"] = struct3507
  1639. client := &http.Client{}
  1640. bytesData, _ := json.Marshal(data)
  1641. var req *http.Request
  1642. if miConfig.MdtrtareaAdmvs == "320921" {
  1643. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1644. } else {
  1645. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1646. }
  1647. resp, _ := client.Do(req)
  1648. defer resp.Body.Close()
  1649. body, ioErr := ioutil.ReadAll(resp.Body)
  1650. if ioErr != nil {
  1651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1652. }
  1653. var respJSON map[string]interface{}
  1654. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1657. return
  1658. }
  1659. var resSix10265 ResultSix10265 //1101结果
  1660. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1661. result, _ := json.Marshal(respJSON)
  1662. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1663. utils.ErrorLog("解析失败:%v", err)
  1664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1665. return
  1666. }
  1667. res.InfRefmsgid = resSix10265.InfRefmsgid
  1668. //res.Output = resSix10265.Output
  1669. res.ErrMsg = resSix10265.ErrMsg
  1670. res.Cainfo = resSix10265.Cainfo
  1671. res.WarnMsg = resSix10265.WarnMsg
  1672. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1673. res.Infcode = infocode
  1674. }
  1675. if res.Infcode == 0 {
  1676. item.IsSale = 0
  1677. item.SaleDate = ""
  1678. item.Bchno = ""
  1679. err2 := service.SaveDF(item)
  1680. if err2 == nil {
  1681. var struct3507_2 models.Struct3507
  1682. struct3507_2.OrgName = miConfig.OrgName
  1683. struct3507_2.AccessKey = miConfig.AccessKey
  1684. struct3507_2.RequestUrl = miConfig.Url
  1685. struct3507_2.Opter = roles.UserName
  1686. struct3507_2.FixmedinsCode = miConfig.Code
  1687. struct3507_2.Code = miConfig.Code
  1688. struct3507_2.SecretKey = miConfig.SecretKey
  1689. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1690. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1691. struct3507_2.Url = miConfig.Url
  1692. struct3507_2.AppId = miConfig.Cainfo
  1693. struct3507_2.AppSecret = miConfig.AppSecret
  1694. struct3507_2.Enckey = miConfig.EncKey
  1695. struct3507_2.SignKey = miConfig.SignKey
  1696. struct3507_2.SecretKey = miConfig.SecretKey
  1697. struct3507_2.FixmedinsBchno = item.BgBchno
  1698. struct3507_2.InvDataType = "2"
  1699. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1700. //saveLog(result11, result22, "3507", "3507")
  1701. //var respJSON3 map[string]interface{}
  1702. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1703. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1704. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1705. // return
  1706. //}
  1707. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1708. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1709. // utils.ErrorLog("解析失败:%v", err)
  1710. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1711. // return
  1712. //}
  1713. if miConfig.MdtrtareaAdmvs == "350500" {
  1714. result11, result22, _ := service.FJyb3507(struct3507_2)
  1715. saveLog(result11, result22, "3507", "3507")
  1716. var respJSON3 map[string]interface{}
  1717. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1720. return
  1721. }
  1722. userJSONBytes3, _ := json.Marshal(respJSON3)
  1723. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1724. utils.ErrorLog("解析失败:%v", err)
  1725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1726. return
  1727. }
  1728. } else {
  1729. data := make(map[string]interface{})
  1730. data["struct_3507s"] = struct3507_2
  1731. client := &http.Client{}
  1732. bytesData, _ := json.Marshal(data)
  1733. var req *http.Request
  1734. if miConfig.MdtrtareaAdmvs == "320921" {
  1735. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1736. } else {
  1737. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1738. }
  1739. resp, _ := client.Do(req)
  1740. defer resp.Body.Close()
  1741. body, ioErr := ioutil.ReadAll(resp.Body)
  1742. if ioErr != nil {
  1743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1744. }
  1745. var respJSON map[string]interface{}
  1746. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1749. return
  1750. }
  1751. var resSix10265 ResultSix10265 //1101结果
  1752. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1753. result, _ := json.Marshal(respJSON)
  1754. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1755. utils.ErrorLog("解析失败:%v", err)
  1756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1757. return
  1758. }
  1759. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1760. //res.Output = resSix10265.Output
  1761. res2.ErrMsg = resSix10265.ErrMsg
  1762. res2.Cainfo = resSix10265.Cainfo
  1763. res2.WarnMsg = resSix10265.WarnMsg
  1764. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1765. res2.Infcode = infocode
  1766. }
  1767. if res2.Infcode == 0 {
  1768. item.IsChange = 0
  1769. item.BgBchno = ""
  1770. service.SaveDF2(item)
  1771. } else {
  1772. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1773. }
  1774. }
  1775. } else {
  1776. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1777. }
  1778. }
  1779. if item.IsSale == 1 && item.IsChange == 0 {
  1780. var res FJ3507Result
  1781. var struct3507 models.Struct3507
  1782. struct3507.FixmedinsBchno = item.Bchno
  1783. struct3507.InvDataType = "4"
  1784. struct3507.Opter = roles.UserName
  1785. struct3507.FixmedinsCode = miConfig.Code
  1786. struct3507.Code = miConfig.Code
  1787. struct3507.OrgName = miConfig.OrgName
  1788. struct3507.AccessKey = miConfig.AccessKey
  1789. struct3507.RequestUrl = miConfig.Url
  1790. struct3507.SecretKey = miConfig.SecretKey
  1791. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1792. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1793. struct3507.Url = miConfig.Url
  1794. struct3507.AppId = miConfig.Cainfo
  1795. struct3507.AppSecret = miConfig.AppSecret
  1796. struct3507.Enckey = miConfig.EncKey
  1797. struct3507.SignKey = miConfig.SignKey
  1798. struct3507.SecretKey = miConfig.SecretKey
  1799. //result, result1, _ := service.FJyb3507(struct3507)
  1800. //saveLog(result, result1, "3507", "3507")
  1801. //
  1802. //var respJSON3 map[string]interface{}
  1803. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1804. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1805. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1806. // return
  1807. //}
  1808. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1809. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1810. // utils.ErrorLog("解析失败:%v", err)
  1811. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1812. // return
  1813. //}
  1814. if miConfig.MdtrtareaAdmvs == "350500" {
  1815. result, result1, _ := service.FJyb3507(struct3507)
  1816. saveLog(result, result1, "3507", "3507")
  1817. var respJSON2 map[string]interface{}
  1818. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1821. return
  1822. }
  1823. userJSONBytes2, _ := json.Marshal(respJSON2)
  1824. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1825. utils.ErrorLog("解析失败:%v", err)
  1826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1827. return
  1828. }
  1829. } else {
  1830. data := make(map[string]interface{})
  1831. data["struct_3507s"] = struct3507
  1832. client := &http.Client{}
  1833. bytesData, _ := json.Marshal(data)
  1834. var req *http.Request
  1835. if miConfig.MdtrtareaAdmvs == "320921" {
  1836. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1837. } else {
  1838. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1839. }
  1840. resp, _ := client.Do(req)
  1841. defer resp.Body.Close()
  1842. body, ioErr := ioutil.ReadAll(resp.Body)
  1843. if ioErr != nil {
  1844. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1845. }
  1846. var respJSON map[string]interface{}
  1847. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1848. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1850. return
  1851. }
  1852. var resSix10265 ResultSix10265 //1101结果
  1853. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1854. result, _ := json.Marshal(respJSON)
  1855. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1856. utils.ErrorLog("解析失败:%v", err)
  1857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1858. return
  1859. }
  1860. res.InfRefmsgid = resSix10265.InfRefmsgid
  1861. //res.Output = resSix10265.Output
  1862. res.ErrMsg = resSix10265.ErrMsg
  1863. res.Cainfo = resSix10265.Cainfo
  1864. res.WarnMsg = resSix10265.WarnMsg
  1865. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1866. res.Infcode = infocode
  1867. }
  1868. if res.Infcode == 0 {
  1869. item.IsSale = 0
  1870. item.SaleDate = ""
  1871. service.SaveDF(item)
  1872. } else {
  1873. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1874. }
  1875. }
  1876. if item.IsSale == 2 && item.IsChange == 0 {
  1877. var res FJ3507Result
  1878. var struct3507 models.Struct3507
  1879. struct3507.FixmedinsBchno = item.Bchno
  1880. struct3507.InvDataType = "4"
  1881. struct3507.Opter = roles.UserName
  1882. struct3507.FixmedinsCode = miConfig.Code
  1883. struct3507.Code = miConfig.Code
  1884. struct3507.OrgName = miConfig.OrgName
  1885. struct3507.AccessKey = miConfig.AccessKey
  1886. struct3507.RequestUrl = miConfig.Url
  1887. struct3507.SecretKey = miConfig.SecretKey
  1888. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1889. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1890. struct3507.Url = miConfig.Url
  1891. struct3507.AppId = miConfig.Cainfo
  1892. struct3507.AppSecret = miConfig.AppSecret
  1893. struct3507.Enckey = miConfig.EncKey
  1894. struct3507.SignKey = miConfig.SignKey
  1895. struct3507.SecretKey = miConfig.SecretKey
  1896. //result, result1, _ := service.FJyb3507(struct3507)
  1897. //saveLog(result, result1, "3507", "3507")
  1898. //
  1899. //var respJSON3 map[string]interface{}
  1900. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1901. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1902. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1903. // return
  1904. //}
  1905. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1906. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1907. // utils.ErrorLog("解析失败:%v", err)
  1908. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1909. // return
  1910. //}
  1911. if miConfig.MdtrtareaAdmvs == "350500" {
  1912. result, result1, _ := service.FJyb3507(struct3507)
  1913. saveLog(result, result1, "3507", "3507")
  1914. var respJSON2 map[string]interface{}
  1915. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1918. return
  1919. }
  1920. userJSONBytes2, _ := json.Marshal(respJSON2)
  1921. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1922. utils.ErrorLog("解析失败:%v", err)
  1923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1924. return
  1925. }
  1926. } else {
  1927. data := make(map[string]interface{})
  1928. data["struct_3507s"] = struct3507
  1929. client := &http.Client{}
  1930. bytesData, _ := json.Marshal(data)
  1931. var req *http.Request
  1932. if miConfig.MdtrtareaAdmvs == "320921" {
  1933. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1934. } else {
  1935. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1936. }
  1937. resp, _ := client.Do(req)
  1938. defer resp.Body.Close()
  1939. body, ioErr := ioutil.ReadAll(resp.Body)
  1940. if ioErr != nil {
  1941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1942. }
  1943. var respJSON map[string]interface{}
  1944. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1947. return
  1948. }
  1949. var resSix10265 ResultSix10265 //1101结果
  1950. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1951. result, _ := json.Marshal(respJSON)
  1952. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1953. utils.ErrorLog("解析失败:%v", err)
  1954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1955. return
  1956. }
  1957. res.InfRefmsgid = resSix10265.InfRefmsgid
  1958. //res.Output = resSix10265.Output
  1959. res.ErrMsg = resSix10265.ErrMsg
  1960. res.Cainfo = resSix10265.Cainfo
  1961. res.WarnMsg = resSix10265.WarnMsg
  1962. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1963. res.Infcode = infocode
  1964. }
  1965. if res.Infcode == 0 {
  1966. item.IsSale = 0
  1967. item.SaleDate = ""
  1968. item.Bchno = ""
  1969. service.SaveDF(item)
  1970. } else {
  1971. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1972. }
  1973. }
  1974. if item.IsSale == 0 && item.IsChange == 1 {
  1975. var res FJ3507Result
  1976. var struct3507 models.Struct3507
  1977. struct3507.FixmedinsBchno = item.BgBchno
  1978. struct3507.InvDataType = "2"
  1979. struct3507.Opter = roles.UserName
  1980. struct3507.FixmedinsCode = miConfig.Code
  1981. struct3507.Code = miConfig.Code
  1982. struct3507.OrgName = miConfig.OrgName
  1983. struct3507.AccessKey = miConfig.AccessKey
  1984. struct3507.RequestUrl = miConfig.Url
  1985. struct3507.SecretKey = miConfig.SecretKey
  1986. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1987. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1988. struct3507.Url = miConfig.Url
  1989. struct3507.AppId = miConfig.Cainfo
  1990. struct3507.AppSecret = miConfig.AppSecret
  1991. struct3507.Enckey = miConfig.EncKey
  1992. struct3507.SignKey = miConfig.SignKey
  1993. struct3507.SecretKey = miConfig.SecretKey
  1994. //result, result1, _ := service.FJyb3507(struct3507)
  1995. //saveLog(result, result1, "3507", "3507")
  1996. //
  1997. //var respJSON3 map[string]interface{}
  1998. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1999. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2000. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2001. // return
  2002. //}
  2003. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2004. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2005. // utils.ErrorLog("解析失败:%v", err)
  2006. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2007. // return
  2008. //}
  2009. if miConfig.MdtrtareaAdmvs == "350500" {
  2010. result, result1, _ := service.FJyb3507(struct3507)
  2011. saveLog(result, result1, "3507", "3507")
  2012. var respJSON2 map[string]interface{}
  2013. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2016. return
  2017. }
  2018. userJSONBytes2, _ := json.Marshal(respJSON2)
  2019. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2020. utils.ErrorLog("解析失败:%v", err)
  2021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2022. return
  2023. }
  2024. } else {
  2025. data := make(map[string]interface{})
  2026. data["struct_3507s"] = struct3507
  2027. client := &http.Client{}
  2028. bytesData, _ := json.Marshal(data)
  2029. var req *http.Request
  2030. if miConfig.MdtrtareaAdmvs == "320921" {
  2031. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2032. } else {
  2033. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2034. }
  2035. resp, _ := client.Do(req)
  2036. defer resp.Body.Close()
  2037. body, ioErr := ioutil.ReadAll(resp.Body)
  2038. if ioErr != nil {
  2039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2040. }
  2041. var respJSON map[string]interface{}
  2042. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2043. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2045. return
  2046. }
  2047. var resSix10265 ResultSix10265 //1101结果
  2048. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2049. result, _ := json.Marshal(respJSON)
  2050. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2051. utils.ErrorLog("解析失败:%v", err)
  2052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2053. return
  2054. }
  2055. res.InfRefmsgid = resSix10265.InfRefmsgid
  2056. //res.Output = resSix10265.Output
  2057. res.ErrMsg = resSix10265.ErrMsg
  2058. res.Cainfo = resSix10265.Cainfo
  2059. res.WarnMsg = resSix10265.WarnMsg
  2060. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2061. res.Infcode = infocode
  2062. }
  2063. if res.Infcode == 0 {
  2064. item.IsChange = 0
  2065. item.BgBchno = ""
  2066. service.SaveDF2(item)
  2067. } else {
  2068. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2069. }
  2070. }
  2071. }
  2072. if len(err) == 0 {
  2073. c.ServeSuccessJSON(map[string]interface{}{
  2074. "msg": "删除销售变更成功",
  2075. })
  2076. } else {
  2077. c.ServeSuccessJSON(map[string]interface{}{
  2078. "failed_code": -10,
  2079. "msg": err,
  2080. })
  2081. }
  2082. }
  2083. //func (c *HisApiController) DeleteXSandBGTwo() {
  2084. // patient_id, _ := c.GetInt64("patient_id")
  2085. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2086. // //id_arr := strings.Split(ids, ",")
  2087. // times := c.GetString("time", "")
  2088. // timeLayout := "2006-01-02"
  2089. // loc, _ := time.LoadLocation("Local")
  2090. // var stime, etime int64
  2091. // if times == "" {
  2092. // stime, etime = GetNowTime()
  2093. // } else {
  2094. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2095. // stime = stmp.Unix()
  2096. // etime = stime + 86399
  2097. // }
  2098. // advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2099. // var flows []*models.DrugFlow
  2100. // for _, item := range advicelist {
  2101. // flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.ID, times, c.GetAdminUserInfo().CurrentOrgId)
  2102. // flows = append(flows, flow...)
  2103. // }
  2104. //
  2105. // //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2106. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2107. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2108. //
  2109. // var err []string
  2110. // for _, item := range flows {
  2111. // if item.IsSale == 1 && item.IsChange == 1 {
  2112. // var res FJ3507Result
  2113. // var res2 FJ3507Result
  2114. //
  2115. // var struct3507 models.Struct3507
  2116. // struct3507.FixmedinsBchno = item.Bchno
  2117. // struct3507.InvDataType = "4"
  2118. // struct3507.Opter = roles.UserName
  2119. // struct3507.OrgName = miConfig.OrgName
  2120. // struct3507.AccessKey = miConfig.AccessKey
  2121. // struct3507.RequestUrl = miConfig.Url
  2122. // struct3507.FixmedinsCode = miConfig.Code
  2123. // struct3507.SecretKey = miConfig.SecretKey
  2124. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2125. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2126. // struct3507.Url = miConfig.Url
  2127. // struct3507.AppId = miConfig.Cainfo
  2128. // struct3507.AppSecret = miConfig.AppSecret
  2129. // struct3507.Enckey = miConfig.EncKey
  2130. // struct3507.SignKey = miConfig.SignKey
  2131. // struct3507.SecretKey = miConfig.SecretKey
  2132. //
  2133. // //result, result1, _ := service.FJyb3507(struct3507)
  2134. // //saveLog(result, result1, "3507", "3507")
  2135. //
  2136. // if miConfig.MdtrtareaAdmvs == "350500" {
  2137. // result, result1, _ := service.FJyb3507(struct3507)
  2138. // saveLog(result, result1, "3507", "3507")
  2139. // var respJSON2 map[string]interface{}
  2140. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2141. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2142. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2143. // return
  2144. // }
  2145. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2146. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2147. // utils.ErrorLog("解析失败:%v", err)
  2148. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2149. // return
  2150. // }
  2151. // } else {
  2152. // data := make(map[string]interface{})
  2153. // data["struct_3507s"] = struct3507
  2154. // client := &http.Client{}
  2155. // bytesData, _ := json.Marshal(data)
  2156. // var req *http.Request
  2157. // if miConfig.MdtrtareaAdmvs == "320921" {
  2158. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2159. // } else {
  2160. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2161. // }
  2162. //
  2163. // resp, _ := client.Do(req)
  2164. // defer resp.Body.Close()
  2165. // body, ioErr := ioutil.ReadAll(resp.Body)
  2166. // if ioErr != nil {
  2167. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2168. // }
  2169. // var respJSON map[string]interface{}
  2170. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2171. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2172. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2173. // return
  2174. // }
  2175. // var resSix10265 ResultSix10265 //1101结果
  2176. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2177. // result, _ := json.Marshal(respJSON)
  2178. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2179. // utils.ErrorLog("解析失败:%v", err)
  2180. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2181. // return
  2182. // }
  2183. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2184. // //res.Output = resSix10265.Output
  2185. // res.ErrMsg = resSix10265.ErrMsg
  2186. // res.Cainfo = resSix10265.Cainfo
  2187. // res.WarnMsg = resSix10265.WarnMsg
  2188. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2189. // res.Infcode = infocode
  2190. // }
  2191. //
  2192. // if res.Infcode == 0 {
  2193. // item.IsSale = 0
  2194. // item.SaleDate = ""
  2195. // item.Bchno = ""
  2196. //
  2197. // err2 := service.SaveDF(item)
  2198. // if err2 == nil {
  2199. // var struct3507_2 models.Struct3507
  2200. // struct3507_2.OrgName = miConfig.OrgName
  2201. // struct3507_2.AccessKey = miConfig.AccessKey
  2202. // struct3507_2.RequestUrl = miConfig.Url
  2203. // struct3507_2.Opter = roles.UserName
  2204. // struct3507_2.FixmedinsCode = miConfig.Code
  2205. // struct3507_2.Code = miConfig.Code
  2206. //
  2207. // struct3507_2.SecretKey = miConfig.SecretKey
  2208. // struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2209. // struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2210. // struct3507_2.Url = miConfig.Url
  2211. // struct3507_2.AppId = miConfig.Cainfo
  2212. // struct3507_2.AppSecret = miConfig.AppSecret
  2213. // struct3507_2.Enckey = miConfig.EncKey
  2214. // struct3507_2.SignKey = miConfig.SignKey
  2215. // struct3507_2.SecretKey = miConfig.SecretKey
  2216. // struct3507_2.FixmedinsBchno = item.BgBchno
  2217. // struct3507_2.InvDataType = "2"
  2218. //
  2219. // if miConfig.MdtrtareaAdmvs == "350500" {
  2220. // result11, result22, _ := service.FJyb3507(struct3507_2)
  2221. // saveLog(result11, result22, "3507", "3507")
  2222. //
  2223. // var respJSON3 map[string]interface{}
  2224. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2225. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2226. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2227. // return
  2228. // }
  2229. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2230. // if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2231. // utils.ErrorLog("解析失败:%v", err)
  2232. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2233. // return
  2234. // }
  2235. // } else {
  2236. //
  2237. // data := make(map[string]interface{})
  2238. // data["struct_3507s"] = struct3507_2
  2239. // client := &http.Client{}
  2240. // bytesData, _ := json.Marshal(data)
  2241. // var req *http.Request
  2242. // if miConfig.MdtrtareaAdmvs == "320921" {
  2243. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2244. // } else {
  2245. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2246. // }
  2247. //
  2248. // resp, _ := client.Do(req)
  2249. // defer resp.Body.Close()
  2250. // body, ioErr := ioutil.ReadAll(resp.Body)
  2251. // if ioErr != nil {
  2252. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2253. // }
  2254. // var respJSON map[string]interface{}
  2255. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2256. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2257. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2258. // return
  2259. // }
  2260. // var resSix10265 ResultSix10265 //1101结果
  2261. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2262. // result, _ := json.Marshal(respJSON)
  2263. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2264. // utils.ErrorLog("解析失败:%v", err)
  2265. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2266. // return
  2267. // }
  2268. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2269. // //res.Output = resSix10265.Output
  2270. // res2.ErrMsg = resSix10265.ErrMsg
  2271. // res2.Cainfo = resSix10265.Cainfo
  2272. // res2.WarnMsg = resSix10265.WarnMsg
  2273. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2274. // res2.Infcode = infocode
  2275. // }
  2276. //
  2277. // if res2.Infcode == 0 {
  2278. // item.IsChange = 0
  2279. // item.BgBchno = ""
  2280. // service.SaveDF2(item)
  2281. // } else {
  2282. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2283. // }
  2284. // }
  2285. // } else {
  2286. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2287. // }
  2288. //
  2289. // }
  2290. // if item.IsSale == 2 && item.IsChange == 1 {
  2291. // var res FJ3507Result
  2292. // var res2 FJ3507Result
  2293. //
  2294. // var struct3507 models.Struct3507
  2295. // struct3507.FixmedinsBchno = item.Bchno
  2296. // struct3507.InvDataType = "4"
  2297. // struct3507.Opter = roles.UserName
  2298. // struct3507.OrgName = miConfig.OrgName
  2299. // struct3507.AccessKey = miConfig.AccessKey
  2300. // struct3507.RequestUrl = miConfig.Url
  2301. // struct3507.FixmedinsCode = miConfig.Code
  2302. // struct3507.Code = miConfig.Code
  2303. //
  2304. // struct3507.SecretKey = miConfig.SecretKey
  2305. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2306. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2307. // struct3507.Url = miConfig.Url
  2308. // struct3507.AppId = miConfig.Cainfo
  2309. // struct3507.AppSecret = miConfig.AppSecret
  2310. // struct3507.Enckey = miConfig.EncKey
  2311. // struct3507.SignKey = miConfig.SignKey
  2312. // struct3507.SecretKey = miConfig.SecretKey
  2313. // //result, result1, _ := service.FJyb3507(struct3507)
  2314. // //saveLog(result, result1, "3507", "3507")
  2315. // //
  2316. // //var respJSON2 map[string]interface{}
  2317. // //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2318. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2319. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2320. // // return
  2321. // //}
  2322. // //userJSONBytes2, _ := json.Marshal(respJSON2)
  2323. // //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2324. // // utils.ErrorLog("解析失败:%v", err)
  2325. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2326. // // return
  2327. // //}
  2328. //
  2329. // if miConfig.MdtrtareaAdmvs == "350500" {
  2330. // result, result1, _ := service.FJyb3507(struct3507)
  2331. // saveLog(result, result1, "3507", "3507")
  2332. // var respJSON2 map[string]interface{}
  2333. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2334. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2335. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2336. // return
  2337. // }
  2338. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2339. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2340. // utils.ErrorLog("解析失败:%v", err)
  2341. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2342. // return
  2343. // }
  2344. // } else {
  2345. // data := make(map[string]interface{})
  2346. // data["struct_3507s"] = struct3507
  2347. // client := &http.Client{}
  2348. // bytesData, _ := json.Marshal(data)
  2349. // var req *http.Request
  2350. // if miConfig.MdtrtareaAdmvs == "320921" {
  2351. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2352. // } else {
  2353. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2354. // }
  2355. //
  2356. // resp, _ := client.Do(req)
  2357. // defer resp.Body.Close()
  2358. // body, ioErr := ioutil.ReadAll(resp.Body)
  2359. // if ioErr != nil {
  2360. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2361. // }
  2362. // var respJSON map[string]interface{}
  2363. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2364. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2365. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2366. // return
  2367. // }
  2368. // var resSix10265 ResultSix10265 //1101结果
  2369. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2370. // result, _ := json.Marshal(respJSON)
  2371. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2372. // utils.ErrorLog("解析失败:%v", err)
  2373. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2374. // return
  2375. // }
  2376. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2377. // //res.Output = resSix10265.Output
  2378. // res.ErrMsg = resSix10265.ErrMsg
  2379. // res.Cainfo = resSix10265.Cainfo
  2380. // res.WarnMsg = resSix10265.WarnMsg
  2381. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2382. // res.Infcode = infocode
  2383. // }
  2384. //
  2385. // if res.Infcode == 0 {
  2386. // item.IsSale = 0
  2387. // item.SaleDate = ""
  2388. // item.Bchno = ""
  2389. // err2 := service.SaveDF(item)
  2390. // if err2 == nil {
  2391. // var struct3507_2 models.Struct3507
  2392. // struct3507_2.OrgName = miConfig.OrgName
  2393. // struct3507_2.AccessKey = miConfig.AccessKey
  2394. // struct3507_2.RequestUrl = miConfig.Url
  2395. // struct3507_2.Opter = roles.UserName
  2396. // struct3507_2.FixmedinsCode = miConfig.Code
  2397. // struct3507_2.Code = miConfig.Code
  2398. //
  2399. // struct3507_2.SecretKey = miConfig.SecretKey
  2400. // struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2401. // struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2402. // struct3507_2.Url = miConfig.Url
  2403. // struct3507_2.AppId = miConfig.Cainfo
  2404. // struct3507_2.AppSecret = miConfig.AppSecret
  2405. // struct3507_2.Enckey = miConfig.EncKey
  2406. // struct3507_2.SignKey = miConfig.SignKey
  2407. // struct3507_2.SecretKey = miConfig.SecretKey
  2408. // struct3507_2.FixmedinsBchno = item.BgBchno
  2409. // struct3507_2.InvDataType = "2"
  2410. //
  2411. // //result11, result22, _ := service.FJyb3507(struct3507_2)
  2412. // //saveLog(result11, result22, "3507", "3507")
  2413. // //var respJSON3 map[string]interface{}
  2414. // //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2415. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2416. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2417. // // return
  2418. // //}
  2419. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2420. // //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2421. // // utils.ErrorLog("解析失败:%v", err)
  2422. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2423. // // return
  2424. // //}
  2425. //
  2426. // if miConfig.MdtrtareaAdmvs == "350500" {
  2427. // result11, result22, _ := service.FJyb3507(struct3507_2)
  2428. // saveLog(result11, result22, "3507", "3507")
  2429. //
  2430. // var respJSON3 map[string]interface{}
  2431. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2432. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2433. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2434. // return
  2435. // }
  2436. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2437. // if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2438. // utils.ErrorLog("解析失败:%v", err)
  2439. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2440. // return
  2441. // }
  2442. // } else {
  2443. //
  2444. // data := make(map[string]interface{})
  2445. // data["struct_3507s"] = struct3507_2
  2446. // client := &http.Client{}
  2447. // bytesData, _ := json.Marshal(data)
  2448. // var req *http.Request
  2449. // if miConfig.MdtrtareaAdmvs == "320921" {
  2450. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2451. // } else {
  2452. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2453. // }
  2454. //
  2455. // resp, _ := client.Do(req)
  2456. // defer resp.Body.Close()
  2457. // body, ioErr := ioutil.ReadAll(resp.Body)
  2458. // if ioErr != nil {
  2459. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2460. // }
  2461. // var respJSON map[string]interface{}
  2462. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2463. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2464. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2465. // return
  2466. // }
  2467. // var resSix10265 ResultSix10265 //1101结果
  2468. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2469. // result, _ := json.Marshal(respJSON)
  2470. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2471. // utils.ErrorLog("解析失败:%v", err)
  2472. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2473. // return
  2474. // }
  2475. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2476. // //res.Output = resSix10265.Output
  2477. // res2.ErrMsg = resSix10265.ErrMsg
  2478. // res2.Cainfo = resSix10265.Cainfo
  2479. // res2.WarnMsg = resSix10265.WarnMsg
  2480. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2481. // res2.Infcode = infocode
  2482. // }
  2483. // if res2.Infcode == 0 {
  2484. // item.IsChange = 0
  2485. // item.BgBchno = ""
  2486. // service.SaveDF2(item)
  2487. // } else {
  2488. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2489. // }
  2490. // }
  2491. // } else {
  2492. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2493. // }
  2494. //
  2495. // }
  2496. // if item.IsSale == 1 && item.IsChange == 0 {
  2497. //
  2498. // var res FJ3507Result
  2499. // var struct3507 models.Struct3507
  2500. // struct3507.FixmedinsBchno = item.Bchno
  2501. // struct3507.InvDataType = "4"
  2502. // struct3507.Opter = roles.UserName
  2503. // struct3507.FixmedinsCode = miConfig.Code
  2504. // struct3507.Code = miConfig.Code
  2505. //
  2506. // struct3507.OrgName = miConfig.OrgName
  2507. // struct3507.AccessKey = miConfig.AccessKey
  2508. // struct3507.RequestUrl = miConfig.Url
  2509. // struct3507.SecretKey = miConfig.SecretKey
  2510. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2511. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2512. // struct3507.Url = miConfig.Url
  2513. // struct3507.AppId = miConfig.Cainfo
  2514. // struct3507.AppSecret = miConfig.AppSecret
  2515. // struct3507.Enckey = miConfig.EncKey
  2516. // struct3507.SignKey = miConfig.SignKey
  2517. // struct3507.SecretKey = miConfig.SecretKey
  2518. // //result, result1, _ := service.FJyb3507(struct3507)
  2519. // //saveLog(result, result1, "3507", "3507")
  2520. // //
  2521. // //var respJSON3 map[string]interface{}
  2522. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2523. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2524. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2525. // // return
  2526. // //}
  2527. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2528. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2529. // // utils.ErrorLog("解析失败:%v", err)
  2530. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2531. // // return
  2532. // //}
  2533. // if miConfig.MdtrtareaAdmvs == "350500" {
  2534. // result, result1, _ := service.FJyb3507(struct3507)
  2535. // saveLog(result, result1, "3507", "3507")
  2536. // var respJSON2 map[string]interface{}
  2537. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2538. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2539. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2540. // return
  2541. // }
  2542. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2543. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2544. // utils.ErrorLog("解析失败:%v", err)
  2545. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2546. // return
  2547. // }
  2548. // } else {
  2549. // data := make(map[string]interface{})
  2550. // data["struct_3507s"] = struct3507
  2551. // client := &http.Client{}
  2552. // bytesData, _ := json.Marshal(data)
  2553. // var req *http.Request
  2554. // if miConfig.MdtrtareaAdmvs == "320921" {
  2555. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2556. // } else {
  2557. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2558. // }
  2559. //
  2560. // resp, _ := client.Do(req)
  2561. // defer resp.Body.Close()
  2562. // body, ioErr := ioutil.ReadAll(resp.Body)
  2563. // if ioErr != nil {
  2564. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2565. // }
  2566. // var respJSON map[string]interface{}
  2567. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2568. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2569. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2570. // return
  2571. // }
  2572. // var resSix10265 ResultSix10265 //1101结果
  2573. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2574. // result, _ := json.Marshal(respJSON)
  2575. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2576. // utils.ErrorLog("解析失败:%v", err)
  2577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2578. // return
  2579. // }
  2580. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2581. // //res.Output = resSix10265.Output
  2582. // res.ErrMsg = resSix10265.ErrMsg
  2583. // res.Cainfo = resSix10265.Cainfo
  2584. // res.WarnMsg = resSix10265.WarnMsg
  2585. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2586. // res.Infcode = infocode
  2587. // }
  2588. //
  2589. // if res.Infcode == 0 {
  2590. // item.IsSale = 0
  2591. // item.SaleDate = ""
  2592. // service.SaveDF(item)
  2593. // } else {
  2594. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2595. // }
  2596. // }
  2597. // if item.IsSale == 2 && item.IsChange == 0 {
  2598. //
  2599. // var res FJ3507Result
  2600. // var struct3507 models.Struct3507
  2601. // struct3507.FixmedinsBchno = item.Bchno
  2602. // struct3507.InvDataType = "4"
  2603. // struct3507.Opter = roles.UserName
  2604. // struct3507.FixmedinsCode = miConfig.Code
  2605. // struct3507.Code = miConfig.Code
  2606. //
  2607. // struct3507.OrgName = miConfig.OrgName
  2608. // struct3507.AccessKey = miConfig.AccessKey
  2609. // struct3507.RequestUrl = miConfig.Url
  2610. // struct3507.SecretKey = miConfig.SecretKey
  2611. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2612. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2613. // struct3507.Url = miConfig.Url
  2614. // struct3507.AppId = miConfig.Cainfo
  2615. // struct3507.AppSecret = miConfig.AppSecret
  2616. // struct3507.Enckey = miConfig.EncKey
  2617. // struct3507.SignKey = miConfig.SignKey
  2618. // struct3507.SecretKey = miConfig.SecretKey
  2619. // //result, result1, _ := service.FJyb3507(struct3507)
  2620. // //saveLog(result, result1, "3507", "3507")
  2621. // //
  2622. // //var respJSON3 map[string]interface{}
  2623. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2624. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2625. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2626. // // return
  2627. // //}
  2628. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2629. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2630. // // utils.ErrorLog("解析失败:%v", err)
  2631. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2632. // // return
  2633. // //}
  2634. // if miConfig.MdtrtareaAdmvs == "350500" {
  2635. // result, result1, _ := service.FJyb3507(struct3507)
  2636. // saveLog(result, result1, "3507", "3507")
  2637. // var respJSON2 map[string]interface{}
  2638. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2639. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2640. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2641. // return
  2642. // }
  2643. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2644. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2645. // utils.ErrorLog("解析失败:%v", err)
  2646. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2647. // return
  2648. // }
  2649. // } else {
  2650. // data := make(map[string]interface{})
  2651. // data["struct_3507s"] = struct3507
  2652. // client := &http.Client{}
  2653. // bytesData, _ := json.Marshal(data)
  2654. // var req *http.Request
  2655. // if miConfig.MdtrtareaAdmvs == "320921" {
  2656. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2657. // } else {
  2658. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2659. // }
  2660. //
  2661. // resp, _ := client.Do(req)
  2662. // defer resp.Body.Close()
  2663. // body, ioErr := ioutil.ReadAll(resp.Body)
  2664. // if ioErr != nil {
  2665. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2666. // }
  2667. // var respJSON map[string]interface{}
  2668. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2669. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2670. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2671. // return
  2672. // }
  2673. // var resSix10265 ResultSix10265 //1101结果
  2674. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2675. // result, _ := json.Marshal(respJSON)
  2676. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2677. // utils.ErrorLog("解析失败:%v", err)
  2678. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2679. // return
  2680. // }
  2681. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2682. // //res.Output = resSix10265.Output
  2683. // res.ErrMsg = resSix10265.ErrMsg
  2684. // res.Cainfo = resSix10265.Cainfo
  2685. // res.WarnMsg = resSix10265.WarnMsg
  2686. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2687. // res.Infcode = infocode
  2688. // }
  2689. //
  2690. // if res.Infcode == 0 {
  2691. // item.IsSale = 0
  2692. // item.SaleDate = ""
  2693. // item.Bchno = ""
  2694. //
  2695. // service.SaveDF(item)
  2696. // } else {
  2697. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2698. // }
  2699. // }
  2700. // if item.IsSale == 0 && item.IsChange == 1 {
  2701. //
  2702. // var res FJ3507Result
  2703. // var struct3507 models.Struct3507
  2704. // struct3507.FixmedinsBchno = item.BgBchno
  2705. // struct3507.InvDataType = "2"
  2706. // struct3507.Opter = roles.UserName
  2707. // struct3507.FixmedinsCode = miConfig.Code
  2708. // struct3507.Code = miConfig.Code
  2709. //
  2710. // struct3507.OrgName = miConfig.OrgName
  2711. // struct3507.AccessKey = miConfig.AccessKey
  2712. // struct3507.RequestUrl = miConfig.Url
  2713. // struct3507.SecretKey = miConfig.SecretKey
  2714. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2715. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2716. // struct3507.Url = miConfig.Url
  2717. // struct3507.AppId = miConfig.Cainfo
  2718. // struct3507.AppSecret = miConfig.AppSecret
  2719. // struct3507.Enckey = miConfig.EncKey
  2720. // struct3507.SignKey = miConfig.SignKey
  2721. // struct3507.SecretKey = miConfig.SecretKey
  2722. // //result, result1, _ := service.FJyb3507(struct3507)
  2723. // //saveLog(result, result1, "3507", "3507")
  2724. // //
  2725. // //var respJSON3 map[string]interface{}
  2726. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2727. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2728. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2729. // // return
  2730. // //}
  2731. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2732. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2733. // // utils.ErrorLog("解析失败:%v", err)
  2734. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2735. // // return
  2736. // //}
  2737. // if miConfig.MdtrtareaAdmvs == "350500" {
  2738. // result, result1, _ := service.FJyb3507(struct3507)
  2739. // saveLog(result, result1, "3507", "3507")
  2740. // var respJSON2 map[string]interface{}
  2741. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2742. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2743. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2744. // return
  2745. // }
  2746. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2747. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2748. // utils.ErrorLog("解析失败:%v", err)
  2749. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2750. // return
  2751. // }
  2752. // } else {
  2753. // data := make(map[string]interface{})
  2754. // data["struct_3507s"] = struct3507
  2755. // client := &http.Client{}
  2756. // bytesData, _ := json.Marshal(data)
  2757. // var req *http.Request
  2758. // if miConfig.MdtrtareaAdmvs == "320921" {
  2759. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2760. // } else {
  2761. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2762. // }
  2763. //
  2764. // resp, _ := client.Do(req)
  2765. // defer resp.Body.Close()
  2766. // body, ioErr := ioutil.ReadAll(resp.Body)
  2767. // if ioErr != nil {
  2768. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2769. // }
  2770. // var respJSON map[string]interface{}
  2771. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2772. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2773. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2774. // return
  2775. // }
  2776. // var resSix10265 ResultSix10265 //1101结果
  2777. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2778. // result, _ := json.Marshal(respJSON)
  2779. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2780. // utils.ErrorLog("解析失败:%v", err)
  2781. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2782. // return
  2783. // }
  2784. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2785. // //res.Output = resSix10265.Output
  2786. // res.ErrMsg = resSix10265.ErrMsg
  2787. // res.Cainfo = resSix10265.Cainfo
  2788. // res.WarnMsg = resSix10265.WarnMsg
  2789. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2790. // res.Infcode = infocode
  2791. // }
  2792. //
  2793. // if res.Infcode == 0 {
  2794. // item.IsChange = 0
  2795. // item.BgBchno = ""
  2796. // service.SaveDF2(item)
  2797. // } else {
  2798. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2799. // }
  2800. // }
  2801. // }
  2802. // if len(err) == 0 {
  2803. // c.ServeSuccessJSON(map[string]interface{}{
  2804. // "msg": "删除销售变更成功",
  2805. // })
  2806. //
  2807. // } else {
  2808. // c.ServeSuccessJSON(map[string]interface{}{
  2809. // "failed_code": -10,
  2810. // "msg": err,
  2811. // })
  2812. //
  2813. // }
  2814. //
  2815. //}
  2816. // 获取当天起止时间戳
  2817. func GetNowTime() (int64, int64) {
  2818. t := time.Now()
  2819. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2820. timesamp := addTime.Unix()
  2821. return timesamp, timesamp + 86399
  2822. }
  2823. //func (c *HisApiController) ChangeDrugfour() {
  2824. // patient_id, _ := c.GetInt64("patient_id")
  2825. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2826. // //id_arr := strings.Split(ids, ",")
  2827. // times := c.GetString("time", "")
  2828. // timeLayout := "2006-01-02"
  2829. // loc, _ := time.LoadLocation("Local")
  2830. // var stime, etime int64
  2831. // if times == "" {
  2832. // stime, etime = GetNowTime()
  2833. // } else {
  2834. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2835. // stime = stmp.Unix()
  2836. // etime = stime + 86399
  2837. // }
  2838. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2839. // var flows []*models.DrugFlow
  2840. // for _, item := range advicelist {
  2841. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.ID, times, c.GetAdminUserInfo().CurrentOrgId)
  2842. // flows = append(flows, flow...)
  2843. // }
  2844. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2845. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2846. // var err []string
  2847. //
  2848. // for _, item := range flows {
  2849. // var res3 ResultSix
  2850. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2851. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2852. // if prescription.OrderStatus == 2 {
  2853. // //已经结算
  2854. // //判断是否已经销售
  2855. // if item.IsSale == 1 { //是否已经销售,1是 0否
  2856. // //是否已经变更 1是 0否
  2857. // if item.IsChange == 0 { //没变更,进行变更操作
  2858. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2859. //
  2860. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2861. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  2862. // var respJSON3 map[string]interface{}
  2863. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2864. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2865. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2866. // return
  2867. // }
  2868. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2869. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2870. // utils.ErrorLog("解析失败:%v", err)
  2871. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2872. // return
  2873. // }
  2874. // if res3.Infcode == 0 {
  2875. // item.IsChange = 1
  2876. // item.BgBchno = bg_number
  2877. // service.SaveDF2(item)
  2878. // } else {
  2879. //
  2880. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2881. // }
  2882. // }
  2883. // } else { //没销售,
  2884. // var res FJ3507Result
  2885. // var res3507for10188 FJ3507ResultFor10188
  2886. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2887. //
  2888. // //进行商品销售接口
  2889. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2890. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2891. // var respJSON3 map[string]interface{}
  2892. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2893. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2894. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2895. // return
  2896. // }
  2897. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2898. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2899. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2900. // utils.ErrorLog("解析失败:%v", err)
  2901. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2902. // return
  2903. // }
  2904. // //if res3507for10188.Infcode
  2905. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  2906. // //res.Output = resSix10265.Output
  2907. // res.ErrMsg = res3507for10188.ErrMsg
  2908. // res.Cainfo = res3507for10188.Cainfo
  2909. // res.WarnMsg = res3507for10188.WarnMsg
  2910. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2911. // res.Infcode = infocode
  2912. // } else {
  2913. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2914. // utils.ErrorLog("解析失败:%v", err)
  2915. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2916. // return
  2917. // }
  2918. //
  2919. // }
  2920. // if res.Infcode == 0 {
  2921. // item.IsSale = 1
  2922. // item.Bchno = number
  2923. // item.SaleDate = time.Now().Format("2006-01-02")
  2924. //
  2925. // err5 := service.SaveDF(item)
  2926. // if err5 == nil {
  2927. // if item.IsChange == 0 { //没变更,进行变更操作
  2928. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2929. //
  2930. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2931. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  2932. //
  2933. // var respJSON3 map[string]interface{}
  2934. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2935. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2937. // return
  2938. // }
  2939. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2940. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2941. // utils.ErrorLog("解析失败:%v", err)
  2942. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2943. // return
  2944. // }
  2945. // //if res3507for10188.Infcode
  2946. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2947. // //res.Output = resSix10265.Output
  2948. // res3.ErrMsg = res3507for10188.ErrMsg
  2949. // res3.Cainfo = res3507for10188.Cainfo
  2950. // res3.WarnMsg = res3507for10188.WarnMsg
  2951. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2952. // res3.Infcode = infocode
  2953. // } else {
  2954. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2955. // utils.ErrorLog("解析失败:%v", err)
  2956. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2957. // return
  2958. // }
  2959. // }
  2960. // if res3.Infcode == 0 {
  2961. // item.IsChange = 1
  2962. // item.BgBchno = bg_number
  2963. // service.SaveDF2(item)
  2964. // } else {
  2965. //
  2966. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2967. // }
  2968. // }
  2969. // }
  2970. // } else {
  2971. //
  2972. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  2973. // }
  2974. // }
  2975. //
  2976. // } else { //还没结,提示用户去结算,并药品追溯上传
  2977. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  2978. // }
  2979. // }
  2980. // }
  2981. // if len(err) == 0 {
  2982. // c.ServeSuccessJSON(map[string]interface{}{
  2983. // "msg": "销售变更成功",
  2984. // })
  2985. // } else {
  2986. // c.ServeSuccessJSON(map[string]interface{}{
  2987. // "failed_code": -10,
  2988. // "msg": err,
  2989. // })
  2990. // }
  2991. //}
  2992. //func (c *HisApiController) ChangeDrugfour() {
  2993. // patient_id, _ := c.GetInt64("patient_id")
  2994. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2995. // //id_arr := strings.Split(ids, ",")
  2996. // times := c.GetString("time", "")
  2997. // timeLayout := "2006-01-02"
  2998. // loc, _ := time.LoadLocation("Local")
  2999. // var stime, etime int64
  3000. // if times == "" {
  3001. // stime, etime = GetNowTime()
  3002. // } else {
  3003. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3004. // stime = stmp.Unix()
  3005. // etime = stime + 86399
  3006. // }
  3007. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3008. // var flows []*models.DrugFlow
  3009. // for _, item := range advicelist {
  3010. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3011. // flows = append(flows, flow...)
  3012. // }
  3013. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3014. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3015. // var err []string
  3016. //
  3017. // for _, item := range flows {
  3018. // var res3 ResultSix
  3019. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3020. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3021. // if prescription.OrderStatus == 2 {
  3022. // //已经结算
  3023. // //判断是否已经销售
  3024. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3025. // //是否已经变更 1是 0否
  3026. // if item.IsChange == 0 { //没变更,进行变更操作
  3027. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3028. //
  3029. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3030. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3031. // var respJSON3 map[string]interface{}
  3032. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3033. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3034. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3035. // return
  3036. // }
  3037. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3038. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3039. // utils.ErrorLog("解析失败:%v", err)
  3040. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3041. // return
  3042. // }
  3043. // if res3.Infcode == 0 {
  3044. // item.IsChange = 1
  3045. // item.BgBchno = bg_number
  3046. // service.SaveDF2(item)
  3047. // } else {
  3048. //
  3049. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3050. // }
  3051. // }
  3052. // } else { //没销售,
  3053. // var res FJ3507Result
  3054. // var res3507for10188 FJ3507ResultFor10188
  3055. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3056. //
  3057. // //进行商品销售接口
  3058. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3059. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3060. // var respJSON3 map[string]interface{}
  3061. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3062. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3063. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3064. // return
  3065. // }
  3066. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3067. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3068. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3069. // utils.ErrorLog("解析失败:%v", err)
  3070. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3071. // return
  3072. // }
  3073. // //if res3507for10188.Infcode
  3074. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3075. // //res.Output = resSix10265.Output
  3076. // res.ErrMsg = res3507for10188.ErrMsg
  3077. // res.Cainfo = res3507for10188.Cainfo
  3078. // res.WarnMsg = res3507for10188.WarnMsg
  3079. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3080. // res.Infcode = infocode
  3081. // } else {
  3082. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3083. // utils.ErrorLog("解析失败:%v", err)
  3084. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3085. // return
  3086. // }
  3087. //
  3088. // }
  3089. // if res.Infcode == 0 {
  3090. // item.IsSale = 1
  3091. // item.Bchno = number
  3092. // item.SaleDate = time.Now().Format("2006-01-02")
  3093. //
  3094. // err5 := service.SaveDF(item)
  3095. // if err5 == nil {
  3096. // if item.IsChange == 0 { //没变更,进行变更操作
  3097. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3098. //
  3099. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3100. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3101. //
  3102. // var respJSON3 map[string]interface{}
  3103. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3104. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3106. // return
  3107. // }
  3108. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3109. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3110. // utils.ErrorLog("解析失败:%v", err)
  3111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3112. // return
  3113. // }
  3114. // //if res3507for10188.Infcode
  3115. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3116. // //res.Output = resSix10265.Output
  3117. // res3.ErrMsg = res3507for10188.ErrMsg
  3118. // res3.Cainfo = res3507for10188.Cainfo
  3119. // res3.WarnMsg = res3507for10188.WarnMsg
  3120. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3121. // res3.Infcode = infocode
  3122. // } else {
  3123. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3124. // utils.ErrorLog("解析失败:%v", err)
  3125. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3126. // return
  3127. // }
  3128. // }
  3129. // if res3.Infcode == 0 {
  3130. // item.IsChange = 1
  3131. // item.BgBchno = bg_number
  3132. // service.SaveDF2(item)
  3133. // } else {
  3134. //
  3135. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3136. // }
  3137. // }
  3138. // }
  3139. // } else {
  3140. //
  3141. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3142. // }
  3143. // }
  3144. //
  3145. // } else { //还没结,提示用户去结算,并药品追溯上传
  3146. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3147. // }
  3148. // }
  3149. // }
  3150. // if len(err) == 0 {
  3151. // c.ServeSuccessJSON(map[string]interface{}{
  3152. // "msg": "销售变更成功",
  3153. // })
  3154. // } else {
  3155. // c.ServeSuccessJSON(map[string]interface{}{
  3156. // "failed_code": -10,
  3157. // "msg": err,
  3158. // })
  3159. // }
  3160. //}
  3161. func (c *HisApiController) ChangeDrug() {
  3162. ids := c.GetString("ids")
  3163. id_arr := strings.Split(ids, ",")
  3164. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3165. admin_user_id, _ := c.GetInt64("admin_user_id")
  3166. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3167. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3168. var err []string
  3169. for _, item := range flows {
  3170. var res3 ResultSix
  3171. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3172. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3173. if prescription.OrderStatus == 2 {
  3174. //已经结算
  3175. //判断是否已经销售
  3176. if item.IsSale == 1 { //是否已经销售,1是 0否
  3177. //是否已经变更 1是 0否
  3178. if item.IsChange == 0 { //没变更,进行变更操作
  3179. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3180. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3181. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3182. var respJSON3 map[string]interface{}
  3183. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3186. return
  3187. }
  3188. userJSONBytes3, _ := json.Marshal(respJSON3)
  3189. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3190. utils.ErrorLog("解析失败:%v", err)
  3191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3192. return
  3193. }
  3194. if res3.Infcode == 0 {
  3195. item.IsChange = 1
  3196. item.BgBchno = bg_number
  3197. service.SaveDF2(item)
  3198. } else {
  3199. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3200. }
  3201. }
  3202. } else { //没销售,
  3203. var res FJ3507Result
  3204. var res3507for10188 FJ3507ResultFor10188
  3205. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3206. //进行商品销售接口
  3207. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3208. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3209. var respJSON3 map[string]interface{}
  3210. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3213. return
  3214. }
  3215. userJSONBytes3, _ := json.Marshal(respJSON3)
  3216. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3217. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3218. utils.ErrorLog("解析失败:%v", err)
  3219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3220. return
  3221. }
  3222. //if res3507for10188.Infcode
  3223. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3224. //res.Output = resSix10265.Output
  3225. res.ErrMsg = res3507for10188.ErrMsg
  3226. res.Cainfo = res3507for10188.Cainfo
  3227. res.WarnMsg = res3507for10188.WarnMsg
  3228. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3229. res.Infcode = infocode
  3230. } else {
  3231. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3232. utils.ErrorLog("解析失败:%v", err)
  3233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3234. return
  3235. }
  3236. }
  3237. if res.Infcode == 0 {
  3238. item.IsSale = 1
  3239. item.Bchno = number
  3240. item.SaleDate = time.Now().Format("2006-01-02")
  3241. err5 := service.SaveDF(item)
  3242. if err5 == nil {
  3243. if item.IsChange == 0 { //没变更,进行变更操作
  3244. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3245. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3246. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3247. var respJSON3 map[string]interface{}
  3248. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3251. return
  3252. }
  3253. userJSONBytes3, _ := json.Marshal(respJSON3)
  3254. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3255. utils.ErrorLog("解析失败:%v", err)
  3256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3257. return
  3258. }
  3259. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3260. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3261. utils.ErrorLog("解析失败:%v", err)
  3262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3263. return
  3264. }
  3265. //if res3507for10188.Infcode
  3266. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3267. //res.Output = resSix10265.Output
  3268. res3.ErrMsg = res3507for10188.ErrMsg
  3269. res3.Cainfo = res3507for10188.Cainfo
  3270. res3.WarnMsg = res3507for10188.WarnMsg
  3271. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3272. res3.Infcode = infocode
  3273. } else {
  3274. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3275. utils.ErrorLog("解析失败:%v", err)
  3276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3277. return
  3278. }
  3279. }
  3280. if res3.Infcode == 0 {
  3281. item.IsChange = 1
  3282. item.BgBchno = bg_number
  3283. service.SaveDF2(item)
  3284. } else {
  3285. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3286. }
  3287. }
  3288. }
  3289. } else {
  3290. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3291. }
  3292. }
  3293. } else { //还没结算
  3294. var res3507for10188 FJ3507ResultFor10188
  3295. if item.IsChange == 0 { //没变更,进行变更操作
  3296. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3297. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3298. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3299. var respJSON3 map[string]interface{}
  3300. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3301. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3303. return
  3304. }
  3305. userJSONBytes3, _ := json.Marshal(respJSON3)
  3306. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3307. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3308. utils.ErrorLog("解析失败:%v", err)
  3309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3310. return
  3311. }
  3312. //if res3507for10188.Infcode
  3313. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3314. //res.Output = resSix10265.Output
  3315. res3.ErrMsg = res3507for10188.ErrMsg
  3316. res3.Cainfo = res3507for10188.Cainfo
  3317. res3.WarnMsg = res3507for10188.WarnMsg
  3318. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3319. res3.Infcode = infocode
  3320. } else {
  3321. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3322. utils.ErrorLog("解析失败:%v", err)
  3323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3324. return
  3325. }
  3326. }
  3327. if res3.Infcode == 0 {
  3328. item.IsChange = 1
  3329. item.BgBchno = bg_number
  3330. service.SaveDF2(item)
  3331. } else {
  3332. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3333. }
  3334. }
  3335. }
  3336. } else if item.ConsumableType == 7 {
  3337. var res3507for10188 FJ3507ResultFor10188
  3338. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3339. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3340. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3341. //判断是否已经销售
  3342. if item.IsSale == 2 { //是否已经销售,1是 0否
  3343. //是否已经变更 1是 0否
  3344. if item.IsChange == 0 { //没变更,进行变更操作
  3345. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3346. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3347. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3348. var respJSON3 map[string]interface{}
  3349. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3352. return
  3353. }
  3354. userJSONBytes3, _ := json.Marshal(respJSON3)
  3355. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3356. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3357. utils.ErrorLog("解析失败:%v", err)
  3358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3359. return
  3360. }
  3361. //if res3507for10188.Infcode
  3362. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3363. //res.Output = resSix10265.Output
  3364. res3.ErrMsg = res3507for10188.ErrMsg
  3365. res3.Cainfo = res3507for10188.Cainfo
  3366. res3.WarnMsg = res3507for10188.WarnMsg
  3367. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3368. res3.Infcode = infocode
  3369. } else {
  3370. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3371. utils.ErrorLog("解析失败:%v", err)
  3372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3373. return
  3374. }
  3375. }
  3376. if res3.Infcode == 0 {
  3377. item.IsChange = 1
  3378. item.BgBchno = bg_number
  3379. service.SaveDF2(item)
  3380. } else {
  3381. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3382. }
  3383. }
  3384. } else { //没销售,
  3385. //进行商品销售退货接口
  3386. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3387. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3388. saveLog(result111, result222, "3506", "销售退货")
  3389. var res7 FJ3507Result
  3390. //进行商品销售接口
  3391. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3392. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3393. var respJSON3 map[string]interface{}
  3394. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3397. return
  3398. }
  3399. userJSONBytes3, _ := json.Marshal(respJSON3)
  3400. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3401. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3402. utils.ErrorLog("解析失败:%v", err)
  3403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3404. return
  3405. }
  3406. //if res3507for10188.Infcode
  3407. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3408. //res.Output = resSix10265.Output
  3409. res7.ErrMsg = res3507for10188.ErrMsg
  3410. res7.Cainfo = res3507for10188.Cainfo
  3411. res7.WarnMsg = res3507for10188.WarnMsg
  3412. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3413. res7.Infcode = infocode
  3414. } else {
  3415. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3416. utils.ErrorLog("解析失败:%v", err)
  3417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3418. return
  3419. }
  3420. }
  3421. if res7.Infcode == 0 {
  3422. item.IsSale = 2
  3423. item.SaleDate = item.SaleDate
  3424. item.Bchno = number
  3425. service.SaveDF(item)
  3426. if item.IsChange == 0 { //没变更,进行变更操作
  3427. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3428. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3429. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3430. var respJSON3 map[string]interface{}
  3431. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3434. return
  3435. }
  3436. userJSONBytes3, _ := json.Marshal(respJSON3)
  3437. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3438. // utils.ErrorLog("解析失败:%v", err)
  3439. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3440. // return
  3441. //}
  3442. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3443. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3444. utils.ErrorLog("解析失败:%v", err)
  3445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3446. return
  3447. }
  3448. //if res3507for10188.Infcode
  3449. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3450. //res.Output = resSix10265.Output
  3451. res3.ErrMsg = res3507for10188.ErrMsg
  3452. res3.Cainfo = res3507for10188.Cainfo
  3453. res3.WarnMsg = res3507for10188.WarnMsg
  3454. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3455. res3.Infcode = infocode
  3456. } else {
  3457. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3458. utils.ErrorLog("解析失败:%v", err)
  3459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3460. return
  3461. }
  3462. }
  3463. if res3.Infcode == 0 {
  3464. item.IsChange = 1
  3465. item.BgBchno = bg_number
  3466. service.SaveDF2(item)
  3467. } else {
  3468. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3469. }
  3470. }
  3471. } else {
  3472. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3473. }
  3474. }
  3475. } else { //还没结算
  3476. if item.IsChange == 0 { //没变更,进行变更操作
  3477. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3478. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3479. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3480. var respJSON3 map[string]interface{}
  3481. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3484. return
  3485. }
  3486. userJSONBytes3, _ := json.Marshal(respJSON3)
  3487. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3488. // utils.ErrorLog("解析失败:%v", err)
  3489. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3490. // return
  3491. //}
  3492. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3493. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3494. utils.ErrorLog("解析失败:%v", err)
  3495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3496. return
  3497. }
  3498. //if res3507for10188.Infcode
  3499. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3500. //res.Output = resSix10265.Output
  3501. res3.ErrMsg = res3507for10188.ErrMsg
  3502. res3.Cainfo = res3507for10188.Cainfo
  3503. res3.WarnMsg = res3507for10188.WarnMsg
  3504. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3505. res3.Infcode = infocode
  3506. } else {
  3507. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3508. utils.ErrorLog("解析失败:%v", err)
  3509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3510. return
  3511. }
  3512. }
  3513. if res3.Infcode == 0 {
  3514. item.IsChange = 1
  3515. item.BgBchno = bg_number
  3516. service.SaveDF2(item)
  3517. } else {
  3518. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3519. }
  3520. }
  3521. }
  3522. }
  3523. }
  3524. if len(err) == 0 {
  3525. c.ServeSuccessJSON(map[string]interface{}{
  3526. "msg": "销售变更成功",
  3527. })
  3528. } else {
  3529. c.ServeSuccessJSON(map[string]interface{}{
  3530. "failed_code": -10,
  3531. "msg": err,
  3532. })
  3533. }
  3534. }
  3535. func (c *HisApiController) ChangeDrugtwo() {
  3536. //ids := c.GetString("ids")
  3537. //id_arr := strings.Split(ids, ",")
  3538. flows, _ := service.GetNewDrugFlowInfotwo()
  3539. admin_user_id, _ := c.GetInt64("admin_user_id")
  3540. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3541. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3542. var err []string
  3543. for _, item := range flows {
  3544. var res3 ResultSix
  3545. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3546. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3547. if prescription.OrderStatus == 2 {
  3548. //已经结算
  3549. //判断是否已经销售
  3550. if item.IsSale == 1 { //是否已经销售,1是 0否
  3551. //是否已经变更 1是 0否
  3552. if item.IsChange == 0 { //没变更,进行变更操作
  3553. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3554. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3555. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3556. var respJSON3 map[string]interface{}
  3557. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3560. return
  3561. }
  3562. userJSONBytes3, _ := json.Marshal(respJSON3)
  3563. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3564. utils.ErrorLog("解析失败:%v", err)
  3565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3566. return
  3567. }
  3568. if res3.Infcode == 0 {
  3569. item.IsChange = 1
  3570. item.BgBchno = bg_number
  3571. service.SaveDF2(item)
  3572. } else {
  3573. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3574. }
  3575. }
  3576. } else { //没销售,
  3577. var res FJ3507Result
  3578. var res3507for10188 FJ3507ResultFor10188
  3579. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3580. //进行商品销售接口
  3581. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3582. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3583. var respJSON3 map[string]interface{}
  3584. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3587. return
  3588. }
  3589. userJSONBytes3, _ := json.Marshal(respJSON3)
  3590. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3591. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3592. utils.ErrorLog("解析失败:%v", err)
  3593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3594. return
  3595. }
  3596. //if res3507for10188.Infcode
  3597. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3598. //res.Output = resSix10265.Output
  3599. res.ErrMsg = res3507for10188.ErrMsg
  3600. res.Cainfo = res3507for10188.Cainfo
  3601. res.WarnMsg = res3507for10188.WarnMsg
  3602. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3603. res.Infcode = infocode
  3604. } else {
  3605. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3606. utils.ErrorLog("解析失败:%v", err)
  3607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3608. return
  3609. }
  3610. }
  3611. if res.Infcode == 0 {
  3612. item.IsSale = 1
  3613. item.Bchno = number
  3614. item.SaleDate = time.Now().Format("2006-01-02")
  3615. err5 := service.SaveDF(item)
  3616. if err5 == nil {
  3617. if item.IsChange == 0 { //没变更,进行变更操作
  3618. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3619. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3620. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3621. var respJSON3 map[string]interface{}
  3622. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3625. return
  3626. }
  3627. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3628. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3629. utils.ErrorLog("解析失败:%v", err)
  3630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3631. return
  3632. }
  3633. //if res3507for10188.Infcode
  3634. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3635. //res.Output = resSix10265.Output
  3636. res3.ErrMsg = res3507for10188.ErrMsg
  3637. res3.Cainfo = res3507for10188.Cainfo
  3638. res3.WarnMsg = res3507for10188.WarnMsg
  3639. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3640. res3.Infcode = infocode
  3641. } else {
  3642. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3643. utils.ErrorLog("解析失败:%v", err)
  3644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3645. return
  3646. }
  3647. }
  3648. if res3.Infcode == 0 {
  3649. item.IsChange = 1
  3650. item.BgBchno = bg_number
  3651. service.SaveDF2(item)
  3652. } else {
  3653. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3654. }
  3655. }
  3656. }
  3657. } else {
  3658. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3659. }
  3660. }
  3661. } else { //还没结算
  3662. var res3507for10188 FJ3507ResultFor10188
  3663. if item.IsChange == 0 { //没变更,进行变更操作
  3664. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3665. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3666. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3667. var respJSON3 map[string]interface{}
  3668. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3671. return
  3672. }
  3673. userJSONBytes3, _ := json.Marshal(respJSON3)
  3674. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3675. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3676. utils.ErrorLog("解析失败:%v", err)
  3677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3678. return
  3679. }
  3680. //if res3507for10188.Infcode
  3681. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3682. //res.Output = resSix10265.Output
  3683. res3.ErrMsg = res3507for10188.ErrMsg
  3684. res3.Cainfo = res3507for10188.Cainfo
  3685. res3.WarnMsg = res3507for10188.WarnMsg
  3686. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3687. res3.Infcode = infocode
  3688. } else {
  3689. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3690. utils.ErrorLog("解析失败:%v", err)
  3691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3692. return
  3693. }
  3694. }
  3695. if res3.Infcode == 0 {
  3696. item.IsChange = 1
  3697. item.BgBchno = bg_number
  3698. service.SaveDF2(item)
  3699. } else {
  3700. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3701. }
  3702. }
  3703. }
  3704. } else if item.ConsumableType == 7 {
  3705. var res3507for10188 FJ3507ResultFor10188
  3706. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3707. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3708. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3709. //判断是否已经销售
  3710. if item.IsSale == 2 { //是否已经销售,1是 0否
  3711. //是否已经变更 1是 0否
  3712. if item.IsChange == 0 { //没变更,进行变更操作
  3713. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3714. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3715. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3716. var respJSON3 map[string]interface{}
  3717. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3720. return
  3721. }
  3722. userJSONBytes3, _ := json.Marshal(respJSON3)
  3723. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3724. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3725. utils.ErrorLog("解析失败:%v", err)
  3726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3727. return
  3728. }
  3729. //if res3507for10188.Infcode
  3730. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3731. //res.Output = resSix10265.Output
  3732. res3.ErrMsg = res3507for10188.ErrMsg
  3733. res3.Cainfo = res3507for10188.Cainfo
  3734. res3.WarnMsg = res3507for10188.WarnMsg
  3735. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3736. res3.Infcode = infocode
  3737. } else {
  3738. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3739. utils.ErrorLog("解析失败:%v", err)
  3740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3741. return
  3742. }
  3743. }
  3744. if res3.Infcode == 0 {
  3745. item.IsChange = 1
  3746. item.BgBchno = bg_number
  3747. service.SaveDF2(item)
  3748. } else {
  3749. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3750. }
  3751. }
  3752. } else { //没销售,
  3753. //进行商品销售退货接口
  3754. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3755. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3756. saveLog(result111, result222, "3506", "销售退货")
  3757. var res7 FJ3507Result
  3758. //进行商品销售接口
  3759. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3760. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3761. var respJSON3 map[string]interface{}
  3762. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3765. return
  3766. }
  3767. userJSONBytes3, _ := json.Marshal(respJSON3)
  3768. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3769. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3770. utils.ErrorLog("解析失败:%v", err)
  3771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3772. return
  3773. }
  3774. //if res3507for10188.Infcode
  3775. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3776. //res.Output = resSix10265.Output
  3777. res7.ErrMsg = res3507for10188.ErrMsg
  3778. res7.Cainfo = res3507for10188.Cainfo
  3779. res7.WarnMsg = res3507for10188.WarnMsg
  3780. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3781. res7.Infcode = infocode
  3782. } else {
  3783. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3784. utils.ErrorLog("解析失败:%v", err)
  3785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3786. return
  3787. }
  3788. }
  3789. if res7.Infcode == 0 {
  3790. item.IsSale = 2
  3791. item.SaleDate = item.SaleDate
  3792. item.Bchno = number
  3793. service.SaveDF(item)
  3794. if item.IsChange == 0 { //没变更,进行变更操作
  3795. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3796. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3797. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3798. var respJSON3 map[string]interface{}
  3799. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3800. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3802. return
  3803. }
  3804. userJSONBytes3, _ := json.Marshal(respJSON3)
  3805. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3806. // utils.ErrorLog("解析失败:%v", err)
  3807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3808. // return
  3809. //}
  3810. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3811. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3812. utils.ErrorLog("解析失败:%v", err)
  3813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3814. return
  3815. }
  3816. //if res3507for10188.Infcode
  3817. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3818. //res.Output = resSix10265.Output
  3819. res3.ErrMsg = res3507for10188.ErrMsg
  3820. res3.Cainfo = res3507for10188.Cainfo
  3821. res3.WarnMsg = res3507for10188.WarnMsg
  3822. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3823. res3.Infcode = infocode
  3824. } else {
  3825. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3826. utils.ErrorLog("解析失败:%v", err)
  3827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3828. return
  3829. }
  3830. }
  3831. if res3.Infcode == 0 {
  3832. item.IsChange = 1
  3833. item.BgBchno = bg_number
  3834. service.SaveDF2(item)
  3835. } else {
  3836. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3837. }
  3838. }
  3839. } else {
  3840. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3841. }
  3842. }
  3843. } else { //还没结算
  3844. if item.IsChange == 0 { //没变更,进行变更操作
  3845. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3846. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3847. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3848. var respJSON3 map[string]interface{}
  3849. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3852. return
  3853. }
  3854. userJSONBytes3, _ := json.Marshal(respJSON3)
  3855. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3856. // utils.ErrorLog("解析失败:%v", err)
  3857. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3858. // return
  3859. //}
  3860. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3861. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3862. utils.ErrorLog("解析失败:%v", err)
  3863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3864. return
  3865. }
  3866. //if res3507for10188.Infcode
  3867. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3868. //res.Output = resSix10265.Output
  3869. res3.ErrMsg = res3507for10188.ErrMsg
  3870. res3.Cainfo = res3507for10188.Cainfo
  3871. res3.WarnMsg = res3507for10188.WarnMsg
  3872. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3873. res3.Infcode = infocode
  3874. } else {
  3875. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3876. utils.ErrorLog("解析失败:%v", err)
  3877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3878. return
  3879. }
  3880. }
  3881. if res3.Infcode == 0 {
  3882. item.IsChange = 1
  3883. item.BgBchno = bg_number
  3884. service.SaveDF2(item)
  3885. } else {
  3886. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3887. }
  3888. }
  3889. }
  3890. }
  3891. }
  3892. if len(err) == 0 {
  3893. c.ServeSuccessJSON(map[string]interface{}{
  3894. "msg": "销售变更成功",
  3895. })
  3896. } else {
  3897. c.ServeSuccessJSON(map[string]interface{}{
  3898. "failed_code": -10,
  3899. "msg": err,
  3900. })
  3901. }
  3902. }
  3903. func (c *HisApiController) ChangeDrugthree() {
  3904. //ids := c.GetString("ids")
  3905. //id_arr := strings.Split(ids, ",")
  3906. flows, _ := service.GetNewDrugFlowInfothree()
  3907. admin_user_id, _ := c.GetInt64("admin_user_id")
  3908. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3909. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3910. var err []string
  3911. for _, item := range flows {
  3912. var res3 ResultSix
  3913. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3914. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3915. if prescription.OrderStatus == 2 {
  3916. //已经结算
  3917. //判断是否已经销售
  3918. if item.IsSale == 1 { //是否已经销售,1是 0否
  3919. //是否已经变更 1是 0否
  3920. if item.IsChange == 0 { //没变更,进行变更操作
  3921. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3922. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3923. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3924. var respJSON3 map[string]interface{}
  3925. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3928. return
  3929. }
  3930. userJSONBytes3, _ := json.Marshal(respJSON3)
  3931. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3932. utils.ErrorLog("解析失败:%v", err)
  3933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3934. return
  3935. }
  3936. if res3.Infcode == 0 {
  3937. item.IsChange = 1
  3938. item.BgBchno = bg_number
  3939. service.SaveDF2(item)
  3940. } else {
  3941. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3942. }
  3943. }
  3944. } else { //没销售,
  3945. var res FJ3507Result
  3946. var res3507for10188 FJ3507ResultFor10188
  3947. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3948. //进行商品销售接口
  3949. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3950. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3951. var respJSON3 map[string]interface{}
  3952. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3953. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3955. return
  3956. }
  3957. userJSONBytes3, _ := json.Marshal(respJSON3)
  3958. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3959. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3960. utils.ErrorLog("解析失败:%v", err)
  3961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3962. return
  3963. }
  3964. //if res3507for10188.Infcode
  3965. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3966. //res.Output = resSix10265.Output
  3967. res.ErrMsg = res3507for10188.ErrMsg
  3968. res.Cainfo = res3507for10188.Cainfo
  3969. res.WarnMsg = res3507for10188.WarnMsg
  3970. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3971. res.Infcode = infocode
  3972. } else {
  3973. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3974. utils.ErrorLog("解析失败:%v", err)
  3975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3976. return
  3977. }
  3978. }
  3979. if res.Infcode == 0 {
  3980. item.IsSale = 1
  3981. item.Bchno = number
  3982. item.SaleDate = time.Now().Format("2006-01-02")
  3983. err5 := service.SaveDF(item)
  3984. if err5 == nil {
  3985. if item.IsChange == 0 { //没变更,进行变更操作
  3986. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3987. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3988. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3989. var respJSON3 map[string]interface{}
  3990. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3993. return
  3994. }
  3995. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  3996. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3997. utils.ErrorLog("解析失败:%v", err)
  3998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3999. return
  4000. }
  4001. //if res3507for10188.Infcode
  4002. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4003. //res.Output = resSix10265.Output
  4004. res3.ErrMsg = res3507for10188.ErrMsg
  4005. res3.Cainfo = res3507for10188.Cainfo
  4006. res3.WarnMsg = res3507for10188.WarnMsg
  4007. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4008. res3.Infcode = infocode
  4009. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4010. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4011. utils.ErrorLog("解析失败:%v", err)
  4012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4013. return
  4014. }
  4015. //if res3507for10188.Infcode
  4016. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4017. //res.Output = resSix10265.Output
  4018. res3.ErrMsg = res3507for10188.ErrMsg
  4019. res3.Cainfo = res3507for10188.Cainfo
  4020. res3.WarnMsg = res3507for10188.WarnMsg
  4021. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4022. res3.Infcode = infocode
  4023. } else {
  4024. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4025. utils.ErrorLog("解析失败:%v", err)
  4026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4027. return
  4028. }
  4029. }
  4030. if res3.Infcode == 0 {
  4031. item.IsChange = 1
  4032. item.BgBchno = bg_number
  4033. service.SaveDF2(item)
  4034. } else {
  4035. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4036. }
  4037. }
  4038. }
  4039. } else {
  4040. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4041. }
  4042. }
  4043. } else { //还没结算
  4044. var res3507for10188 FJ3507ResultFor10188
  4045. if item.IsChange == 0 { //没变更,进行变更操作
  4046. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4047. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4048. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4049. var respJSON3 map[string]interface{}
  4050. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4053. return
  4054. }
  4055. userJSONBytes3, _ := json.Marshal(respJSON3)
  4056. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4057. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4058. utils.ErrorLog("解析失败:%v", err)
  4059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4060. return
  4061. }
  4062. //if res3507for10188.Infcode
  4063. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4064. //res.Output = resSix10265.Output
  4065. res3.ErrMsg = res3507for10188.ErrMsg
  4066. res3.Cainfo = res3507for10188.Cainfo
  4067. res3.WarnMsg = res3507for10188.WarnMsg
  4068. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4069. res3.Infcode = infocode
  4070. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4071. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4072. utils.ErrorLog("解析失败:%v", err)
  4073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4074. return
  4075. }
  4076. //if res3507for10188.Infcode
  4077. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4078. //res.Output = resSix10265.Output
  4079. res3.ErrMsg = res3507for10188.ErrMsg
  4080. res3.Cainfo = res3507for10188.Cainfo
  4081. res3.WarnMsg = res3507for10188.WarnMsg
  4082. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4083. res3.Infcode = infocode
  4084. } else {
  4085. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4086. utils.ErrorLog("解析失败:%v", err)
  4087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4088. return
  4089. }
  4090. }
  4091. if res3.Infcode == 0 {
  4092. item.IsChange = 1
  4093. item.BgBchno = bg_number
  4094. service.SaveDF2(item)
  4095. } else {
  4096. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4097. }
  4098. }
  4099. }
  4100. } else if item.ConsumableType == 7 {
  4101. var res3507for10188 FJ3507ResultFor10188
  4102. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4103. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4104. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4105. //判断是否已经销售
  4106. if item.IsSale == 2 { //是否已经销售,1是 0否
  4107. //是否已经变更 1是 0否
  4108. if item.IsChange == 0 { //没变更,进行变更操作
  4109. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4110. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4111. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4112. var respJSON3 map[string]interface{}
  4113. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4116. return
  4117. }
  4118. userJSONBytes3, _ := json.Marshal(respJSON3)
  4119. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4120. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4121. utils.ErrorLog("解析失败:%v", err)
  4122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4123. return
  4124. }
  4125. //if res3507for10188.Infcode
  4126. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4127. //res.Output = resSix10265.Output
  4128. res3.ErrMsg = res3507for10188.ErrMsg
  4129. res3.Cainfo = res3507for10188.Cainfo
  4130. res3.WarnMsg = res3507for10188.WarnMsg
  4131. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4132. res3.Infcode = infocode
  4133. } else {
  4134. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4135. utils.ErrorLog("解析失败:%v", err)
  4136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4137. return
  4138. }
  4139. }
  4140. if res3.Infcode == 0 {
  4141. item.IsChange = 1
  4142. item.BgBchno = bg_number
  4143. service.SaveDF2(item)
  4144. } else {
  4145. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4146. }
  4147. }
  4148. } else { //没销售,
  4149. //进行商品销售退货接口
  4150. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4151. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4152. saveLog(result111, result222, "3506", "销售退货")
  4153. var res7 FJ3507Result
  4154. //进行商品销售接口
  4155. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4156. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4157. var respJSON3 map[string]interface{}
  4158. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4161. return
  4162. }
  4163. userJSONBytes3, _ := json.Marshal(respJSON3)
  4164. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4165. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4166. utils.ErrorLog("解析失败:%v", err)
  4167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4168. return
  4169. }
  4170. //if res3507for10188.Infcode
  4171. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4172. //res.Output = resSix10265.Output
  4173. res7.ErrMsg = res3507for10188.ErrMsg
  4174. res7.Cainfo = res3507for10188.Cainfo
  4175. res7.WarnMsg = res3507for10188.WarnMsg
  4176. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4177. res7.Infcode = infocode
  4178. } else {
  4179. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4180. utils.ErrorLog("解析失败:%v", err)
  4181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4182. return
  4183. }
  4184. }
  4185. if res7.Infcode == 0 {
  4186. item.IsSale = 2
  4187. item.SaleDate = item.SaleDate
  4188. item.Bchno = number
  4189. service.SaveDF(item)
  4190. if item.IsChange == 0 { //没变更,进行变更操作
  4191. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4192. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4193. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4194. var respJSON3 map[string]interface{}
  4195. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4198. return
  4199. }
  4200. userJSONBytes3, _ := json.Marshal(respJSON3)
  4201. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4202. // utils.ErrorLog("解析失败:%v", err)
  4203. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4204. // return
  4205. //}
  4206. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4207. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4208. utils.ErrorLog("解析失败:%v", err)
  4209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4210. return
  4211. }
  4212. //if res3507for10188.Infcode
  4213. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4214. //res.Output = resSix10265.Output
  4215. res3.ErrMsg = res3507for10188.ErrMsg
  4216. res3.Cainfo = res3507for10188.Cainfo
  4217. res3.WarnMsg = res3507for10188.WarnMsg
  4218. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4219. res3.Infcode = infocode
  4220. } else {
  4221. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4222. utils.ErrorLog("解析失败:%v", err)
  4223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4224. return
  4225. }
  4226. }
  4227. if res3.Infcode == 0 {
  4228. item.IsChange = 1
  4229. item.BgBchno = bg_number
  4230. service.SaveDF2(item)
  4231. } else {
  4232. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4233. }
  4234. }
  4235. } else {
  4236. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4237. }
  4238. }
  4239. } else { //还没结算
  4240. if item.IsChange == 0 { //没变更,进行变更操作
  4241. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4242. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4243. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4244. var respJSON3 map[string]interface{}
  4245. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4246. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4248. return
  4249. }
  4250. userJSONBytes3, _ := json.Marshal(respJSON3)
  4251. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4252. // utils.ErrorLog("解析失败:%v", err)
  4253. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4254. // return
  4255. //}
  4256. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4257. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4258. utils.ErrorLog("解析失败:%v", err)
  4259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4260. return
  4261. }
  4262. //if res3507for10188.Infcode
  4263. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4264. //res.Output = resSix10265.Output
  4265. res3.ErrMsg = res3507for10188.ErrMsg
  4266. res3.Cainfo = res3507for10188.Cainfo
  4267. res3.WarnMsg = res3507for10188.WarnMsg
  4268. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4269. res3.Infcode = infocode
  4270. } else {
  4271. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4272. utils.ErrorLog("解析失败:%v", err)
  4273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4274. return
  4275. }
  4276. }
  4277. if res3.Infcode == 0 {
  4278. item.IsChange = 1
  4279. item.BgBchno = bg_number
  4280. service.SaveDF2(item)
  4281. } else {
  4282. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4283. }
  4284. }
  4285. }
  4286. }
  4287. }
  4288. if len(err) == 0 {
  4289. c.ServeSuccessJSON(map[string]interface{}{
  4290. "msg": "销售变更成功",
  4291. })
  4292. } else {
  4293. c.ServeSuccessJSON(map[string]interface{}{
  4294. "failed_code": -10,
  4295. "msg": err,
  4296. })
  4297. }
  4298. }
  4299. func (c *HisApiController) ChangeDrugTen() {
  4300. //ids := c.GetString("ids")
  4301. //id_arr := strings.Split(ids, ",")
  4302. //now := time.Now()
  4303. timestamp := 1729526400
  4304. flows, _ := service.GetNewDrugFlowInforTen(timestamp, c.GetAdminUserInfo().CurrentOrgId)
  4305. admin_user_id, _ := c.GetInt64("admin_user_id")
  4306. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4307. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4308. var err []string
  4309. for _, item := range flows {
  4310. var res3 ResultSix
  4311. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4312. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4313. continue
  4314. }
  4315. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4316. continue
  4317. }
  4318. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4319. if prescription.OrderStatus == 2 {
  4320. //已经结算
  4321. //判断是否已经销售
  4322. if item.IsSale == 1 { //是否已经销售,1是 0否
  4323. //是否已经变更 1是 0否
  4324. if item.IsChange == 0 { //没变更,进行变更操作
  4325. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4326. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4327. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4328. var respJSON3 map[string]interface{}
  4329. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4332. return
  4333. }
  4334. userJSONBytes3, _ := json.Marshal(respJSON3)
  4335. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4336. utils.ErrorLog("解析失败:%v", err)
  4337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4338. return
  4339. }
  4340. if res3.Infcode == 0 {
  4341. item.IsChange = 1
  4342. item.BgBchno = bg_number
  4343. service.SaveDF2(item)
  4344. } else {
  4345. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4346. }
  4347. }
  4348. } else { //没销售,
  4349. var res FJ3507Result
  4350. var res3507for10188 FJ3507ResultFor10188
  4351. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4352. //进行商品销售接口
  4353. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4354. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4355. var respJSON3 map[string]interface{}
  4356. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4359. return
  4360. }
  4361. userJSONBytes3, _ := json.Marshal(respJSON3)
  4362. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4363. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4364. utils.ErrorLog("解析失败:%v", err)
  4365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4366. return
  4367. }
  4368. //if res3507for10188.Infcode
  4369. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4370. //res.Output = resSix10265.Output
  4371. res.ErrMsg = res3507for10188.ErrMsg
  4372. res.Cainfo = res3507for10188.Cainfo
  4373. res.WarnMsg = res3507for10188.WarnMsg
  4374. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4375. res.Infcode = infocode
  4376. } else {
  4377. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4378. utils.ErrorLog("解析失败:%v", err)
  4379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4380. return
  4381. }
  4382. }
  4383. if res.Infcode == 0 {
  4384. item.IsSale = 1
  4385. item.Bchno = number
  4386. item.SaleDate = time.Now().Format("2006-01-02")
  4387. err5 := service.SaveDF(item)
  4388. if err5 == nil {
  4389. if item.IsChange == 0 { //没变更,进行变更操作
  4390. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4391. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4392. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4393. var respJSON3 map[string]interface{}
  4394. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4397. return
  4398. }
  4399. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4400. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4401. utils.ErrorLog("解析失败:%v", err)
  4402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4403. return
  4404. }
  4405. //if res3507for10188.Infcode
  4406. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4407. //res.Output = resSix10265.Output
  4408. res3.ErrMsg = res3507for10188.ErrMsg
  4409. res3.Cainfo = res3507for10188.Cainfo
  4410. res3.WarnMsg = res3507for10188.WarnMsg
  4411. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4412. res3.Infcode = infocode
  4413. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4414. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4415. utils.ErrorLog("解析失败:%v", err)
  4416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4417. return
  4418. }
  4419. //if res3507for10188.Infcode
  4420. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4421. //res.Output = resSix10265.Output
  4422. res3.ErrMsg = res3507for10188.ErrMsg
  4423. res3.Cainfo = res3507for10188.Cainfo
  4424. res3.WarnMsg = res3507for10188.WarnMsg
  4425. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4426. res3.Infcode = infocode
  4427. } else {
  4428. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4429. utils.ErrorLog("解析失败:%v", err)
  4430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4431. return
  4432. }
  4433. }
  4434. if res3.Infcode == 0 {
  4435. item.IsChange = 1
  4436. item.BgBchno = bg_number
  4437. service.SaveDF2(item)
  4438. return
  4439. } else {
  4440. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4441. }
  4442. }
  4443. }
  4444. } else {
  4445. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4446. }
  4447. }
  4448. } else { //还没结算
  4449. var res3507for10188 FJ3507ResultFor10188
  4450. if item.IsChange == 0 { //没变更,进行变更操作
  4451. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4452. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4453. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4454. var respJSON3 map[string]interface{}
  4455. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4458. return
  4459. }
  4460. userJSONBytes3, _ := json.Marshal(respJSON3)
  4461. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4462. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4463. utils.ErrorLog("解析失败:%v", err)
  4464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4465. return
  4466. }
  4467. //if res3507for10188.Infcode
  4468. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4469. //res.Output = resSix10265.Output
  4470. res3.ErrMsg = res3507for10188.ErrMsg
  4471. res3.Cainfo = res3507for10188.Cainfo
  4472. res3.WarnMsg = res3507for10188.WarnMsg
  4473. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4474. res3.Infcode = infocode
  4475. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4476. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4477. utils.ErrorLog("解析失败:%v", err)
  4478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4479. return
  4480. }
  4481. //if res3507for10188.Infcode
  4482. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4483. //res.Output = resSix10265.Output
  4484. res3.ErrMsg = res3507for10188.ErrMsg
  4485. res3.Cainfo = res3507for10188.Cainfo
  4486. res3.WarnMsg = res3507for10188.WarnMsg
  4487. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4488. res3.Infcode = infocode
  4489. } else {
  4490. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4491. utils.ErrorLog("解析失败:%v", err)
  4492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4493. return
  4494. }
  4495. }
  4496. if res3.Infcode == 0 {
  4497. item.IsChange = 1
  4498. item.BgBchno = bg_number
  4499. service.SaveDF2(item)
  4500. } else {
  4501. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4502. }
  4503. }
  4504. }
  4505. } else if item.ConsumableType == 7 {
  4506. var res3507for10188 FJ3507ResultFor10188
  4507. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4508. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4509. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4510. //判断是否已经销售
  4511. if item.IsSale == 2 { //是否已经销售,1是 0否
  4512. //是否已经变更 1是 0否
  4513. if item.IsChange == 0 { //没变更,进行变更操作
  4514. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4515. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4516. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4517. var respJSON3 map[string]interface{}
  4518. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4521. return
  4522. }
  4523. userJSONBytes3, _ := json.Marshal(respJSON3)
  4524. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4525. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4526. utils.ErrorLog("解析失败:%v", err)
  4527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4528. return
  4529. }
  4530. //if res3507for10188.Infcode
  4531. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4532. //res.Output = resSix10265.Output
  4533. res3.ErrMsg = res3507for10188.ErrMsg
  4534. res3.Cainfo = res3507for10188.Cainfo
  4535. res3.WarnMsg = res3507for10188.WarnMsg
  4536. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4537. res3.Infcode = infocode
  4538. } else {
  4539. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4540. utils.ErrorLog("解析失败:%v", err)
  4541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4542. return
  4543. }
  4544. }
  4545. if res3.Infcode == 0 {
  4546. item.IsChange = 1
  4547. item.BgBchno = bg_number
  4548. service.SaveDF2(item)
  4549. } else {
  4550. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4551. }
  4552. }
  4553. } else { //没销售,
  4554. //进行商品销售退货接口
  4555. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4556. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4557. saveLog(result111, result222, "3506", "销售退货")
  4558. var res7 FJ3507Result
  4559. //进行商品销售接口
  4560. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4561. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4562. var respJSON3 map[string]interface{}
  4563. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4566. return
  4567. }
  4568. userJSONBytes3, _ := json.Marshal(respJSON3)
  4569. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4570. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4571. utils.ErrorLog("解析失败:%v", err)
  4572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4573. return
  4574. }
  4575. //if res3507for10188.Infcode
  4576. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4577. //res.Output = resSix10265.Output
  4578. res7.ErrMsg = res3507for10188.ErrMsg
  4579. res7.Cainfo = res3507for10188.Cainfo
  4580. res7.WarnMsg = res3507for10188.WarnMsg
  4581. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4582. res7.Infcode = infocode
  4583. } else {
  4584. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4585. utils.ErrorLog("解析失败:%v", err)
  4586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4587. return
  4588. }
  4589. }
  4590. if res7.Infcode == 0 {
  4591. item.IsSale = 2
  4592. item.SaleDate = item.SaleDate
  4593. item.Bchno = number
  4594. service.SaveDF(item)
  4595. if item.IsChange == 0 { //没变更,进行变更操作
  4596. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4597. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4598. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4599. var respJSON3 map[string]interface{}
  4600. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4603. return
  4604. }
  4605. userJSONBytes3, _ := json.Marshal(respJSON3)
  4606. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4607. // utils.ErrorLog("解析失败:%v", err)
  4608. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4609. // return
  4610. //}
  4611. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4612. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4613. utils.ErrorLog("解析失败:%v", err)
  4614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4615. return
  4616. }
  4617. //if res3507for10188.Infcode
  4618. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4619. //res.Output = resSix10265.Output
  4620. res3.ErrMsg = res3507for10188.ErrMsg
  4621. res3.Cainfo = res3507for10188.Cainfo
  4622. res3.WarnMsg = res3507for10188.WarnMsg
  4623. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4624. res3.Infcode = infocode
  4625. } else {
  4626. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4627. utils.ErrorLog("解析失败:%v", err)
  4628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4629. return
  4630. }
  4631. }
  4632. if res3.Infcode == 0 {
  4633. item.IsChange = 1
  4634. item.BgBchno = bg_number
  4635. service.SaveDF2(item)
  4636. } else {
  4637. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4638. }
  4639. }
  4640. } else {
  4641. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4642. }
  4643. }
  4644. } else { //还没结算
  4645. if item.IsChange == 0 { //没变更,进行变更操作
  4646. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4647. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4648. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4649. var respJSON3 map[string]interface{}
  4650. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4653. return
  4654. }
  4655. userJSONBytes3, _ := json.Marshal(respJSON3)
  4656. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4657. // utils.ErrorLog("解析失败:%v", err)
  4658. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4659. // return
  4660. //}
  4661. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4662. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4663. utils.ErrorLog("解析失败:%v", err)
  4664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4665. return
  4666. }
  4667. //if res3507for10188.Infcode
  4668. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4669. //res.Output = resSix10265.Output
  4670. res3.ErrMsg = res3507for10188.ErrMsg
  4671. res3.Cainfo = res3507for10188.Cainfo
  4672. res3.WarnMsg = res3507for10188.WarnMsg
  4673. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4674. res3.Infcode = infocode
  4675. } else {
  4676. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4677. utils.ErrorLog("解析失败:%v", err)
  4678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4679. return
  4680. }
  4681. }
  4682. if res3.Infcode == 0 {
  4683. item.IsChange = 1
  4684. item.BgBchno = bg_number
  4685. service.SaveDF2(item)
  4686. } else {
  4687. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4688. }
  4689. }
  4690. }
  4691. }
  4692. }
  4693. if len(err) == 0 {
  4694. c.ServeSuccessJSON(map[string]interface{}{
  4695. "msg": "销售变更成功",
  4696. })
  4697. } else {
  4698. c.ServeSuccessJSON(map[string]interface{}{
  4699. "failed_code": -10,
  4700. "msg": err,
  4701. })
  4702. }
  4703. }
  4704. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4705. var struct3502 models.Struct3502
  4706. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4707. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4708. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4709. struct3502.FixmedinsCode = miConfig.Code
  4710. struct3502.Code = miConfig.Code
  4711. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4712. struct3502.Opter = role.UserName
  4713. struct3502.RxFlag = "1"
  4714. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4715. struct3502.OrgName = miConfig.OrgName
  4716. struct3502.AccessKey = miConfig.AccessKey
  4717. struct3502.RequestUrl = miConfig.Url
  4718. struct3502.SecretKey = miConfig.SecretKey
  4719. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4720. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4721. struct3502.Url = miConfig.Url
  4722. struct3502.AppId = miConfig.Cainfo
  4723. struct3502.AppSecret = miConfig.AppSecret
  4724. struct3502.Enckey = miConfig.EncKey
  4725. struct3502.SignKey = miConfig.SignKey
  4726. struct3502.SecretKey = miConfig.SecretKey
  4727. struct3502.InvChgType = chgType
  4728. struct3502.FixmedinsBchno = number
  4729. struct3502.Cnt = strconv.FormatInt(count, 10)
  4730. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4731. //result1, result2, _ := service.FJyb3502(struct3502)
  4732. if miConfig.MdtrtareaAdmvs == "350500" {
  4733. result1, result2, _ := service.FJyb3502(struct3502)
  4734. //saveLog(result1, result2, "3502", "3502")
  4735. return result1, result2
  4736. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4737. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4738. return result1, result2
  4739. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4740. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4741. return result1, result2
  4742. } else {
  4743. data := make(map[string]interface{})
  4744. data["struct_3502s"] = struct3502
  4745. client := &http.Client{}
  4746. bytesData, _ := json.Marshal(data)
  4747. var req *http.Request
  4748. if miConfig.MdtrtareaAdmvs == "320921" {
  4749. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4750. } else {
  4751. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4752. }
  4753. resp, _ := client.Do(req)
  4754. defer resp.Body.Close()
  4755. body, ioErr := ioutil.ReadAll(resp.Body)
  4756. if ioErr != nil {
  4757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4758. }
  4759. var respJSON map[string]interface{}
  4760. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4762. }
  4763. //var resSix10265 ResultSix10265 //1101结果
  4764. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4765. result, _ := json.Marshal(respJSON)
  4766. return string(result), ""
  4767. }
  4768. }
  4769. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4770. var struct3505 models.Struct3505
  4771. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4772. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4773. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4774. struct3505.FixmedinsBchno = number
  4775. struct3505.Opter = role.UserName
  4776. struct3505.FixmedinsCode = miConfig.Code
  4777. struct3505.Code = miConfig.Code
  4778. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  4779. struct3505.PrscDrName = roles.UserName
  4780. if org_id == 10191 {
  4781. struct3505.PharName = "刘水山"
  4782. struct3505.PharPracCertNo = "2015026350260000002611351127"
  4783. }
  4784. if org_id == 10188 {
  4785. struct3505.PharName = "李汉清"
  4786. struct3505.PharPracCertNo = "30220200932022010034"
  4787. }
  4788. if org_id == 10217 {
  4789. struct3505.PharName = "张敏"
  4790. struct3505.PharPracCertNo = "30220230432090100108"
  4791. }
  4792. if org_id == 10318 {
  4793. struct3505.PharName = "邹刘阳"
  4794. struct3505.PharPracCertNo = "210441200001378"
  4795. }
  4796. if org_id == 10402 {
  4797. struct3505.PharName = "刘韶健"
  4798. struct3505.PharPracCertNo = "2015026440262015440501001198"
  4799. }
  4800. if org_id == 10567 {
  4801. struct3505.PharName = "范小兰"
  4802. struct3505.PharPracCertNo = "0200102079485"
  4803. }
  4804. order := service.GetHisOrderByNumber(pre.BatchNumber)
  4805. struct3505.SetlId = order.SetlId
  4806. struct3505.MdtrtSn = order.MdtrtId
  4807. struct3505.ManuLotnum = drug.Number
  4808. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  4809. struct3505.ExpyEnd = ""
  4810. struct3505.RxFlag = "1"
  4811. struct3505.TrdnFlag = "1"
  4812. struct3505.RtalDocno = order.Number
  4813. struct3505.PsnCertType = "01"
  4814. struct3505.CertNo = order.Certno
  4815. struct3505.PsnNo = order.PsnNo
  4816. struct3505.PsnName = order.PsnName
  4817. struct3505.Url = miConfig.Url
  4818. struct3505.AppId = miConfig.Cainfo
  4819. struct3505.AppSecret = miConfig.AppSecret
  4820. struct3505.Enckey = miConfig.EncKey
  4821. struct3505.SignKey = miConfig.SignKey
  4822. struct3505.SecretKey = miConfig.SecretKey
  4823. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  4824. struct3505.SelRetnCnt = strValue
  4825. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4826. struct3505.SelRetnOpterName = role.UserName
  4827. if order.IsMedicineInsurance == 1 {
  4828. struct3505.MdtrtSetlType = "1"
  4829. } else {
  4830. struct3505.MdtrtSetlType = "2"
  4831. }
  4832. struct3505.OrgName = miConfig.OrgName
  4833. struct3505.AccessKey = miConfig.AccessKey
  4834. struct3505.RequestUrl = miConfig.Url
  4835. struct3505.SecretKey = miConfig.SecretKey
  4836. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4837. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4838. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4839. if miConfig.MdtrtareaAdmvs == "350500" {
  4840. result1, result2, _ := service.FJyb3505(struct3505)
  4841. return result1, result2
  4842. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4843. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  4844. return result1, result2
  4845. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4846. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  4847. return result1, result2
  4848. } else {
  4849. data := make(map[string]interface{})
  4850. data["struct_3505s"] = struct3505
  4851. client := &http.Client{}
  4852. bytesData, _ := json.Marshal(data)
  4853. var req *http.Request
  4854. if miConfig.MdtrtareaAdmvs == "320921" {
  4855. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  4856. } else {
  4857. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  4858. }
  4859. resp, _ := client.Do(req)
  4860. defer resp.Body.Close()
  4861. body, ioErr := ioutil.ReadAll(resp.Body)
  4862. if ioErr != nil {
  4863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4864. }
  4865. var respJSON map[string]interface{}
  4866. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4868. }
  4869. //var resSix10265 ResultSix10265 //1101结果
  4870. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4871. result, _ := json.Marshal(respJSON)
  4872. return string(result), ""
  4873. }
  4874. }
  4875. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4876. var struct3506 models.Struct3506
  4877. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4878. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4879. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4880. struct3506.FixmedinsCode = miConfig.Code
  4881. struct3506.Code = miConfig.Code
  4882. struct3506.FixmedinsBchno = number
  4883. struct3506.Opter = role.UserName
  4884. order := service.GetHisOrderByNumber(pre.BatchNumber)
  4885. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  4886. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  4887. struct3506.MdtrtSn = order.MdtrtId
  4888. struct3506.ExpyEnd = ""
  4889. struct3506.RxFlag = "0"
  4890. struct3506.TrdnFlag = "1"
  4891. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  4892. struct3506.SelRetnCnt = strValue
  4893. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4894. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  4895. struct3506.SelRetnOpterName = role.UserName
  4896. struct3506.OrgName = miConfig.OrgName
  4897. struct3506.AccessKey = miConfig.AccessKey
  4898. struct3506.RequestUrl = miConfig.Url
  4899. struct3506.SecretKey = miConfig.SecretKey
  4900. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4901. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4902. struct3506.Url = miConfig.Url
  4903. struct3506.AppId = miConfig.Cainfo
  4904. struct3506.AppSecret = miConfig.AppSecret
  4905. struct3506.Enckey = miConfig.EncKey
  4906. struct3506.SignKey = miConfig.SignKey
  4907. struct3506.SecretKey = miConfig.SecretKey
  4908. struct3506.DrugTracCodg = drug.DrugCode
  4909. if miConfig.MdtrtareaAdmvs == "350500" {
  4910. result1, result2, _ := service.FJyb3506(struct3506)
  4911. return result1, result2
  4912. } else {
  4913. data := make(map[string]interface{})
  4914. data["struct_3506s"] = struct3506
  4915. client := &http.Client{}
  4916. bytesData, _ := json.Marshal(data)
  4917. var req *http.Request
  4918. if miConfig.MdtrtareaAdmvs == "320921" {
  4919. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  4920. } else {
  4921. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  4922. }
  4923. resp, _ := client.Do(req)
  4924. defer resp.Body.Close()
  4925. body, ioErr := ioutil.ReadAll(resp.Body)
  4926. if ioErr != nil {
  4927. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4928. }
  4929. var respJSON map[string]interface{}
  4930. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4931. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4932. }
  4933. //var resSix10265 ResultSix10265 //1101结果
  4934. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4935. result, _ := json.Marshal(respJSON)
  4936. return string(result), ""
  4937. }
  4938. }
  4939. func (c *HisApiController) Get1318() {
  4940. adminUser := c.GetAdminUserInfo()
  4941. admin_user_id, _ := c.GetInt64("admin_user_id")
  4942. code := c.GetString("code")
  4943. code = ""
  4944. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4945. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4946. api := ""
  4947. if miConfig.MdtrtareaAdmvs == "320921" {
  4948. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  4949. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  4950. } else {
  4951. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  4952. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  4953. }
  4954. resp, requestErr := http.Get(api)
  4955. if requestErr != nil {
  4956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4957. return
  4958. }
  4959. body, ioErr := ioutil.ReadAll(resp.Body)
  4960. if ioErr != nil {
  4961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4963. return
  4964. }
  4965. var respJSON map[string]interface{}
  4966. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4969. return
  4970. }
  4971. //var res Result2406
  4972. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4973. result, _ := json.Marshal(respJSON)
  4974. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4975. utils.ErrorLog("解析失败:%v", err)
  4976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4977. return
  4978. }
  4979. if res.Infcode == "0" {
  4980. c.ServeSuccessJSON(map[string]interface{}{
  4981. "result": "",
  4982. })
  4983. } else {
  4984. c.ServeSuccessJSON(map[string]interface{}{
  4985. "failed_code": -10,
  4986. "msg": res.ErrMsg,
  4987. })
  4988. */return
  4989. //}
  4990. }
  4991. func (c *HisApiController) Get2503() {
  4992. adminUser := c.GetAdminUserInfo()
  4993. admin_user_id, _ := c.GetInt64("admin_user_id")
  4994. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4995. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4996. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  4997. }
  4998. func (c *HisApiController) Get2406() {
  4999. id, _ := c.GetInt64("id")
  5000. record_time := c.GetString("record_time")
  5001. his_patient_id, _ := c.GetInt64("his_patient_id")
  5002. admin_user_id, _ := c.GetInt64("admin_user_id")
  5003. diagnosis_id := c.GetString("diagnosis")
  5004. timeLayout := "2006-01-02"
  5005. loc, _ := time.LoadLocation("Local")
  5006. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5007. if err != nil {
  5008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5009. return
  5010. }
  5011. recordDateTime := theTime.Unix()
  5012. adminUser := c.GetAdminUserInfo()
  5013. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5014. var config []*models.HisXtDiagnoseConfig
  5015. for _, item := range diagnosis_ids {
  5016. id, _ := strconv.ParseInt(item, 10, 64)
  5017. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5018. config = append(config, &diagnosisConfig)
  5019. }
  5020. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5021. fmt.Println(his_patient_id)
  5022. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5023. //timestamp := time.Now().Unix()
  5024. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5025. var patientPrescription models.HisPrescriptionInfo
  5026. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5027. if patientPrescription.ID == 0 {
  5028. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5029. }
  5030. var res2 Result2406
  5031. if miConfig.MdtrtareaAdmvs == "341203" {
  5032. data := make(map[string]interface{})
  5033. client := &http.Client{}
  5034. data["psn_no"] = his.PsnNo
  5035. data["mdtrt_id"] = his.Number
  5036. data["operator"] = roles.UserName
  5037. data["cert_no"] = his.IdCardNo
  5038. data["org_name"] = miConfig.OrgName
  5039. data["psn_name"] = his.Name
  5040. data["ipt_otp_no"] = his.IptOtpNo
  5041. data["ipt_psn_sp_flag_type"] = "0901"
  5042. data["ipt_psn_sp_flag"] = "1"
  5043. data["fixmedins_code"] = miConfig.Code
  5044. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5045. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5046. data["url"] = miConfig.Url
  5047. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5048. bytesData, _ := json.Marshal(data)
  5049. var req *http.Request
  5050. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5051. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5052. resp, _ := client.Do(req)
  5053. defer resp.Body.Close()
  5054. body, ioErr := ioutil.ReadAll(resp.Body)
  5055. if ioErr != nil {
  5056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5058. return
  5059. }
  5060. var respJSON map[string]interface{}
  5061. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5064. return
  5065. }
  5066. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5067. if status == "0" {
  5068. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5069. c.ServeSuccessJSON(map[string]interface{}{
  5070. "failed_code": -10,
  5071. "msg": err_msg,
  5072. })
  5073. return
  5074. }
  5075. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5076. userJSONBytes, _ := json.Marshal(respJSON)
  5077. fmt.Println("log")
  5078. fmt.Println(string(userJSONBytes))
  5079. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5080. utils.ErrorLog("解析失败:%v", err)
  5081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5082. return
  5083. }
  5084. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5085. data := make(map[string]interface{})
  5086. client := &http.Client{}
  5087. data["psn_no"] = his.PsnNo
  5088. data["mdtrt_id"] = his.Number
  5089. data["operator"] = roles.UserName
  5090. data["cert_no"] = his.IdCardNo
  5091. data["org_name"] = miConfig.OrgName
  5092. data["psn_name"] = his.Name
  5093. data["ipt_otp_no"] = his.IptOtpNo
  5094. data["ipt_psn_sp_flag_type"] = "0901"
  5095. data["ipt_psn_sp_flag"] = "1"
  5096. data["fixmedins_code"] = miConfig.Code
  5097. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5098. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5099. data["url"] = miConfig.Url
  5100. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5101. bytesData, _ := json.Marshal(data)
  5102. var req *http.Request
  5103. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5104. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5105. resp, _ := client.Do(req)
  5106. defer resp.Body.Close()
  5107. body, ioErr := ioutil.ReadAll(resp.Body)
  5108. if ioErr != nil {
  5109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5111. return
  5112. }
  5113. var respJSON map[string]interface{}
  5114. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5115. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5117. return
  5118. }
  5119. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5120. if status == "0" {
  5121. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5122. c.ServeSuccessJSON(map[string]interface{}{
  5123. "failed_code": -10,
  5124. "msg": err_msg,
  5125. })
  5126. return
  5127. }
  5128. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5129. userJSONBytes, _ := json.Marshal(respJSON)
  5130. fmt.Println("log")
  5131. fmt.Println(string(userJSONBytes))
  5132. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5133. utils.ErrorLog("解析失败:%v", err)
  5134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5135. return
  5136. }
  5137. }
  5138. if res2.Infcode != 0 {
  5139. adminUser := c.GetAdminUserInfo()
  5140. errlog := &models.HisOrderError{
  5141. UserOrgId: adminUser.CurrentOrgId,
  5142. Ctime: time.Now().Unix(),
  5143. Mtime: time.Now().Unix(),
  5144. ErrMsg: res2.ErrMsg,
  5145. Status: 1,
  5146. PatientId: id,
  5147. RecordTime: recordDateTime,
  5148. Stage: 3,
  5149. }
  5150. service.CreateErrMsgLog(errlog)
  5151. c.ServeSuccessJSON(map[string]interface{}{
  5152. "failed_code": -10,
  5153. "msg": res2.ErrMsg,
  5154. })
  5155. return
  5156. } else {
  5157. c.ServeSuccessJSON(map[string]interface{}{
  5158. "msg": "上传成功",
  5159. })
  5160. return
  5161. }
  5162. }
  5163. func (c *HisApiController) Get4105() {
  5164. }
  5165. func (c *HisApiController) Post5302() {
  5166. patient_id, _ := c.GetInt64("id")
  5167. admin_user_id, _ := c.GetInt64("admin_user_id")
  5168. p, _ := service.GetHisPatientById(patient_id)
  5169. adminUser := c.GetAdminUserInfo()
  5170. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5171. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5172. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5173. }
  5174. func (c *HisApiController) Get4104() {
  5175. }
  5176. type Output struct {
  5177. CertNo string `json:"certno"`
  5178. PsnName string `json:"psn_name"`
  5179. CardNo string `json:"card_no"`
  5180. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5181. CardSN string `json:"card_sn"`
  5182. PsnCertType string `json:"psn_cert_type"`
  5183. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5184. MdtrtCertType string `json:"mdtrt_cert_type"`
  5185. QRCode string `json:"qrCode"`
  5186. EcToken string `json:"ecToken"`
  5187. }
  5188. type AHResponse struct {
  5189. Body AHBody `json:"body"`
  5190. Code int `json:"code"`
  5191. CSBCode int `json:"csbCode"`
  5192. Message string `json:"message"`
  5193. RequestID string `json:"requestId"`
  5194. State struct{} `json:"state"`
  5195. }
  5196. type AHBody struct {
  5197. ErrMsg string `json:"err_msg"`
  5198. InfRefMsgID string `json:"inf_refmsgid"`
  5199. InfCode int `json:"infcode"`
  5200. Output struct {
  5201. Result []struct {
  5202. BasMednFlag string `json:"bas_medn_flag"`
  5203. ChldMedcFlag string `json:"chld_medc_flag"`
  5204. ChrgitmLv string `json:"chrgitm_lv"`
  5205. Cnt float64 `json:"cnt"`
  5206. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5207. DrtReimFlag string `json:"drt_reim_flag"`
  5208. FeedetlSn string `json:"feedetl_sn"`
  5209. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5210. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5211. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5212. ListSpItemFlag string `json:"list_sp_item_flag"`
  5213. LmtUsedFlag string `json:"lmt_used_flag"`
  5214. MedChrgitmType string `json:"med_chrgitm_type"`
  5215. Memo string `json:"memo"`
  5216. OverlmtAmt float64 `json:"overlmt_amt"`
  5217. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5218. Pric float64 `json:"pric"`
  5219. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5220. SelfpayProp float64 `json:"selfpay_prop"`
  5221. } `json:"result"`
  5222. } `json:"output"`
  5223. }
  5224. type Response struct {
  5225. Output Output `json:"output"`
  5226. Infcode int `json:"infcode"`
  5227. InfRefMsgID string `json:"inf_refmsgid"`
  5228. RefMsgTime string `json:"refmsg_time"`
  5229. RespondTime string `json:"respond_time"`
  5230. ErrMsg string `json:"err_msg"`
  5231. WarnMsg string `json:"warn_msg"`
  5232. SignType string `json:"signtype"`
  5233. CAInfo string `json:"cainfo"`
  5234. }
  5235. func (c *HisApiController) Getquerydata() {
  5236. query_type, _ := c.GetInt64("type")
  5237. refd_setl_flag := c.GetString("refd_setl_flag")
  5238. med_type := c.GetString("med_type")
  5239. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5240. cert_no := c.GetString("cert_no")
  5241. psn_no := c.GetString("psn_no")
  5242. start_time := c.GetString("start_time")
  5243. end_time := c.GetString("end_time")
  5244. page, _ := c.GetInt64("page")
  5245. limit, _ := c.GetInt64("limit")
  5246. var bp models.BusinessParams5262
  5247. bp.RefdSetlFlag = refd_setl_flag
  5248. bp.MedType = med_type
  5249. bp.Certno = cert_no
  5250. bp.Psnno = psn_no
  5251. bp.QBegntime = start_time
  5252. bp.QEndtime = end_time
  5253. if query_type == 1 { //本地
  5254. Post5262(c, bp, page, limit)
  5255. } else { //异地
  5256. Post5267(c, bp, page, limit)
  5257. }
  5258. }
  5259. func (c *HisApiController) Drugscheck() {
  5260. admin_user_id, _ := c.GetInt64("admin_user_id")
  5261. adminUser := c.GetAdminUserInfo()
  5262. var queryResult []QueryResult
  5263. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5264. for _, item := range drugs {
  5265. result := QueryResult{
  5266. ID: item.ID,
  5267. Name: item.DrugName,
  5268. Code: item.MedicalInsuranceNumber,
  5269. List_type_code: "101",
  5270. }
  5271. queryResult = append(queryResult, result)
  5272. }
  5273. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5274. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5275. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5276. for _, item := range queryResult {
  5277. 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)
  5278. }
  5279. }
  5280. func (c *HisApiController) Goodcheck() {
  5281. admin_user_id, _ := c.GetInt64("admin_user_id")
  5282. adminUser := c.GetAdminUserInfo()
  5283. var queryResult []QueryResult
  5284. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5285. for _, item := range goods {
  5286. result := QueryResult{
  5287. ID: item.ID,
  5288. Name: item.GoodName,
  5289. Code: item.SocialSecurityDirectoryCode,
  5290. List_type_code: "301",
  5291. }
  5292. queryResult = append(queryResult, result)
  5293. }
  5294. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5295. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5296. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5297. for _, item := range queryResult {
  5298. 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)
  5299. //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)
  5300. }
  5301. }
  5302. func (c *HisApiController) Projectcheck() {
  5303. admin_user_id, _ := c.GetInt64("admin_user_id")
  5304. adminUser := c.GetAdminUserInfo()
  5305. var queryResult []QueryResult
  5306. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5307. for _, item := range projects {
  5308. result := QueryResult{
  5309. ID: item.ID,
  5310. Name: item.ProjectName,
  5311. Code: item.MedicalCode,
  5312. List_type_code: "201",
  5313. }
  5314. queryResult = append(queryResult, result)
  5315. }
  5316. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5317. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5318. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5319. for _, item := range queryResult {
  5320. 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)
  5321. }
  5322. }
  5323. //func (c *HisApiController)CancleDia(){
  5324. //
  5325. // id, _ := c.GetInt64("id")
  5326. // record_time := c.GetString("record_time")
  5327. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5328. //
  5329. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5330. //
  5331. // diagnosis_id := c.GetString("diagnosis")
  5332. // sick_type, _ := c.GetInt64("sick_type")
  5333. // reg_type, _ := c.GetInt64("p_type")
  5334. // begin_time := c.GetString("begin_time")
  5335. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5336. //
  5337. //
  5338. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5339. //
  5340. // fmt.Println(acct_used_flag)
  5341. //
  5342. //
  5343. // timeLayout := "2006-01-02"
  5344. // loc, _ := time.LoadLocation("Local")
  5345. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5346. // if err != nil {
  5347. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5348. // return
  5349. // }
  5350. // recordDateTime := theTime.Unix()
  5351. // adminUser := c.GetAdminUserInfo()
  5352. //
  5353. //
  5354. //
  5355. //
  5356. //
  5357. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5358. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5359. // var patientPrescription models.HisPrescriptionInfo
  5360. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5361. // if patientPrescription.ID == 0 {
  5362. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5363. // }
  5364. // //if patientPrescription.Do
  5365. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5366. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5367. //
  5368. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5369. //
  5370. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5371. //
  5372. // var config []*models.HisXtDiagnoseConfig
  5373. // for _, item := range diagnosis_ids {
  5374. // id, _ := strconv.ParseInt(item, 10, 64)
  5375. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5376. // config = append(config, &diagnosisConfig)
  5377. // }
  5378. //
  5379. // sickConfig, _ := service.FindSickById(sick_type)
  5380. //
  5381. //
  5382. // data := make(map[string]interface{})
  5383. // client := &http.Client{}
  5384. // data["psn_no"] = his.PsnNo
  5385. // data["mdtrt_id"] = his.Number
  5386. // data["doctor"] = roles.UserName
  5387. // data["department"] = department.Name
  5388. // data["org_name"] = miConfig.OrgName
  5389. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5390. // data["doctor_id"] = doctor_info.DoctorNumber
  5391. // data["new_doctor_name"] = doctor_info.UserName
  5392. // data["fixmedins_code"] = miConfig.Code
  5393. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5394. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5395. // data["secret_key"] = miConfig.SecretKey
  5396. // data["sick_code"] = sickConfig.CountryCode
  5397. // data["sick_name"] = sickConfig.ClassName
  5398. // data["url"] = miConfig.Url
  5399. // data["ak"] = miConfig.AccessKey
  5400. // data["begin_time"] = begin_time
  5401. // data["cainfo"] = miConfig.Cainfo
  5402. // data["is_vaild"] = "0"
  5403. //
  5404. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5405. // data["config"] = config
  5406. // bytesData, _ := json.Marshal(data)
  5407. //
  5408. // var req *http.Request
  5409. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5410. // resp, _ := client.Do(req)
  5411. // defer resp.Body.Close()
  5412. // body, ioErr := ioutil.ReadAll(resp.Body)
  5413. // if ioErr != nil {
  5414. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5415. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5416. // return
  5417. // }
  5418. // var respJSON map[string]interface{}
  5419. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5420. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5421. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5422. // return
  5423. // }
  5424. //
  5425. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5426. // userJSONBytes, _ := json.Marshal(respJSON)
  5427. // fmt.Println("log")
  5428. // fmt.Println(string(userJSONBytes))
  5429. //
  5430. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5431. // utils.ErrorLog("解析失败:%v", err)
  5432. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5433. // return
  5434. // }
  5435. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5436. // res2.Output = ressix10265.Output
  5437. // res2.ErrMsg = ressix10265.ErrMsg
  5438. // res2.Cainfo = ressix10265.Cainfo
  5439. // res2.WarnMsg = ressix10265.WarnMsg
  5440. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5441. // res2.Infcode = infocode
  5442. //
  5443. //}
  5444. func (c *HisApiController) Get4102() {
  5445. order_id, _ := c.GetInt64("order_id")
  5446. admin_user_id, _ := c.GetInt64("admin_user_id")
  5447. stas_type := c.GetString("stas_type")
  5448. order, _ := service.GetHisOrderByIDTwo(order_id)
  5449. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5450. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5451. var pp models.PublicParams
  5452. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5453. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5454. pp.FixmedinsName = miConfig.OrgName
  5455. pp.FixmedinsCode = miConfig.Code
  5456. pp.RequestUrl = miConfig.Url
  5457. pp.Cainfo = miConfig.Cainfo
  5458. pp.SecretKey = miConfig.SecretKey
  5459. pp.AccessKey = miConfig.AccessKey
  5460. pp.OpterName = curRoles.UserName
  5461. if miConfig.MdtrtareaAdmvs == "350500" {
  5462. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5463. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5464. saveLog(result, request, "4102", "清单确认")
  5465. var dat map[string]interface{}
  5466. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5467. fmt.Println(dat)
  5468. } else {
  5469. fmt.Println(err)
  5470. }
  5471. var empty ResultFourteen
  5472. userJSONBytes, _ := json.Marshal(dat)
  5473. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5474. utils.ErrorLog("解析失败:%v", err)
  5475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5476. return
  5477. }
  5478. if empty.Infcode == 0 {
  5479. c.ServeSuccessJSON(map[string]interface{}{
  5480. "msg": "确认成功",
  5481. })
  5482. return
  5483. }
  5484. } else {
  5485. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5486. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5487. result3, request3 := service.Jxyb4105(pp)
  5488. saveLog(result, request, "4102", "清单确认")
  5489. saveLog(result2, request2, "4103", "清单确认")
  5490. saveLog(result3, request3, "4105", "清单统计")
  5491. var dat map[string]interface{}
  5492. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5493. fmt.Println(dat)
  5494. } else {
  5495. fmt.Println(err)
  5496. }
  5497. var empty ResultFourteen
  5498. userJSONBytes, _ := json.Marshal(dat)
  5499. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5500. utils.ErrorLog("解析失败:%v", err)
  5501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5502. return
  5503. }
  5504. if empty.Infcode == 0 {
  5505. c.ServeSuccessJSON(map[string]interface{}{
  5506. "msg": "确认成功",
  5507. })
  5508. return
  5509. }
  5510. }
  5511. }
  5512. // 对账权限查询
  5513. func (c *HisApiController) Get3260() {
  5514. admin_user_id, _ := c.GetInt64("admin_user_id")
  5515. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5516. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5517. var api string
  5518. var res models.JSResult3260
  5519. if miConfig.MdtrtareaAdmvs == "320921" {
  5520. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5521. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5522. } else {
  5523. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5524. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5525. }
  5526. resp, requestErr := http.Get(api)
  5527. if requestErr != nil {
  5528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5529. return
  5530. }
  5531. body, ioErr := ioutil.ReadAll(resp.Body)
  5532. if ioErr != nil {
  5533. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5535. return
  5536. }
  5537. var respJSON map[string]interface{}
  5538. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5541. return
  5542. }
  5543. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5544. result, _ := json.Marshal(respJSON)
  5545. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5546. utils.ErrorLog("解析失败:%v", err)
  5547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5548. return
  5549. }
  5550. if res.Infcode == "0" {
  5551. c.ServeSuccessJSON(map[string]interface{}{
  5552. "result": res.Output.Data,
  5553. })
  5554. } else {
  5555. c.ServeSuccessJSON(map[string]interface{}{
  5556. "failed_code": -10,
  5557. "msg": res.ErrMsg,
  5558. })
  5559. return
  5560. }
  5561. }
  5562. func (c *HisApiController) Get3261() {
  5563. admin_user_id, _ := c.GetInt64("admin_user_id")
  5564. //month := c.GetString("month")
  5565. startTime := c.GetString("start_time")
  5566. //endTime, _ := c.GetString("end_time")
  5567. times := strings.Split(startTime, "-")
  5568. stmt_mon := times[0] + times[1]
  5569. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5570. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5571. var api string
  5572. var res models.JSResult3261
  5573. //var res10265 Result5301For10265
  5574. if miConfig.MdtrtareaAdmvs == "320921" {
  5575. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5576. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5577. } else {
  5578. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5579. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5580. }
  5581. resp, requestErr := http.Get(api)
  5582. if requestErr != nil {
  5583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5584. return
  5585. }
  5586. body, ioErr := ioutil.ReadAll(resp.Body)
  5587. if ioErr != nil {
  5588. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5590. return
  5591. }
  5592. var respJSON map[string]interface{}
  5593. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5596. return
  5597. }
  5598. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5599. result, _ := json.Marshal(respJSON)
  5600. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5601. utils.ErrorLog("解析失败:%v", err)
  5602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5603. return
  5604. }
  5605. if res.Infcode == "0" {
  5606. c.ServeSuccessJSON(map[string]interface{}{
  5607. "result": res.Output,
  5608. })
  5609. } else {
  5610. c.ServeSuccessJSON(map[string]interface{}{
  5611. "failed_code": -10,
  5612. "msg": res.ErrMsg,
  5613. })
  5614. return
  5615. }
  5616. }
  5617. type TempFun struct {
  5618. FundKey string
  5619. FundCode string
  5620. }
  5621. func (c *HisApiController) Get3262() {
  5622. admin_user_id, _ := c.GetInt64("admin_user_id")
  5623. startTime := c.GetString("start_time")
  5624. endTime := c.GetString("end_time")
  5625. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5626. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5627. //timeLayout := "2006-01-02"
  5628. //loc, _ := time.LoadLocation("Local")
  5629. //var theStartTIme int64
  5630. //if len(startTime) > 0 {
  5631. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  5632. // if err != nil {
  5633. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5634. // return
  5635. // }
  5636. // theStartTIme = theTime.Unix()
  5637. //}
  5638. //var theEndtTIme int64
  5639. //if len(endTime) > 0 {
  5640. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  5641. // if err != nil {
  5642. // utils.ErrorLog(err.Error())
  5643. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5644. // return
  5645. // }
  5646. // theEndtTIme = theTime.Unix()
  5647. //}
  5648. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5649. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5650. for _, team := range datas {
  5651. fmt.Println(team.PsnTime)
  5652. for _, team_two := range datas_two {
  5653. fmt.Println(team_two.PsnTime)
  5654. if team.FundKey == team_two.FundKey {
  5655. fmt.Println(team_two.PsnTime)
  5656. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  5657. fmt.Println(team.PsnTime)
  5658. }
  5659. }
  5660. }
  5661. fmt.Println("1111")
  5662. fmt.Println(datas)
  5663. fmt.Println("1111")
  5664. var twos []models.FixMonRecDetailFileInTwo
  5665. for _, team := range datas {
  5666. var two models.FixMonRecDetailFileInTwo
  5667. two.MedType = team.MedType
  5668. two.Insutype = team.Insutype
  5669. two.PsnType = team.PsnType
  5670. two.MedType = team.MedType
  5671. two.FixBlngAdmdvs = "999999"
  5672. two.InsuAdmdvs = "555555"
  5673. two.PsnTime = team.PsnTime
  5674. two.PsnCnt = team.PsnCnt
  5675. two.FundKey = team.FundKey
  5676. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  5677. fps, _ := strconv.ParseFloat(team.Fund, 64)
  5678. ia, _ := strconv.ParseFloat(team.Amt, 64)
  5679. two.MedfeeSumAmt = ms
  5680. two.InscpAmt = ia
  5681. two.FundPaySumAmt = fps
  5682. twos = append(twos, two)
  5683. }
  5684. //startTime := c.GetString("start_time")
  5685. //endTime, _ := c.GetString("end_time")
  5686. times := strings.Split(startTime, "-")
  5687. stmt_mon := times[0] + times[1]
  5688. var funs []models.FundDetail
  5689. for _, item := range datas {
  5690. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  5691. funs = append(funs, fun...)
  5692. }
  5693. var funInfos []models.Fund
  5694. //for _, item := range funs {
  5695. // var rf []models.FundInfo
  5696. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  5697. // for _, subitem := range rf {
  5698. // var fund models.Fund
  5699. // fund.FundCode = subitem.FundPayType
  5700. // fund.FundName = subitem.FundPayTypeName
  5701. // fund.FundAmt = subitem.FundPayAmt
  5702. // fund.FundKey = item.FundKey
  5703. // fund.InsuAdmdvs = "555555"
  5704. // fund.FixBlngAdmdvs = "999999"
  5705. // funInfos = append(funInfos, fund)
  5706. // }
  5707. //}
  5708. var tempFuns []TempFun
  5709. for _, funInfo := range funInfos {
  5710. var tempFun TempFun
  5711. tempFun.FundKey = funInfo.FundKey
  5712. tempFun.FundCode = funInfo.FundCode
  5713. tempFuns = append(tempFuns, tempFun)
  5714. }
  5715. tempFuns = RemoveRepeatedFunElement(tempFuns)
  5716. fmt.Println(tempFuns)
  5717. var funInfosTwo []models.Fund
  5718. decimal.DivisionPrecision = 2
  5719. for _, item := range tempFuns {
  5720. var fund models.Fund
  5721. for _, subItem := range funInfos {
  5722. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  5723. fund.FundKey = subItem.FundKey
  5724. fund.InsuAdmdvs = subItem.InsuAdmdvs
  5725. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  5726. fund.FundName = subItem.FundName
  5727. fund.FundCode = subItem.FundCode
  5728. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  5729. }
  5730. }
  5731. funInfosTwo = append(funInfosTwo, fund)
  5732. }
  5733. fmt.Println("funInfosTwo")
  5734. fmt.Println(funInfosTwo)
  5735. var upld_btch string
  5736. var empty models.JSResultEmpty
  5737. data := make(map[string]interface{})
  5738. data["org_name"] = miConfig.OrgName
  5739. data["doctor"] = curRoles.UserName
  5740. data["doctor_name"] = curRoles.UserName
  5741. data["fixmedins_code"] = miConfig.Code
  5742. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5743. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5744. data["secret_key"] = miConfig.SecretKey
  5745. data["url"] = miConfig.Url
  5746. data["ak"] = miConfig.AccessKey
  5747. data["cainfo"] = miConfig.Cainfo
  5748. data["datas"] = twos
  5749. data["fund"] = funInfosTwo
  5750. fmt.Println(twos)
  5751. month := time.Unix(1557042972, 0).Format("1")
  5752. year := time.Now().Format("2006")
  5753. month = time.Now().Format("01")
  5754. day := time.Now().Format("02")
  5755. hour := time.Now().Format("15")
  5756. min := time.Now().Format("04")
  5757. sec := time.Now().Format("05")
  5758. fix_fill_date := year + month + day + hour + min + sec
  5759. data["fix_fill_dept"] = miConfig.OrgName
  5760. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  5761. data["fix_fill_psn"] = curRoles.UserName
  5762. data["fix_fill_date"] = fix_fill_date
  5763. data["stmt_loc"] = "2"
  5764. data["setl_mon"] = stmt_mon
  5765. upld_btch = "0"
  5766. data["upld_btch"] = upld_btch
  5767. //fmt.Println(data)
  5768. client := &http.Client{}
  5769. bytesData, _ := json.Marshal(data)
  5770. var req *http.Request
  5771. if miConfig.MdtrtareaAdmvs == "320921" {
  5772. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  5773. } else {
  5774. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  5775. }
  5776. resp, _ := client.Do(req)
  5777. defer resp.Body.Close()
  5778. body, ioErr := ioutil.ReadAll(resp.Body)
  5779. if ioErr != nil {
  5780. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5782. }
  5783. var respJSON map[string]interface{}
  5784. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5787. }
  5788. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5789. //fmt.Println(respJSON)
  5790. result, _ := json.Marshal(respJSON)
  5791. //fmt.Println(result)
  5792. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  5793. utils.ErrorLog("解析失败:%v", err)
  5794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5795. }
  5796. if empty.Infcode != "0" {
  5797. c.ServeSuccessJSON(map[string]interface{}{
  5798. "failed_code": -10,
  5799. "msg": empty.ErrMsg,
  5800. })
  5801. return
  5802. } else {
  5803. c.ServeSuccessJSON(map[string]interface{}{
  5804. "msg": "上传成功",
  5805. })
  5806. return
  5807. }
  5808. }
  5809. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  5810. newArr = make([]TempFun, 0)
  5811. for i := 0; i < len(arr); i++ {
  5812. repeat := false
  5813. for j := i + 1; j < len(arr); j++ {
  5814. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  5815. repeat = true
  5816. break
  5817. }
  5818. }
  5819. if !repeat {
  5820. newArr = append(newArr, arr[i])
  5821. }
  5822. }
  5823. return
  5824. }
  5825. func (c *HisApiController) Get3263() {
  5826. admin_user_id, _ := c.GetInt64("admin_user_id")
  5827. startTime := c.GetString("start_time")
  5828. //endTime, _ := c.GetString("end_time")
  5829. times := strings.Split(startTime, "-")
  5830. setl_mon := times[0] + times[1]
  5831. upld_btch := "0"
  5832. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5833. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5834. var result3263 models.JSResult3263
  5835. data := make(map[string]interface{})
  5836. data["org_name"] = miConfig.OrgName
  5837. data["doctor"] = curRoles.UserName
  5838. data["doctor_name"] = curRoles.UserName
  5839. data["fixmedins_code"] = miConfig.Code
  5840. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5841. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5842. data["secret_key"] = miConfig.SecretKey
  5843. data["url"] = miConfig.Url
  5844. data["ak"] = miConfig.AccessKey
  5845. data["cainfo"] = miConfig.Cainfo
  5846. data["setl_mon"] = setl_mon
  5847. data["stmt_loc"] = "2"
  5848. data["upld_btch"] = upld_btch
  5849. client := &http.Client{}
  5850. bytesData, _ := json.Marshal(data)
  5851. var req *http.Request
  5852. if miConfig.MdtrtareaAdmvs == "320921" {
  5853. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5854. } else {
  5855. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5856. }
  5857. resp, _ := client.Do(req)
  5858. defer resp.Body.Close()
  5859. body, ioErr := ioutil.ReadAll(resp.Body)
  5860. if ioErr != nil {
  5861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5863. }
  5864. var respJSON map[string]interface{}
  5865. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5868. }
  5869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5870. fmt.Println(respJSON)
  5871. result, _ := json.Marshal(respJSON)
  5872. fmt.Println(result)
  5873. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  5874. utils.ErrorLog("解析失败:%v", err)
  5875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5876. }
  5877. if result3263.Infcode != "0" {
  5878. c.ServeSuccessJSON(map[string]interface{}{
  5879. "failed_code": -10,
  5880. "msg": result3263.ErrMsg,
  5881. })
  5882. return
  5883. } else {
  5884. c.ServeSuccessJSON(map[string]interface{}{
  5885. "list": result3263.Output,
  5886. })
  5887. return
  5888. }
  5889. }
  5890. func (c *HisApiController) Get3264() {
  5891. admin_user_id, _ := c.GetInt64("admin_user_id")
  5892. startTime := c.GetString("start_time")
  5893. //endTime, _ := c.GetString("end_time")
  5894. times := strings.Split(startTime, "-")
  5895. setl_mon := times[0] + times[1]
  5896. upld_btch := "0"
  5897. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5898. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5899. //solidify_id := []
  5900. var result3263 models.JSResult3263
  5901. data := make(map[string]interface{})
  5902. data["org_name"] = miConfig.OrgName
  5903. data["doctor"] = curRoles.UserName
  5904. data["doctor_name"] = curRoles.UserName
  5905. data["fixmedins_code"] = miConfig.Code
  5906. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5907. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5908. data["secret_key"] = miConfig.SecretKey
  5909. data["url"] = miConfig.Url
  5910. data["ak"] = miConfig.AccessKey
  5911. data["cainfo"] = miConfig.Cainfo
  5912. data["setl_mon"] = setl_mon
  5913. data["stmt_loc"] = "2"
  5914. data["upld_btch"] = upld_btch
  5915. client := &http.Client{}
  5916. bytesData, _ := json.Marshal(data)
  5917. var req3263 *http.Request
  5918. if miConfig.MdtrtareaAdmvs == "320921" {
  5919. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5920. } else {
  5921. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5922. }
  5923. resp, _ := client.Do(req3263)
  5924. defer resp.Body.Close()
  5925. body, ioErr := ioutil.ReadAll(resp.Body)
  5926. if ioErr != nil {
  5927. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5929. }
  5930. var respJSON3263 map[string]interface{}
  5931. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  5932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5934. }
  5935. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5936. fmt.Println(respJSON3263)
  5937. result, _ := json.Marshal(respJSON3263)
  5938. fmt.Println(result)
  5939. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  5940. utils.ErrorLog("解析失败:%v", err)
  5941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5942. }
  5943. var ids []string
  5944. for _, item := range result3263.Output {
  5945. ids = append(ids, item.SolidifyID)
  5946. }
  5947. var empty models.JSResultEmpty
  5948. data2 := make(map[string]interface{})
  5949. data2["org_name"] = miConfig.OrgName
  5950. data2["doctor"] = curRoles.UserName
  5951. data2["doctor_name"] = curRoles.UserName
  5952. data2["fixmedins_code"] = miConfig.Code
  5953. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5954. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5955. data2["secret_key"] = miConfig.SecretKey
  5956. data2["url"] = miConfig.Url
  5957. data2["ak"] = miConfig.AccessKey
  5958. data2["cainfo"] = miConfig.Cainfo
  5959. data2["setl_mon"] = setl_mon
  5960. data2["stmt_loc"] = "2"
  5961. data2["upld_btch"] = upld_btch
  5962. data2["solidify_id"] = ids
  5963. client2 := &http.Client{}
  5964. bytesData2, _ := json.Marshal(data2)
  5965. var req *http.Request
  5966. if miConfig.MdtrtareaAdmvs == "320921" {
  5967. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  5968. } else {
  5969. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  5970. }
  5971. resp2, _ := client2.Do(req)
  5972. defer resp.Body.Close()
  5973. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5974. if ioErr2 != nil {
  5975. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5977. }
  5978. var respJSON map[string]interface{}
  5979. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  5980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5982. }
  5983. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5984. fmt.Println(respJSON)
  5985. result2, _ := json.Marshal(respJSON)
  5986. fmt.Println(result2)
  5987. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  5988. utils.ErrorLog("解析失败:%v", err)
  5989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5990. }
  5991. if empty.Infcode != "0" {
  5992. c.ServeSuccessJSON(map[string]interface{}{
  5993. "failed_code": -10,
  5994. "msg": empty.ErrMsg,
  5995. })
  5996. return
  5997. } else {
  5998. c.ServeSuccessJSON(map[string]interface{}{
  5999. "msg": "",
  6000. })
  6001. return
  6002. }
  6003. }
  6004. func (c *HisApiController) Get3265() {
  6005. admin_user_id, _ := c.GetInt64("admin_user_id")
  6006. startTime := c.GetString("start_time")
  6007. //endTime, _ := c.GetString("end_time")
  6008. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6009. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6010. times := strings.Split(startTime, "-")
  6011. setl_mon := times[0] + times[1]
  6012. var upld_btch string
  6013. upld_btch = "0"
  6014. //var empty models.JSResultEmpty
  6015. var result3265 models.JSResult3264
  6016. var result3263 models.JSResult3263
  6017. data2 := make(map[string]interface{})
  6018. data2["org_name"] = miConfig.OrgName
  6019. data2["doctor"] = curRoles.UserName
  6020. data2["doctor_name"] = curRoles.UserName
  6021. data2["fixmedins_code"] = miConfig.Code
  6022. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6023. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6024. data2["secret_key"] = miConfig.SecretKey
  6025. data2["url"] = miConfig.Url
  6026. data2["ak"] = miConfig.AccessKey
  6027. data2["cainfo"] = miConfig.Cainfo
  6028. data2["setl_mon"] = setl_mon
  6029. data2["stmt_loc"] = "2"
  6030. data2["upld_btch"] = upld_btch
  6031. client2 := &http.Client{}
  6032. bytesData2, _ := json.Marshal(data2)
  6033. var req3263 *http.Request
  6034. if miConfig.MdtrtareaAdmvs == "320921" {
  6035. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6036. } else {
  6037. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6038. }
  6039. resp2, _ := client2.Do(req3263)
  6040. defer resp2.Body.Close()
  6041. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6042. if ioErr2 != nil {
  6043. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6045. }
  6046. var respJSON3263 map[string]interface{}
  6047. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6050. }
  6051. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6052. fmt.Println(respJSON3263)
  6053. result2, _ := json.Marshal(respJSON3263)
  6054. fmt.Println(result2)
  6055. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6056. utils.ErrorLog("解析失败:%v", err)
  6057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6058. }
  6059. var ids []string
  6060. for _, item := range result3263.Output {
  6061. ids = append(ids, item.SolidifyID)
  6062. }
  6063. data := make(map[string]interface{})
  6064. data["org_name"] = miConfig.OrgName
  6065. data["doctor"] = curRoles.UserName
  6066. data["doctor_name"] = curRoles.UserName
  6067. data["fixmedins_code"] = miConfig.Code
  6068. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6069. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6070. data["secret_key"] = miConfig.SecretKey
  6071. data["url"] = miConfig.Url
  6072. data["ak"] = miConfig.AccessKey
  6073. data["cainfo"] = miConfig.Cainfo
  6074. data["setl_mon"] = setl_mon
  6075. data["solidify_id"] = ids
  6076. month := time.Unix(1557042972, 0).Format("1")
  6077. year := time.Now().Format("2006")
  6078. month = time.Now().Format("01")
  6079. day := time.Now().Format("02")
  6080. hour := time.Now().Format("15")
  6081. min := time.Now().Format("04")
  6082. sec := time.Now().Format("05")
  6083. fix_fill_date := year + month + day + hour + min + sec
  6084. data["fix_fill_dept"] = miConfig.OrgName
  6085. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6086. data["fix_fill_psn"] = curRoles.UserName
  6087. data["fix_fill_date"] = fix_fill_date
  6088. data["stmt_loc"] = "2"
  6089. data["upld_btch"] = upld_btch
  6090. client := &http.Client{}
  6091. bytesData, _ := json.Marshal(data)
  6092. var req *http.Request
  6093. if miConfig.MdtrtareaAdmvs == "320921" {
  6094. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6095. } else {
  6096. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6097. }
  6098. resp, _ := client.Do(req)
  6099. defer resp.Body.Close()
  6100. body, ioErr := ioutil.ReadAll(resp.Body)
  6101. if ioErr != nil {
  6102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6104. }
  6105. var respJSON map[string]interface{}
  6106. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6109. }
  6110. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6111. fmt.Println(respJSON)
  6112. result, _ := json.Marshal(respJSON)
  6113. fmt.Println(result)
  6114. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6115. utils.ErrorLog("解析失败:%v", err)
  6116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6117. }
  6118. if result3265.Infcode != "0" {
  6119. c.ServeSuccessJSON(map[string]interface{}{
  6120. "failed_code": -10,
  6121. "msg": result3265.ErrMsg,
  6122. })
  6123. return
  6124. } else {
  6125. c.ServeSuccessJSON(map[string]interface{}{
  6126. "info": result3265.Output,
  6127. })
  6128. return
  6129. }
  6130. }
  6131. func (c *HisApiController) Get3266() {
  6132. admin_user_id, _ := c.GetInt64("admin_user_id")
  6133. startTime := c.GetString("start_time")
  6134. //endTime, _ := c.GetString("end_time")
  6135. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6136. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6137. times := strings.Split(startTime, "-")
  6138. stmt_mon := times[0] + times[1]
  6139. var upld_btch string
  6140. //var empty models.JSResultEmpty
  6141. var result3265 models.JSResult3264
  6142. data := make(map[string]interface{})
  6143. data["org_name"] = miConfig.OrgName
  6144. data["doctor"] = curRoles.UserName
  6145. data["doctor_name"] = curRoles.UserName
  6146. data["fixmedins_code"] = miConfig.Code
  6147. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6148. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6149. data["secret_key"] = miConfig.SecretKey
  6150. data["url"] = miConfig.Url
  6151. data["ak"] = miConfig.AccessKey
  6152. data["cainfo"] = miConfig.Cainfo
  6153. data["setl_mon"] = stmt_mon
  6154. month := time.Unix(1557042972, 0).Format("1")
  6155. year := time.Now().Format("2006")
  6156. month = time.Now().Format("01")
  6157. day := time.Now().Format("02")
  6158. hour := time.Now().Format("15")
  6159. min := time.Now().Format("04")
  6160. sec := time.Now().Format("05")
  6161. fix_fill_date := year + month + day + hour + min + sec
  6162. data["fix_fill_dept"] = miConfig.OrgName
  6163. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6164. data["fix_fill_psn"] = curRoles.UserName
  6165. data["fix_fill_date"] = fix_fill_date
  6166. data["stmt_loc"] = "2"
  6167. upld_btch = "0"
  6168. data["upld_btch"] = upld_btch
  6169. client := &http.Client{}
  6170. bytesData, _ := json.Marshal(data)
  6171. var req *http.Request
  6172. if miConfig.MdtrtareaAdmvs == "320921" {
  6173. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6174. } else {
  6175. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6176. }
  6177. resp, _ := client.Do(req)
  6178. defer resp.Body.Close()
  6179. body, ioErr := ioutil.ReadAll(resp.Body)
  6180. if ioErr != nil {
  6181. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6183. }
  6184. var respJSON map[string]interface{}
  6185. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6188. }
  6189. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6190. fmt.Println(respJSON)
  6191. result, _ := json.Marshal(respJSON)
  6192. fmt.Println(result)
  6193. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6194. utils.ErrorLog("解析失败:%v", err)
  6195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6196. }
  6197. if result3265.Infcode != "0" {
  6198. c.ServeSuccessJSON(map[string]interface{}{
  6199. "failed_code": -10,
  6200. "msg": result3265.ErrMsg,
  6201. })
  6202. return
  6203. } else {
  6204. c.ServeSuccessJSON(map[string]interface{}{
  6205. "info": result3265.Output,
  6206. })
  6207. return
  6208. }
  6209. }
  6210. func (c *HisApiController) Get3267() {
  6211. admin_user_id, _ := c.GetInt64("admin_user_id")
  6212. startTime := c.GetString("start_time")
  6213. //endTime, _ := c.GetString("end_time")
  6214. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6215. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6216. times := strings.Split(startTime, "-")
  6217. setl_mon := times[0] + times[1]
  6218. var upld_btch string
  6219. //var empty models.JSResultEmpty
  6220. var result3265 models.JSResult3264
  6221. upld_btch = "0"
  6222. data := make(map[string]interface{})
  6223. data["org_name"] = miConfig.OrgName
  6224. data["doctor"] = curRoles.UserName
  6225. data["doctor_name"] = curRoles.UserName
  6226. data["fixmedins_code"] = miConfig.Code
  6227. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6228. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6229. data["secret_key"] = miConfig.SecretKey
  6230. data["url"] = miConfig.Url
  6231. data["ak"] = miConfig.AccessKey
  6232. data["cainfo"] = miConfig.Cainfo
  6233. data["setl_mon"] = setl_mon
  6234. data["stmt_loc"] = "2"
  6235. data["upld_btch"] = upld_btch
  6236. client := &http.Client{}
  6237. bytesData, _ := json.Marshal(data)
  6238. var req *http.Request
  6239. if miConfig.MdtrtareaAdmvs == "320921" {
  6240. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6241. } else {
  6242. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6243. }
  6244. resp, _ := client.Do(req)
  6245. defer resp.Body.Close()
  6246. body, ioErr := ioutil.ReadAll(resp.Body)
  6247. if ioErr != nil {
  6248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6250. }
  6251. var respJSON map[string]interface{}
  6252. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6255. }
  6256. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6257. fmt.Println(respJSON)
  6258. result, _ := json.Marshal(respJSON)
  6259. fmt.Println(result)
  6260. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6261. utils.ErrorLog("解析失败:%v", err)
  6262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6263. }
  6264. if result3265.Infcode != "0" {
  6265. c.ServeSuccessJSON(map[string]interface{}{
  6266. "failed_code": -10,
  6267. "msg": result3265.ErrMsg,
  6268. })
  6269. return
  6270. } else {
  6271. c.ServeSuccessJSON(map[string]interface{}{
  6272. "info": result3265.Output.Data,
  6273. })
  6274. return
  6275. }
  6276. }
  6277. func (c *HisApiController) Get3268() {
  6278. admin_user_id, _ := c.GetInt64("admin_user_id")
  6279. startTime := c.GetString("start_time")
  6280. endTime := c.GetString("end_time")
  6281. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6282. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6283. times := strings.Split(startTime, "-")
  6284. setl_mon := times[0] + times[1]
  6285. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6286. var twos []models.FixMonRecDetailFileInTwo
  6287. var funs []models.FundDetail
  6288. for _, item := range datas {
  6289. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6290. funs = append(funs, fun...)
  6291. }
  6292. var funInfos []models.Fund
  6293. //for _, item := range funs {
  6294. // var rf []models.FundInfo
  6295. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6296. // for _, subitem := range rf {
  6297. // var fund models.Fund
  6298. // fund.FundCode = subitem.FundPayType
  6299. // fund.FundName = subitem.FundPayTypeName
  6300. // fund.FundAmt = subitem.FundPayAmt
  6301. // fund.FundKey = item.FundKey
  6302. // fund.InsuAdmdvs = "555555"
  6303. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6304. // funInfos = append(funInfos, fund)
  6305. // }
  6306. //}
  6307. for _, team := range datas {
  6308. var two models.FixMonRecDetailFileInTwo
  6309. two.SetlDate = time.Now().Format("2006-01-02")
  6310. two.MedType = team.MedType
  6311. two.Insutype = team.Insutype
  6312. two.PsnType = team.PsnType
  6313. two.MedType = team.MedType
  6314. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6315. two.InsuAdmdvs = team.InsuAdmdvs
  6316. two.PsnTime = team.PsnTime
  6317. two.PsnCnt = team.PsnCnt
  6318. two.FundKey = team.FundKey
  6319. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6320. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6321. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6322. two.MedfeeSumAmt = ms
  6323. two.InscpAmt = ia
  6324. two.FundPaySumAmt = fps
  6325. twos = append(twos, two)
  6326. }
  6327. var upld_btch string
  6328. upld_btch = "0"
  6329. var empty models.JSResultEmpty
  6330. data := make(map[string]interface{})
  6331. data["org_name"] = miConfig.OrgName
  6332. data["doctor"] = curRoles.UserName
  6333. data["doctor_name"] = curRoles.UserName
  6334. data["fixmedins_code"] = miConfig.Code
  6335. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6336. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6337. data["secret_key"] = miConfig.SecretKey
  6338. data["url"] = miConfig.Url
  6339. data["ak"] = miConfig.AccessKey
  6340. data["cainfo"] = miConfig.Cainfo
  6341. data["datas"] = twos
  6342. data["fund"] = funInfos
  6343. data["setl_mon"] = setl_mon
  6344. month := time.Unix(1557042972, 0).Format("1")
  6345. year := time.Now().Format("2006")
  6346. month = time.Now().Format("01")
  6347. day := time.Now().Format("02")
  6348. hour := time.Now().Format("15")
  6349. min := time.Now().Format("04")
  6350. sec := time.Now().Format("05")
  6351. fix_fill_date := year + month + day + hour + min + sec
  6352. data["fix_fill_dept"] = miConfig.OrgName
  6353. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6354. data["fix_fill_psn"] = curRoles.UserName
  6355. data["fix_fill_date"] = fix_fill_date
  6356. data["stmt_loc"] = "2"
  6357. data["upld_btch"] = upld_btch
  6358. client := &http.Client{}
  6359. bytesData, _ := json.Marshal(data)
  6360. var req *http.Request
  6361. if miConfig.MdtrtareaAdmvs == "320921" {
  6362. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6363. } else {
  6364. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6365. }
  6366. resp, _ := client.Do(req)
  6367. defer resp.Body.Close()
  6368. body, ioErr := ioutil.ReadAll(resp.Body)
  6369. if ioErr != nil {
  6370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6372. }
  6373. var respJSON map[string]interface{}
  6374. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6377. }
  6378. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6379. fmt.Println(respJSON)
  6380. result, _ := json.Marshal(respJSON)
  6381. fmt.Println(result)
  6382. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6383. utils.ErrorLog("解析失败:%v", err)
  6384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6385. }
  6386. if empty.Infcode != "0" {
  6387. c.ServeSuccessJSON(map[string]interface{}{
  6388. "failed_code": -10,
  6389. "msg": empty.ErrMsg,
  6390. })
  6391. return
  6392. } else {
  6393. c.ServeSuccessJSON(map[string]interface{}{
  6394. "msg": "上传成功",
  6395. })
  6396. return
  6397. }
  6398. }
  6399. func (c *HisApiController) Get3269() {
  6400. admin_user_id, _ := c.GetInt64("admin_user_id")
  6401. startTime := c.GetString("start_time")
  6402. //endTime, _ := c.GetString("end_time")
  6403. times := strings.Split(startTime, "-")
  6404. setl_mon := times[0] + times[1]
  6405. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6406. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6407. var result3263 models.JSResult3263
  6408. data := make(map[string]interface{})
  6409. data["org_name"] = miConfig.OrgName
  6410. data["doctor"] = curRoles.UserName
  6411. data["doctor_name"] = curRoles.UserName
  6412. data["fixmedins_code"] = miConfig.Code
  6413. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6414. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6415. data["secret_key"] = miConfig.SecretKey
  6416. data["url"] = miConfig.Url
  6417. data["ak"] = miConfig.AccessKey
  6418. data["cainfo"] = miConfig.Cainfo
  6419. data["setl_mon"] = setl_mon
  6420. data["stmt_loc"] = "2"
  6421. client := &http.Client{}
  6422. bytesData, _ := json.Marshal(data)
  6423. var req *http.Request
  6424. if miConfig.MdtrtareaAdmvs == "320921" {
  6425. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6426. } else {
  6427. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6428. }
  6429. resp, _ := client.Do(req)
  6430. defer resp.Body.Close()
  6431. body, ioErr := ioutil.ReadAll(resp.Body)
  6432. if ioErr != nil {
  6433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6435. }
  6436. var respJSON map[string]interface{}
  6437. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6438. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6440. }
  6441. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6442. fmt.Println(respJSON)
  6443. result, _ := json.Marshal(respJSON)
  6444. fmt.Println(result)
  6445. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6446. utils.ErrorLog("解析失败:%v", err)
  6447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6448. }
  6449. if result3263.Infcode != "0" {
  6450. c.ServeSuccessJSON(map[string]interface{}{
  6451. "failed_code": -10,
  6452. "msg": result3263.ErrMsg,
  6453. })
  6454. return
  6455. } else {
  6456. c.ServeSuccessJSON(map[string]interface{}{
  6457. "msg": "上传成功",
  6458. })
  6459. return
  6460. }
  6461. }
  6462. func (c *HisApiController) Get3270() {
  6463. admin_user_id, _ := c.GetInt64("admin_user_id")
  6464. startTime := c.GetString("start_time")
  6465. //endTime, _ := c.GetString("end_time")
  6466. times := strings.Split(startTime, "-")
  6467. setl_mon := times[0] + times[1]
  6468. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6469. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6470. var result3263 models.JSResult3263
  6471. data2 := make(map[string]interface{})
  6472. data2["org_name"] = miConfig.OrgName
  6473. data2["doctor"] = curRoles.UserName
  6474. data2["doctor_name"] = curRoles.UserName
  6475. data2["fixmedins_code"] = miConfig.Code
  6476. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6477. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6478. data2["secret_key"] = miConfig.SecretKey
  6479. data2["url"] = miConfig.Url
  6480. data2["ak"] = miConfig.AccessKey
  6481. data2["cainfo"] = miConfig.Cainfo
  6482. data2["setl_mon"] = setl_mon
  6483. data2["stmt_loc"] = "2"
  6484. client2 := &http.Client{}
  6485. bytesData2, _ := json.Marshal(data2)
  6486. var req3263 *http.Request
  6487. if miConfig.MdtrtareaAdmvs == "320921" {
  6488. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6489. } else {
  6490. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6491. }
  6492. resp2, _ := client2.Do(req3263)
  6493. defer resp2.Body.Close()
  6494. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6495. if ioErr2 != nil {
  6496. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6498. }
  6499. var respJSON3263 map[string]interface{}
  6500. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6503. }
  6504. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6505. fmt.Println(respJSON3263)
  6506. result2, _ := json.Marshal(respJSON3263)
  6507. fmt.Println(result2)
  6508. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6509. utils.ErrorLog("解析失败:%v", err)
  6510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6511. }
  6512. var ids []string
  6513. for _, item := range result3263.Output {
  6514. ids = append(ids, item.SolidifyID)
  6515. }
  6516. var result3264 models.JSResult3264
  6517. data := make(map[string]interface{})
  6518. data["org_name"] = miConfig.OrgName
  6519. data["doctor"] = curRoles.UserName
  6520. data["doctor_name"] = curRoles.UserName
  6521. data["fixmedins_code"] = miConfig.Code
  6522. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6523. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6524. data["secret_key"] = miConfig.SecretKey
  6525. data["url"] = miConfig.Url
  6526. data["ak"] = miConfig.AccessKey
  6527. data["cainfo"] = miConfig.Cainfo
  6528. data["setl_mon"] = setl_mon
  6529. data["stmt_loc"] = "2"
  6530. data["solidify_id"] = ids
  6531. client := &http.Client{}
  6532. bytesData, _ := json.Marshal(data)
  6533. var req *http.Request
  6534. if miConfig.MdtrtareaAdmvs == "320921" {
  6535. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6536. } else {
  6537. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6538. }
  6539. resp, _ := client.Do(req)
  6540. defer resp.Body.Close()
  6541. body, ioErr := ioutil.ReadAll(resp.Body)
  6542. if ioErr != nil {
  6543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6545. }
  6546. var respJSON map[string]interface{}
  6547. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6550. }
  6551. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6552. fmt.Println(respJSON)
  6553. result, _ := json.Marshal(respJSON)
  6554. fmt.Println(result)
  6555. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  6556. utils.ErrorLog("解析失败:%v", err)
  6557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6558. }
  6559. if result3264.Infcode != "0" {
  6560. c.ServeSuccessJSON(map[string]interface{}{
  6561. "failed_code": -10,
  6562. "msg": result3264.ErrMsg,
  6563. })
  6564. return
  6565. } else {
  6566. c.ServeSuccessJSON(map[string]interface{}{
  6567. "info": result3264.Output,
  6568. })
  6569. return
  6570. }
  6571. }
  6572. func (c *HisApiController) Get3271() {
  6573. admin_user_id, _ := c.GetInt64("admin_user_id")
  6574. startTime := c.GetString("start_time")
  6575. //endTime, _ := c.GetString("end_time")
  6576. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6577. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6578. times := strings.Split(startTime, "-")
  6579. setl_mon := times[0] + times[1]
  6580. //var empty models.JSResultEmpty
  6581. var result3265 models.JSResult3264
  6582. var result3263 models.JSResult3263
  6583. data2 := make(map[string]interface{})
  6584. data2["org_name"] = miConfig.OrgName
  6585. data2["doctor"] = curRoles.UserName
  6586. data2["doctor_name"] = curRoles.UserName
  6587. data2["fixmedins_code"] = miConfig.Code
  6588. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6589. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6590. data2["secret_key"] = miConfig.SecretKey
  6591. data2["url"] = miConfig.Url
  6592. data2["ak"] = miConfig.AccessKey
  6593. data2["cainfo"] = miConfig.Cainfo
  6594. data2["setl_mon"] = setl_mon
  6595. data2["stmt_loc"] = "2"
  6596. client2 := &http.Client{}
  6597. bytesData2, _ := json.Marshal(data2)
  6598. var req3263 *http.Request
  6599. if miConfig.MdtrtareaAdmvs == "320921" {
  6600. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6601. } else {
  6602. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6603. }
  6604. resp2, _ := client2.Do(req3263)
  6605. defer resp2.Body.Close()
  6606. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6607. if ioErr2 != nil {
  6608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6610. }
  6611. var respJSON3263 map[string]interface{}
  6612. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6613. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6615. }
  6616. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6617. fmt.Println(respJSON3263)
  6618. result2, _ := json.Marshal(respJSON3263)
  6619. fmt.Println(result2)
  6620. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6621. utils.ErrorLog("解析失败:%v", err)
  6622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6623. }
  6624. var ids []string
  6625. for _, item := range result3263.Output {
  6626. ids = append(ids, item.SolidifyID)
  6627. }
  6628. data := make(map[string]interface{})
  6629. data["org_name"] = miConfig.OrgName
  6630. data["doctor"] = curRoles.UserName
  6631. data["doctor_name"] = curRoles.UserName
  6632. data["fixmedins_code"] = miConfig.Code
  6633. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6634. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6635. data["secret_key"] = miConfig.SecretKey
  6636. data["url"] = miConfig.Url
  6637. data["ak"] = miConfig.AccessKey
  6638. data["cainfo"] = miConfig.Cainfo
  6639. data["setl_mon"] = setl_mon
  6640. data["solidify_id"] = ids
  6641. month := time.Unix(1557042972, 0).Format("1")
  6642. year := time.Now().Format("2006")
  6643. month = time.Now().Format("01")
  6644. day := time.Now().Format("02")
  6645. hour := time.Now().Format("15")
  6646. min := time.Now().Format("04")
  6647. sec := time.Now().Format("05")
  6648. fix_fill_date := year + month + day + hour + min + sec
  6649. data["fix_fill_dept"] = miConfig.OrgName
  6650. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6651. data["fix_fill_psn"] = curRoles.UserName
  6652. data["fix_fill_date"] = fix_fill_date
  6653. data["stmt_loc"] = "2"
  6654. client := &http.Client{}
  6655. bytesData, _ := json.Marshal(data)
  6656. var req *http.Request
  6657. if miConfig.MdtrtareaAdmvs == "320921" {
  6658. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6659. } else {
  6660. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6661. }
  6662. resp, _ := client.Do(req)
  6663. defer resp.Body.Close()
  6664. body, ioErr := ioutil.ReadAll(resp.Body)
  6665. if ioErr != nil {
  6666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6668. }
  6669. var respJSON map[string]interface{}
  6670. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6673. }
  6674. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6675. fmt.Println(respJSON)
  6676. result, _ := json.Marshal(respJSON)
  6677. fmt.Println(result)
  6678. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6679. utils.ErrorLog("解析失败:%v", err)
  6680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6681. }
  6682. if result3265.Infcode != "0" {
  6683. c.ServeSuccessJSON(map[string]interface{}{
  6684. "failed_code": -10,
  6685. "msg": result3265.ErrMsg,
  6686. })
  6687. return
  6688. } else {
  6689. c.ServeSuccessJSON(map[string]interface{}{
  6690. "info": result3265.Output.Data,
  6691. })
  6692. return
  6693. }
  6694. }
  6695. func (c *HisApiController) Get3272() {
  6696. admin_user_id, _ := c.GetInt64("admin_user_id")
  6697. startTime := c.GetString("start_time")
  6698. //endTime, _ := c.GetString("end_time")
  6699. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6700. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6701. times := strings.Split(startTime, "-")
  6702. setl_mon := times[0] + times[1]
  6703. var upld_btch string
  6704. //var empty models.JSResultEmpty
  6705. var result3265 models.JSResult3264
  6706. data := make(map[string]interface{})
  6707. data["org_name"] = miConfig.OrgName
  6708. data["doctor"] = curRoles.UserName
  6709. data["doctor_name"] = curRoles.UserName
  6710. data["fixmedins_code"] = miConfig.Code
  6711. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6712. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6713. data["secret_key"] = miConfig.SecretKey
  6714. data["url"] = miConfig.Url
  6715. data["ak"] = miConfig.AccessKey
  6716. data["cainfo"] = miConfig.Cainfo
  6717. data["setl_mon"] = setl_mon
  6718. month := time.Unix(1557042972, 0).Format("1")
  6719. year := time.Now().Format("2006")
  6720. month = time.Now().Format("01")
  6721. day := time.Now().Format("02")
  6722. hour := time.Now().Format("15")
  6723. min := time.Now().Format("04")
  6724. sec := time.Now().Format("05")
  6725. fix_fill_date := year + month + day + hour + min + sec
  6726. data["fix_fill_dept"] = miConfig.OrgName
  6727. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6728. data["fix_fill_psn"] = curRoles.UserName
  6729. data["fix_fill_date"] = fix_fill_date
  6730. data["stmt_loc"] = "2"
  6731. data["upld_btch"] = upld_btch
  6732. client := &http.Client{}
  6733. bytesData, _ := json.Marshal(data)
  6734. var req *http.Request
  6735. if miConfig.MdtrtareaAdmvs == "320921" {
  6736. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  6737. } else {
  6738. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  6739. }
  6740. resp, _ := client.Do(req)
  6741. defer resp.Body.Close()
  6742. body, ioErr := ioutil.ReadAll(resp.Body)
  6743. if ioErr != nil {
  6744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6746. }
  6747. var respJSON map[string]interface{}
  6748. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6751. }
  6752. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6753. fmt.Println(respJSON)
  6754. result, _ := json.Marshal(respJSON)
  6755. fmt.Println(result)
  6756. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6757. utils.ErrorLog("解析失败:%v", err)
  6758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6759. }
  6760. if result3265.Infcode != "0" {
  6761. c.ServeSuccessJSON(map[string]interface{}{
  6762. "failed_code": -10,
  6763. "msg": result3265.ErrMsg,
  6764. })
  6765. return
  6766. } else {
  6767. c.ServeSuccessJSON(map[string]interface{}{
  6768. "info": result3265.Output,
  6769. })
  6770. return
  6771. }
  6772. }
  6773. func (c *HisApiController) Get3273() {
  6774. admin_user_id, _ := c.GetInt64("admin_user_id")
  6775. startTime := c.GetString("start_time")
  6776. //endTime, _ := c.GetString("end_time")
  6777. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6778. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6779. times := strings.Split(startTime, "-")
  6780. setl_mon := times[0] + times[1]
  6781. var result3265 models.JSResult3264
  6782. data := make(map[string]interface{})
  6783. data["org_name"] = miConfig.OrgName
  6784. data["doctor"] = curRoles.UserName
  6785. data["doctor_name"] = curRoles.UserName
  6786. data["fixmedins_code"] = miConfig.Code
  6787. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6788. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6789. data["secret_key"] = miConfig.SecretKey
  6790. data["url"] = miConfig.Url
  6791. data["ak"] = miConfig.AccessKey
  6792. data["cainfo"] = miConfig.Cainfo
  6793. data["setl_mon"] = setl_mon
  6794. data["stmt_loc"] = "2"
  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/3273", bytes.NewReader(bytesData))
  6800. } else {
  6801. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", 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{})["request_log"].(map[string]interface{})
  6816. fmt.Println(respJSON)
  6817. result, _ := json.Marshal(respJSON)
  6818. fmt.Println(result)
  6819. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6820. utils.ErrorLog("解析失败:%v", err)
  6821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6822. }
  6823. if result3265.Infcode != "0" {
  6824. c.ServeSuccessJSON(map[string]interface{}{
  6825. "failed_code": -10,
  6826. "msg": result3265.ErrMsg,
  6827. })
  6828. return
  6829. } else {
  6830. c.ServeSuccessJSON(map[string]interface{}{
  6831. "info": result3265.Output.Data,
  6832. })
  6833. return
  6834. }
  6835. }
  6836. func (c *HisApiController) Get3274() {
  6837. //if miConfig.MdtrtareaAdmvs == "320921" {
  6838. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6839. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6840. // "&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
  6841. //
  6842. //} else {
  6843. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6844. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6845. // "&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
  6846. //
  6847. //}
  6848. }
  6849. func (c *HisApiController) Get3275() {
  6850. //if miConfig.MdtrtareaAdmvs == "320921" {
  6851. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6852. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6853. // "&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
  6854. //
  6855. //} else {
  6856. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6857. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6858. // "&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
  6859. //
  6860. //}
  6861. }
  6862. func (c *HisApiController) Get3276() {
  6863. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6864. //month := c.GetString("month")
  6865. //
  6866. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6867. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6868. //var api string
  6869. //var res Result5301
  6870. //
  6871. //if miConfig.MdtrtareaAdmvs == "320921" {
  6872. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6873. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6874. //} else {
  6875. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6876. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6877. //}
  6878. //
  6879. //resp, requestErr := http.Get(api)
  6880. //if requestErr != nil {
  6881. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6882. // return
  6883. //}
  6884. //
  6885. //body, ioErr := ioutil.ReadAll(resp.Body)
  6886. //if ioErr != nil {
  6887. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6888. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6889. // return
  6890. //}
  6891. //var respJSON map[string]interface{}
  6892. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6893. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6894. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6895. // return
  6896. //}
  6897. //
  6898. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6899. //result, _ := json.Marshal(respJSON)
  6900. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6901. // utils.ErrorLog("解析失败:%v", err)
  6902. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6903. // return
  6904. //}
  6905. }
  6906. func (c *HisApiController) Get3277() {
  6907. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6908. //month := c.GetString("month")
  6909. //
  6910. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6911. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6912. //var api string
  6913. //var res Result5301
  6914. //
  6915. //if miConfig.MdtrtareaAdmvs == "320921" {
  6916. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6917. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6918. //} else {
  6919. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6920. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6921. //}
  6922. //
  6923. //resp, requestErr := http.Get(api)
  6924. //if requestErr != nil {
  6925. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6926. // return
  6927. //}
  6928. //
  6929. //body, ioErr := ioutil.ReadAll(resp.Body)
  6930. //if ioErr != nil {
  6931. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6933. // return
  6934. //}
  6935. //var respJSON map[string]interface{}
  6936. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6937. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6938. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6939. // return
  6940. //}
  6941. //
  6942. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6943. //result, _ := json.Marshal(respJSON)
  6944. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6945. // utils.ErrorLog("解析失败:%v", err)
  6946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6947. // return
  6948. //}
  6949. }
  6950. func (c *HisApiController) GetCFYLJG001() {
  6951. admin_user_id, _ := c.GetInt64("admin_user_id")
  6952. patient_id, _ := c.GetInt64("patient_id")
  6953. his_patient_id, _ := c.GetInt64("his_patient_id")
  6954. record_time := c.GetString("record_time")
  6955. admin_user_id = 3626
  6956. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6957. psn, _ := service.GetPsnByPatientId(patient_id)
  6958. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6959. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6960. var cFYLJG001 models.CFYLJG001
  6961. timeLayout := "2006-01-02"
  6962. loc, _ := time.LoadLocation("Local")
  6963. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6964. if err != nil {
  6965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6966. return
  6967. }
  6968. recordDateTime := theTime.Unix()
  6969. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6970. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6971. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6972. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  6973. //dept, _ := service.GetDepartMentDetail(info.Departments)
  6974. for _, item := range prescriptions {
  6975. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  6976. if his.IdCardType == 1 {
  6977. bas := strings.Split(psn.CardInfo, "|")
  6978. basNumber := bas[1]
  6979. fmt.Println(basNumber)
  6980. card_sn := bas[3]
  6981. card_no := bas[2]
  6982. cFYLJG001.MdtrtCertType = "03"
  6983. cFYLJG001.CardSn = card_sn
  6984. cFYLJG001.MdtrtCertNo = card_no
  6985. cFYLJG001.EcToken = ""
  6986. cFYLJG001.AuthNo = ""
  6987. } else if his.IdCardType == 2 {
  6988. cFYLJG001.MdtrtCertType = "02"
  6989. cFYLJG001.CardSn = ""
  6990. cFYLJG001.MdtrtCertNo = his.IdCardNo
  6991. cFYLJG001.EcToken = ""
  6992. cFYLJG001.AuthNo = ""
  6993. } else if his.IdCardType == 4 {
  6994. cFYLJG001.MdtrtCertType = "01"
  6995. cFYLJG001.CardSn = ""
  6996. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  6997. cFYLJG001.EcToken = psn.VerifyNumber
  6998. cFYLJG001.AuthNo = ""
  6999. }
  7000. cFYLJG001.BizTypeCode = "01"
  7001. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7002. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7003. cFYLJG001.RxTypeCode = "1"
  7004. tempTime := time.Unix(item.PreTime, 0)
  7005. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7006. cFYLJG001.PrscTime = timeFormatOne
  7007. var count float64
  7008. if item.Type == 1 {
  7009. for _, sumItem := range item.HisDoctorAdviceInfo {
  7010. count = count + sumItem.PrescribingNumber
  7011. }
  7012. }
  7013. cFYLJG001.RxDrugCnt = count
  7014. cFYLJG001.ValiDays = "5"
  7015. ts := time.Unix(item.PreTime, 0)
  7016. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7017. tempTime3 := time.Unix(record_time2, 0)
  7018. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7019. cFYLJG001.ValiEndTime = timeFormat3
  7020. cFYLJG001.RxCotnFlag = "0"
  7021. for _, subItem := range item.HisDoctorAdviceInfo {
  7022. var drug models.RxDrug
  7023. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7024. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7025. drug.RxItemTypeCode = "11"
  7026. drug.DrugDosform = "乳膏剂" //TODO
  7027. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7028. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7029. }
  7030. drug.MedcWayDscr = subItem.DeliveryWay
  7031. tempTime2 := time.Unix(subItem.StartTime, 0)
  7032. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7033. drug.MedcBegntime = timeFormatTwo
  7034. if subItem.Day > 0 {
  7035. ts := time.Unix(subItem.StartTime, 0)
  7036. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7037. tempTime4 := time.Unix(record_time, 0)
  7038. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7039. drug.MedcEndtime = timeFormat5
  7040. } else {
  7041. tempTime2 := time.Unix(subItem.StartTime, 0)
  7042. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7043. drug.MedcEndtime = timeFormatTwo
  7044. }
  7045. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7046. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7047. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7048. drug.DrugCnt = subItem.PrescribingNumber
  7049. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7050. drug.DrugGenname = subItem.AdviceName
  7051. drug.MedcWayCodg = subItem.DeliveryWay
  7052. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7053. drug.SinDoscnt = subItem.SingleDose
  7054. drug.SinDosunt = subItem.SingleDoseUnit
  7055. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7056. drug.UsedFrquName = subItem.ExecutionFrequency
  7057. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7058. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7059. drug.HospApprFlag = "1"
  7060. cFYLJG001.List = append(cFYLJG001.List, drug)
  7061. }
  7062. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7063. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7064. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7065. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7066. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7067. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7068. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7069. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7070. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7071. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7072. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7073. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7074. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7075. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7076. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7077. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7078. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7079. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7080. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7081. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7082. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7083. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7084. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7085. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7086. tempTime2 := time.Now().Unix()
  7087. tempTime6 := time.Unix(tempTime2, 0)
  7088. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7089. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7090. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7091. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7092. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7093. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7094. //memo := make(map[string]interface{})
  7095. //inputData := make(map[string]interface{}, 0)
  7096. //type MyData struct {
  7097. // Insutype string `json:"insutype"`
  7098. //}
  7099. //
  7100. // data := MyData{
  7101. // Insutype: his.Insutype,
  7102. //}
  7103. //
  7104. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7105. var config []*models.HisXtDiagnoseConfig
  7106. for _, item := range diagnosis_ids {
  7107. id, _ := strconv.ParseInt(item, 10, 64)
  7108. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7109. config = append(config, &diagnosisConfig)
  7110. }
  7111. for index, subitem := range config {
  7112. if index == 0 {
  7113. var dia models.DiseInfo
  7114. dia.DiagType = "1"
  7115. dia.MaindiagFlag = "1"
  7116. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7117. dia.DiagCode = subitem.CountryCode
  7118. dia.DiagName = subitem.ClassName
  7119. dia.DiagDept = "肾内科"
  7120. dia.DiagDrNo = doctor.DoctorNumber
  7121. dia.DiagDrName = doctor.UserName
  7122. tempTime3 := time.Unix(item.PreTime, 0)
  7123. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7124. dia.DiagTime = timeFormatTwo
  7125. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7126. } else {
  7127. var dia models.DiseInfo
  7128. dia.DiagType = "1"
  7129. dia.MaindiagFlag = "0"
  7130. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7131. dia.DiagCode = subitem.CountryCode
  7132. dia.DiagName = subitem.ClassName
  7133. dia.DiagDept = "肾内科"
  7134. dia.DiagDrNo = doctor.DoctorNumber
  7135. dia.DiagDrName = doctor.UserName
  7136. tempTime3 := time.Unix(item.PreTime, 0)
  7137. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7138. dia.DiagTime = timeFormatTwo
  7139. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7140. }
  7141. }
  7142. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7143. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7144. var res ResultCFYLJG001
  7145. var respJSON2 map[string]interface{}
  7146. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7149. return
  7150. }
  7151. userJSONBytes2, _ := json.Marshal(respJSON2)
  7152. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7153. utils.ErrorLog("解析失败:%v", err)
  7154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7155. return
  7156. }
  7157. if res.Infcode == -1 {
  7158. c.ServeSuccessJSON(map[string]interface{}{
  7159. "failed_code": -10,
  7160. "msg": res.ErrMsg,
  7161. })
  7162. return
  7163. } else {
  7164. var flow models.HisPrescriptionFlow
  7165. flow.Ctime = time.Now().Unix()
  7166. flow.SignDigest = ""
  7167. flow.RxTraceCode = res.Output.RxTraceCode
  7168. flow.HiRxno = res.Output.HiRxno
  7169. flow.MID = his.Number
  7170. flow.Status = 1
  7171. flow.DCode = doctor_info.DoctorNumber
  7172. flow.OriginalRxFile = ""
  7173. flow.OriginalValue = ""
  7174. flow.SignCertDn = ""
  7175. flow.UserOrgId = 10454
  7176. flow.SignCertSn = ""
  7177. flow.Mtime = time.Now().Unix()
  7178. service.Createflow(&flow)
  7179. c.ServeSuccessJSON(map[string]interface{}{
  7180. "msg": "上传成功",
  7181. })
  7182. }
  7183. }
  7184. }
  7185. func (c *HisApiController) GetCFYLJG002() {
  7186. admin_user_id, _ := c.GetInt64("admin_user_id")
  7187. his_patient_id, _ := c.GetInt64("his_patient_id")
  7188. record_time := c.GetString("record_time")
  7189. admin_user_id = 3626
  7190. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7191. //id, _ := c.GetInt64("id")
  7192. admin_user_id = 3626
  7193. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7194. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7195. flow, _ := service.Getflowtwo(his.Number)
  7196. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7197. //record_time := c.GetString("record_time")
  7198. patient_id, _ := c.GetInt64("patient_id")
  7199. //patient_id = 23834
  7200. //record_time = "2023-09-18"
  7201. timeLayout := "2006-01-02"
  7202. loc, _ := time.LoadLocation("Local")
  7203. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7204. if err != nil {
  7205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7206. return
  7207. }
  7208. recordDateTime := theTime.Unix()
  7209. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7210. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7211. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7212. dept, _ := service.GetDepartMentDetail(info.Departments)
  7213. inputData := make(map[string]interface{})
  7214. inputData["rxTraceCode"] = flow.RxTraceCode
  7215. inputData["hiRxno"] = flow.HiRxno
  7216. inputData["mdtrtId"] = flow.MID
  7217. inputData["patnName"] = his.PsnName
  7218. inputData["psnCertType"] = his.PsnCertType
  7219. inputData["certno"] = his.Certno
  7220. inputData["fixmedinsName"] = miConfig.OrgName
  7221. inputData["fixmedinsCode"] = miConfig.Code
  7222. inputData["drCode"] = doctor_info.DoctorNumber
  7223. inputData["prscDrName"] = doctor_info.UserName
  7224. inputData["pharDeptName"] = dept.Name
  7225. inputData["pharDeptCode"] = dept.Number
  7226. inputData["pharProfttlCodg"] = dept.Name
  7227. inputData["pharProfttlName"] = ""
  7228. inputData["pharCode"] = "HY440309002107"
  7229. inputData["pharCertType"] = "01"
  7230. inputData["pharCertno"] = "430482199408260023"
  7231. inputData["pharName"] = "彭斯遥"
  7232. inputData["pharPracCertNo"] = ""
  7233. tempTime2 := time.Unix(info.Ctime, 0)
  7234. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7235. inputData["pharChkTime"] = timeFormatTwo
  7236. bytesData, _ := json.Marshal(inputData)
  7237. fmt.Println(string(bytesData))
  7238. encoded := base64.StdEncoding.EncodeToString(bytesData)
  7239. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7240. if err != nil {
  7241. fmt.Println("Error reading PDF file:", err)
  7242. return
  7243. }
  7244. // 将 PDF 文件内容进行 Base64 编码
  7245. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7246. fmt.Println(err)
  7247. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7248. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7249. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7250. var res2 Result002
  7251. var respJSON2 map[string]interface{}
  7252. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7255. return
  7256. }
  7257. userJSONBytes2, _ := json.Marshal(respJSON2)
  7258. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7259. utils.ErrorLog("解析失败:%v", err)
  7260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7261. return
  7262. }
  7263. if res2.Infcode == 0 {
  7264. flow.Ctime = time.Now().Unix()
  7265. flow.SignDigest = res2.Output.SignDigest
  7266. flow.RxFile = res2.Output.RxFile
  7267. flow.MID = his.Number
  7268. flow.Status = 1
  7269. flow.DCode = doctor_info.DoctorNumber
  7270. flow.OriginalRxFile = rx_encoded
  7271. flow.OriginalValue = encoded
  7272. flow.SignCertDn = res2.Output.SignCertDn
  7273. flow.SignCertSn = res2.Output.SignCertSn
  7274. flow.Mtime = time.Now().Unix()
  7275. service.Saveflow(flow)
  7276. c.ServeSuccessJSON(map[string]interface{}{
  7277. "msg": "预签名成功",
  7278. })
  7279. } else {
  7280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7281. return
  7282. }
  7283. }
  7284. func (c *HisApiController) GetCFYLJG003() {
  7285. admin_user_id, _ := c.GetInt64("admin_user_id")
  7286. his_patient_id, _ := c.GetInt64("his_patient_id")
  7287. record_time := c.GetString("record_time")
  7288. admin_user_id = 3626
  7289. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7290. //id, _ := c.GetInt64("id")
  7291. admin_user_id = 3626
  7292. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7293. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7294. flow, _ := service.Getflowtwo(his.Number)
  7295. //id = 3
  7296. patient_id, _ := c.GetInt64("patient_id")
  7297. //patient_id = 23834
  7298. //record_time = "2023-09-18"
  7299. timeLayout := "2006-01-02"
  7300. loc, _ := time.LoadLocation("Local")
  7301. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7302. if err != nil {
  7303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7304. return
  7305. }
  7306. recordDateTime := theTime.Unix()
  7307. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7308. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7309. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7310. dept, _ := service.GetDepartMentDetail(info.Departments)
  7311. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7312. var cFYLJG003 models.CFYLJG003
  7313. cFYLJG003.RxTraceCode = flow.RxTraceCode
  7314. cFYLJG003.HiRxno = flow.HiRxno
  7315. cFYLJG003.MdtrtID = flow.MID
  7316. cFYLJG003.PatnName = his.Name
  7317. cFYLJG003.Certno = his.Certno
  7318. cFYLJG003.FixmedinsName = miConfig.OrgName
  7319. cFYLJG003.FixmedinsCode = miConfig.Code
  7320. cFYLJG003.DrCode = doctor_info.DoctorNumber
  7321. cFYLJG003.PrscDrName = doctor_info.UserName
  7322. cFYLJG003.PharDeptName = dept.Name
  7323. cFYLJG003.PharDeptCode = dept.Number
  7324. cFYLJG003.PharCode = "HY440309002107"
  7325. cFYLJG003.PharCertType = "01"
  7326. cFYLJG003.PharCertno = "430482199408260023"
  7327. cFYLJG003.PharName = "彭斯遥"
  7328. cFYLJG003.PsnCertType = "01"
  7329. cFYLJG003.RxFile = flow.RxFile
  7330. cFYLJG003.SignDigest = flow.SignDigest
  7331. cFYLJG003.FixmedinsCode = miConfig.Code
  7332. cFYLJG003.PsnCertType = "01"
  7333. cFYLJG003.PharProfttlCodg = dept.Name
  7334. //inputData["pharProfttlCodg"] =dept.Name
  7335. tempTime2 := time.Unix(info.Ctime, 0)
  7336. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7337. cFYLJG003.PharChkTime = timeFormatTwo
  7338. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7339. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7340. var res ResultCFYLJG003
  7341. var respJSON2 map[string]interface{}
  7342. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7345. return
  7346. }
  7347. userJSONBytes2, _ := json.Marshal(respJSON2)
  7348. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7349. utils.ErrorLog("解析失败:%v", err)
  7350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7351. return
  7352. }
  7353. if res.Infcode == -1 {
  7354. c.ServeSuccessJSON(map[string]interface{}{
  7355. "failed_code": -10,
  7356. "msg": res.ErrMsg,
  7357. })
  7358. return
  7359. } else {
  7360. c.ServeSuccessJSON(map[string]interface{}{
  7361. "info": res.Output,
  7362. })
  7363. }
  7364. }
  7365. func (c *HisApiController) GetCFYLJG004() {
  7366. admin_user_id, _ := c.GetInt64("admin_user_id")
  7367. his_patient_id, _ := c.GetInt64("his_patient_id")
  7368. record_time := c.GetString("record_time")
  7369. admin_user_id = 3626
  7370. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7371. //id, _ := c.GetInt64("id")
  7372. admin_user_id = 3626
  7373. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7374. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7375. flow, _ := service.Getflowtwo(his.Number)
  7376. //id = 3
  7377. patient_id, _ := c.GetInt64("patient_id")
  7378. //patient_id = 23834
  7379. //record_time = "2023-09-18"
  7380. timeLayout := "2006-01-02"
  7381. loc, _ := time.LoadLocation("Local")
  7382. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7383. if err != nil {
  7384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7385. return
  7386. }
  7387. recordDateTime := theTime.Unix()
  7388. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7389. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7390. var cFYLJG004 models.CFYLJG004
  7391. cFYLJG004.HiRxno = flow.HiRxno
  7392. cFYLJG004.FixmedinsCode = miConfig.Code
  7393. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7394. cFYLJG004.UndoDrCertType = "01"
  7395. cFYLJG004.UndoRea = "撤销处方"
  7396. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7397. cFYLJG004.UndoDrName = doctor_info.UserName
  7398. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7399. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7400. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7401. var res ResultCFYLJG004
  7402. var respJSON2 map[string]interface{}
  7403. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7406. return
  7407. }
  7408. userJSONBytes2, _ := json.Marshal(respJSON2)
  7409. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7410. utils.ErrorLog("解析失败:%v", err)
  7411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7412. return
  7413. }
  7414. if res.Infcode == -1 {
  7415. c.ServeSuccessJSON(map[string]interface{}{
  7416. "failed_code": -10,
  7417. "msg": res.ErrMsg,
  7418. })
  7419. return
  7420. } else {
  7421. flow.Status = 0
  7422. service.Saveflow(flow)
  7423. c.ServeSuccessJSON(map[string]interface{}{
  7424. "msg": "撤销成功",
  7425. })
  7426. return
  7427. }
  7428. }
  7429. func (c *HisApiController) GetCFYLJG005() {
  7430. admin_user_id, _ := c.GetInt64("admin_user_id")
  7431. his_patient_id, _ := c.GetInt64("his_patient_id")
  7432. //record_time := c.GetString("record_time")
  7433. admin_user_id = 3626
  7434. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7435. //id, _ := c.GetInt64("id")
  7436. admin_user_id = 3626
  7437. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7438. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7439. flow, _ := service.Getflowtwo(his.Number)
  7440. //id = 3
  7441. var cFYLJG005 models.CFYLJG005
  7442. //patient_id, _ := c.GetInt64("patient_id")
  7443. cFYLJG005.HiRxno = flow.HiRxno
  7444. cFYLJG005.MdtrtID = flow.MID
  7445. cFYLJG005.EcToken = ""
  7446. cFYLJG005.PsnName = his.Name
  7447. cFYLJG005.PsnCertType = "01"
  7448. cFYLJG005.Certno = his.IdCardNo
  7449. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7450. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7451. var res ResultCFYLJG005
  7452. var respJSON2 map[string]interface{}
  7453. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7456. return
  7457. }
  7458. userJSONBytes2, _ := json.Marshal(respJSON2)
  7459. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7460. utils.ErrorLog("解析失败:%v", err)
  7461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7462. return
  7463. }
  7464. if res.Infcode == -1 {
  7465. c.ServeSuccessJSON(map[string]interface{}{
  7466. "failed_code": -10,
  7467. "msg": res.ErrMsg,
  7468. })
  7469. return
  7470. } else {
  7471. c.ServeSuccessJSON(map[string]interface{}{
  7472. "info": res.Output,
  7473. })
  7474. return
  7475. }
  7476. }
  7477. func (c *HisApiController) GetCFYLJG006() {
  7478. admin_user_id, _ := c.GetInt64("admin_user_id")
  7479. his_patient_id, _ := c.GetInt64("his_patient_id")
  7480. admin_user_id = 3626
  7481. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7482. //id, _ := c.GetInt64("id")
  7483. admin_user_id = 3626
  7484. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7485. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7486. flow, _ := service.Getflowtwo(his.Number)
  7487. //id = 3
  7488. patient_id, _ := c.GetInt64("patient_id")
  7489. var cFYLJG006 models.CFYLJG006
  7490. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7491. cFYLJG006.HiRxno = flow.HiRxno
  7492. cFYLJG006.MdtrtID = flow.MID
  7493. cFYLJG006.PsnName = patient.Name
  7494. cFYLJG006.PsnCertType = "01"
  7495. cFYLJG006.Certno = patient.IdCardNo
  7496. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  7497. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  7498. var res ResultCFYLJG006
  7499. var respJSON2 map[string]interface{}
  7500. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7503. return
  7504. }
  7505. userJSONBytes2, _ := json.Marshal(respJSON2)
  7506. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7507. utils.ErrorLog("解析失败:%v", err)
  7508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7509. return
  7510. }
  7511. if res.Infcode == -1 {
  7512. c.ServeSuccessJSON(map[string]interface{}{
  7513. "failed_code": -10,
  7514. "msg": res.ErrMsg,
  7515. })
  7516. return
  7517. } else {
  7518. c.ServeSuccessJSON(map[string]interface{}{
  7519. "info": res.Output,
  7520. })
  7521. return
  7522. }
  7523. }
  7524. func (c *HisApiController) GetCFYLJG007() {
  7525. admin_user_id, _ := c.GetInt64("admin_user_id")
  7526. his_patient_id, _ := c.GetInt64("his_patient_id")
  7527. admin_user_id = 3626
  7528. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7529. //id, _ := c.GetInt64("id")
  7530. admin_user_id = 3626
  7531. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7532. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7533. flow, _ := service.Getflowtwo(his.Number)
  7534. //id = 3
  7535. patient_id, _ := c.GetInt64("patient_id")
  7536. var cFYLJG007 models.CFYLJG007
  7537. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7538. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7539. cFYLJG007.HiRxno = flow.HiRxno
  7540. cFYLJG007.MdtrtID = flow.MID
  7541. cFYLJG007.PsnNo = his.PsnNo
  7542. cFYLJG007.PsnCertType = "01"
  7543. cFYLJG007.Certno = patient.IdCardNo
  7544. cFYLJG007.PsnName = patient.Name
  7545. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  7546. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  7547. var res ResultCFYLJG007
  7548. var respJSON2 map[string]interface{}
  7549. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7552. return
  7553. }
  7554. userJSONBytes2, _ := json.Marshal(respJSON2)
  7555. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7556. utils.ErrorLog("解析失败:%v", err)
  7557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7558. return
  7559. }
  7560. if res.Infcode == -1 {
  7561. c.ServeSuccessJSON(map[string]interface{}{
  7562. "failed_code": -10,
  7563. "msg": res.ErrMsg,
  7564. })
  7565. return
  7566. } else {
  7567. c.ServeSuccessJSON(map[string]interface{}{
  7568. "info": res,
  7569. })
  7570. return
  7571. }
  7572. }
  7573. func (c *HisApiController) GetCFYLJG008() {
  7574. admin_user_id, _ := c.GetInt64("admin_user_id")
  7575. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7576. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7577. var cFYLJG008 models.CFYLJG008
  7578. //id, _ := c.GetInt64("id")
  7579. patient_id, _ := c.GetInt64("patient_id")
  7580. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7581. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7582. //id = 3
  7583. //flow, _ := service.Getflow(id)
  7584. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7585. //
  7586. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7587. //patient_id, _ := c.GetInt64("patient_id")
  7588. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7589. record_time := c.GetString("record_time")
  7590. admin_user_id = 3626
  7591. patient_id = 19424
  7592. //his_patient_id = 263947
  7593. record_time = "2023-08-29"
  7594. timeLayout := "2006-01-02"
  7595. loc, _ := time.LoadLocation("Local")
  7596. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7597. if err != nil {
  7598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7599. return
  7600. }
  7601. recordDateTime := theTime.Unix()
  7602. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7603. cFYLJG008.FixmedinsName = ""
  7604. cFYLJG008.Lat = ""
  7605. cFYLJG008.Lng = ""
  7606. cFYLJG008.OrderType = "1"
  7607. cFYLJG008.PoolareaNo = ""
  7608. cFYLJG008.Lng = ""
  7609. cFYLJG008.PageNum = 1
  7610. cFYLJG008.PageSize = 10
  7611. var MPI models.MedinsProdInvChgDDTO
  7612. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  7613. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  7614. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  7615. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  7616. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  7617. var res ResultCFYLJG008
  7618. var respJSON2 map[string]interface{}
  7619. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7622. return
  7623. }
  7624. userJSONBytes2, _ := json.Marshal(respJSON2)
  7625. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7626. utils.ErrorLog("解析失败:%v", err)
  7627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7628. return
  7629. }
  7630. if res.Infcode == -1 {
  7631. c.ServeSuccessJSON(map[string]interface{}{
  7632. "failed_code": -10,
  7633. "msg": res.ErrMsg,
  7634. })
  7635. return
  7636. } else {
  7637. c.ServeSuccessJSON(map[string]interface{}{
  7638. "info": res.Output,
  7639. })
  7640. return
  7641. }
  7642. }
  7643. func (c *HisApiController) GetBL4201A() {
  7644. order_id, _ := c.GetInt64("order_id")
  7645. admin_user_id, _ := c.GetInt64("admin_user_id")
  7646. order, _ := service.GetHisOrderByIDTwo(order_id)
  7647. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7648. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  7649. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  7650. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7651. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7652. department, _ := service.GetDepartMentDetail(his.Departments)
  7653. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7654. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7655. if order.ID == 0 {
  7656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7657. return
  7658. }
  7659. var struct4201A models.Struct4201A
  7660. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  7661. for _, items := range order_info {
  7662. memo := make(map[string]interface{})
  7663. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7664. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7665. fsiOPFLD.MedType = "14"
  7666. fsiOPFLD.BkkpSn = items.FeedetlSn
  7667. fsiOPFLD.FixmedinsCode = miConfig.Code
  7668. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7669. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7670. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7671. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7672. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7673. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7674. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7675. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7676. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7677. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7678. fsiOPFLD.BilgDeptName = department.Name
  7679. fsiOPFLD.BilgDeptCodg = department.Number
  7680. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7681. fsiOPFLD.BilgDrName = doctor.UserName
  7682. fsiOPFLD.MedChrgitmType = "09"
  7683. memo["hosp_appr_flag"] = "1"
  7684. memo["invoice_no"] = order.MdtrtId
  7685. memo["memo"] = "自费"
  7686. bytesData, _ := json.Marshal(memo)
  7687. fsiOPFLD.Memo = string(bytesData)
  7688. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7689. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7690. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7691. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7692. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7693. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7694. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7695. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7696. fsiOPFLD.BilgDeptName = department.Name
  7697. fsiOPFLD.BilgDeptCodg = department.Number
  7698. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7699. fsiOPFLD.BilgDrName = doctor.UserName
  7700. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7701. case 0:
  7702. break
  7703. case 1:
  7704. fsiOPFLD.MedChrgitmType = "14"
  7705. break
  7706. case 2:
  7707. fsiOPFLD.MedChrgitmType = "05"
  7708. break
  7709. case 3:
  7710. fsiOPFLD.MedChrgitmType = "03"
  7711. break
  7712. case 4:
  7713. fsiOPFLD.MedChrgitmType = "03"
  7714. break
  7715. case 5:
  7716. fsiOPFLD.MedChrgitmType = "08"
  7717. break
  7718. case 6:
  7719. fsiOPFLD.MedChrgitmType = "14"
  7720. break
  7721. case 7:
  7722. fsiOPFLD.MedChrgitmType = "14"
  7723. break
  7724. case 8:
  7725. fsiOPFLD.MedChrgitmType = "03"
  7726. break
  7727. case 9:
  7728. fsiOPFLD.MedChrgitmType = "14"
  7729. break
  7730. case 10:
  7731. fsiOPFLD.MedChrgitmType = "14"
  7732. break
  7733. case 11:
  7734. fsiOPFLD.MedChrgitmType = "06"
  7735. break
  7736. case 12:
  7737. fsiOPFLD.MedChrgitmType = "12"
  7738. break
  7739. case 13:
  7740. fsiOPFLD.MedChrgitmType = "01"
  7741. break
  7742. case 14:
  7743. fsiOPFLD.MedChrgitmType = "04"
  7744. break
  7745. case 15:
  7746. fsiOPFLD.MedChrgitmType = "14"
  7747. break
  7748. }
  7749. memo["hosp_appr_flag"] = "1"
  7750. memo["invoice_no"] = order.MdtrtId
  7751. memo["memo"] = "自费"
  7752. bytesData, _ := json.Marshal(memo)
  7753. fsiOPFLD.Memo = string(bytesData)
  7754. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7755. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  7756. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7757. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7758. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7759. fsiOPFLD.BilgDeptName = department.Name
  7760. fsiOPFLD.BilgDeptCodg = department.Number
  7761. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7762. fsiOPFLD.BilgDrName = doctor.UserName
  7763. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7764. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7765. fsiOPFLD.MedChrgitmType = "08"
  7766. memo["hosp_appr_flag"] = "1"
  7767. memo["invoice_no"] = order.MdtrtId
  7768. memo["memo"] = "自费"
  7769. bytesData, _ := json.Marshal(memo)
  7770. fsiOPFLD.Memo = string(bytesData)
  7771. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7772. }
  7773. }
  7774. }
  7775. for _, items := range order_info_two {
  7776. memo := make(map[string]interface{})
  7777. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7778. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7779. fsiOPFLD.MedType = "14"
  7780. fsiOPFLD.BkkpSn = items.FeedetlSn
  7781. fsiOPFLD.FixmedinsCode = miConfig.Code
  7782. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7783. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7784. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7785. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7786. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7787. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7788. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7789. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7790. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7791. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7792. fsiOPFLD.BilgDeptName = department.Name
  7793. fsiOPFLD.BilgDeptCodg = department.Number
  7794. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7795. fsiOPFLD.BilgDrName = doctor.UserName
  7796. fsiOPFLD.MedChrgitmType = "09"
  7797. memo["hosp_appr_flag"] = "1"
  7798. memo["invoice_no"] = order.MdtrtId
  7799. memo["memo"] = "自费"
  7800. bytesData, _ := json.Marshal(memo)
  7801. fsiOPFLD.Memo = string(bytesData)
  7802. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7803. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7804. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7805. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7806. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7807. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7808. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7809. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7810. fsiOPFLD.BilgDeptName = department.Name
  7811. fsiOPFLD.BilgDeptCodg = department.Number
  7812. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7813. fsiOPFLD.BilgDrName = doctor.UserName
  7814. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7815. case 0:
  7816. break
  7817. case 1:
  7818. fsiOPFLD.MedChrgitmType = "14"
  7819. break
  7820. case 2:
  7821. fsiOPFLD.MedChrgitmType = "05"
  7822. break
  7823. case 3:
  7824. fsiOPFLD.MedChrgitmType = "03"
  7825. break
  7826. case 4:
  7827. fsiOPFLD.MedChrgitmType = "03"
  7828. break
  7829. case 5:
  7830. fsiOPFLD.MedChrgitmType = "08"
  7831. break
  7832. case 6:
  7833. fsiOPFLD.MedChrgitmType = "14"
  7834. break
  7835. case 7:
  7836. fsiOPFLD.MedChrgitmType = "14"
  7837. break
  7838. case 8:
  7839. fsiOPFLD.MedChrgitmType = "03"
  7840. break
  7841. case 9:
  7842. fsiOPFLD.MedChrgitmType = "14"
  7843. break
  7844. case 10:
  7845. fsiOPFLD.MedChrgitmType = "14"
  7846. break
  7847. case 11:
  7848. fsiOPFLD.MedChrgitmType = "06"
  7849. break
  7850. case 12:
  7851. fsiOPFLD.MedChrgitmType = "12"
  7852. break
  7853. case 13:
  7854. fsiOPFLD.MedChrgitmType = "01"
  7855. break
  7856. case 14:
  7857. fsiOPFLD.MedChrgitmType = "04"
  7858. break
  7859. case 15:
  7860. fsiOPFLD.MedChrgitmType = "14"
  7861. break
  7862. }
  7863. memo["hosp_appr_flag"] = "1"
  7864. memo["invoice_no"] = order.MdtrtId
  7865. memo["memo"] = "自费"
  7866. bytesData, _ := json.Marshal(memo)
  7867. fsiOPFLD.Memo = string(bytesData)
  7868. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7869. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  7870. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7871. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7872. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7873. fsiOPFLD.BilgDeptName = department.Name
  7874. fsiOPFLD.BilgDeptCodg = department.Number
  7875. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7876. fsiOPFLD.BilgDrName = doctor.UserName
  7877. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7878. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7879. fsiOPFLD.MedChrgitmType = "08"
  7880. memo["hosp_appr_flag"] = "1"
  7881. memo["invoice_no"] = order.MdtrtId
  7882. memo["memo"] = "自费"
  7883. bytesData, _ := json.Marshal(memo)
  7884. fsiOPFLD.Memo = string(bytesData)
  7885. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7886. }
  7887. }
  7888. }
  7889. fmt.Println(fsiOPFLDs)
  7890. struct4201A.Fopfd = fsiOPFLDs
  7891. fmt.Println(struct4201A.Fopfd)
  7892. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  7893. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  7894. var res2 ResultSix
  7895. var respJSON2 map[string]interface{}
  7896. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7899. return
  7900. }
  7901. userJSONBytes2, _ := json.Marshal(respJSON2)
  7902. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7903. utils.ErrorLog("解析失败:%v", err)
  7904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7905. return
  7906. }
  7907. if res2.Infcode != 0 {
  7908. c.ServeSuccessJSON(map[string]interface{}{
  7909. "failed_code": -10,
  7910. "msg": res2.ErrMsg,
  7911. })
  7912. return
  7913. } else {
  7914. order.IsUploadOrderInfo = 1
  7915. service.UpdateOrder(order)
  7916. c.ServeSuccessJSON(map[string]interface{}{
  7917. "msg": "上传成功",
  7918. })
  7919. }
  7920. }
  7921. func (c *HisApiController) Get2505() {
  7922. admin_user_id, _ := c.GetInt64("admin_user_id")
  7923. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  7924. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7925. 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)
  7926. }
  7927. func (c *HisApiController) Get4201A() {
  7928. order_id, _ := c.GetInt64("order_id")
  7929. admin_user_id, _ := c.GetInt64("admin_user_id")
  7930. order, _ := service.GetHisOrderByIDTwo(order_id)
  7931. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7932. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  7933. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  7934. //order_info = append(order_info, order_info_two...)
  7935. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7936. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7937. department, _ := service.GetDepartMentDetail(his.Departments)
  7938. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7939. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7940. if order.ID == 0 {
  7941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7942. return
  7943. }
  7944. var struct4201A models.Struct4201A
  7945. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  7946. for _, items := range order_info {
  7947. memo := make(map[string]interface{})
  7948. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7949. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7950. fsiOPFLD.MedType = "14"
  7951. fsiOPFLD.BkkpSn = items.FeedetlSn
  7952. fsiOPFLD.FixmedinsCode = miConfig.Code
  7953. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7954. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7955. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7956. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7957. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7958. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7959. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7960. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7961. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7962. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7963. fsiOPFLD.BilgDeptName = department.Name
  7964. fsiOPFLD.BilgDeptCodg = department.Number
  7965. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7966. fsiOPFLD.BilgDrName = doctor.UserName
  7967. fsiOPFLD.MedChrgitmType = "09"
  7968. memo["hosp_appr_flag"] = "1"
  7969. memo["invoice_no"] = order.MdtrtId
  7970. memo["memo"] = "自费"
  7971. bytesData, _ := json.Marshal(memo)
  7972. fsiOPFLD.Memo = string(bytesData)
  7973. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7974. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7975. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7976. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7977. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7978. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7979. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7980. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7981. fsiOPFLD.BilgDeptName = department.Name
  7982. fsiOPFLD.BilgDeptCodg = department.Number
  7983. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7984. fsiOPFLD.BilgDrName = doctor.UserName
  7985. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7986. case 0:
  7987. break
  7988. case 1:
  7989. fsiOPFLD.MedChrgitmType = "14"
  7990. break
  7991. case 2:
  7992. fsiOPFLD.MedChrgitmType = "05"
  7993. break
  7994. case 3:
  7995. fsiOPFLD.MedChrgitmType = "03"
  7996. break
  7997. case 4:
  7998. fsiOPFLD.MedChrgitmType = "03"
  7999. break
  8000. case 5:
  8001. fsiOPFLD.MedChrgitmType = "08"
  8002. break
  8003. case 6:
  8004. fsiOPFLD.MedChrgitmType = "14"
  8005. break
  8006. case 7:
  8007. fsiOPFLD.MedChrgitmType = "14"
  8008. break
  8009. case 8:
  8010. fsiOPFLD.MedChrgitmType = "03"
  8011. break
  8012. case 9:
  8013. fsiOPFLD.MedChrgitmType = "14"
  8014. break
  8015. case 10:
  8016. fsiOPFLD.MedChrgitmType = "14"
  8017. break
  8018. case 11:
  8019. fsiOPFLD.MedChrgitmType = "06"
  8020. break
  8021. case 12:
  8022. fsiOPFLD.MedChrgitmType = "12"
  8023. break
  8024. case 13:
  8025. fsiOPFLD.MedChrgitmType = "01"
  8026. break
  8027. case 14:
  8028. fsiOPFLD.MedChrgitmType = "04"
  8029. break
  8030. case 15:
  8031. fsiOPFLD.MedChrgitmType = "14"
  8032. break
  8033. }
  8034. memo["hosp_appr_flag"] = "1"
  8035. memo["invoice_no"] = order.MdtrtId
  8036. memo["memo"] = "自费"
  8037. bytesData, _ := json.Marshal(memo)
  8038. fsiOPFLD.Memo = string(bytesData)
  8039. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8040. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8041. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8042. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8043. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8044. fsiOPFLD.BilgDeptName = department.Name
  8045. fsiOPFLD.BilgDeptCodg = department.Number
  8046. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8047. fsiOPFLD.BilgDrName = doctor.UserName
  8048. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8049. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8050. fsiOPFLD.MedChrgitmType = "08"
  8051. memo["hosp_appr_flag"] = "1"
  8052. memo["invoice_no"] = order.MdtrtId
  8053. memo["memo"] = "自费"
  8054. bytesData, _ := json.Marshal(memo)
  8055. fsiOPFLD.Memo = string(bytesData)
  8056. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8057. }
  8058. }
  8059. }
  8060. for _, items := range order_info_two {
  8061. memo := make(map[string]interface{})
  8062. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8063. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8064. fsiOPFLD.MedType = "14"
  8065. fsiOPFLD.BkkpSn = items.FeedetlSn
  8066. fsiOPFLD.FixmedinsCode = miConfig.Code
  8067. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8068. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8069. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8070. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8071. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8072. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8073. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8074. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8075. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8076. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8077. fsiOPFLD.BilgDeptName = department.Name
  8078. fsiOPFLD.BilgDeptCodg = department.Number
  8079. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8080. fsiOPFLD.BilgDrName = doctor.UserName
  8081. fsiOPFLD.MedChrgitmType = "09"
  8082. memo["hosp_appr_flag"] = "1"
  8083. memo["invoice_no"] = order.MdtrtId
  8084. memo["memo"] = "自费"
  8085. bytesData, _ := json.Marshal(memo)
  8086. fsiOPFLD.Memo = string(bytesData)
  8087. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8088. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8089. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8090. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8091. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8092. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8093. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8094. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8095. fsiOPFLD.BilgDeptName = department.Name
  8096. fsiOPFLD.BilgDeptCodg = department.Number
  8097. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8098. fsiOPFLD.BilgDrName = doctor.UserName
  8099. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8100. case 0:
  8101. break
  8102. case 1:
  8103. fsiOPFLD.MedChrgitmType = "14"
  8104. break
  8105. case 2:
  8106. fsiOPFLD.MedChrgitmType = "05"
  8107. break
  8108. case 3:
  8109. fsiOPFLD.MedChrgitmType = "03"
  8110. break
  8111. case 4:
  8112. fsiOPFLD.MedChrgitmType = "03"
  8113. break
  8114. case 5:
  8115. fsiOPFLD.MedChrgitmType = "08"
  8116. break
  8117. case 6:
  8118. fsiOPFLD.MedChrgitmType = "14"
  8119. break
  8120. case 7:
  8121. fsiOPFLD.MedChrgitmType = "14"
  8122. break
  8123. case 8:
  8124. fsiOPFLD.MedChrgitmType = "03"
  8125. break
  8126. case 9:
  8127. fsiOPFLD.MedChrgitmType = "14"
  8128. break
  8129. case 10:
  8130. fsiOPFLD.MedChrgitmType = "14"
  8131. break
  8132. case 11:
  8133. fsiOPFLD.MedChrgitmType = "06"
  8134. break
  8135. case 12:
  8136. fsiOPFLD.MedChrgitmType = "12"
  8137. break
  8138. case 13:
  8139. fsiOPFLD.MedChrgitmType = "01"
  8140. break
  8141. case 14:
  8142. fsiOPFLD.MedChrgitmType = "04"
  8143. break
  8144. case 15:
  8145. fsiOPFLD.MedChrgitmType = "14"
  8146. break
  8147. }
  8148. memo["hosp_appr_flag"] = "1"
  8149. memo["invoice_no"] = order.MdtrtId
  8150. memo["memo"] = "自费"
  8151. bytesData, _ := json.Marshal(memo)
  8152. fsiOPFLD.Memo = string(bytesData)
  8153. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8154. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8155. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8156. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8157. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8158. fsiOPFLD.BilgDeptName = department.Name
  8159. fsiOPFLD.BilgDeptCodg = department.Number
  8160. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8161. fsiOPFLD.BilgDrName = doctor.UserName
  8162. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8163. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8164. fsiOPFLD.MedChrgitmType = "08"
  8165. memo["hosp_appr_flag"] = "1"
  8166. memo["invoice_no"] = order.MdtrtId
  8167. memo["memo"] = "自费"
  8168. bytesData, _ := json.Marshal(memo)
  8169. fsiOPFLD.Memo = string(bytesData)
  8170. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8171. }
  8172. }
  8173. }
  8174. fmt.Println(fsiOPFLDs)
  8175. struct4201A.Fopfd = fsiOPFLDs
  8176. fmt.Println(struct4201A.Fopfd)
  8177. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8178. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8179. var res2 ResultSix
  8180. var respJSON2 map[string]interface{}
  8181. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8184. return
  8185. }
  8186. userJSONBytes2, _ := json.Marshal(respJSON2)
  8187. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8188. utils.ErrorLog("解析失败:%v", err)
  8189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8190. return
  8191. }
  8192. if res2.Infcode != 0 {
  8193. c.ServeSuccessJSON(map[string]interface{}{
  8194. "failed_code": -10,
  8195. "msg": res2.ErrMsg,
  8196. })
  8197. return
  8198. } else {
  8199. order.IsUploadOrderInfo = 1
  8200. service.UpdateOrder(order)
  8201. c.ServeSuccessJSON(map[string]interface{}{
  8202. "msg": "上传成功",
  8203. })
  8204. }
  8205. }
  8206. func (c *HisApiController) Get4202() {
  8207. order_id, _ := c.GetInt64("order_id")
  8208. admin_user_id, _ := c.GetInt64("admin_user_id")
  8209. order, _ := service.GetHisOrderByIDTwo(order_id)
  8210. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8211. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8212. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8213. if order.ID == 0 {
  8214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8215. return
  8216. }
  8217. var struct4202 models.Struct4202
  8218. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8219. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8220. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8221. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8222. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8223. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8224. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8225. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8226. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8227. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8228. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8229. var config []*models.HisXtDiagnoseConfig
  8230. for _, item := range diagnosis_ids {
  8231. id, _ := strconv.ParseInt(item, 10, 64)
  8232. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8233. config = append(config, &diagnosisConfig)
  8234. }
  8235. var tempDiaginfos []models.OwnPayPatnDiagListD
  8236. for index, item := range config {
  8237. if index == 0 {
  8238. var tempDiaginfo models.OwnPayPatnDiagListD
  8239. tempDiaginfo.InoutDiagType = "1"
  8240. tempDiaginfo.DiagCode = item.CountryCode
  8241. tempDiaginfo.DiagName = item.CountryContentName
  8242. tempDiaginfo.DiagType = "1"
  8243. tempDiaginfo.DiagSrtNo = "1"
  8244. tempDiaginfo.MaindiagFlag = "1"
  8245. tempDiaginfo.ValiFlag = "1"
  8246. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8247. } else {
  8248. var tempDiaginfo models.OwnPayPatnDiagListD
  8249. tempDiaginfo.DiagCode = item.CountryCode
  8250. tempDiaginfo.DiagName = item.CountryContentName
  8251. tempDiaginfo.DiagType = "2"
  8252. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8253. tempDiaginfo.MaindiagFlag = "0"
  8254. tempDiaginfo.ValiFlag = "1"
  8255. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8256. }
  8257. }
  8258. struct4202.ODiagListD = tempDiaginfos
  8259. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8260. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8261. var res2 ResultSix
  8262. var respJSON2 map[string]interface{}
  8263. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8266. return
  8267. }
  8268. userJSONBytes2, _ := json.Marshal(respJSON2)
  8269. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8270. utils.ErrorLog("解析失败:%v", err)
  8271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8272. return
  8273. }
  8274. if res2.Infcode != 0 {
  8275. c.ServeSuccessJSON(map[string]interface{}{
  8276. "failed_code": -10,
  8277. "msg": res2.ErrMsg,
  8278. })
  8279. return
  8280. } else {
  8281. order.IsUploadDiagnose = 1
  8282. service.UpdateOrder(order)
  8283. c.ServeSuccessJSON(map[string]interface{}{
  8284. "msg": "上传成功",
  8285. })
  8286. }
  8287. }
  8288. func (c *HisApiController) Get4203() {
  8289. admin_user_id, _ := c.GetInt64("admin_user_id")
  8290. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8291. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8292. order_id, _ := c.GetInt64("order_id")
  8293. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8294. number := ""
  8295. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8296. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8297. if his.ID == 0 {
  8298. number = hospital.Number
  8299. } else {
  8300. number = his.Number
  8301. }
  8302. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8303. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8304. var res2 ResultSix
  8305. var respJSON2 map[string]interface{}
  8306. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8309. return
  8310. }
  8311. userJSONBytes2, _ := json.Marshal(respJSON2)
  8312. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8313. utils.ErrorLog("解析失败:%v", err)
  8314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8315. return
  8316. }
  8317. if res2.Infcode != 0 {
  8318. c.ServeSuccessJSON(map[string]interface{}{
  8319. "failed_code": -10,
  8320. "msg": res2.ErrMsg,
  8321. })
  8322. return
  8323. } else {
  8324. order.IsUploadSuccess = 1
  8325. service.UpdateOrderTwo(order)
  8326. c.ServeSuccessJSON(map[string]interface{}{
  8327. "msg": "上传成功",
  8328. })
  8329. }
  8330. }
  8331. func (c *HisApiController) Get4205() {
  8332. order_id, _ := c.GetInt64("order_id")
  8333. admin_user_id, _ := c.GetInt64("admin_user_id")
  8334. fapiao_code := c.GetString("fapiao_code")
  8335. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8336. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8337. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8338. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8339. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8340. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8341. //order_info = append(order_info, order_info_two...)
  8342. department, _ := service.GetDepartMentDetail(his.Departments)
  8343. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8344. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8345. if order.ID == 0 {
  8346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8347. return
  8348. }
  8349. var struct4201A models.Struct4201A
  8350. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8351. for _, items := range order_info {
  8352. memo := make(map[string]interface{})
  8353. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8354. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8355. fsiOPFLD.MedType = pre.MedType
  8356. fsiOPFLD.FixmedinsCode = miConfig.Code
  8357. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8358. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8359. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8360. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8361. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8362. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8363. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8364. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8365. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8366. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8367. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8368. fsiOPFLD.BilgDeptName = department.Name
  8369. fsiOPFLD.BilgDeptCodg = department.Number
  8370. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8371. fsiOPFLD.BilgDrName = doctor.UserName
  8372. fsiOPFLD.MedChrgitmType = "09"
  8373. memo["hosp_appr_flag"] = "1"
  8374. memo["invoice_no"] = fapiao_code
  8375. memo["memo"] = "自费"
  8376. bytesData, _ := json.Marshal(memo)
  8377. fsiOPFLD.Memo = string(bytesData)
  8378. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8379. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8380. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8381. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8382. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8383. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8384. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8385. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8386. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8387. fsiOPFLD.BilgDeptName = department.Name
  8388. fsiOPFLD.BilgDeptCodg = department.Number
  8389. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8390. fsiOPFLD.BilgDrName = doctor.UserName
  8391. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8392. case 0:
  8393. break
  8394. case 1:
  8395. fsiOPFLD.MedChrgitmType = "14"
  8396. break
  8397. case 2:
  8398. fsiOPFLD.MedChrgitmType = "05"
  8399. break
  8400. case 3:
  8401. fsiOPFLD.MedChrgitmType = "03"
  8402. break
  8403. case 4:
  8404. fsiOPFLD.MedChrgitmType = "03"
  8405. break
  8406. case 5:
  8407. fsiOPFLD.MedChrgitmType = "08"
  8408. break
  8409. case 6:
  8410. fsiOPFLD.MedChrgitmType = "14"
  8411. break
  8412. case 7:
  8413. fsiOPFLD.MedChrgitmType = "14"
  8414. break
  8415. case 8:
  8416. fsiOPFLD.MedChrgitmType = "03"
  8417. break
  8418. case 9:
  8419. fsiOPFLD.MedChrgitmType = "14"
  8420. break
  8421. case 10:
  8422. fsiOPFLD.MedChrgitmType = "14"
  8423. break
  8424. case 11:
  8425. fsiOPFLD.MedChrgitmType = "06"
  8426. break
  8427. case 12:
  8428. fsiOPFLD.MedChrgitmType = "12"
  8429. break
  8430. case 13:
  8431. fsiOPFLD.MedChrgitmType = "01"
  8432. break
  8433. case 14:
  8434. fsiOPFLD.MedChrgitmType = "04"
  8435. break
  8436. case 15:
  8437. fsiOPFLD.MedChrgitmType = "14"
  8438. break
  8439. }
  8440. memo["hosp_appr_flag"] = "1"
  8441. memo["invoice_no"] = fapiao_code
  8442. memo["memo"] = "自费"
  8443. bytesData, _ := json.Marshal(memo)
  8444. fsiOPFLD.Memo = string(bytesData)
  8445. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8446. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8447. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8448. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8449. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8450. fsiOPFLD.BilgDeptName = department.Name
  8451. fsiOPFLD.BilgDeptCodg = department.Number
  8452. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8453. fsiOPFLD.BilgDrName = doctor.UserName
  8454. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8455. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8456. fsiOPFLD.MedChrgitmType = "08"
  8457. memo["hosp_appr_flag"] = "1"
  8458. memo["invoice_no"] = fapiao_code
  8459. memo["memo"] = "自费"
  8460. bytesData, _ := json.Marshal(memo)
  8461. fsiOPFLD.Memo = string(bytesData)
  8462. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8463. }
  8464. }
  8465. }
  8466. for _, items := range order_info_two {
  8467. memo := make(map[string]interface{})
  8468. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8469. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8470. fsiOPFLD.MedType = pre.MedType
  8471. fsiOPFLD.BkkpSn = items.FeedetlSn
  8472. fsiOPFLD.FixmedinsCode = miConfig.Code
  8473. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8474. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8475. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8476. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8477. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8478. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8479. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8480. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8481. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8482. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8483. fsiOPFLD.BilgDeptName = department.Name
  8484. fsiOPFLD.BilgDeptCodg = department.Number
  8485. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8486. fsiOPFLD.BilgDrName = doctor.UserName
  8487. fsiOPFLD.MedChrgitmType = "09"
  8488. memo["hosp_appr_flag"] = "1"
  8489. memo["invoice_no"] = fapiao_code
  8490. memo["memo"] = "自费"
  8491. bytesData, _ := json.Marshal(memo)
  8492. fsiOPFLD.Memo = string(bytesData)
  8493. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8494. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8495. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8496. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8497. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8498. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8499. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8500. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8501. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8502. fsiOPFLD.BilgDeptName = department.Name
  8503. fsiOPFLD.BilgDeptCodg = department.Number
  8504. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8505. fsiOPFLD.BilgDrName = doctor.UserName
  8506. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8507. case 0:
  8508. break
  8509. case 1:
  8510. fsiOPFLD.MedChrgitmType = "14"
  8511. break
  8512. case 2:
  8513. fsiOPFLD.MedChrgitmType = "05"
  8514. break
  8515. case 3:
  8516. fsiOPFLD.MedChrgitmType = "03"
  8517. break
  8518. case 4:
  8519. fsiOPFLD.MedChrgitmType = "03"
  8520. break
  8521. case 5:
  8522. fsiOPFLD.MedChrgitmType = "08"
  8523. break
  8524. case 6:
  8525. fsiOPFLD.MedChrgitmType = "14"
  8526. break
  8527. case 7:
  8528. fsiOPFLD.MedChrgitmType = "14"
  8529. break
  8530. case 8:
  8531. fsiOPFLD.MedChrgitmType = "03"
  8532. break
  8533. case 9:
  8534. fsiOPFLD.MedChrgitmType = "14"
  8535. break
  8536. case 10:
  8537. fsiOPFLD.MedChrgitmType = "14"
  8538. break
  8539. case 11:
  8540. fsiOPFLD.MedChrgitmType = "06"
  8541. break
  8542. case 12:
  8543. fsiOPFLD.MedChrgitmType = "12"
  8544. break
  8545. case 13:
  8546. fsiOPFLD.MedChrgitmType = "01"
  8547. break
  8548. case 14:
  8549. fsiOPFLD.MedChrgitmType = "04"
  8550. break
  8551. case 15:
  8552. fsiOPFLD.MedChrgitmType = "14"
  8553. break
  8554. }
  8555. memo["hosp_appr_flag"] = "1"
  8556. memo["invoice_no"] = fapiao_code
  8557. memo["memo"] = "自费"
  8558. bytesData, _ := json.Marshal(memo)
  8559. fsiOPFLD.Memo = string(bytesData)
  8560. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8561. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8562. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8563. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8564. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8565. fsiOPFLD.BilgDeptName = department.Name
  8566. fsiOPFLD.BilgDeptCodg = department.Number
  8567. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8568. fsiOPFLD.BilgDrName = doctor.UserName
  8569. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8570. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8571. fsiOPFLD.MedChrgitmType = "08"
  8572. memo["hosp_appr_flag"] = "1"
  8573. memo["invoice_no"] = fapiao_code
  8574. memo["memo"] = "自费"
  8575. bytesData, _ := json.Marshal(memo)
  8576. fsiOPFLD.Memo = string(bytesData)
  8577. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8578. }
  8579. }
  8580. }
  8581. fmt.Println(fsiOPFLDs)
  8582. struct4201A.Fopfd = fsiOPFLDs
  8583. fmt.Println(struct4201A.Fopfd)
  8584. var struct4202 models.Struct4202
  8585. timeLayout := "2006-01-02 15:04:05"
  8586. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  8587. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8588. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8589. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8590. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8591. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8592. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8593. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  8594. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  8595. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8596. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8597. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8598. var config []*models.HisXtDiagnoseConfig
  8599. for _, item := range diagnosis_ids {
  8600. id, _ := strconv.ParseInt(item, 10, 64)
  8601. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8602. config = append(config, &diagnosisConfig)
  8603. }
  8604. var tempDiaginfos []models.OwnPayPatnDiagListD
  8605. for index, item := range config {
  8606. if index == 0 {
  8607. var tempDiaginfo models.OwnPayPatnDiagListD
  8608. tempDiaginfo.InoutDiagType = "1"
  8609. tempDiaginfo.DiagCode = item.CountryCode
  8610. tempDiaginfo.DiagName = item.CountryContentName
  8611. tempDiaginfo.DiagType = "1"
  8612. tempDiaginfo.DiagSrtNo = "1"
  8613. tempDiaginfo.MaindiagFlag = "1"
  8614. tempDiaginfo.ValiFlag = "1"
  8615. tempDiaginfo.DiagDrName = doctor.UserName
  8616. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8617. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8618. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8619. } else {
  8620. var tempDiaginfo models.OwnPayPatnDiagListD
  8621. tempDiaginfo.DiagCode = item.CountryCode
  8622. tempDiaginfo.DiagName = item.CountryContentName
  8623. tempDiaginfo.DiagType = "2"
  8624. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8625. tempDiaginfo.MaindiagFlag = "0"
  8626. tempDiaginfo.ValiFlag = "1"
  8627. tempDiaginfo.DiagDrName = doctor.UserName
  8628. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8629. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8630. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8631. }
  8632. }
  8633. struct4202.ODiagListD = tempDiaginfos
  8634. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  8635. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  8636. var res2 ResultSix
  8637. var respJSON2 map[string]interface{}
  8638. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8641. return
  8642. }
  8643. userJSONBytes2, _ := json.Marshal(respJSON2)
  8644. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8645. utils.ErrorLog("解析失败:%v", err)
  8646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8647. return
  8648. }
  8649. if res2.Infcode != 0 {
  8650. c.ServeSuccessJSON(map[string]interface{}{
  8651. "failed_code": -10,
  8652. "msg": res2.ErrMsg,
  8653. })
  8654. return
  8655. } else {
  8656. order.IsUploadDiagnose = 1
  8657. order.IsUploadOrderInfo = 1
  8658. service.UpdateOrderTwo(order)
  8659. c.ServeSuccessJSON(map[string]interface{}{
  8660. "msg": "上传成功",
  8661. })
  8662. }
  8663. }
  8664. func (c *HisApiController) Get4207() {
  8665. admin_user_id, _ := c.GetInt64("admin_user_id")
  8666. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8667. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8668. order_id, _ := c.GetInt64("order_id")
  8669. order, _ := service.GetHisOrderByIDTwo(order_id)
  8670. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8671. var struct4207 models.Struct4207
  8672. struct4207.PageNum = "1"
  8673. struct4207.PageSize = "1000"
  8674. struct4207.FixmedinsCode = miConfig.Code
  8675. struct4207.FixmedinsMdtrtID = order.Number
  8676. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  8677. saveLog(result, requestLog, "4207", "查询")
  8678. var res2 ResultSix
  8679. var respJSON2 map[string]interface{}
  8680. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8683. return
  8684. }
  8685. userJSONBytes2, _ := json.Marshal(respJSON2)
  8686. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8687. utils.ErrorLog("解析失败:%v", err)
  8688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8689. return
  8690. }
  8691. if res2.Infcode != 0 {
  8692. c.ServeSuccessJSON(map[string]interface{}{
  8693. "failed_code": -10,
  8694. "msg": res2.ErrMsg,
  8695. })
  8696. return
  8697. } else {
  8698. c.ServeSuccessJSON(map[string]interface{}{
  8699. "msg": "查询成功",
  8700. })
  8701. }
  8702. }
  8703. func (c *HisApiController) Get4208() {
  8704. admin_user_id, _ := c.GetInt64("admin_user_id")
  8705. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8706. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8707. order_id, _ := c.GetInt64("order_id")
  8708. order, _ := service.GetHisOrderByIDTwo(order_id)
  8709. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8710. var struct4208 models.Struct4208
  8711. struct4208.PageNum = "1"
  8712. struct4208.PageSize = "1000"
  8713. struct4208.PsnCertType = "01"
  8714. struct4208.Certno = his.Certno
  8715. struct4208.MedType = order.MedType
  8716. struct4208.PsnName = his.Name
  8717. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  8718. saveLog(result, requestLog, "4208", "查询")
  8719. var res2 ResultSix
  8720. var respJSON2 map[string]interface{}
  8721. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8724. return
  8725. }
  8726. userJSONBytes2, _ := json.Marshal(respJSON2)
  8727. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8728. utils.ErrorLog("解析失败:%v", err)
  8729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8730. return
  8731. }
  8732. if res2.Infcode != 0 {
  8733. c.ServeSuccessJSON(map[string]interface{}{
  8734. "failed_code": -10,
  8735. "msg": res2.ErrMsg,
  8736. })
  8737. return
  8738. } else {
  8739. c.ServeSuccessJSON(map[string]interface{}{
  8740. "msg": "查询成功",
  8741. })
  8742. }
  8743. }
  8744. func (c *HisApiController) Get4209() {
  8745. admin_user_id, _ := c.GetInt64("admin_user_id")
  8746. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8747. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8748. order_id, _ := c.GetInt64("order_id")
  8749. order, _ := service.GetHisOrderByIDTwo(order_id)
  8750. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8751. var struct4209 models.Struct4209
  8752. struct4209.FixmedinsMdtrtID = order.Number
  8753. struct4209.FixmedinsCode = miConfig.Code
  8754. struct4209.PageSize = "1000"
  8755. struct4209.PageNum = "1"
  8756. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  8757. saveLog(result, requestLog, "4209", "查询")
  8758. var res2 ResultSix
  8759. var respJSON2 map[string]interface{}
  8760. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8763. return
  8764. }
  8765. userJSONBytes2, _ := json.Marshal(respJSON2)
  8766. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8767. utils.ErrorLog("解析失败:%v", err)
  8768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8769. return
  8770. }
  8771. if res2.Infcode != 0 {
  8772. c.ServeSuccessJSON(map[string]interface{}{
  8773. "failed_code": -10,
  8774. "msg": res2.ErrMsg,
  8775. })
  8776. return
  8777. } else {
  8778. c.ServeSuccessJSON(map[string]interface{}{
  8779. "msg": "查询成功",
  8780. })
  8781. }
  8782. }
  8783. type Result3101 struct {
  8784. Infcode string `json:"infcode"`
  8785. InfRefmsgid string `json:"inf_refmsgid"`
  8786. RefmsgTime string `json:"refmsg_time"`
  8787. RespondTime string `json:"respond_time"`
  8788. Enctype string `json:"enctype"`
  8789. Signtype string `json:"signtype"`
  8790. ErrMsg string `json:"err_msg"`
  8791. Output struct {
  8792. Result []struct {
  8793. JudgeResultDetailDtos []struct {
  8794. VolaItemType string `json:"vola_item_type"`
  8795. MdtrtID string `json:"mdtrt_id"`
  8796. JrdID string `json:"jrd_id"`
  8797. PatnID string `json:"patn_id"`
  8798. RxID string `json:"rx_id"`
  8799. VolaAmt interface{} `json:"vola_amt"`
  8800. } `json:"judge_result_detail_dtos"`
  8801. RuleID string `json:"rule_id"`
  8802. VolaEvid string `json:"vola_evid"`
  8803. MdtrtID string `json:"mdtrt_id"`
  8804. RuleName string `json:"rule_name"`
  8805. VolaAmtStas string `json:"vola_amt_stas"`
  8806. JrID string `json:"jr_id"`
  8807. PatnID string `json:"patn_id"`
  8808. SevDeg string `json:"sev_deg"`
  8809. VolaAmt float64 `json:"vola_amt"`
  8810. VolaBhvrType string `json:"vola_bhvr_type"`
  8811. VolaCont string `json:"vola_cont"`
  8812. } `json:"result"`
  8813. } `json:"output"`
  8814. }
  8815. type Resultgd3101 struct {
  8816. Infcode int64 `json:"infcode"`
  8817. InfRefmsgid string `json:"inf_refmsgid"`
  8818. RefmsgTime string `json:"refmsg_time"`
  8819. RespondTime string `json:"respond_time"`
  8820. Enctype string `json:"enctype"`
  8821. Signtype string `json:"signtype"`
  8822. ErrMsg string `json:"err_msg"`
  8823. Output struct {
  8824. Result []struct {
  8825. JudgeResultDetailDtos []struct {
  8826. VolaItemType string `json:"vola_item_type"`
  8827. MdtrtID string `json:"mdtrt_id"`
  8828. JrdID string `json:"jrd_id"`
  8829. PatnID string `json:"patn_id"`
  8830. RxID string `json:"rx_id"`
  8831. VolaAmt interface{} `json:"vola_amt"`
  8832. } `json:"judge_result_detail_dtos"`
  8833. RuleID string `json:"rule_id"`
  8834. VolaEvid string `json:"vola_evid"`
  8835. MdtrtID string `json:"mdtrt_id"`
  8836. RuleName string `json:"rule_name"`
  8837. VolaAmtStas string `json:"vola_amt_stas"`
  8838. JrID string `json:"jr_id"`
  8839. PatnID string `json:"patn_id"`
  8840. SevDeg string `json:"sev_deg"`
  8841. VolaAmt float64 `json:"vola_amt"`
  8842. VolaBhvrType string `json:"vola_bhvr_type"`
  8843. VolaCont string `json:"vola_cont"`
  8844. } `json:"result"`
  8845. } `json:"output"`
  8846. }
  8847. func (c *HisApiController) ReadEleToken() {
  8848. admin_user_id, _ := c.GetInt64("admin_user_id")
  8849. his_patient_id, _ := c.GetInt64("his_patient_id")
  8850. adminUser := c.GetAdminUserInfo()
  8851. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8852. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8853. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8854. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8855. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  8856. if len(tokens) > 0 {
  8857. c.ServeSuccessJSON(map[string]interface{}{
  8858. "msg": "读取成功",
  8859. })
  8860. } else {
  8861. c.ServeSuccessJSON(map[string]interface{}{
  8862. "failed_code": -10,
  8863. "msg": "读取失败",
  8864. })
  8865. }
  8866. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8867. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  8868. if len(tokens) > 0 {
  8869. c.ServeSuccessJSON(map[string]interface{}{
  8870. "msg": "读取成功",
  8871. })
  8872. } else {
  8873. c.ServeSuccessJSON(map[string]interface{}{
  8874. "failed_code": -10,
  8875. "msg": "读取失败",
  8876. })
  8877. }
  8878. } else if miConfig.MdtrtareaAdmvs == "340699" {
  8879. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  8880. if len(tokens) > 0 {
  8881. c.ServeSuccessJSON(map[string]interface{}{
  8882. "msg": "读取成功",
  8883. })
  8884. } else {
  8885. c.ServeSuccessJSON(map[string]interface{}{
  8886. "failed_code": -10,
  8887. "msg": "读取失败",
  8888. })
  8889. }
  8890. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8891. var api string
  8892. 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 +
  8893. "&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"
  8894. resp, requestErr := http.Get(api)
  8895. if requestErr != nil {
  8896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8897. }
  8898. body, ioErr := ioutil.ReadAll(resp.Body)
  8899. if ioErr != nil {
  8900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8902. }
  8903. var respJSON map[string]interface{}
  8904. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8907. return
  8908. }
  8909. var status string
  8910. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8911. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8912. var token string
  8913. var res ResultTwo //1101结果
  8914. var res10265 ResultTwo10265 //1101结果
  8915. if status == "0" { //读卡成功
  8916. var card_info string //卡信息
  8917. var busi_card_info string
  8918. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8919. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8920. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8921. fmt.Println(card_info)
  8922. fmt.Println(busi_card_info)
  8923. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8924. result, _ := json.Marshal(respJSON)
  8925. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8926. utils.ErrorLog("解析失败:%v", err)
  8927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8928. return
  8929. }
  8930. res.ErrMsg = res10265.ErrMsg
  8931. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8932. res.Infcode = infocode
  8933. res.Output = res10265.Output
  8934. res.InfRefmsgid = res10265.InfRefmsgid
  8935. if res.Infcode == 0 {
  8936. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8937. if err == gorm.ErrRecordNotFound {
  8938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8939. return
  8940. } else if err != nil {
  8941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8942. return
  8943. } else {
  8944. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8945. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8946. infoStr := string(Iinfos)
  8947. idetinfoStr := string(Idetinfos)
  8948. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  8949. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8950. psn := &models.HisPsn{
  8951. PsnNo: res.Output.Baseinfo.PsnNo,
  8952. PatientId: patient.ID,
  8953. Certno: res.Output.Baseinfo.Certno,
  8954. Gend: res.Output.Baseinfo.Gend,
  8955. Naty: res.Output.Baseinfo.Naty,
  8956. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8957. PsnName: res.Output.Baseinfo.PsnName,
  8958. Age: float64(age),
  8959. Brdy: b,
  8960. Idetinfo: idetinfoStr,
  8961. Insuinfo: infoStr,
  8962. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8963. CardInfo: card_info,
  8964. VerifyNumber: token,
  8965. IdCardType: 4,
  8966. }
  8967. var rf []*ResultFive
  8968. json.Unmarshal([]byte(infoStr), &rf)
  8969. var insutypes []*ResultFive
  8970. var insutype string
  8971. var is390 int = 0
  8972. var is310 int = 0
  8973. for _, item := range rf {
  8974. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8975. insutypes = append(insutypes, item)
  8976. }
  8977. }
  8978. if len(insutypes) == 1 {
  8979. insutype = insutypes[0].Insutype
  8980. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8981. } else {
  8982. for _, i := range insutypes {
  8983. if i.Insutype == "390" {
  8984. is390 = 1
  8985. }
  8986. if i.Insutype == "310" {
  8987. is310 = 1
  8988. }
  8989. }
  8990. }
  8991. if is390 == 1 {
  8992. insutype = "390"
  8993. }
  8994. if is310 == 1 {
  8995. insutype = "310"
  8996. }
  8997. if len(insutypes) == 0 {
  8998. insutype = "310"
  8999. }
  9000. service.CreateHisPsn(psn)
  9001. c.ServeSuccessJSON(map[string]interface{}{
  9002. "patient": patient,
  9003. "number": token,
  9004. "insutype": insutype,
  9005. })
  9006. }
  9007. } else {
  9008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9009. return
  9010. }
  9011. } else { //读卡失败
  9012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9013. return
  9014. }
  9015. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9016. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9017. if len(errMsg) == 0 {
  9018. type ELeData struct {
  9019. Data struct {
  9020. IdNo string `json:"idNo"`
  9021. IdType string `json:"idType"`
  9022. UserName string `json:"userName"`
  9023. EcToken string `json:"ecToken"`
  9024. InsuOrg string `json:"insuOrg"`
  9025. Gender string `json:"gender"`
  9026. Birthday string `json:"birthday"`
  9027. Nationality string `json:"nationality"`
  9028. Email string `json:"email"`
  9029. Extra string `json:"extra"`
  9030. } `json:"data"`
  9031. Code int `json:"code"`
  9032. Message string `json:"message"`
  9033. }
  9034. var ele ELeData
  9035. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9036. if err != nil {
  9037. utils.ErrorLog("解析失败:%v", err)
  9038. }
  9039. token := ele.Data.EcToken
  9040. if len(token) > 0 {
  9041. psn := &models.HisPsn{
  9042. PsnNo: his.PsnNo,
  9043. Age: 0,
  9044. PatientId: his.PatientId,
  9045. Certno: his.Certno,
  9046. Brdy: his.Brdy,
  9047. Gend: his.Gend,
  9048. Naty: his.Naty,
  9049. PsnCertType: his.PsnCertType,
  9050. PsnName: his.PsnName,
  9051. Idetinfo: his.Idetinfo,
  9052. Insuinfo: his.Iinfo,
  9053. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9054. CardInfo: outPutInfo,
  9055. VerifyNumber: token,
  9056. }
  9057. service.CreateHisPsn(psn)
  9058. }
  9059. if len(token) > 0 {
  9060. c.ServeSuccessJSON(map[string]interface{}{
  9061. "msg": "读取成功",
  9062. })
  9063. } else {
  9064. c.ServeSuccessJSON(map[string]interface{}{
  9065. "failed_code": -10,
  9066. "msg": "读取失败",
  9067. })
  9068. }
  9069. }
  9070. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9071. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9072. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9073. type ELeData struct {
  9074. Data struct {
  9075. IdNo string `json:"idNo"`
  9076. IdType string `json:"idType"`
  9077. UserName string `json:"userName"`
  9078. EcToken string `json:"ecToken"`
  9079. InsuOrg string `json:"insuOrg"`
  9080. Gender string `json:"gender"`
  9081. Birthday string `json:"birthday"`
  9082. Nationality string `json:"nationality"`
  9083. Email string `json:"email"`
  9084. Extra string `json:"extra"`
  9085. } `json:"data"`
  9086. Code int `json:"code"`
  9087. Message string `json:"message"`
  9088. }
  9089. var ele ELeData
  9090. err := json.Unmarshal([]byte(result), &ele)
  9091. if err != nil {
  9092. utils.ErrorLog("解析失败:%v", err)
  9093. }
  9094. token := ele.Data.EcToken
  9095. token = Remove0000(token)
  9096. fmt.Println(ele.Data.UserName)
  9097. 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)
  9098. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9099. var res ResultTwo
  9100. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9101. utils.ErrorLog("解析失败:%v", err)
  9102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9103. return
  9104. }
  9105. if res.Infcode == 0 {
  9106. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9107. if err == gorm.ErrRecordNotFound {
  9108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9109. return
  9110. } else if err != nil {
  9111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9112. return
  9113. } else {
  9114. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9115. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9116. infoStr := string(Iinfos)
  9117. idetinfoStr := string(Idetinfos)
  9118. psn := &models.HisPsn{
  9119. PsnNo: res.Output.Baseinfo.PsnNo,
  9120. PatientId: patient.ID,
  9121. Certno: res.Output.Baseinfo.Certno,
  9122. Gend: res.Output.Baseinfo.Gend,
  9123. Naty: res.Output.Baseinfo.Naty,
  9124. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9125. PsnName: res.Output.Baseinfo.PsnName,
  9126. Idetinfo: idetinfoStr,
  9127. Insuinfo: infoStr,
  9128. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9129. CardInfo: "",
  9130. VerifyNumber: token,
  9131. }
  9132. service.CreateHisPsn(psn)
  9133. c.ServeSuccessJSON(map[string]interface{}{
  9134. "patient": patient,
  9135. "number": token,
  9136. })
  9137. }
  9138. } else {
  9139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9140. return
  9141. }
  9142. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9143. //if initFlag == 0 {
  9144. //c.TestGetJiangXiBasBaseInit()
  9145. //}
  9146. //if initEleFlag == 0 {
  9147. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9148. //}
  9149. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9150. utils.ErrorLog("解析失败:%v", json_result)
  9151. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9152. type ELeData struct {
  9153. Data struct {
  9154. IdNo string `json:"idNo"`
  9155. IdType string `json:"idType"`
  9156. UserName string `json:"userName"`
  9157. EcToken string `json:"ecToken"`
  9158. InsuOrg string `json:"insuOrg"`
  9159. Gender string `json:"gender"`
  9160. Birthday string `json:"birthday"`
  9161. Nationality string `json:"nationality"`
  9162. Email string `json:"email"`
  9163. Extra string `json:"extra"`
  9164. } `json:"data"`
  9165. Code int `json:"code"`
  9166. Message string `json:"message"`
  9167. }
  9168. var ele ELeData
  9169. err := json.Unmarshal([]byte(json_result), &ele)
  9170. if err != nil {
  9171. utils.ErrorLog("解析失败:%v", err)
  9172. }
  9173. token := ele.Data.EcToken
  9174. token = Remove0000(token)
  9175. //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)
  9176. 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)
  9177. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9178. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9179. var res ResultTwo
  9180. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9181. utils.ErrorLog("解析失败:%v", err)
  9182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9183. return
  9184. }
  9185. if res.Infcode == 0 {
  9186. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9187. if err == gorm.ErrRecordNotFound {
  9188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9189. return
  9190. } else if err != nil {
  9191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9192. return
  9193. } else {
  9194. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9195. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9196. infoStr := string(Iinfos)
  9197. idetinfoStr := string(Idetinfos)
  9198. psn := &models.HisPsn{
  9199. PsnNo: res.Output.Baseinfo.PsnNo,
  9200. PatientId: patient.ID,
  9201. Certno: res.Output.Baseinfo.Certno,
  9202. Gend: res.Output.Baseinfo.Gend,
  9203. Naty: res.Output.Baseinfo.Naty,
  9204. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9205. PsnName: res.Output.Baseinfo.PsnName,
  9206. Idetinfo: idetinfoStr,
  9207. Insuinfo: infoStr,
  9208. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9209. CardInfo: "",
  9210. VerifyNumber: token,
  9211. InsuplcAdmdvs: ele.Data.InsuOrg,
  9212. }
  9213. service.CreateHisPsn(psn)
  9214. c.ServeSuccessJSON(map[string]interface{}{
  9215. "patient": patient,
  9216. "number": token,
  9217. })
  9218. }
  9219. } else {
  9220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9221. return
  9222. }
  9223. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9224. res := c.GetoleInfo()
  9225. if res.Infcode == 0 {
  9226. var result string
  9227. if res.Output.MdtrtCertType == "01" {
  9228. 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)
  9229. } else if res.Output.MdtrtCertType == "02" {
  9230. 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)
  9231. } else if res.Output.MdtrtCertType == "03" {
  9232. 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)
  9233. }
  9234. var dat map[string]interface{}
  9235. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9236. fmt.Println(dat)
  9237. } else {
  9238. fmt.Println(err)
  9239. }
  9240. userJSONBytes, _ := json.Marshal(dat)
  9241. var res2 ResultTwo
  9242. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9243. utils.ErrorLog("解析失败:%v", err)
  9244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9245. return
  9246. }
  9247. if res2.Infcode == 0 {
  9248. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9249. if err == gorm.ErrRecordNotFound {
  9250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9251. return
  9252. } else if err != nil {
  9253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9254. return
  9255. } else {
  9256. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9257. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9258. infoStr := string(Iinfos)
  9259. idetinfoStr := string(Idetinfos)
  9260. var rf []*ResultFive
  9261. json.Unmarshal([]byte(infoStr), &rf)
  9262. var insutypes []*ResultFive
  9263. var insutype string
  9264. var is390 int = 0
  9265. var is310 int = 0
  9266. //var insuplc_admdvs string
  9267. for _, item := range rf {
  9268. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9269. insutypes = append(insutypes, item)
  9270. }
  9271. }
  9272. if len(insutypes) == 1 {
  9273. insutype = insutypes[0].Insutype
  9274. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9275. } else {
  9276. for _, i := range insutypes {
  9277. if i.Insutype == "390" {
  9278. is390 = 1
  9279. }
  9280. if i.Insutype == "310" {
  9281. is310 = 1
  9282. }
  9283. }
  9284. }
  9285. if is390 == 1 {
  9286. insutype = "390"
  9287. }
  9288. if is310 == 1 {
  9289. insutype = "310"
  9290. }
  9291. if len(insutypes) == 0 {
  9292. insutype = "310"
  9293. }
  9294. psn := &models.HisPsn{
  9295. PsnNo: res2.Output.Baseinfo.PsnNo,
  9296. PatientId: patient.ID,
  9297. Certno: res2.Output.Baseinfo.Certno,
  9298. Gend: res2.Output.Baseinfo.Gend,
  9299. Naty: res2.Output.Baseinfo.Naty,
  9300. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9301. PsnName: res2.Output.Baseinfo.PsnName,
  9302. Idetinfo: idetinfoStr,
  9303. Insuinfo: infoStr,
  9304. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9305. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9306. VerifyNumber: res.Output.EcToken,
  9307. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9308. }
  9309. service.CreateHisPsn(psn)
  9310. c.ServeSuccessJSON(map[string]interface{}{
  9311. "patient": patient,
  9312. "number": res.Output.CardNo,
  9313. "insutype": insutype,
  9314. })
  9315. }
  9316. } else {
  9317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9318. return
  9319. }
  9320. } else {
  9321. c.ServeSuccessJSON(map[string]interface{}{
  9322. "failed_code": -10,
  9323. "msg": res.ErrMsg,
  9324. })
  9325. }
  9326. } else {
  9327. //if initFlag == 0 {
  9328. // c.TestGetBasBaseInit()
  9329. //}
  9330. //token := c.GetEleBaseInfo()
  9331. //token = Remove0000(token)
  9332. type ELeData struct {
  9333. Code string `json:"code"`
  9334. Data struct {
  9335. Aac002 string `json:"aac002"`
  9336. Aaz500 string `json:"aaz500"`
  9337. ActCardNo string `json:"actCardNo"`
  9338. Bab520 string `json:"bab520"`
  9339. Bkz543 string `json:"bkz543"`
  9340. BusinessType string `json:"businessType"`
  9341. CertfCodg string `json:"certfCodg"`
  9342. EcIndexNo string `json:"ecIndexNo"`
  9343. EcToken string `json:"ecToken"`
  9344. ID0000 string `json:"id0000"`
  9345. IDNo string `json:"idNo"`
  9346. IDType string `json:"idType"`
  9347. Idcode string `json:"idcode"`
  9348. IdentityToken string `json:"identity_token"`
  9349. InsuOrg string `json:"insuOrg"`
  9350. OfficeID string `json:"officeId"`
  9351. OfficeName string `json:"officeName"`
  9352. OperatorID string `json:"operatorId"`
  9353. OperatorName string `json:"operatorName"`
  9354. OrgID string `json:"orgId"`
  9355. UserName string `json:"userName"`
  9356. } `json:"data"`
  9357. Infno interface{} `json:"infno"`
  9358. Message string `json:"message"`
  9359. OrgID string `json:"orgId"`
  9360. TransType string `json:"transType"`
  9361. }
  9362. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9363. fmt.Println(result)
  9364. outPutInfo := Remove0000(result)
  9365. fmt.Println(outPutInfo)
  9366. var ele ELeData
  9367. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9368. if err != nil {
  9369. utils.ErrorLog("解析失败:%v", err)
  9370. }
  9371. token := ele.Data.EcToken
  9372. var result2 string
  9373. var requestLog2 string
  9374. if len(token) > 0 {
  9375. if strings.Contains(ele.Data.IDNo, "HKG") {
  9376. 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)
  9377. } else {
  9378. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  9379. }
  9380. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9381. var res ResultTwo
  9382. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9383. utils.ErrorLog("解析失败:%v", err)
  9384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9385. return
  9386. }
  9387. if res.Infcode == 0 {
  9388. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9389. if err == gorm.ErrRecordNotFound {
  9390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9391. return
  9392. } else if err != nil {
  9393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9394. return
  9395. } else {
  9396. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9397. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9398. infoStr := string(Iinfos)
  9399. idetinfoStr := string(Idetinfos)
  9400. psn := &models.HisPsn{
  9401. PsnNo: res.Output.Baseinfo.PsnNo,
  9402. PatientId: patient.ID,
  9403. Certno: res.Output.Baseinfo.Certno,
  9404. Gend: res.Output.Baseinfo.Gend,
  9405. Naty: res.Output.Baseinfo.Naty,
  9406. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9407. PsnName: res.Output.Baseinfo.PsnName,
  9408. Idetinfo: idetinfoStr,
  9409. Insuinfo: infoStr,
  9410. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9411. CardInfo: "",
  9412. VerifyNumber: token,
  9413. }
  9414. service.CreateHisPsn(psn)
  9415. c.ServeSuccessJSON(map[string]interface{}{
  9416. "msg": "读取成功",
  9417. })
  9418. }
  9419. } else {
  9420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9421. return
  9422. }
  9423. } else {
  9424. c.ServeSuccessJSON(map[string]interface{}{
  9425. "failed_code": -10,
  9426. "msg": "读取失败",
  9427. })
  9428. }
  9429. }
  9430. }
  9431. func (c *HisApiController) ReadEleFace() {
  9432. admin_user_id, _ := c.GetInt64("admin_user_id")
  9433. //his_patient_id, _ := c.GetInt64("his_patient_id")
  9434. adminUser := c.GetAdminUserInfo()
  9435. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9436. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9437. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9438. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9439. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9440. if len(tokens) > 0 {
  9441. c.ServeSuccessJSON(map[string]interface{}{
  9442. "msg": "读取成功",
  9443. })
  9444. } else {
  9445. c.ServeSuccessJSON(map[string]interface{}{
  9446. "failed_code": -10,
  9447. "msg": "读取失败",
  9448. })
  9449. }
  9450. }
  9451. }
  9452. func (c *HisApiController) Get9001() {
  9453. adminUser := c.GetAdminUserInfo()
  9454. admin_user_id, _ := c.GetInt64("admin_user_id")
  9455. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9456. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9457. if miConfig.MdtrtareaAdmvs == "350500" {
  9458. service.GetFjAuthorizationInfo(miConfig.Code)
  9459. } else if miConfig.MdtrtareaAdmvs == "131023" {
  9460. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9461. var dat map[string]interface{}
  9462. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9463. fmt.Println(dat)
  9464. } else {
  9465. fmt.Println(err)
  9466. }
  9467. userJSONBytes, _ := json.Marshal(dat)
  9468. var res models.Result9001
  9469. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9470. utils.ErrorLog("解析失败:%v", err)
  9471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9472. return
  9473. }
  9474. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9475. fmt.Println(miConfig.SecretKey)
  9476. var res models.Result9001Two
  9477. 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 +
  9478. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  9479. resp, requestErr := http.Get(api)
  9480. if requestErr != nil {
  9481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9482. return
  9483. }
  9484. body, ioErr := ioutil.ReadAll(resp.Body)
  9485. if ioErr != nil {
  9486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9488. return
  9489. }
  9490. var respJSON map[string]interface{}
  9491. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9494. return
  9495. }
  9496. status := respJSON["data"].(map[string]interface{})["status"].(string)
  9497. if status == "0" {
  9498. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  9499. c.ServeSuccessJSON(map[string]interface{}{
  9500. "failed_code": -10,
  9501. "msg": err_msg,
  9502. })
  9503. return
  9504. }
  9505. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9506. result, _ := json.Marshal(respJSON)
  9507. fmt.Println("log")
  9508. fmt.Println(string(result))
  9509. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9510. utils.ErrorLog("解析失败:%v", err)
  9511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9512. return
  9513. }
  9514. if res.Infcode == 0 {
  9515. sign := models.HisSignIn{
  9516. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9517. SignNo: res.Output.Signinoutb.SignNo,
  9518. SignTime: "",
  9519. Ctime: time.Now().Unix(),
  9520. Mtime: time.Now().Unix(),
  9521. Status: 1,
  9522. InputLog: "",
  9523. OutputLog: "",
  9524. FixmedinsCode: miConfig.Code,
  9525. }
  9526. err := service.CreateSignIn(&sign)
  9527. if err == nil {
  9528. c.ServeSuccessJSON(map[string]interface{}{
  9529. "msg": "签到成功",
  9530. })
  9531. }
  9532. } else {
  9533. c.ServeSuccessJSON(map[string]interface{}{
  9534. "failed_code": -10,
  9535. "msg": res.ErrMsg,
  9536. })
  9537. return
  9538. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9539. //return
  9540. }
  9541. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9542. fmt.Println(miConfig.SecretKey)
  9543. var res models.Result9001Two
  9544. 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 +
  9545. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  9546. resp, requestErr := http.Get(api)
  9547. if requestErr != nil {
  9548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9549. return
  9550. }
  9551. body, ioErr := ioutil.ReadAll(resp.Body)
  9552. if ioErr != nil {
  9553. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9555. return
  9556. }
  9557. var respJSON map[string]interface{}
  9558. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9561. return
  9562. }
  9563. status := respJSON["data"].(map[string]interface{})["status"].(string)
  9564. if status == "0" {
  9565. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  9566. c.ServeSuccessJSON(map[string]interface{}{
  9567. "failed_code": -10,
  9568. "msg": err_msg,
  9569. })
  9570. return
  9571. }
  9572. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9573. result, _ := json.Marshal(respJSON)
  9574. fmt.Println("log")
  9575. fmt.Println(string(result))
  9576. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9577. utils.ErrorLog("解析失败:%v", err)
  9578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9579. return
  9580. }
  9581. if res.Infcode == 0 {
  9582. sign := models.HisSignIn{
  9583. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9584. SignNo: res.Output.Signinoutb.SignNo,
  9585. SignTime: "",
  9586. Ctime: time.Now().Unix(),
  9587. Mtime: time.Now().Unix(),
  9588. Status: 1,
  9589. InputLog: "",
  9590. OutputLog: "",
  9591. FixmedinsCode: miConfig.Code,
  9592. }
  9593. err := service.CreateSignIn(&sign)
  9594. if err == nil {
  9595. c.ServeSuccessJSON(map[string]interface{}{
  9596. "msg": "签到成功",
  9597. })
  9598. }
  9599. } else {
  9600. c.ServeSuccessJSON(map[string]interface{}{
  9601. "failed_code": -10,
  9602. "msg": res.ErrMsg,
  9603. })
  9604. return
  9605. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9606. //return
  9607. }
  9608. } else {
  9609. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  9610. var dat map[string]interface{}
  9611. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9612. fmt.Println(dat)
  9613. } else {
  9614. fmt.Println(err)
  9615. }
  9616. userJSONBytes, _ := json.Marshal(dat)
  9617. var res models.Result9001
  9618. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9619. utils.ErrorLog("解析失败:%v", err)
  9620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9621. return
  9622. }
  9623. if res.Infcode == 0 {
  9624. sign := models.HisSignIn{
  9625. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9626. SignNo: res.Output.Signinoutb.SignNo,
  9627. SignTime: res.Output.Signinoutb.SignTime,
  9628. Ctime: time.Now().Unix(),
  9629. Mtime: time.Now().Unix(),
  9630. Status: 1,
  9631. InputLog: "",
  9632. OutputLog: "",
  9633. FixmedinsCode: miConfig.Code,
  9634. }
  9635. err := service.CreateSignIn(&sign)
  9636. if err == nil {
  9637. c.ServeSuccessJSON(map[string]interface{}{
  9638. "msg": "签到成功",
  9639. })
  9640. }
  9641. }
  9642. }
  9643. }
  9644. 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) {
  9645. var res Result3101
  9646. adminUser := c.GetAdminUserInfo()
  9647. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9648. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9649. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9650. //record_time := c.GetString("record_time")
  9651. //trig_scen := c.GetString("trig_scen")
  9652. timeLayout := "2006-01-02"
  9653. loc, _ := time.LoadLocation("Local")
  9654. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9655. if err != nil {
  9656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9657. return res
  9658. }
  9659. recordDateTime := theTime.Unix()
  9660. var patientPrescription models.HisPrescriptionInfo
  9661. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9662. //if patientPrescription.ID == 0 {
  9663. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9664. //}
  9665. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9666. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9667. //
  9668. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  9669. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9670. var pp models.PublicParams
  9671. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9672. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9673. pp.FixmedinsName = miConfig.OrgName
  9674. pp.FixmedinsCode = miConfig.Code
  9675. pp.RequestUrl = miConfig.Url
  9676. pp.Cainfo = miConfig.Cainfo
  9677. pp.SecretKey = miConfig.SecretKey
  9678. pp.AccessKey = miConfig.AccessKey
  9679. pp.OpterName = roles.UserName
  9680. var config []*models.HisXtDiagnoseConfig
  9681. for _, item := range diagnosis_ids {
  9682. id, _ := strconv.ParseInt(item, 10, 64)
  9683. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9684. config = append(config, &diagnosisConfig)
  9685. }
  9686. var pd models.PatientDtos
  9687. pd.PatnID = his.PsnNo
  9688. pd.PatnName = his.Name
  9689. pd.Gend = his.Gend
  9690. pd.Brdy = his.Brdy
  9691. pd.Poolarea = miConfig.MdtrtareaAdmvs
  9692. pd.CurrMdtrtID = his.Number
  9693. var fed models.FsiEncounterDtos
  9694. fed.MdtrtID = his.Number
  9695. fed.MedinsID = miConfig.Code
  9696. fed.MedinsName = miConfig.OrgName
  9697. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  9698. fed.MedMdtrtType = "1"
  9699. fed.MedinsType = "1"
  9700. fed.MedinsLv = "11"
  9701. tm := time.Unix(his.RecordDate, 0)
  9702. s_tm := tm.Format("2006-01-02 15:04:05")
  9703. fed.AdmDate = s_tm
  9704. fed.DscgDate = s_tm
  9705. fed.DscgMainDiseCodg = config[0].CountryCode
  9706. fed.DscgMainDiseName = config[0].CountryContentName
  9707. //诊断信息
  9708. var fdds []*models.FsiDiagnoseDtos
  9709. for index, item := range config {
  9710. if index == 0 {
  9711. var fdd models.FsiDiagnoseDtos
  9712. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9713. fdd.InoutDiseType = "1"
  9714. fdd.MaindiseFlag = "1"
  9715. fdd.DiseDate = s_tm
  9716. fdd.DiasSrtNo = "1"
  9717. fdd.DiseName = item.CountryContentName
  9718. fdd.DiseCodg = item.CountryCode
  9719. fdds = append(fdds, &fdd)
  9720. } else {
  9721. var fdd models.FsiDiagnoseDtos
  9722. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9723. fdd.InoutDiseType = "1"
  9724. fdd.MaindiseFlag = "1"
  9725. fdd.DiseDate = s_tm
  9726. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  9727. fdd.DiseName = item.CountryContentName
  9728. fdd.DiseCodg = item.CountryCode
  9729. fdds = append(fdds, &fdd)
  9730. }
  9731. }
  9732. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  9733. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  9734. fed.AdmDeptName = de.Name
  9735. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  9736. fed.DscgDeptName = de.Name
  9737. fed.MedMdtrtType = "1"
  9738. fed.MedType = "11"
  9739. //if his.Insutype == "390" {
  9740. // fed.MedType = "1402"
  9741. //} else {
  9742. // fed.MedType = "9933"
  9743. //}
  9744. var orders []*models.FsiOrderDtos
  9745. if trig_scen == "2" {
  9746. //处方医嘱信息
  9747. for _, item := range prescriptions {
  9748. for _, subItem := range item.HisDoctorAdviceInfo {
  9749. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9750. var order models.FsiOrderDtos
  9751. order.RxID = strconv.FormatInt(item.ID, 10)
  9752. order.Rxno = strconv.FormatInt(item.ID, 10)
  9753. order.LongDrordFlag = "0"
  9754. order.HilistType = "1"
  9755. order.ChrgType = "1"
  9756. order.DrordBhvr = "-"
  9757. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9758. order.HosplistName = subItem.BaseDrugLib.DrugName
  9759. order.HilistLv = "1"
  9760. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9761. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9762. order.HosplistName = subItem.BaseDrugLib.DrugName
  9763. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  9764. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9765. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  9766. order.OwnpayAmt = ""
  9767. order.SelfpayAmt = ""
  9768. order.Spec = ""
  9769. order.SpecUnt = ""
  9770. order.DrordBegnDate = s_tm
  9771. order.DrordStopDate = ""
  9772. order.DrordDrCodg = doctor_info.DoctorNumber
  9773. order.DrordDeptName = department.Name
  9774. order.DrordDeptCodg = department.Number
  9775. order.DrordDrName = doctor_info.UserName
  9776. order.DrordDrProfttl = "234"
  9777. order.CurrDrordFlag = "1"
  9778. orders = append(orders, &order)
  9779. }
  9780. }
  9781. for _, subItem := range item.HisPrescriptionProject {
  9782. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  9783. var order models.FsiOrderDtos
  9784. order.RxID = strconv.FormatInt(item.ID, 10)
  9785. order.Rxno = strconv.FormatInt(item.ID, 10)
  9786. order.LongDrordFlag = "0"
  9787. order.HilistType = "1"
  9788. order.ChrgType = "1"
  9789. order.DrordBhvr = "-"
  9790. order.HilistCode = subItem.HisProject.MedicalCode
  9791. order.HosplistName = subItem.HisProject.ProjectName
  9792. order.HilistLv = "1"
  9793. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9794. order.HosplistCode = subItem.HisProject.MedicalCode
  9795. order.HosplistName = subItem.HisProject.ProjectName
  9796. order.Cnt = subItem.Count
  9797. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9798. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9799. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9800. order.OwnpayAmt = ""
  9801. order.SelfpayAmt = ""
  9802. order.Spec = ""
  9803. order.SpecUnt = ""
  9804. order.DrordBegnDate = s_tm
  9805. order.DrordStopDate = ""
  9806. order.DrordDrCodg = doctor_info.DoctorNumber
  9807. order.DrordDeptName = department.Name
  9808. order.DrordDeptCodg = department.Number
  9809. order.DrordDrName = doctor_info.UserName
  9810. order.DrordDrProfttl = "234"
  9811. order.CurrDrordFlag = "1"
  9812. orders = append(orders, &order)
  9813. }
  9814. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  9815. var order models.FsiOrderDtos
  9816. order.RxID = strconv.FormatInt(item.ID, 10)
  9817. order.Rxno = strconv.FormatInt(item.ID, 10)
  9818. order.LongDrordFlag = "0"
  9819. order.HilistType = "1"
  9820. order.ChrgType = "1"
  9821. order.DrordBhvr = "-"
  9822. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9823. order.HosplistName = subItem.GoodInfo.GoodName
  9824. order.HilistLv = "1"
  9825. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9826. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9827. order.HosplistName = subItem.GoodInfo.GoodName
  9828. order.Cnt = subItem.Count
  9829. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9830. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9831. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9832. order.OwnpayAmt = ""
  9833. order.SelfpayAmt = ""
  9834. order.Spec = ""
  9835. order.SpecUnt = ""
  9836. order.DrordBegnDate = s_tm
  9837. order.DrordStopDate = ""
  9838. order.DrordDrCodg = doctor_info.DoctorNumber
  9839. order.DrordDeptName = department.Name
  9840. order.DrordDeptCodg = department.Number
  9841. order.DrordDrName = doctor_info.UserName
  9842. order.DrordDrProfttl = "234"
  9843. order.CurrDrordFlag = "1"
  9844. orders = append(orders, &order)
  9845. }
  9846. }
  9847. }
  9848. //处方医嘱信息
  9849. }
  9850. fed.MatnStas = "0"
  9851. fed.MedfeeSumamt = "0"
  9852. fed.OwnpayAmt = "0"
  9853. fed.SelfpayAmt = "0"
  9854. fed.AcctPayamt = "0"
  9855. fed.MaAmt = "0"
  9856. fed.HifpPayamt = "0"
  9857. fed.SetlTotlnum = "1"
  9858. fed.Insutype = his.Insutype
  9859. fed.ReimFlag = "0"
  9860. fed.OutSetlFlag = "0"
  9861. var fopd []*models.FsiOperationDtosData
  9862. data := make(map[string]interface{})
  9863. data["fed"] = fed
  9864. data["fdd"] = fdds
  9865. data["fod"] = orders
  9866. data["pd"] = pd
  9867. data["pp"] = pp
  9868. data["fopd"] = fopd
  9869. data["trig_scen"] = trig_scen
  9870. fmt.Println(data)
  9871. fmt.Println(fed)
  9872. fmt.Println(fdds)
  9873. fmt.Println(orders)
  9874. fmt.Println(pd)
  9875. fmt.Println(pp)
  9876. fmt.Println(fopd)
  9877. client := &http.Client{}
  9878. bytesData, _ := json.Marshal(data)
  9879. var req *http.Request
  9880. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9881. if miConfig.MdtrtareaAdmvs == "320921" {
  9882. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9883. } else {
  9884. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9885. }
  9886. resp, _ := client.Do(req)
  9887. defer resp.Body.Close()
  9888. body, ioErr := ioutil.ReadAll(resp.Body)
  9889. if ioErr != nil {
  9890. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9892. return res
  9893. }
  9894. var respJSON map[string]interface{}
  9895. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9898. return res
  9899. }
  9900. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  9901. fmt.Println(respJSON)
  9902. result, _ := json.Marshal(respJSON)
  9903. fmt.Println(result)
  9904. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9905. utils.ErrorLog("解析失败:%v", err)
  9906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9907. return res
  9908. }
  9909. return res
  9910. } else {
  9911. //if miConfig.MdtrtareaAdmvs == "441202" {
  9912. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  9913. saveLog(output, input, "3101", "事前")
  9914. if err := json.Unmarshal([]byte(output), &res); err != nil {
  9915. utils.ErrorLog("解析失败:%v", err)
  9916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9917. return
  9918. }
  9919. return res
  9920. //}
  9921. }
  9922. }
  9923. 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) {
  9924. adminUser := c.GetAdminUserInfo()
  9925. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9926. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9927. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9928. //record_time := c.GetString("record_time")
  9929. //trig_scen := c.GetString("trig_scen")
  9930. timeLayout := "2006-01-02"
  9931. loc, _ := time.LoadLocation("Local")
  9932. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9933. if err != nil {
  9934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9935. return res
  9936. }
  9937. recordDateTime := theTime.Unix()
  9938. var patientPrescription models.HisPrescriptionInfo
  9939. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9940. if patientPrescription.ID == 0 {
  9941. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9942. }
  9943. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9944. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9945. //
  9946. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  9947. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9948. var pp models.PublicParams
  9949. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9950. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9951. pp.FixmedinsName = miConfig.OrgName
  9952. pp.FixmedinsCode = miConfig.Code
  9953. pp.RequestUrl = miConfig.Url
  9954. pp.Cainfo = miConfig.Cainfo
  9955. pp.SecretKey = miConfig.SecretKey
  9956. pp.AccessKey = miConfig.AccessKey
  9957. pp.OpterName = roles.UserName
  9958. var config []*models.HisXtDiagnoseConfig
  9959. for _, item := range diagnosis_ids {
  9960. id, _ := strconv.ParseInt(item, 10, 64)
  9961. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9962. config = append(config, &diagnosisConfig)
  9963. }
  9964. var pd models.PatientDtos
  9965. pd.PatnID = his.PsnNo
  9966. pd.PatnName = his.Name
  9967. pd.Gend = his.Gend
  9968. pd.Brdy = his.Brdy
  9969. pd.Poolarea = his.InsuplcAdmdvs
  9970. pd.CurrMdtrtID = his.Number
  9971. var fed models.FsiEncounterDtos
  9972. fed.MdtrtID = his.Number
  9973. fed.MedinsID = miConfig.Code
  9974. fed.MedinsName = miConfig.OrgName
  9975. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  9976. fed.MedMdtrtType = "1"
  9977. fed.MedinsType = "1"
  9978. fed.MedinsLv = "11"
  9979. tm := time.Unix(his.RecordDate, 0)
  9980. s_tm := tm.Format("2006-01-02 15:04:05")
  9981. fed.AdmDate = s_tm
  9982. fed.DscgDate = s_tm
  9983. fed.DscgMainDiseCodg = config[0].CountryCode
  9984. fed.DscgMainDiseName = config[0].CountryContentName
  9985. //诊断信息
  9986. var fdds []*models.FsiDiagnoseDtos
  9987. for index, item := range config {
  9988. if index == 0 {
  9989. var fdd models.FsiDiagnoseDtos
  9990. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9991. fdd.InoutDiseType = "1"
  9992. fdd.MaindiseFlag = "1"
  9993. fdd.DiseDate = s_tm
  9994. fdd.DiasSrtNo = "1"
  9995. fdd.DiseName = item.CountryContentName
  9996. fdd.DiseCodg = item.CountryCode
  9997. fdds = append(fdds, &fdd)
  9998. } else {
  9999. var fdd models.FsiDiagnoseDtos
  10000. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10001. fdd.InoutDiseType = "1"
  10002. fdd.MaindiseFlag = "1"
  10003. fdd.DiseDate = s_tm
  10004. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10005. fdd.DiseName = item.CountryContentName
  10006. fdd.DiseCodg = item.CountryCode
  10007. fdds = append(fdds, &fdd)
  10008. }
  10009. }
  10010. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10011. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10012. fed.AdmDeptName = department.Name
  10013. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10014. fed.DscgDeptName = department.Name
  10015. fed.MedMdtrtType = "1"
  10016. fed.MedType = "11"
  10017. //if his.Insutype == "390" {
  10018. // fed.MedType = "1402"
  10019. //} else {
  10020. // fed.MedType = "9933"
  10021. //}
  10022. var orders []*models.FsiOrderDtos
  10023. if trig_scen == "2" {
  10024. //处方医嘱信息
  10025. for _, item := range prescriptions {
  10026. for _, subItem := range item.HisDoctorAdviceInfo {
  10027. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10028. var order models.FsiOrderDtos
  10029. order.RxID = strconv.FormatInt(item.ID, 10)
  10030. order.Rxno = strconv.FormatInt(item.ID, 10)
  10031. order.LongDrordFlag = "0"
  10032. order.HilistType = "1"
  10033. order.ChrgType = "1"
  10034. order.DrordBhvr = "-"
  10035. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10036. order.HosplistName = subItem.BaseDrugLib.DrugName
  10037. order.HilistLv = "1"
  10038. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10039. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10040. order.HosplistName = subItem.BaseDrugLib.DrugName
  10041. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10042. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10043. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10044. order.OwnpayAmt = ""
  10045. order.SelfpayAmt = ""
  10046. order.Spec = ""
  10047. order.SpecUnt = ""
  10048. order.DrordBegnDate = s_tm
  10049. order.DrordStopDate = ""
  10050. order.DrordDrCodg = doctor_info.DoctorNumber
  10051. order.DrordDeptName = department.Name
  10052. order.DrordDeptCodg = department.Number
  10053. order.DrordDrName = doctor_info.UserName
  10054. order.DrordDrProfttl = "234"
  10055. order.CurrDrordFlag = "1"
  10056. orders = append(orders, &order)
  10057. }
  10058. }
  10059. for _, subItem := range item.HisPrescriptionProject {
  10060. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10061. var order models.FsiOrderDtos
  10062. order.RxID = strconv.FormatInt(item.ID, 10)
  10063. order.Rxno = strconv.FormatInt(item.ID, 10)
  10064. order.LongDrordFlag = "0"
  10065. order.HilistType = "1"
  10066. order.ChrgType = "1"
  10067. order.DrordBhvr = "-"
  10068. order.HilistCode = subItem.HisProject.MedicalCode
  10069. order.HosplistName = subItem.HisProject.ProjectName
  10070. order.HilistLv = "1"
  10071. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10072. order.HosplistCode = subItem.HisProject.MedicalCode
  10073. order.HosplistName = subItem.HisProject.ProjectName
  10074. order.Cnt = subItem.Count
  10075. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10076. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10077. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10078. order.OwnpayAmt = ""
  10079. order.SelfpayAmt = ""
  10080. order.Spec = ""
  10081. order.SpecUnt = ""
  10082. order.DrordBegnDate = s_tm
  10083. order.DrordStopDate = ""
  10084. order.DrordDrCodg = doctor_info.DoctorNumber
  10085. order.DrordDeptName = department.Name
  10086. order.DrordDeptCodg = department.Number
  10087. order.DrordDrName = doctor_info.UserName
  10088. order.DrordDrProfttl = "234"
  10089. order.CurrDrordFlag = "1"
  10090. orders = append(orders, &order)
  10091. }
  10092. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10093. var order models.FsiOrderDtos
  10094. order.RxID = strconv.FormatInt(item.ID, 10)
  10095. order.Rxno = strconv.FormatInt(item.ID, 10)
  10096. order.LongDrordFlag = "0"
  10097. order.HilistType = "1"
  10098. order.ChrgType = "1"
  10099. order.DrordBhvr = "-"
  10100. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10101. order.HosplistName = subItem.GoodInfo.GoodName
  10102. order.HilistLv = "1"
  10103. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10104. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10105. order.HosplistName = subItem.GoodInfo.GoodName
  10106. order.Cnt = subItem.Count
  10107. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10108. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10109. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10110. order.OwnpayAmt = ""
  10111. order.SelfpayAmt = ""
  10112. order.Spec = ""
  10113. order.SpecUnt = ""
  10114. order.DrordBegnDate = s_tm
  10115. order.DrordStopDate = ""
  10116. order.DrordDrCodg = doctor_info.DoctorNumber
  10117. order.DrordDeptName = department.Name
  10118. order.DrordDeptCodg = department.Number
  10119. order.DrordDrName = doctor_info.UserName
  10120. order.DrordDrProfttl = "234"
  10121. order.CurrDrordFlag = "1"
  10122. orders = append(orders, &order)
  10123. }
  10124. }
  10125. }
  10126. //处方医嘱信息
  10127. }
  10128. fed.MatnStas = "0"
  10129. fed.MedfeeSumamt = "0"
  10130. fed.OwnpayAmt = "0"
  10131. fed.SelfpayAmt = "0"
  10132. fed.AcctPayamt = "0"
  10133. fed.MaAmt = "0"
  10134. fed.HifpPayamt = "0"
  10135. fed.SetlTotlnum = "1"
  10136. fed.Insutype = his.Insutype
  10137. fed.ReimFlag = "0"
  10138. fed.OutSetlFlag = "0"
  10139. var fopd []*models.FsiOperationDtosData
  10140. data := make(map[string]interface{})
  10141. data["fed"] = fed
  10142. data["fdd"] = fdds
  10143. data["fod"] = orders
  10144. data["pd"] = pd
  10145. data["pp"] = pp
  10146. data["fopd"] = fopd
  10147. data["trig_scen"] = trig_scen
  10148. fmt.Println(data)
  10149. fmt.Println(fed)
  10150. fmt.Println(fdds)
  10151. fmt.Println(orders)
  10152. fmt.Println(pd)
  10153. fmt.Println(pp)
  10154. fmt.Println(fopd)
  10155. client := &http.Client{}
  10156. bytesData, _ := json.Marshal(data)
  10157. var req *http.Request
  10158. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10159. if miConfig.MdtrtareaAdmvs == "320921" {
  10160. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10161. } else {
  10162. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10163. }
  10164. resp, _ := client.Do(req)
  10165. defer resp.Body.Close()
  10166. body, ioErr := ioutil.ReadAll(resp.Body)
  10167. if ioErr != nil {
  10168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10170. return res
  10171. }
  10172. var respJSON map[string]interface{}
  10173. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10176. return res
  10177. }
  10178. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10179. fmt.Println(respJSON)
  10180. result, _ := json.Marshal(respJSON)
  10181. fmt.Println(result)
  10182. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10183. utils.ErrorLog("解析失败:%v", err)
  10184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10185. return res
  10186. }
  10187. return res
  10188. } else {
  10189. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10190. saveLog(output, input, "3101", "事前")
  10191. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10192. utils.ErrorLog("解析失败:%v", err)
  10193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10194. return
  10195. }
  10196. return res
  10197. }
  10198. return res
  10199. }
  10200. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10201. ////patient_id, _ := c.GetInt64("patient_id")
  10202. //order_id, _ := c.GetInt64("order_id")
  10203. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10204. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10205. //trig_scen := c.GetString("trig_scen")
  10206. adminUser := c.GetAdminUserInfo()
  10207. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10208. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10209. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10210. record_time := c.GetString("record_time")
  10211. order, _ := service.GetHisOrderByID(order_id)
  10212. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10213. timeLayout := "2006-01-02"
  10214. loc, _ := time.LoadLocation("Local")
  10215. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10216. if err != nil {
  10217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10218. return
  10219. }
  10220. recordDateTime := theTime.Unix()
  10221. var patientPrescription models.HisPrescriptionInfo
  10222. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10223. if patientPrescription.ID == 0 {
  10224. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10225. }
  10226. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10227. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10228. //
  10229. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10230. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10231. var pp models.PublicParams
  10232. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10233. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10234. pp.FixmedinsName = miConfig.OrgName
  10235. pp.FixmedinsCode = miConfig.Code
  10236. pp.RequestUrl = miConfig.Url
  10237. pp.Cainfo = miConfig.Cainfo
  10238. pp.SecretKey = miConfig.SecretKey
  10239. pp.AccessKey = miConfig.AccessKey
  10240. pp.OpterName = roles.UserName
  10241. var config []*models.HisXtDiagnoseConfig
  10242. for _, item := range diagnosis_ids {
  10243. id, _ := strconv.ParseInt(item, 10, 64)
  10244. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10245. config = append(config, &diagnosisConfig)
  10246. }
  10247. var pd models.PatientDtos
  10248. pd.PatnID = his.PsnNo
  10249. pd.PatnName = his.Name
  10250. pd.Gend = his.Gend
  10251. pd.Brdy = psn_info.Brdy
  10252. pd.Poolarea = his.InsuplcAdmdvs
  10253. pd.CurrMdtrtID = his.Number
  10254. var fed models.FsiEncounterDtos
  10255. fed.MdtrtID = his.Number
  10256. fed.MedinsID = miConfig.Code
  10257. fed.MedinsName = miConfig.OrgName
  10258. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10259. fed.MedMdtrtType = "1"
  10260. fed.MedinsType = "1"
  10261. fed.MedinsLv = "11"
  10262. tm := time.Unix(his.RecordDate, 0)
  10263. s_tm := tm.Format("2006-01-02 15:04:05")
  10264. fed.AdmDate = s_tm
  10265. fed.DscgDate = s_tm
  10266. fed.DscgMainDiseCodg = config[0].CountryCode
  10267. fed.DscgMainDiseName = config[0].CountryContentName
  10268. //诊断信息
  10269. var fdds []*models.FsiDiagnoseDtos
  10270. for index, item := range config {
  10271. if index == 0 {
  10272. var fdd models.FsiDiagnoseDtos
  10273. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10274. fdd.InoutDiseType = "1"
  10275. fdd.MaindiseFlag = "1"
  10276. fdd.DiseDate = s_tm
  10277. fdd.DiasSrtNo = "1"
  10278. fdd.DiseName = item.CountryContentName
  10279. fdd.DiseCodg = item.CountryCode
  10280. fdds = append(fdds, &fdd)
  10281. } else {
  10282. var fdd models.FsiDiagnoseDtos
  10283. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10284. fdd.InoutDiseType = "1"
  10285. fdd.MaindiseFlag = "1"
  10286. fdd.DiseDate = s_tm
  10287. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10288. fdd.DiseName = item.CountryContentName
  10289. fdd.DiseCodg = item.CountryCode
  10290. fdds = append(fdds, &fdd)
  10291. }
  10292. }
  10293. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10294. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10295. fed.AdmDeptName = department.Name
  10296. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10297. fed.DscgDeptName = department.Name
  10298. fed.MedType = order.MedType
  10299. //处方医嘱信息
  10300. var orders []*models.FsiOrderDtos
  10301. //for _, item := range prescriptions {
  10302. // for _, subItem := range item.HisDoctorAdviceInfo {
  10303. // var order models.FsiOrderDtos
  10304. // order.RxID = strconv.FormatInt(item.ID, 10)
  10305. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10306. // order.LongDrordFlag = "0"
  10307. // order.HilistType = "1"
  10308. // order.ChrgType = "1"
  10309. // order.DrordBhvr = "-"
  10310. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10311. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10312. // order.HilistLv = "1"
  10313. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10314. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10315. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10316. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10317. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10318. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10319. // order.OwnpayAmt = ""
  10320. // order.SelfpayAmt = ""
  10321. // order.Spec = ""
  10322. // order.SpecUnt = ""
  10323. // order.DrordBegnDate = s_tm
  10324. // order.DrordStopDate = ""
  10325. // order.DrordDrCodg = "1"
  10326. // order.DrordDeptName = department.Name
  10327. // order.DrordDrCodg = "1"
  10328. // order.DrordDrName = doctor_info.UserName
  10329. // order.DrordDrProfttl = ""
  10330. // order.CurrDrordFlag = "1"
  10331. // orders = append(orders, &order)
  10332. // }
  10333. // for _, subItem := range item.HisPrescriptionProject {
  10334. // if subItem.Type == 2 {
  10335. // var order models.FsiOrderDtos
  10336. // order.RxID = strconv.FormatInt(item.ID, 10)
  10337. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10338. // order.LongDrordFlag = "0"
  10339. // order.HilistType = "1"
  10340. // order.ChrgType = "1"
  10341. // order.DrordBhvr = "-"
  10342. // order.HilistCode = subItem.HisProject.MedicalCode
  10343. // order.HosplistName = subItem.HisProject.ProjectName
  10344. // order.HilistLv = "1"
  10345. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10346. // order.HosplistCode = subItem.HisProject.MedicalCode
  10347. // order.HosplistName = subItem.HisProject.ProjectName
  10348. // order.Cnt = subItem.Count
  10349. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10350. //
  10351. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10352. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10353. // order.OwnpayAmt = ""
  10354. // order.SelfpayAmt = ""
  10355. // order.Spec = ""
  10356. // order.SpecUnt = ""
  10357. // order.DrordBegnDate = s_tm
  10358. // order.DrordStopDate = ""
  10359. // order.DrordDrCodg = "1"
  10360. // order.DrordDeptName = department.Name
  10361. // order.DrordDrCodg = "1"
  10362. // order.DrordDrName = doctor_info.UserName
  10363. // order.DrordDrProfttl = ""
  10364. // order.CurrDrordFlag = "1"
  10365. // orders = append(orders, &order)
  10366. //
  10367. // }
  10368. // if subItem.Type == 3 {
  10369. //
  10370. // var order models.FsiOrderDtos
  10371. // order.RxID = strconv.FormatInt(item.ID, 10)
  10372. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10373. // order.LongDrordFlag = "0"
  10374. // order.HilistType = "1"
  10375. // order.ChrgType = "1"
  10376. // order.DrordBhvr = "-"
  10377. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10378. // order.HosplistName = subItem.GoodInfo.GoodName
  10379. // order.HilistLv = "1"
  10380. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10381. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10382. // order.HosplistName = subItem.GoodInfo.GoodName
  10383. // order.Cnt = subItem.Count
  10384. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10385. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10386. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10387. // order.OwnpayAmt = ""
  10388. // order.SelfpayAmt = ""
  10389. // order.Spec = ""
  10390. // order.SpecUnt = ""
  10391. // order.DrordBegnDate = s_tm
  10392. // order.DrordStopDate = ""
  10393. // order.DrordDrCodg = "1"
  10394. // order.DrordDeptName = department.Name
  10395. // order.DrordDrCodg = "1"
  10396. // order.DrordDrName = doctor_info.UserName
  10397. // order.DrordDrProfttl = ""
  10398. // order.CurrDrordFlag = "1"
  10399. // orders = append(orders, &order)
  10400. //
  10401. // }
  10402. // }
  10403. //}
  10404. for _, item := range prescriptions {
  10405. for _, subItem := range item.HisDoctorAdviceInfo {
  10406. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10407. var order models.FsiOrderDtos
  10408. order.RxID = strconv.FormatInt(item.ID, 10)
  10409. order.Rxno = strconv.FormatInt(item.ID, 10)
  10410. order.LongDrordFlag = "0"
  10411. order.HilistType = "1"
  10412. order.ChrgType = "1"
  10413. order.DrordBhvr = "-"
  10414. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10415. order.HosplistName = subItem.BaseDrugLib.DrugName
  10416. order.HilistLv = "1"
  10417. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10418. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10419. order.HosplistName = subItem.BaseDrugLib.DrugName
  10420. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10421. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10422. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10423. order.OwnpayAmt = ""
  10424. order.SelfpayAmt = ""
  10425. order.Spec = ""
  10426. order.SpecUnt = ""
  10427. order.DrordBegnDate = s_tm
  10428. order.DrordStopDate = ""
  10429. order.DrordDrCodg = doctor_info.DoctorNumber
  10430. order.DrordDeptName = department.Name
  10431. order.DrordDeptCodg = department.Number
  10432. order.DrordDrName = doctor_info.UserName
  10433. order.DrordDrProfttl = "234"
  10434. order.CurrDrordFlag = "1"
  10435. orders = append(orders, &order)
  10436. }
  10437. }
  10438. for _, subItem := range item.HisPrescriptionProject {
  10439. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10440. var order models.FsiOrderDtos
  10441. order.RxID = strconv.FormatInt(item.ID, 10)
  10442. order.Rxno = strconv.FormatInt(item.ID, 10)
  10443. order.LongDrordFlag = "0"
  10444. order.HilistType = "1"
  10445. order.ChrgType = "1"
  10446. order.DrordBhvr = "-"
  10447. order.HilistCode = subItem.HisProject.MedicalCode
  10448. order.HosplistName = subItem.HisProject.ProjectName
  10449. order.HilistLv = "1"
  10450. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10451. order.HosplistCode = subItem.HisProject.MedicalCode
  10452. order.HosplistName = subItem.HisProject.ProjectName
  10453. order.Cnt = subItem.Count
  10454. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10455. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10456. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10457. order.OwnpayAmt = ""
  10458. order.SelfpayAmt = ""
  10459. order.Spec = ""
  10460. order.SpecUnt = ""
  10461. order.DrordBegnDate = s_tm
  10462. order.DrordStopDate = ""
  10463. order.DrordDrCodg = doctor_info.DoctorNumber
  10464. order.DrordDeptName = department.Name
  10465. order.DrordDeptCodg = department.Number
  10466. order.DrordDrName = doctor_info.UserName
  10467. order.DrordDrProfttl = "234"
  10468. order.CurrDrordFlag = "1"
  10469. orders = append(orders, &order)
  10470. }
  10471. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10472. var order models.FsiOrderDtos
  10473. order.RxID = strconv.FormatInt(item.ID, 10)
  10474. order.Rxno = strconv.FormatInt(item.ID, 10)
  10475. order.LongDrordFlag = "0"
  10476. order.HilistType = "1"
  10477. order.ChrgType = "1"
  10478. order.DrordBhvr = "0"
  10479. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10480. order.HosplistName = subItem.GoodInfo.GoodName
  10481. order.HilistLv = "1"
  10482. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10483. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10484. order.HosplistName = subItem.GoodInfo.GoodName
  10485. order.Cnt = subItem.Count
  10486. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10487. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10488. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10489. order.OwnpayAmt = ""
  10490. order.SelfpayAmt = ""
  10491. order.Spec = ""
  10492. order.SpecUnt = ""
  10493. order.DrordBegnDate = s_tm
  10494. order.DrordStopDate = ""
  10495. order.DrordDrCodg = doctor_info.DoctorNumber
  10496. order.DrordDeptName = department.Name
  10497. order.DrordDeptCodg = department.Number
  10498. order.DrordDrName = doctor_info.UserName
  10499. order.DrordDrProfttl = "234"
  10500. order.CurrDrordFlag = "1"
  10501. orders = append(orders, &order)
  10502. }
  10503. }
  10504. }
  10505. //处方医嘱信息
  10506. fed.MatnStas = "0"
  10507. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  10508. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  10509. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  10510. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  10511. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  10512. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  10513. fed.SetlTotlnum = "1"
  10514. fed.Insutype = his.Insutype
  10515. fed.ReimFlag = "0"
  10516. fed.OutSetlFlag = "0"
  10517. var fopd []*models.FsiOperationDtosData
  10518. data := make(map[string]interface{})
  10519. data["fed"] = fed
  10520. data["fdd"] = fdds
  10521. data["fod"] = orders
  10522. data["pd"] = pd
  10523. data["pp"] = pp
  10524. data["fopd"] = fopd
  10525. data["trig_scen"] = trig_scen
  10526. client := &http.Client{}
  10527. bytesData, _ := json.Marshal(data)
  10528. var req *http.Request
  10529. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10530. if miConfig.MdtrtareaAdmvs == "320921" {
  10531. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10532. } else {
  10533. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10534. }
  10535. resp, _ := client.Do(req)
  10536. defer resp.Body.Close()
  10537. body, ioErr := ioutil.ReadAll(resp.Body)
  10538. if ioErr != nil {
  10539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10541. return res
  10542. }
  10543. var respJSON map[string]interface{}
  10544. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10547. return res
  10548. }
  10549. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10550. result, _ := json.Marshal(respJSON)
  10551. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10552. utils.ErrorLog("解析失败:%v", err)
  10553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10554. return res
  10555. }
  10556. return res
  10557. } else {
  10558. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10559. saveLog(output, input, "3102", "事中")
  10560. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10561. utils.ErrorLog("解析失败:%v", err)
  10562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10563. return
  10564. }
  10565. return res
  10566. }
  10567. return res
  10568. }
  10569. 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) {
  10570. var res Resultgd3101
  10571. adminUser := c.GetAdminUserInfo()
  10572. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10573. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10574. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10575. //record_time := c.GetString("record_time")
  10576. //trig_scen := c.GetString("trig_scen")
  10577. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  10578. //psn_info, _ := service.GetPatientId(patient_id)
  10579. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  10580. timeLayout := "2006-01-02"
  10581. loc, _ := time.LoadLocation("Local")
  10582. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10583. if err != nil {
  10584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10585. return res
  10586. }
  10587. recordDateTime := theTime.Unix()
  10588. var patientPrescription models.HisPrescriptionInfo
  10589. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10590. //if patientPrescription.ID == 0 {
  10591. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10592. //}
  10593. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10594. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10595. //
  10596. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10597. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10598. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  10599. var pp models.PublicParams
  10600. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10601. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10602. pp.FixmedinsName = miConfig.OrgName
  10603. pp.FixmedinsCode = miConfig.Code
  10604. pp.RequestUrl = miConfig.Url
  10605. pp.Cainfo = miConfig.Cainfo
  10606. pp.SecretKey = miConfig.SecretKey
  10607. pp.AccessKey = miConfig.AccessKey
  10608. pp.OpterName = roles.UserName
  10609. var config []*models.HisXtDiagnoseConfig
  10610. for _, item := range diagnosis_ids {
  10611. id, _ := strconv.ParseInt(item, 10, 64)
  10612. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10613. config = append(config, &diagnosisConfig)
  10614. }
  10615. var pd models.PatientDtos
  10616. pd.PatnID = his.PsnNo
  10617. pd.PatnName = his.Name
  10618. pd.Gend = his.Gend
  10619. pd.Brdy = str
  10620. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10621. pd.CurrMdtrtID = his.Number
  10622. var fed models.FsiEncounterDtos
  10623. fed.MdtrtID = his.Number
  10624. fed.MedinsID = miConfig.Code
  10625. fed.MedinsName = miConfig.OrgName
  10626. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10627. fed.MedMdtrtType = "1"
  10628. fed.MedinsType = "1"
  10629. fed.MedinsLv = "11"
  10630. tm := time.Unix(his.RecordDate, 0)
  10631. s_tm := tm.Format("2006-01-02 15:04:05")
  10632. fed.AdmDate = s_tm
  10633. fed.DscgDate = s_tm
  10634. fed.DscgMainDiseCodg = config[0].CountryCode
  10635. fed.DscgMainDiseName = config[0].CountryContentName
  10636. //诊断信息
  10637. var fdds []*models.FsiDiagnoseDtos
  10638. for index, item := range config {
  10639. if index == 0 {
  10640. var fdd models.FsiDiagnoseDtos
  10641. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10642. fdd.InoutDiseType = "1"
  10643. fdd.MaindiseFlag = "1"
  10644. fdd.DiseDate = s_tm
  10645. fdd.DiasSrtNo = "1"
  10646. fdd.DiseName = item.CountryContentName
  10647. fdd.DiseCodg = item.CountryCode
  10648. fdds = append(fdds, &fdd)
  10649. } else {
  10650. var fdd models.FsiDiagnoseDtos
  10651. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10652. fdd.InoutDiseType = "1"
  10653. fdd.MaindiseFlag = "1"
  10654. fdd.DiseDate = s_tm
  10655. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10656. fdd.DiseName = item.CountryContentName
  10657. fdd.DiseCodg = item.CountryCode
  10658. fdds = append(fdds, &fdd)
  10659. }
  10660. }
  10661. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10662. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10663. fed.AdmDeptName = de.Name
  10664. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10665. fed.DscgDeptName = de.Name
  10666. fed.MedMdtrtType = "1"
  10667. fed.MedType = "11"
  10668. //if his.Insutype == "390" {
  10669. // fed.MedType = "1402"
  10670. //} else {
  10671. // fed.MedType = "9933"
  10672. //}
  10673. var orders []*models.FsiOrderDtos
  10674. if trig_scen == "2" {
  10675. //处方医嘱信息
  10676. for _, item := range prescriptions {
  10677. for _, subItem := range item.HisDoctorAdviceInfo {
  10678. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10679. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  10680. var order models.FsiOrderDtos
  10681. order.RxID = strconv.FormatInt(item.ID, 10)
  10682. order.Rxno = strconv.FormatInt(item.ID, 10)
  10683. order.LongDrordFlag = "0"
  10684. order.HilistType = "1"
  10685. order.ChrgType = "1"
  10686. order.DrordBhvr = "0"
  10687. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10688. order.HosplistName = subItem.BaseDrugLib.DrugName
  10689. order.HilistLv = "1"
  10690. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10691. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10692. order.HosplistName = subItem.BaseDrugLib.DrugName
  10693. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10694. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10695. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10696. order.OwnpayAmt = ""
  10697. order.SelfpayAmt = ""
  10698. order.Spec = spec
  10699. order.SpecUnt = subItem.PrescribingNumberUnit
  10700. order.DrordBegnDate = s_tm
  10701. order.DrordStopDate = ""
  10702. order.DrordDrCodg = doctor_info.DoctorNumber
  10703. order.DrordDeptName = department.Name
  10704. order.DrordDeptCodg = department.Number
  10705. order.DrordDrName = doctor_info.UserName
  10706. order.DrordDrProfttl = "234"
  10707. order.CurrDrordFlag = "1"
  10708. orders = append(orders, &order)
  10709. }
  10710. }
  10711. for _, subItem := range item.HisPrescriptionProject {
  10712. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10713. var order models.FsiOrderDtos
  10714. order.RxID = strconv.FormatInt(item.ID, 10)
  10715. order.Rxno = strconv.FormatInt(item.ID, 10)
  10716. order.LongDrordFlag = "0"
  10717. order.HilistType = "1"
  10718. order.ChrgType = "1"
  10719. order.DrordBhvr = "0"
  10720. order.HilistCode = subItem.HisProject.MedicalCode
  10721. order.HosplistName = subItem.HisProject.ProjectName
  10722. order.HilistLv = "1"
  10723. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10724. order.HosplistCode = subItem.HisProject.MedicalCode
  10725. order.HosplistName = subItem.HisProject.ProjectName
  10726. order.Cnt = subItem.Count
  10727. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10728. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10729. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10730. order.OwnpayAmt = ""
  10731. order.SelfpayAmt = ""
  10732. order.Spec = subItem.Unit
  10733. order.SpecUnt = subItem.Unit
  10734. order.DrordBegnDate = s_tm
  10735. order.DrordStopDate = ""
  10736. order.DrordDrCodg = doctor_info.DoctorNumber
  10737. order.DrordDeptName = department.Name
  10738. order.DrordDeptCodg = department.Number
  10739. order.DrordDrName = doctor_info.UserName
  10740. order.DrordDrProfttl = "234"
  10741. order.CurrDrordFlag = "1"
  10742. orders = append(orders, &order)
  10743. }
  10744. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10745. var order models.FsiOrderDtos
  10746. order.RxID = strconv.FormatInt(item.ID, 10)
  10747. order.Rxno = strconv.FormatInt(item.ID, 10)
  10748. order.LongDrordFlag = "0"
  10749. order.HilistType = "1"
  10750. order.ChrgType = "1"
  10751. order.DrordBhvr = "0"
  10752. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10753. order.HosplistName = subItem.GoodInfo.GoodName
  10754. order.HilistLv = "1"
  10755. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10756. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10757. order.HosplistName = subItem.GoodInfo.GoodName
  10758. order.Cnt = subItem.Count
  10759. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10760. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10761. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10762. order.OwnpayAmt = ""
  10763. order.SelfpayAmt = ""
  10764. order.Spec = subItem.GoodInfo.SpecificationName
  10765. order.SpecUnt = subItem.Unit
  10766. order.DrordBegnDate = s_tm
  10767. order.DrordStopDate = ""
  10768. order.DrordDrCodg = doctor_info.DoctorNumber
  10769. order.DrordDeptName = department.Name
  10770. order.DrordDeptCodg = department.Number
  10771. order.DrordDrName = doctor_info.UserName
  10772. order.DrordDrProfttl = "234"
  10773. order.CurrDrordFlag = "1"
  10774. orders = append(orders, &order)
  10775. }
  10776. }
  10777. }
  10778. //处方医嘱信息
  10779. }
  10780. fed.MatnStas = "0"
  10781. fed.MedfeeSumamt = "0"
  10782. fed.OwnpayAmt = "0"
  10783. fed.SelfpayAmt = "0"
  10784. fed.AcctPayamt = "0"
  10785. fed.MaAmt = "0"
  10786. fed.HifpPayamt = "0"
  10787. fed.SetlTotlnum = "1"
  10788. fed.Insutype = his.Insutype
  10789. fed.ReimFlag = "0"
  10790. fed.OutSetlFlag = "0"
  10791. var fopd []*models.FsiOperationDtosData
  10792. data := make(map[string]interface{})
  10793. data["fed"] = fed
  10794. data["fdd"] = fdds
  10795. data["fod"] = orders
  10796. data["pd"] = pd
  10797. data["pp"] = pp
  10798. data["fopd"] = fopd
  10799. data["trig_scen"] = trig_scen
  10800. fmt.Println(data)
  10801. fmt.Println(fed)
  10802. fmt.Println(fdds)
  10803. fmt.Println(orders)
  10804. fmt.Println(pd)
  10805. fmt.Println(pp)
  10806. fmt.Println(fopd)
  10807. client := &http.Client{}
  10808. bytesData, _ := json.Marshal(data)
  10809. var req *http.Request
  10810. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10811. if miConfig.MdtrtareaAdmvs == "320921" {
  10812. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10813. } else {
  10814. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10815. }
  10816. resp, _ := client.Do(req)
  10817. defer resp.Body.Close()
  10818. body, ioErr := ioutil.ReadAll(resp.Body)
  10819. if ioErr != nil {
  10820. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10822. return res
  10823. }
  10824. var respJSON map[string]interface{}
  10825. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10828. return res
  10829. }
  10830. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10831. fmt.Println(respJSON)
  10832. result, _ := json.Marshal(respJSON)
  10833. fmt.Println(result)
  10834. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10835. utils.ErrorLog("解析失败:%v", err)
  10836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10837. return res
  10838. }
  10839. return res
  10840. } else {
  10841. //if miConfig.MdtrtareaAdmvs == "441202" {
  10842. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10843. saveLog(output, input, "3101", "事前")
  10844. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10845. utils.ErrorLog("解析失败:%v", err)
  10846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10847. return
  10848. }
  10849. return res
  10850. //}
  10851. }
  10852. }
  10853. 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) {
  10854. adminUser := c.GetAdminUserInfo()
  10855. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10856. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10857. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10858. //record_time := c.GetString("record_time")
  10859. //trig_scen := c.GetString("trig_scen")
  10860. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  10861. timeLayout := "2006-01-02"
  10862. loc, _ := time.LoadLocation("Local")
  10863. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10864. if err != nil {
  10865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10866. return res
  10867. }
  10868. recordDateTime := theTime.Unix()
  10869. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  10870. var patientPrescription models.HisPrescriptionInfo
  10871. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10872. if patientPrescription.ID == 0 {
  10873. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10874. }
  10875. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10876. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10877. //
  10878. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10879. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10880. var pp models.PublicParams
  10881. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10882. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10883. pp.FixmedinsName = miConfig.OrgName
  10884. pp.FixmedinsCode = miConfig.Code
  10885. pp.RequestUrl = miConfig.Url
  10886. pp.Cainfo = miConfig.Cainfo
  10887. pp.SecretKey = miConfig.SecretKey
  10888. pp.AccessKey = miConfig.AccessKey
  10889. pp.OpterName = roles.UserName
  10890. var config []*models.HisXtDiagnoseConfig
  10891. for _, item := range diagnosis_ids {
  10892. id, _ := strconv.ParseInt(item, 10, 64)
  10893. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10894. config = append(config, &diagnosisConfig)
  10895. }
  10896. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  10897. var pd models.PatientDtos
  10898. pd.PatnID = his.PsnNo
  10899. pd.PatnName = his.Name
  10900. pd.Gend = his.Gend
  10901. pd.Brdy = str
  10902. pd.Poolarea = his.InsuplcAdmdvs
  10903. pd.CurrMdtrtID = his.Number
  10904. var fed models.FsiEncounterDtos
  10905. fed.MdtrtID = his.Number
  10906. fed.MedinsID = miConfig.Code
  10907. fed.MedinsName = miConfig.OrgName
  10908. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10909. fed.MedMdtrtType = "1"
  10910. fed.MedinsType = "1"
  10911. fed.MedinsLv = "11"
  10912. tm := time.Unix(his.RecordDate, 0)
  10913. s_tm := tm.Format("2006-01-02 15:04:05")
  10914. fed.AdmDate = s_tm
  10915. fed.DscgDate = s_tm
  10916. fed.DscgMainDiseCodg = config[0].CountryCode
  10917. fed.DscgMainDiseName = config[0].CountryContentName
  10918. //诊断信息
  10919. var fdds []*models.FsiDiagnoseDtos
  10920. for index, item := range config {
  10921. if index == 0 {
  10922. var fdd models.FsiDiagnoseDtos
  10923. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10924. fdd.InoutDiseType = "1"
  10925. fdd.MaindiseFlag = "1"
  10926. fdd.DiseDate = s_tm
  10927. fdd.DiasSrtNo = "1"
  10928. fdd.DiseName = item.CountryContentName
  10929. fdd.DiseCodg = item.CountryCode
  10930. fdds = append(fdds, &fdd)
  10931. } else {
  10932. var fdd models.FsiDiagnoseDtos
  10933. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10934. fdd.InoutDiseType = "1"
  10935. fdd.MaindiseFlag = "1"
  10936. fdd.DiseDate = s_tm
  10937. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10938. fdd.DiseName = item.CountryContentName
  10939. fdd.DiseCodg = item.CountryCode
  10940. fdds = append(fdds, &fdd)
  10941. }
  10942. }
  10943. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10944. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10945. fed.AdmDeptName = department.Name
  10946. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10947. fed.DscgDeptName = department.Name
  10948. fed.MedMdtrtType = "1"
  10949. fed.MedType = "11"
  10950. //if his.Insutype == "390" {
  10951. // fed.MedType = "1402"
  10952. //} else {
  10953. // fed.MedType = "9933"
  10954. //}
  10955. var orders []*models.FsiOrderDtos
  10956. if trig_scen == "2" {
  10957. //处方医嘱信息
  10958. for _, item := range prescriptions {
  10959. for _, subItem := range item.HisDoctorAdviceInfo {
  10960. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10961. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  10962. var order models.FsiOrderDtos
  10963. order.RxID = strconv.FormatInt(item.ID, 10)
  10964. order.Rxno = strconv.FormatInt(item.ID, 10)
  10965. order.LongDrordFlag = "0"
  10966. order.HilistType = "1"
  10967. order.ChrgType = "1"
  10968. order.DrordBhvr = "0"
  10969. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10970. order.HosplistName = subItem.BaseDrugLib.DrugName
  10971. order.HilistLv = "1"
  10972. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10973. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10974. order.HosplistName = subItem.BaseDrugLib.DrugName
  10975. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10976. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10977. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10978. order.OwnpayAmt = ""
  10979. order.SelfpayAmt = ""
  10980. order.Spec = spec
  10981. order.SpecUnt = subItem.PrescribingNumberUnit
  10982. order.DrordBegnDate = s_tm
  10983. order.DrordStopDate = ""
  10984. order.DrordDrCodg = doctor_info.DoctorNumber
  10985. order.DrordDeptName = department.Name
  10986. order.DrordDeptCodg = department.Number
  10987. order.DrordDrName = doctor_info.UserName
  10988. order.DrordDrProfttl = "234"
  10989. order.CurrDrordFlag = "1"
  10990. orders = append(orders, &order)
  10991. }
  10992. }
  10993. for _, subItem := range item.HisPrescriptionProject {
  10994. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10995. var order models.FsiOrderDtos
  10996. order.RxID = strconv.FormatInt(item.ID, 10)
  10997. order.Rxno = strconv.FormatInt(item.ID, 10)
  10998. order.LongDrordFlag = "0"
  10999. order.HilistType = "1"
  11000. order.ChrgType = "1"
  11001. order.DrordBhvr = "0"
  11002. order.HilistCode = subItem.HisProject.MedicalCode
  11003. order.HosplistName = subItem.HisProject.ProjectName
  11004. order.HilistLv = "1"
  11005. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11006. order.HosplistCode = subItem.HisProject.MedicalCode
  11007. order.HosplistName = subItem.HisProject.ProjectName
  11008. order.Cnt = subItem.Count
  11009. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11010. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11011. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11012. order.OwnpayAmt = ""
  11013. order.SelfpayAmt = ""
  11014. order.Spec = subItem.Unit
  11015. order.SpecUnt = subItem.Unit
  11016. order.DrordBegnDate = s_tm
  11017. order.DrordStopDate = ""
  11018. order.DrordDrCodg = doctor_info.DoctorNumber
  11019. order.DrordDeptName = department.Name
  11020. order.DrordDeptCodg = department.Number
  11021. order.DrordDrName = doctor_info.UserName
  11022. order.DrordDrProfttl = "234"
  11023. order.CurrDrordFlag = "1"
  11024. orders = append(orders, &order)
  11025. }
  11026. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11027. var order models.FsiOrderDtos
  11028. order.RxID = strconv.FormatInt(item.ID, 10)
  11029. order.Rxno = strconv.FormatInt(item.ID, 10)
  11030. order.LongDrordFlag = "0"
  11031. order.HilistType = "1"
  11032. order.ChrgType = "1"
  11033. order.DrordBhvr = "0"
  11034. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11035. order.HosplistName = subItem.GoodInfo.GoodName
  11036. order.HilistLv = "1"
  11037. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11038. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11039. order.HosplistName = subItem.GoodInfo.GoodName
  11040. order.Cnt = subItem.Count
  11041. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11042. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11043. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11044. order.OwnpayAmt = ""
  11045. order.SelfpayAmt = ""
  11046. order.Spec = subItem.GoodInfo.SpecificationName
  11047. order.SpecUnt = subItem.Unit
  11048. order.DrordBegnDate = s_tm
  11049. order.DrordStopDate = ""
  11050. order.DrordDrCodg = doctor_info.DoctorNumber
  11051. order.DrordDeptName = department.Name
  11052. order.DrordDeptCodg = department.Number
  11053. order.DrordDrName = doctor_info.UserName
  11054. order.DrordDrProfttl = "234"
  11055. order.CurrDrordFlag = "1"
  11056. orders = append(orders, &order)
  11057. }
  11058. }
  11059. }
  11060. //处方医嘱信息
  11061. }
  11062. fed.MatnStas = "0"
  11063. fed.MedfeeSumamt = "0"
  11064. fed.OwnpayAmt = "0"
  11065. fed.SelfpayAmt = "0"
  11066. fed.AcctPayamt = "0"
  11067. fed.MaAmt = "0"
  11068. fed.HifpPayamt = "0"
  11069. fed.SetlTotlnum = "1"
  11070. fed.Insutype = his.Insutype
  11071. fed.ReimFlag = "0"
  11072. fed.OutSetlFlag = "0"
  11073. var fopd []*models.FsiOperationDtosData
  11074. data := make(map[string]interface{})
  11075. data["fed"] = fed
  11076. data["fdd"] = fdds
  11077. data["fod"] = orders
  11078. data["pd"] = pd
  11079. data["pp"] = pp
  11080. data["fopd"] = fopd
  11081. data["trig_scen"] = trig_scen
  11082. fmt.Println(data)
  11083. fmt.Println(fed)
  11084. fmt.Println(fdds)
  11085. fmt.Println(orders)
  11086. fmt.Println(pd)
  11087. fmt.Println(pp)
  11088. fmt.Println(fopd)
  11089. client := &http.Client{}
  11090. bytesData, _ := json.Marshal(data)
  11091. var req *http.Request
  11092. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11093. if miConfig.MdtrtareaAdmvs == "320921" {
  11094. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11095. } else {
  11096. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11097. }
  11098. resp, _ := client.Do(req)
  11099. defer resp.Body.Close()
  11100. body, ioErr := ioutil.ReadAll(resp.Body)
  11101. if ioErr != nil {
  11102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11104. return res
  11105. }
  11106. var respJSON map[string]interface{}
  11107. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11110. return res
  11111. }
  11112. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11113. fmt.Println(respJSON)
  11114. result, _ := json.Marshal(respJSON)
  11115. fmt.Println(result)
  11116. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11117. utils.ErrorLog("解析失败:%v", err)
  11118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11119. return res
  11120. }
  11121. return res
  11122. } else {
  11123. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11124. saveLog(output, input, "3101", "事前")
  11125. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11126. utils.ErrorLog("解析失败:%v", err)
  11127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11128. return
  11129. }
  11130. return res
  11131. }
  11132. return res
  11133. }
  11134. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11135. ////patient_id, _ := c.GetInt64("patient_id")
  11136. //order_id, _ := c.GetInt64("order_id")
  11137. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11138. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11139. //trig_scen := c.GetString("trig_scen")
  11140. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11141. //utils.ErrorLog("解析失败:%v", psn_info)
  11142. adminUser := c.GetAdminUserInfo()
  11143. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11144. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11145. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11146. record_time := c.GetString("record_time")
  11147. order, _ := service.GetHisOrderByID(order_id)
  11148. timeLayout := "2006-01-02"
  11149. loc, _ := time.LoadLocation("Local")
  11150. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11151. if err != nil {
  11152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11153. return
  11154. }
  11155. recordDateTime := theTime.Unix()
  11156. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11157. var patientPrescription models.HisPrescriptionInfo
  11158. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11159. if patientPrescription.ID == 0 {
  11160. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11161. }
  11162. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11163. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11164. //
  11165. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11166. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11167. var pp models.PublicParams
  11168. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11169. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11170. pp.FixmedinsName = miConfig.OrgName
  11171. pp.FixmedinsCode = miConfig.Code
  11172. pp.RequestUrl = miConfig.Url
  11173. pp.Cainfo = miConfig.Cainfo
  11174. pp.SecretKey = miConfig.SecretKey
  11175. pp.AccessKey = miConfig.AccessKey
  11176. pp.OpterName = roles.UserName
  11177. var config []*models.HisXtDiagnoseConfig
  11178. for _, item := range diagnosis_ids {
  11179. id, _ := strconv.ParseInt(item, 10, 64)
  11180. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11181. config = append(config, &diagnosisConfig)
  11182. }
  11183. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11184. var pd models.PatientDtos
  11185. pd.PatnID = his.PsnNo
  11186. pd.PatnName = his.Name
  11187. pd.Gend = his.Gend
  11188. pd.Brdy = str
  11189. pd.Poolarea = his.InsuplcAdmdvs
  11190. pd.CurrMdtrtID = his.Number
  11191. var fed models.FsiEncounterDtos
  11192. fed.MdtrtID = his.Number
  11193. fed.MedinsID = miConfig.Code
  11194. fed.MedinsName = miConfig.OrgName
  11195. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11196. fed.MedMdtrtType = "1"
  11197. fed.MedinsType = "1"
  11198. fed.MedinsLv = "11"
  11199. tm := time.Unix(his.RecordDate, 0)
  11200. s_tm := tm.Format("2006-01-02 15:04:05")
  11201. fed.AdmDate = s_tm
  11202. fed.DscgDate = s_tm
  11203. fed.DscgMainDiseCodg = config[0].CountryCode
  11204. fed.DscgMainDiseName = config[0].CountryContentName
  11205. //诊断信息
  11206. var fdds []*models.FsiDiagnoseDtos
  11207. for index, item := range config {
  11208. if index == 0 {
  11209. var fdd models.FsiDiagnoseDtos
  11210. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11211. fdd.InoutDiseType = "1"
  11212. fdd.MaindiseFlag = "1"
  11213. fdd.DiseDate = s_tm
  11214. fdd.DiasSrtNo = "1"
  11215. fdd.DiseName = item.CountryContentName
  11216. fdd.DiseCodg = item.CountryCode
  11217. fdds = append(fdds, &fdd)
  11218. } else {
  11219. var fdd models.FsiDiagnoseDtos
  11220. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11221. fdd.InoutDiseType = "1"
  11222. fdd.MaindiseFlag = "1"
  11223. fdd.DiseDate = s_tm
  11224. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11225. fdd.DiseName = item.CountryContentName
  11226. fdd.DiseCodg = item.CountryCode
  11227. fdds = append(fdds, &fdd)
  11228. }
  11229. }
  11230. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11231. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11232. fed.AdmDeptName = department.Name
  11233. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11234. fed.DscgDeptName = department.Name
  11235. fed.MedType = order.MedType
  11236. //处方医嘱信息
  11237. var orders []*models.FsiOrderDtos
  11238. //for _, item := range prescriptions {
  11239. // for _, subItem := range item.HisDoctorAdviceInfo {
  11240. // var order models.FsiOrderDtos
  11241. // order.RxID = strconv.FormatInt(item.ID, 10)
  11242. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11243. // order.LongDrordFlag = "0"
  11244. // order.HilistType = "1"
  11245. // order.ChrgType = "1"
  11246. // order.DrordBhvr = "-"
  11247. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11248. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11249. // order.HilistLv = "1"
  11250. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11251. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11252. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11253. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11254. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11255. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11256. // order.OwnpayAmt = ""
  11257. // order.SelfpayAmt = ""
  11258. // order.Spec = ""
  11259. // order.SpecUnt = ""
  11260. // order.DrordBegnDate = s_tm
  11261. // order.DrordStopDate = ""
  11262. // order.DrordDrCodg = "1"
  11263. // order.DrordDeptName = department.Name
  11264. // order.DrordDrCodg = "1"
  11265. // order.DrordDrName = doctor_info.UserName
  11266. // order.DrordDrProfttl = ""
  11267. // order.CurrDrordFlag = "1"
  11268. // orders = append(orders, &order)
  11269. // }
  11270. // for _, subItem := range item.HisPrescriptionProject {
  11271. // if subItem.Type == 2 {
  11272. // var order models.FsiOrderDtos
  11273. // order.RxID = strconv.FormatInt(item.ID, 10)
  11274. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11275. // order.LongDrordFlag = "0"
  11276. // order.HilistType = "1"
  11277. // order.ChrgType = "1"
  11278. // order.DrordBhvr = "-"
  11279. // order.HilistCode = subItem.HisProject.MedicalCode
  11280. // order.HosplistName = subItem.HisProject.ProjectName
  11281. // order.HilistLv = "1"
  11282. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11283. // order.HosplistCode = subItem.HisProject.MedicalCode
  11284. // order.HosplistName = subItem.HisProject.ProjectName
  11285. // order.Cnt = subItem.Count
  11286. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11287. //
  11288. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11289. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11290. // order.OwnpayAmt = ""
  11291. // order.SelfpayAmt = ""
  11292. // order.Spec = ""
  11293. // order.SpecUnt = ""
  11294. // order.DrordBegnDate = s_tm
  11295. // order.DrordStopDate = ""
  11296. // order.DrordDrCodg = "1"
  11297. // order.DrordDeptName = department.Name
  11298. // order.DrordDrCodg = "1"
  11299. // order.DrordDrName = doctor_info.UserName
  11300. // order.DrordDrProfttl = ""
  11301. // order.CurrDrordFlag = "1"
  11302. // orders = append(orders, &order)
  11303. //
  11304. // }
  11305. // if subItem.Type == 3 {
  11306. //
  11307. // var order models.FsiOrderDtos
  11308. // order.RxID = strconv.FormatInt(item.ID, 10)
  11309. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11310. // order.LongDrordFlag = "0"
  11311. // order.HilistType = "1"
  11312. // order.ChrgType = "1"
  11313. // order.DrordBhvr = "-"
  11314. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11315. // order.HosplistName = subItem.GoodInfo.GoodName
  11316. // order.HilistLv = "1"
  11317. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11318. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11319. // order.HosplistName = subItem.GoodInfo.GoodName
  11320. // order.Cnt = subItem.Count
  11321. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11322. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11323. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11324. // order.OwnpayAmt = ""
  11325. // order.SelfpayAmt = ""
  11326. // order.Spec = ""
  11327. // order.SpecUnt = ""
  11328. // order.DrordBegnDate = s_tm
  11329. // order.DrordStopDate = ""
  11330. // order.DrordDrCodg = "1"
  11331. // order.DrordDeptName = department.Name
  11332. // order.DrordDrCodg = "1"
  11333. // order.DrordDrName = doctor_info.UserName
  11334. // order.DrordDrProfttl = ""
  11335. // order.CurrDrordFlag = "1"
  11336. // orders = append(orders, &order)
  11337. //
  11338. // }
  11339. // }
  11340. //}
  11341. for _, item := range prescriptions {
  11342. for _, subItem := range item.HisDoctorAdviceInfo {
  11343. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11344. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11345. var order models.FsiOrderDtos
  11346. order.RxID = strconv.FormatInt(item.ID, 10)
  11347. order.Rxno = strconv.FormatInt(item.ID, 10)
  11348. order.LongDrordFlag = "0"
  11349. order.HilistType = "1"
  11350. order.ChrgType = "1"
  11351. order.DrordBhvr = "0"
  11352. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11353. order.HosplistName = subItem.BaseDrugLib.DrugName
  11354. order.HilistLv = "1"
  11355. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11356. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11357. order.HosplistName = subItem.BaseDrugLib.DrugName
  11358. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11359. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11360. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11361. order.OwnpayAmt = ""
  11362. order.SelfpayAmt = ""
  11363. order.Spec = spec
  11364. order.SpecUnt = subItem.PrescribingNumberUnit
  11365. order.DrordBegnDate = s_tm
  11366. order.DrordStopDate = ""
  11367. order.DrordDrCodg = doctor_info.DoctorNumber
  11368. order.DrordDeptName = department.Name
  11369. order.DrordDeptCodg = department.Number
  11370. order.DrordDrName = doctor_info.UserName
  11371. order.DrordDrProfttl = "234"
  11372. order.CurrDrordFlag = "1"
  11373. orders = append(orders, &order)
  11374. }
  11375. }
  11376. for _, subItem := range item.HisPrescriptionProject {
  11377. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11378. var order models.FsiOrderDtos
  11379. order.RxID = strconv.FormatInt(item.ID, 10)
  11380. order.Rxno = strconv.FormatInt(item.ID, 10)
  11381. order.LongDrordFlag = "0"
  11382. order.HilistType = "1"
  11383. order.ChrgType = "1"
  11384. order.DrordBhvr = "0"
  11385. order.HilistCode = subItem.HisProject.MedicalCode
  11386. order.HosplistName = subItem.HisProject.ProjectName
  11387. order.HilistLv = "1"
  11388. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11389. order.HosplistCode = subItem.HisProject.MedicalCode
  11390. order.HosplistName = subItem.HisProject.ProjectName
  11391. order.Cnt = subItem.Count
  11392. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11393. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11394. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11395. order.OwnpayAmt = ""
  11396. order.SelfpayAmt = ""
  11397. order.Spec = subItem.Unit
  11398. order.SpecUnt = subItem.Unit
  11399. order.DrordBegnDate = s_tm
  11400. order.DrordStopDate = ""
  11401. order.DrordDrCodg = doctor_info.DoctorNumber
  11402. order.DrordDeptName = department.Name
  11403. order.DrordDeptCodg = department.Number
  11404. order.DrordDrName = doctor_info.UserName
  11405. order.DrordDrProfttl = "234"
  11406. order.CurrDrordFlag = "1"
  11407. orders = append(orders, &order)
  11408. }
  11409. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11410. var order models.FsiOrderDtos
  11411. order.RxID = strconv.FormatInt(item.ID, 10)
  11412. order.Rxno = strconv.FormatInt(item.ID, 10)
  11413. order.LongDrordFlag = "0"
  11414. order.HilistType = "1"
  11415. order.ChrgType = "1"
  11416. order.DrordBhvr = "0"
  11417. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11418. order.HosplistName = subItem.GoodInfo.GoodName
  11419. order.HilistLv = "1"
  11420. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11421. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11422. order.HosplistName = subItem.GoodInfo.GoodName
  11423. order.Cnt = subItem.Count
  11424. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11425. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11426. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11427. order.OwnpayAmt = ""
  11428. order.SelfpayAmt = ""
  11429. order.Spec = subItem.GoodInfo.SpecificationName
  11430. order.SpecUnt = subItem.Unit
  11431. order.DrordBegnDate = s_tm
  11432. order.DrordStopDate = ""
  11433. order.DrordDrCodg = doctor_info.DoctorNumber
  11434. order.DrordDeptName = department.Name
  11435. order.DrordDeptCodg = department.Number
  11436. order.DrordDrName = doctor_info.UserName
  11437. order.DrordDrProfttl = "234"
  11438. order.CurrDrordFlag = "1"
  11439. orders = append(orders, &order)
  11440. }
  11441. }
  11442. }
  11443. //处方医嘱信息
  11444. fed.MatnStas = "0"
  11445. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11446. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11447. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11448. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11449. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11450. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11451. fed.SetlTotlnum = "1"
  11452. fed.Insutype = his.Insutype
  11453. fed.ReimFlag = "0"
  11454. fed.OutSetlFlag = "0"
  11455. var fopd []*models.FsiOperationDtosData
  11456. data := make(map[string]interface{})
  11457. data["fed"] = fed
  11458. data["fdd"] = fdds
  11459. data["fod"] = orders
  11460. data["pd"] = pd
  11461. data["pp"] = pp
  11462. data["fopd"] = fopd
  11463. data["trig_scen"] = trig_scen
  11464. client := &http.Client{}
  11465. bytesData, _ := json.Marshal(data)
  11466. var req *http.Request
  11467. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11468. if miConfig.MdtrtareaAdmvs == "320921" {
  11469. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11470. } else {
  11471. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11472. }
  11473. resp, _ := client.Do(req)
  11474. defer resp.Body.Close()
  11475. body, ioErr := ioutil.ReadAll(resp.Body)
  11476. if ioErr != nil {
  11477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11479. return res
  11480. }
  11481. var respJSON map[string]interface{}
  11482. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11485. return res
  11486. }
  11487. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11488. result, _ := json.Marshal(respJSON)
  11489. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11490. utils.ErrorLog("解析失败:%v", err)
  11491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11492. return res
  11493. }
  11494. return res
  11495. } else {
  11496. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11497. saveLog(output, input, "3102", "事中")
  11498. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11499. utils.ErrorLog("解析失败:%v", err)
  11500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11501. return
  11502. }
  11503. return res
  11504. }
  11505. return res
  11506. }
  11507. func (c *HisApiController) Check() {
  11508. psn_no := c.GetString("psn_no")
  11509. in := c.GetString("in")
  11510. mt := c.GetString("mt")
  11511. baseParams := models.BaseParams{
  11512. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  11513. FixmedinsCode: "H15049901371",
  11514. InsuplcAdmdvs: "150499",
  11515. MdtrtareaAdmvs: "150499",
  11516. OrgName: "赤峰费森血液透析中心",
  11517. Doctor: "1111",
  11518. }
  11519. service.Gdyb2001(baseParams, psn_no, in, mt)
  11520. }
  11521. func (c *HisApiController) GetPsnNcdsInfo() {
  11522. admin_user_id, _ := c.GetInt64("admin_user_id")
  11523. patient_id, _ := c.GetInt64("patient_id")
  11524. //id, _ := c.GetInt64("id")
  11525. adminUser := c.GetAdminUserInfo()
  11526. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11527. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11528. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  11529. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11530. //psn_record, _ := service.GetP(id)
  11531. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11532. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  11533. //
  11534. //if psn_record.ID == 0 {
  11535. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  11536. // return
  11537. //}
  11538. var res Result5301
  11539. var res10265 Result5301For10265
  11540. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11541. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11542. var api string
  11543. if miConfig.MdtrtareaAdmvs == "320921" {
  11544. 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 +
  11545. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11546. } else {
  11547. 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 +
  11548. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11549. }
  11550. resp, requestErr := http.Get(api)
  11551. if requestErr != nil {
  11552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11553. return
  11554. }
  11555. body, ioErr := ioutil.ReadAll(resp.Body)
  11556. if ioErr != nil {
  11557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11559. return
  11560. }
  11561. var respJSON map[string]interface{}
  11562. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11565. return
  11566. }
  11567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11568. result, _ := json.Marshal(respJSON)
  11569. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11570. utils.ErrorLog("解析失败:%v", err)
  11571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11572. return
  11573. }
  11574. res.ErrMsg = res10265.ErrMsg
  11575. res.Output = res10265.Output
  11576. res.InfRefmsgid = res10265.InfRefmsgid
  11577. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11578. res.Infcode = infocode
  11579. } else if miConfig.MdtrtareaAdmvs == "341203" {
  11580. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11581. var api string
  11582. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  11583. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11584. resp, requestErr := http.Get(api)
  11585. if requestErr != nil {
  11586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11587. return
  11588. }
  11589. body, ioErr := ioutil.ReadAll(resp.Body)
  11590. if ioErr != nil {
  11591. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11593. return
  11594. }
  11595. var respJSON map[string]interface{}
  11596. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11599. return
  11600. }
  11601. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11602. if status == "0" {
  11603. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11604. c.ServeSuccessJSON(map[string]interface{}{
  11605. "failed_code": -10,
  11606. "msg": err_msg,
  11607. })
  11608. return
  11609. }
  11610. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11611. result, _ := json.Marshal(respJSON)
  11612. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11613. utils.ErrorLog("解析失败:%v", err)
  11614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11615. return
  11616. }
  11617. } else if miConfig.MdtrtareaAdmvs == "340699" {
  11618. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11619. var api string
  11620. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  11621. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11622. resp, requestErr := http.Get(api)
  11623. if requestErr != nil {
  11624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11625. return
  11626. }
  11627. body, ioErr := ioutil.ReadAll(resp.Body)
  11628. if ioErr != nil {
  11629. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11631. return
  11632. }
  11633. var respJSON map[string]interface{}
  11634. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11637. return
  11638. }
  11639. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11640. if status == "0" {
  11641. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11642. c.ServeSuccessJSON(map[string]interface{}{
  11643. "failed_code": -10,
  11644. "msg": err_msg,
  11645. })
  11646. return
  11647. }
  11648. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11649. result, _ := json.Marshal(respJSON)
  11650. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11651. utils.ErrorLog("解析失败:%v", err)
  11652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11653. return
  11654. }
  11655. } else if miConfig.MdtrtareaAdmvs == "360302" {
  11656. p, _ := service.GetHisPatientById(patient_id)
  11657. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11658. var dat map[string]interface{}
  11659. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11660. fmt.Println(dat)
  11661. } else {
  11662. fmt.Println(err)
  11663. }
  11664. userJSONBytes, _ := json.Marshal(dat)
  11665. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11666. utils.ErrorLog("解析失败:%v", err)
  11667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11668. return
  11669. }
  11670. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11671. p, _ := service.GetHisPatientById(patient_id)
  11672. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11673. var dat map[string]interface{}
  11674. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11675. fmt.Println(dat)
  11676. } else {
  11677. fmt.Println(err)
  11678. }
  11679. userJSONBytes, _ := json.Marshal(dat)
  11680. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11681. utils.ErrorLog("解析失败:%v", err)
  11682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11683. return
  11684. }
  11685. } else if miConfig.MdtrtareaAdmvs == "420200" {
  11686. p, _ := service.GetHisPatientById(patient_id)
  11687. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  11688. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11689. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11690. resp, requestErr := http.Get(api)
  11691. if requestErr != nil {
  11692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11693. return
  11694. }
  11695. body, ioErr := ioutil.ReadAll(resp.Body)
  11696. if ioErr != nil {
  11697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11699. return
  11700. }
  11701. var respJSON map[string]interface{}
  11702. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11705. return
  11706. }
  11707. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11708. result, _ := json.Marshal(respJSON)
  11709. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11710. utils.ErrorLog("解析失败:%v", err)
  11711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11712. return
  11713. }
  11714. } else if miConfig.MdtrtareaAdmvs == "420902" {
  11715. p, _ := service.GetHisPatientById(patient_id)
  11716. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  11717. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11718. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11719. resp, requestErr := http.Get(api)
  11720. if requestErr != nil {
  11721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11722. return
  11723. }
  11724. body, ioErr := ioutil.ReadAll(resp.Body)
  11725. if ioErr != nil {
  11726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11728. return
  11729. }
  11730. var respJSON map[string]interface{}
  11731. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11734. return
  11735. }
  11736. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11737. result, _ := json.Marshal(respJSON)
  11738. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11739. utils.ErrorLog("解析失败:%v", err)
  11740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11741. return
  11742. }
  11743. } else if miConfig.MdtrtareaAdmvs == "421182" {
  11744. p, _ := service.GetHisPatientById(patient_id)
  11745. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  11746. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11747. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11748. resp, requestErr := http.Get(api)
  11749. if requestErr != nil {
  11750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11751. return
  11752. }
  11753. body, ioErr := ioutil.ReadAll(resp.Body)
  11754. if ioErr != nil {
  11755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11757. return
  11758. }
  11759. var respJSON map[string]interface{}
  11760. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11763. return
  11764. }
  11765. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11766. result, _ := json.Marshal(respJSON)
  11767. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11768. utils.ErrorLog("解析失败:%v", err)
  11769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11770. return
  11771. }
  11772. } else if miConfig.MdtrtareaAdmvs == "420902" {
  11773. p, _ := service.GetHisPatientById(patient_id)
  11774. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  11775. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11776. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11777. resp, requestErr := http.Get(api)
  11778. if requestErr != nil {
  11779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11780. return
  11781. }
  11782. body, ioErr := ioutil.ReadAll(resp.Body)
  11783. if ioErr != nil {
  11784. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11786. return
  11787. }
  11788. var respJSON map[string]interface{}
  11789. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11792. return
  11793. }
  11794. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11795. result, _ := json.Marshal(respJSON)
  11796. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11797. utils.ErrorLog("解析失败:%v", err)
  11798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11799. return
  11800. }
  11801. } else if miConfig.MdtrtareaAdmvs == "421300" {
  11802. p, _ := service.GetHisPatientById(patient_id)
  11803. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  11804. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11805. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11806. resp, requestErr := http.Get(api)
  11807. if requestErr != nil {
  11808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11809. return
  11810. }
  11811. body, ioErr := ioutil.ReadAll(resp.Body)
  11812. if ioErr != nil {
  11813. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11815. return
  11816. }
  11817. var respJSON map[string]interface{}
  11818. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11821. return
  11822. }
  11823. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11824. result, _ := json.Marshal(respJSON)
  11825. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11826. utils.ErrorLog("解析失败:%v", err)
  11827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11828. return
  11829. }
  11830. } else if miConfig.MdtrtareaAdmvs == "441799" {
  11831. p, _ := service.GetHisPatientById(patient_id)
  11832. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  11833. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11834. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11835. resp, requestErr := http.Get(api)
  11836. if requestErr != nil {
  11837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11838. return
  11839. }
  11840. body, ioErr := ioutil.ReadAll(resp.Body)
  11841. if ioErr != nil {
  11842. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11844. return
  11845. }
  11846. var respJSON map[string]interface{}
  11847. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11848. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11850. return
  11851. }
  11852. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11853. result, _ := json.Marshal(respJSON)
  11854. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11855. utils.ErrorLog("解析失败:%v", err)
  11856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11857. return
  11858. }
  11859. } else {
  11860. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  11861. var dat map[string]interface{}
  11862. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11863. fmt.Println(dat)
  11864. } else {
  11865. fmt.Println(err)
  11866. }
  11867. userJSONBytes, _ := json.Marshal(dat)
  11868. if miConfig.Code == "H15049901371" {
  11869. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  11870. utils.ErrorLog("解析失败:%v", err)
  11871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11872. return
  11873. }
  11874. res.InfRefmsgid = res10265.InfRefmsgid
  11875. res.Output = res10265.Output
  11876. res.ErrMsg = res10265.ErrMsg
  11877. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11878. res.Infcode = infocode
  11879. } else {
  11880. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11881. utils.ErrorLog("解析失败:%v", err)
  11882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11883. return
  11884. }
  11885. }
  11886. }
  11887. if res.Infcode == 0 {
  11888. c.ServeSuccessJSON(map[string]interface{}{
  11889. "result": res.Output.Result,
  11890. })
  11891. }
  11892. }
  11893. func (c *HisApiController) CheckInsutype() {
  11894. his_patient_id, _ := c.GetInt64("his_patient_id")
  11895. admin_user_id, _ := c.GetInt64("admin_user_id")
  11896. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11897. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11898. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11899. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11900. var dat map[string]interface{}
  11901. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11902. fmt.Println(dat)
  11903. } else {
  11904. fmt.Println(err)
  11905. }
  11906. userJSONBytes, _ := json.Marshal(dat)
  11907. var res Result90100
  11908. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11909. utils.ErrorLog("解析失败:%v", err)
  11910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11911. return
  11912. }
  11913. if res.Infcode != 0 {
  11914. c.ServeSuccessJSON(map[string]interface{}{
  11915. "failed_code": -10,
  11916. "msg": res.ErrMsg,
  11917. })
  11918. return
  11919. } else {
  11920. fmt.Println(res)
  11921. }
  11922. }
  11923. func (c *HisApiController) CheckCardPWD() {
  11924. card_pwd := c.GetString("card_pwd")
  11925. his_patient_id, _ := c.GetInt64("his_patient_id")
  11926. admin_user_id, _ := c.GetInt64("admin_user_id")
  11927. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11928. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11929. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11930. psn, _ := service.GetPsnByPatientId(his.PatientId)
  11931. bas := strings.Split(psn.CardInfo, "|")
  11932. basNumber := bas[2]
  11933. if psn.InsuplcAdmdvs[:4] == "4403" {
  11934. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  11935. var dat map[string]interface{}
  11936. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11937. fmt.Println(dat)
  11938. } else {
  11939. fmt.Println(err)
  11940. }
  11941. userJSONBytes, _ := json.Marshal(dat)
  11942. var res Result90991
  11943. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11944. utils.ErrorLog("解析失败:%v", err)
  11945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11946. return
  11947. }
  11948. if res.Infcode != 0 {
  11949. c.ServeSuccessJSON(map[string]interface{}{
  11950. "failed_code": -10,
  11951. "msg": res.ErrMsg,
  11952. })
  11953. return
  11954. } else {
  11955. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  11956. var msg string
  11957. switch res.Output.Result.CardStat {
  11958. case "00":
  11959. msg = "未激活"
  11960. break
  11961. case "10":
  11962. msg = "激活"
  11963. break
  11964. case "20":
  11965. msg = "窗口挂失"
  11966. break
  11967. case "21":
  11968. msg = "电话挂失"
  11969. break
  11970. case "22":
  11971. msg = "单位网上申报挂失"
  11972. break
  11973. case "23":
  11974. msg = "保健办挂失"
  11975. break
  11976. case "24":
  11977. msg = "个人网上挂失"
  11978. break
  11979. case "25":
  11980. msg = "网上服务大厅挂失"
  11981. break
  11982. case "30":
  11983. msg = "注销"
  11984. break
  11985. case "40":
  11986. msg = "回收"
  11987. break
  11988. case "99":
  11989. msg = "制卡中(无效卡)"
  11990. break
  11991. }
  11992. c.ServeSuccessJSON(map[string]interface{}{
  11993. "failed_code": -10,
  11994. "msg": msg,
  11995. })
  11996. return
  11997. } else {
  11998. c.ServeSuccessJSON(map[string]interface{}{
  11999. "msg": "校验成功",
  12000. })
  12001. return
  12002. }
  12003. }
  12004. } else {
  12005. c.ServeSuccessJSON(map[string]interface{}{
  12006. "msg": "校验成功",
  12007. })
  12008. return
  12009. }
  12010. }
  12011. func (c *HisApiController) CheckCardPWDTwo() {
  12012. //card_pwd := c.GetString("card_pwd")
  12013. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12014. admin_user_id, _ := c.GetInt64("admin_user_id")
  12015. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12016. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12017. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12018. var dat map[string]interface{}
  12019. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12020. fmt.Println(dat)
  12021. } else {
  12022. fmt.Println(err)
  12023. }
  12024. userJSONBytes, _ := json.Marshal(dat)
  12025. var res Result90991
  12026. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12027. utils.ErrorLog("解析失败:%v", err)
  12028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12029. return
  12030. }
  12031. if res.Infcode != 0 {
  12032. c.ServeSuccessJSON(map[string]interface{}{
  12033. "failed_code": -10,
  12034. "msg": res.ErrMsg,
  12035. })
  12036. return
  12037. } else {
  12038. if res.Output.Result.SscnoCheckStat == "0" {
  12039. var msg string
  12040. switch res.Output.Result.CardStat {
  12041. case "00":
  12042. msg = "未激活"
  12043. break
  12044. case "10":
  12045. msg = "激活"
  12046. break
  12047. case "20":
  12048. msg = "窗口挂失"
  12049. break
  12050. case "21":
  12051. msg = "电话挂失"
  12052. break
  12053. case "22":
  12054. msg = "单位网上申报挂失"
  12055. break
  12056. case "23":
  12057. msg = "保健办挂失"
  12058. break
  12059. case "24":
  12060. msg = "个人网上挂失"
  12061. break
  12062. case "25":
  12063. msg = "网上服务大厅挂失"
  12064. break
  12065. case "30":
  12066. msg = "注销"
  12067. break
  12068. case "40":
  12069. msg = "回收"
  12070. break
  12071. case "99":
  12072. msg = "制卡中(无效卡)"
  12073. break
  12074. }
  12075. c.ServeSuccessJSON(map[string]interface{}{
  12076. "failed_code": -10,
  12077. "msg": msg,
  12078. })
  12079. return
  12080. } else {
  12081. c.ServeSuccessJSON(map[string]interface{}{
  12082. "msg": "校验成功",
  12083. })
  12084. return
  12085. }
  12086. }
  12087. }
  12088. type ELeCertData struct {
  12089. Data struct {
  12090. Extra string `json:"extra"`
  12091. IDNo string `json:"idNo"`
  12092. IDType string `json:"idType"`
  12093. EcToken string `json:"ecToken"`
  12094. InsuOrg string `json:"insuOrg"`
  12095. UserName string `json:"userName"`
  12096. EcIndexNo string `json:"ecIndexNo"`
  12097. Gender string `json:"gender"`
  12098. Birthday string `json:"birthday"`
  12099. Nationality string `json:"nationality"`
  12100. Email string `json:"email"`
  12101. } `json:"OutData"`
  12102. }
  12103. func (c *HisApiController) ReadCard() {
  12104. id_card_type, _ := c.GetInt64("id_card_type")
  12105. admin_user_id, _ := c.GetInt64("admin_user_id")
  12106. certificates, _ := c.GetInt64("certificates")
  12107. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12108. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12109. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12110. switch id_card_type {
  12111. case 1:
  12112. if miConfig.MdtrtareaAdmvs == "421300" {
  12113. var res ResultTwo
  12114. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12115. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12116. "&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)
  12117. resp, requestErr := http.Get(api)
  12118. if requestErr != nil {
  12119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12120. return
  12121. }
  12122. body, ioErr := ioutil.ReadAll(resp.Body)
  12123. if ioErr != nil {
  12124. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12126. return
  12127. }
  12128. var respJSON map[string]interface{}
  12129. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12132. return
  12133. }
  12134. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12135. result, _ := json.Marshal(respJSON)
  12136. fmt.Println("log")
  12137. fmt.Println(string(result))
  12138. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12139. utils.ErrorLog("解析失败:%v", err)
  12140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12141. return
  12142. }
  12143. if res.Infcode == 0 {
  12144. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12145. if err == gorm.ErrRecordNotFound {
  12146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12147. return
  12148. } else if err != nil {
  12149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12150. return
  12151. } else {
  12152. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12153. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12154. infoStr := string(Iinfos)
  12155. idetinfoStr := string(Idetinfos)
  12156. var rf []*ResultFive
  12157. json.Unmarshal([]byte(infoStr), &rf)
  12158. var insutypes []*ResultFive
  12159. var insutype string
  12160. var is390 int = 0
  12161. var is310 int = 0
  12162. for _, item := range rf {
  12163. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12164. insutypes = append(insutypes, item)
  12165. }
  12166. }
  12167. if len(insutypes) == 1 {
  12168. insutype = insutypes[0].Insutype
  12169. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12170. } else {
  12171. for _, i := range insutypes {
  12172. if i.Insutype == "390" {
  12173. is390 = 1
  12174. }
  12175. if i.Insutype == "310" {
  12176. is310 = 1
  12177. }
  12178. }
  12179. }
  12180. if is390 == 1 {
  12181. insutype = "390"
  12182. }
  12183. if is310 == 1 {
  12184. insutype = "310"
  12185. }
  12186. if len(insutypes) == 0 {
  12187. insutype = "390"
  12188. }
  12189. var insuplc_admdvs string
  12190. for _, item := range rf {
  12191. if item.Insutype == insutype {
  12192. insuplc_admdvs = item.InsuplcAdmdvs
  12193. }
  12194. }
  12195. if strings.Contains(insuplc_admdvs, "4213") {
  12196. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12197. }
  12198. psn := &models.HisPsn{
  12199. PsnNo: res.Output.Baseinfo.PsnNo,
  12200. PatientId: patient.ID,
  12201. Certno: res.Output.Baseinfo.Certno,
  12202. Gend: res.Output.Baseinfo.Gend,
  12203. Naty: res.Output.Baseinfo.Naty,
  12204. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12205. PsnName: res.Output.Baseinfo.PsnName,
  12206. Idetinfo: idetinfoStr,
  12207. Insuinfo: infoStr,
  12208. InsuplcAdmdvs: insuplc_admdvs,
  12209. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12210. }
  12211. service.CreateHisPsn(psn)
  12212. c.ServeSuccessJSON(map[string]interface{}{
  12213. "patient": patient,
  12214. "number": res.Output.Baseinfo.Certno,
  12215. })
  12216. }
  12217. } else {
  12218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12219. return
  12220. }
  12221. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12222. var res ResultTwo
  12223. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12224. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12225. "&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)
  12226. resp, requestErr := http.Get(api)
  12227. if requestErr != nil {
  12228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12229. return
  12230. }
  12231. body, ioErr := ioutil.ReadAll(resp.Body)
  12232. if ioErr != nil {
  12233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12235. return
  12236. }
  12237. var respJSON map[string]interface{}
  12238. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12241. return
  12242. }
  12243. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12244. result, _ := json.Marshal(respJSON)
  12245. fmt.Println("log")
  12246. fmt.Println(string(result))
  12247. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12248. utils.ErrorLog("解析失败:%v", err)
  12249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12250. return
  12251. }
  12252. if res.Infcode == 0 {
  12253. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12254. if err == gorm.ErrRecordNotFound {
  12255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12256. return
  12257. } else if err != nil {
  12258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12259. return
  12260. } else {
  12261. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12262. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12263. infoStr := string(Iinfos)
  12264. idetinfoStr := string(Idetinfos)
  12265. psn := &models.HisPsn{
  12266. PsnNo: res.Output.Baseinfo.PsnNo,
  12267. PatientId: patient.ID,
  12268. Certno: res.Output.Baseinfo.Certno,
  12269. Gend: res.Output.Baseinfo.Gend,
  12270. Naty: res.Output.Baseinfo.Naty,
  12271. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12272. PsnName: res.Output.Baseinfo.PsnName,
  12273. Idetinfo: idetinfoStr,
  12274. Insuinfo: infoStr,
  12275. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12276. }
  12277. service.CreateHisPsn(psn)
  12278. var rf []*ResultFive
  12279. json.Unmarshal([]byte(infoStr), &rf)
  12280. var insutypes []*ResultFive
  12281. var insutype string
  12282. var is390 int = 0
  12283. var is310 int = 0
  12284. for _, item := range rf {
  12285. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12286. insutypes = append(insutypes, item)
  12287. }
  12288. }
  12289. if len(insutypes) == 1 {
  12290. insutype = insutypes[0].Insutype
  12291. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12292. } else {
  12293. for _, i := range insutypes {
  12294. if i.Insutype == "390" {
  12295. is390 = 1
  12296. }
  12297. if i.Insutype == "310" {
  12298. is310 = 1
  12299. }
  12300. }
  12301. }
  12302. if is390 == 1 {
  12303. insutype = "390"
  12304. }
  12305. if is310 == 1 {
  12306. insutype = "310"
  12307. }
  12308. if len(insutypes) == 0 {
  12309. insutype = "310"
  12310. }
  12311. c.ServeSuccessJSON(map[string]interface{}{
  12312. "patient": patient,
  12313. "number": res.Output.Baseinfo.Certno,
  12314. "insutype": insutype,
  12315. })
  12316. }
  12317. } else {
  12318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12319. return
  12320. }
  12321. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12322. var res ResultTwo
  12323. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12324. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12325. "&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)
  12326. resp, requestErr := http.Get(api)
  12327. if requestErr != nil {
  12328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12329. return
  12330. }
  12331. body, ioErr := ioutil.ReadAll(resp.Body)
  12332. if ioErr != nil {
  12333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12335. return
  12336. }
  12337. var respJSON map[string]interface{}
  12338. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12341. return
  12342. }
  12343. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12344. result, _ := json.Marshal(respJSON)
  12345. fmt.Println("log")
  12346. fmt.Println(string(result))
  12347. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12348. utils.ErrorLog("解析失败:%v", err)
  12349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12350. return
  12351. }
  12352. if res.Infcode == 0 {
  12353. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12354. if err == gorm.ErrRecordNotFound {
  12355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12356. return
  12357. } else if err != nil {
  12358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12359. return
  12360. } else {
  12361. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12362. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12363. infoStr := string(Iinfos)
  12364. idetinfoStr := string(Idetinfos)
  12365. var rf []*ResultFive
  12366. json.Unmarshal([]byte(infoStr), &rf)
  12367. var insutypes []*ResultFive
  12368. var insutype string
  12369. var is390 int = 0
  12370. var is310 int = 0
  12371. for _, item := range rf {
  12372. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12373. insutypes = append(insutypes, item)
  12374. }
  12375. }
  12376. if len(insutypes) == 1 {
  12377. insutype = insutypes[0].Insutype
  12378. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12379. } else {
  12380. for _, i := range insutypes {
  12381. if i.Insutype == "390" {
  12382. is390 = 1
  12383. }
  12384. if i.Insutype == "310" {
  12385. is310 = 1
  12386. }
  12387. }
  12388. }
  12389. if is390 == 1 {
  12390. insutype = "390"
  12391. }
  12392. if is310 == 1 {
  12393. insutype = "310"
  12394. }
  12395. if len(insutypes) == 0 {
  12396. insutype = "390"
  12397. }
  12398. var insuplc_admdvs string
  12399. for _, item := range rf {
  12400. if item.Insutype == insutype {
  12401. insuplc_admdvs = item.InsuplcAdmdvs
  12402. }
  12403. }
  12404. psn := &models.HisPsn{
  12405. PsnNo: res.Output.Baseinfo.PsnNo,
  12406. PatientId: patient.ID,
  12407. Certno: res.Output.Baseinfo.Certno,
  12408. Gend: res.Output.Baseinfo.Gend,
  12409. Naty: res.Output.Baseinfo.Naty,
  12410. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12411. PsnName: res.Output.Baseinfo.PsnName,
  12412. Idetinfo: idetinfoStr,
  12413. Insuinfo: infoStr,
  12414. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12415. InsuplcAdmdvs: insuplc_admdvs,
  12416. }
  12417. service.CreateHisPsn(psn)
  12418. for _, item := range rf {
  12419. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12420. insutypes = append(insutypes, item)
  12421. }
  12422. }
  12423. if len(insutypes) == 1 {
  12424. insutype = insutypes[0].Insutype
  12425. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12426. } else {
  12427. for _, i := range insutypes {
  12428. if i.Insutype == "390" {
  12429. is390 = 1
  12430. }
  12431. if i.Insutype == "310" {
  12432. is310 = 1
  12433. }
  12434. }
  12435. }
  12436. if is390 == 1 {
  12437. insutype = "390"
  12438. }
  12439. if is310 == 1 {
  12440. insutype = "310"
  12441. }
  12442. if len(insutypes) == 0 {
  12443. insutype = "310"
  12444. }
  12445. c.ServeSuccessJSON(map[string]interface{}{
  12446. "patient": patient,
  12447. "number": res.Output.Baseinfo.Certno,
  12448. "insutype": insutype,
  12449. })
  12450. }
  12451. } else {
  12452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12453. return
  12454. }
  12455. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12456. var res ResultTwo
  12457. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  12458. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12459. "&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)
  12460. resp, requestErr := http.Get(api)
  12461. if requestErr != nil {
  12462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12463. return
  12464. }
  12465. body, ioErr := ioutil.ReadAll(resp.Body)
  12466. if ioErr != nil {
  12467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12469. return
  12470. }
  12471. var respJSON map[string]interface{}
  12472. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12475. return
  12476. }
  12477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12478. result, _ := json.Marshal(respJSON)
  12479. fmt.Println("log")
  12480. fmt.Println(string(result))
  12481. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12482. utils.ErrorLog("解析失败:%v", err)
  12483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12484. return
  12485. }
  12486. if res.Infcode == 0 {
  12487. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12488. if err == gorm.ErrRecordNotFound {
  12489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12490. return
  12491. } else if err != nil {
  12492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12493. return
  12494. } else {
  12495. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12496. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12497. infoStr := string(Iinfos)
  12498. idetinfoStr := string(Idetinfos)
  12499. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12500. psn := &models.HisPsn{
  12501. PsnNo: res.Output.Baseinfo.PsnNo,
  12502. PatientId: patient.ID,
  12503. Certno: res.Output.Baseinfo.Certno,
  12504. Brdy: b,
  12505. Age: float64(age),
  12506. Gend: res.Output.Baseinfo.Gend,
  12507. Naty: res.Output.Baseinfo.Naty,
  12508. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12509. PsnName: res.Output.Baseinfo.PsnName,
  12510. Idetinfo: idetinfoStr,
  12511. Insuinfo: infoStr,
  12512. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12513. }
  12514. service.CreateHisPsn(psn)
  12515. var rf []*ResultFive
  12516. json.Unmarshal([]byte(infoStr), &rf)
  12517. var insutypes []*ResultFive
  12518. var insutype string
  12519. var is390 int = 0
  12520. var is310 int = 0
  12521. for _, item := range rf {
  12522. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12523. insutypes = append(insutypes, item)
  12524. }
  12525. }
  12526. if len(insutypes) == 1 {
  12527. insutype = insutypes[0].Insutype
  12528. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12529. } else {
  12530. for _, i := range insutypes {
  12531. if i.Insutype == "390" {
  12532. is390 = 1
  12533. }
  12534. if i.Insutype == "310" {
  12535. is310 = 1
  12536. }
  12537. }
  12538. }
  12539. if is390 == 1 {
  12540. insutype = "390"
  12541. }
  12542. if is310 == 1 {
  12543. insutype = "310"
  12544. }
  12545. if len(insutypes) == 0 {
  12546. insutype = "310"
  12547. }
  12548. c.ServeSuccessJSON(map[string]interface{}{
  12549. "patient": patient,
  12550. "number": res.Output.Baseinfo.Certno,
  12551. "insutype": insutype,
  12552. })
  12553. }
  12554. } else {
  12555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12556. return
  12557. }
  12558. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12559. var api string
  12560. if miConfig.MdtrtareaAdmvs == "320921" {
  12561. 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 +
  12562. "&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
  12563. fmt.Println(api)
  12564. } else {
  12565. 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 +
  12566. "&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)
  12567. }
  12568. resp, requestErr := http.Get(api)
  12569. if requestErr != nil {
  12570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12571. return
  12572. }
  12573. body, ioErr := ioutil.ReadAll(resp.Body)
  12574. if ioErr != nil {
  12575. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12577. return
  12578. }
  12579. var respJSON map[string]interface{}
  12580. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12583. return
  12584. }
  12585. var status string
  12586. status = respJSON["data"].(map[string]interface{})["status"].(string)
  12587. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  12588. //console.log()
  12589. fmt.Println("type===")
  12590. fmt.Println(card_type)
  12591. var token string
  12592. var res ResultTwo //1101结果
  12593. var res10265 ResultTwo10265 //1101结果
  12594. var card_info string //卡信息
  12595. var busi_card_info string
  12596. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  12597. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12598. if status == "0" { //读卡成功
  12599. if card_type == "1" {
  12600. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12601. result, _ := json.Marshal(respJSON)
  12602. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12603. utils.ErrorLog("解析失败:%v", err)
  12604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12605. return
  12606. }
  12607. res.ErrMsg = res10265.ErrMsg
  12608. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12609. res.Infcode = infocode
  12610. res.Output = res10265.Output
  12611. res.InfRefmsgid = res10265.InfRefmsgid
  12612. } else {
  12613. //var card_info string //卡信息
  12614. //var busi_card_info string
  12615. token = respJSON["data"].(map[string]interface{})["token"].(string)
  12616. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12617. //fmt.Println(card_info)
  12618. //fmt.Println(busi_card_info)
  12619. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12620. result, _ := json.Marshal(respJSON)
  12621. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12622. utils.ErrorLog("解析失败:%v", err)
  12623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12624. return
  12625. }
  12626. res.ErrMsg = res10265.ErrMsg
  12627. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12628. res.Infcode = infocode
  12629. res.Output = res10265.Output
  12630. res.InfRefmsgid = res10265.InfRefmsgid
  12631. }
  12632. if res.Infcode == 0 {
  12633. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12634. if err == gorm.ErrRecordNotFound {
  12635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12636. return
  12637. } else if err != nil {
  12638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12639. return
  12640. } else {
  12641. if card_type == "1" {
  12642. bas := strings.Split(card_info, "|")
  12643. basNumber := bas[2]
  12644. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12645. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12646. infoStr := string(Iinfos)
  12647. idetinfoStr := string(Idetinfos)
  12648. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12649. psn := &models.HisPsn{
  12650. PsnNo: res.Output.Baseinfo.PsnNo,
  12651. PatientId: patient.ID,
  12652. Certno: res.Output.Baseinfo.Certno,
  12653. Brdy: b,
  12654. Age: float64(age),
  12655. Gend: res.Output.Baseinfo.Gend,
  12656. Naty: res.Output.Baseinfo.Naty,
  12657. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12658. PsnName: res.Output.Baseinfo.PsnName,
  12659. Idetinfo: idetinfoStr,
  12660. Insuinfo: infoStr,
  12661. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12662. CardInfo: card_info,
  12663. VerifyNumber: busi_card_info,
  12664. }
  12665. service.CreateHisPsn(psn)
  12666. var rf []*ResultFive
  12667. json.Unmarshal([]byte(infoStr), &rf)
  12668. var insutypes []*ResultFive
  12669. var insutype string
  12670. var is390 int = 0
  12671. var is310 int = 0
  12672. for _, item := range rf {
  12673. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12674. insutypes = append(insutypes, item)
  12675. }
  12676. }
  12677. if len(insutypes) == 1 {
  12678. insutype = insutypes[0].Insutype
  12679. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12680. } else {
  12681. for _, i := range insutypes {
  12682. if i.Insutype == "390" {
  12683. is390 = 1
  12684. }
  12685. if i.Insutype == "310" {
  12686. is310 = 1
  12687. }
  12688. }
  12689. }
  12690. if is390 == 1 {
  12691. insutype = "390"
  12692. }
  12693. if is310 == 1 {
  12694. insutype = "310"
  12695. }
  12696. if len(insutypes) == 0 {
  12697. insutype = "310"
  12698. }
  12699. c.ServeSuccessJSON(map[string]interface{}{
  12700. "patient": patient,
  12701. "number": basNumber,
  12702. "insutype": insutype,
  12703. })
  12704. } else {
  12705. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12706. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12707. infoStr := string(Iinfos)
  12708. idetinfoStr := string(Idetinfos)
  12709. psn := &models.HisPsn{
  12710. PsnNo: res.Output.Baseinfo.PsnNo,
  12711. PatientId: patient.ID,
  12712. Certno: res.Output.Baseinfo.Certno,
  12713. Gend: res.Output.Baseinfo.Gend,
  12714. Naty: res.Output.Baseinfo.Naty,
  12715. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12716. PsnName: res.Output.Baseinfo.PsnName,
  12717. Idetinfo: idetinfoStr,
  12718. Insuinfo: infoStr,
  12719. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12720. CardInfo: card_info,
  12721. VerifyNumber: token,
  12722. }
  12723. service.CreateHisPsn(psn)
  12724. c.ServeSuccessJSON(map[string]interface{}{
  12725. "patient": patient,
  12726. "number": token,
  12727. })
  12728. }
  12729. }
  12730. } else {
  12731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12732. return
  12733. }
  12734. } else { //读卡失败
  12735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12736. return
  12737. }
  12738. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12739. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  12740. cardnum = DeleteExtraSpaceTwo(cardnum)
  12741. cardCode = DeleteExtraSpaceTwo(cardCode)
  12742. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  12743. name = DeleteExtraSpaceTwo(name)
  12744. errmsg = DeleteExtraSpaceTwo(errmsg)
  12745. cardnum = Remove0000(cardnum)
  12746. cardCode = Remove0000(cardCode)
  12747. id_card_no = Remove0000(id_card_no)
  12748. name = Remove0000(name)
  12749. errmsg = Remove0000(errmsg)
  12750. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  12751. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  12752. //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)
  12753. //fmt.Println(result2)
  12754. //fmt.Println(requestLog2)
  12755. //fmt.Println(errMsgLog2)
  12756. 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)
  12757. saveLog(result, requestLog, "1101", "获取人员信息")
  12758. fmt.Println(errMsgLog)
  12759. if len(errMsgLog) > 0 {
  12760. } else {
  12761. var dat map[string]interface{}
  12762. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12763. fmt.Println(dat)
  12764. } else {
  12765. fmt.Println(err)
  12766. }
  12767. userJSONBytes, _ := json.Marshal(dat)
  12768. var res ResultTwo
  12769. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12770. utils.ErrorLog("解析失败:%v", err)
  12771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12772. return
  12773. }
  12774. res.ErrMsg = errMsgLog
  12775. if res.Infcode == 0 {
  12776. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12777. if err == gorm.ErrRecordNotFound {
  12778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12779. return
  12780. } else if err != nil {
  12781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12782. return
  12783. } else {
  12784. fmt.Println(res)
  12785. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12786. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12787. infoStr := string(Iinfos)
  12788. idetinfoStr := string(Idetinfos)
  12789. var rf []*ResultFive
  12790. json.Unmarshal([]byte(infoStr), &rf)
  12791. var insutypes []*ResultFive
  12792. var insutype string
  12793. var is390 int = 0
  12794. var is310 int = 0
  12795. for _, item := range rf {
  12796. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12797. insutypes = append(insutypes, item)
  12798. }
  12799. }
  12800. if len(insutypes) == 1 {
  12801. insutype = insutypes[0].Insutype
  12802. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12803. } else {
  12804. for _, i := range insutypes {
  12805. if i.Insutype == "390" {
  12806. is390 = 1
  12807. }
  12808. if i.Insutype == "310" {
  12809. is310 = 1
  12810. }
  12811. }
  12812. }
  12813. if is390 == 1 {
  12814. insutype = "390"
  12815. }
  12816. if is310 == 1 {
  12817. insutype = "310"
  12818. }
  12819. if len(insutypes) == 0 {
  12820. insutype = "390"
  12821. }
  12822. var insuplc_admdvs string
  12823. for _, item := range rf {
  12824. if item.Insutype == insutype {
  12825. insuplc_admdvs = item.InsuplcAdmdvs
  12826. }
  12827. }
  12828. psn := &models.HisPsn{
  12829. PsnNo: res.Output.Baseinfo.PsnNo,
  12830. PatientId: patient.ID,
  12831. Certno: res.Output.Baseinfo.Certno,
  12832. Gend: res.Output.Baseinfo.Gend,
  12833. Naty: res.Output.Baseinfo.Naty,
  12834. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12835. PsnName: res.Output.Baseinfo.PsnName,
  12836. Idetinfo: idetinfoStr,
  12837. Insuinfo: infoStr,
  12838. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12839. CardInfo: basStr,
  12840. VerifyNumber: "",
  12841. InsuplcAdmdvs: insuplc_admdvs,
  12842. }
  12843. service.CreateHisPsn(psn)
  12844. c.ServeSuccessJSON(map[string]interface{}{
  12845. "patient": patient,
  12846. "number": cardnum,
  12847. "insutype": insutype,
  12848. })
  12849. }
  12850. } else {
  12851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12852. return
  12853. }
  12854. }
  12855. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12856. fmt.Println(initFlag)
  12857. fmt.Println("initFlag")
  12858. if initFlag == 0 {
  12859. c.TestGetJiangXiBasBaseInit()
  12860. }
  12861. basStr := c.GetBasBaseInfo()
  12862. if len(basStr) == 0 {
  12863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12864. return
  12865. }
  12866. fmt.Println(basStr)
  12867. bas := strings.Split(basStr, "|")
  12868. basNumber := bas[1]
  12869. fmt.Println(basNumber)
  12870. card_sn := bas[3]
  12871. fmt.Println(card_sn)
  12872. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  12873. 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)
  12874. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  12875. var dat map[string]interface{}
  12876. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12877. fmt.Println(dat)
  12878. } else {
  12879. fmt.Println(err)
  12880. }
  12881. userJSONBytes, _ := json.Marshal(dat)
  12882. var res ResultTwo
  12883. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12884. utils.ErrorLog("解析失败:%v", err)
  12885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12886. return
  12887. }
  12888. if res.Infcode == 0 {
  12889. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  12890. if err == gorm.ErrRecordNotFound {
  12891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12892. return
  12893. } else if err != nil {
  12894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12895. return
  12896. } else {
  12897. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12898. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12899. infoStr := string(Iinfos)
  12900. idetinfoStr := string(Idetinfos)
  12901. var rf []*ResultFive
  12902. json.Unmarshal([]byte(infoStr), &rf)
  12903. var insutypes []*ResultFive
  12904. var insutype string
  12905. var is390 int = 0
  12906. var is310 int = 0
  12907. var insuplc_admdvs string
  12908. for _, item := range rf {
  12909. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12910. insutypes = append(insutypes, item)
  12911. }
  12912. }
  12913. if len(insutypes) == 1 {
  12914. insutype = insutypes[0].Insutype
  12915. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12916. } else {
  12917. for _, i := range insutypes {
  12918. if i.Insutype == "390" {
  12919. is390 = 1
  12920. }
  12921. if i.Insutype == "310" {
  12922. is310 = 1
  12923. }
  12924. }
  12925. }
  12926. if is390 == 1 {
  12927. insutype = "390"
  12928. }
  12929. if is310 == 1 {
  12930. insutype = "310"
  12931. }
  12932. if len(insutypes) == 0 {
  12933. insutype = "310"
  12934. }
  12935. for _, item := range rf {
  12936. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  12937. insuplc_admdvs = item.InsuplcAdmdvs
  12938. }
  12939. }
  12940. psn := &models.HisPsn{
  12941. PsnNo: res.Output.Baseinfo.PsnNo,
  12942. PatientId: patient.ID,
  12943. Certno: res.Output.Baseinfo.Certno,
  12944. Gend: res.Output.Baseinfo.Gend,
  12945. Naty: res.Output.Baseinfo.Naty,
  12946. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12947. PsnName: res.Output.Baseinfo.PsnName,
  12948. Idetinfo: idetinfoStr,
  12949. Insuinfo: infoStr,
  12950. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12951. CardInfo: basStr,
  12952. InsuplcAdmdvs: insuplc_admdvs,
  12953. VerifyNumber: "",
  12954. }
  12955. service.CreateHisPsn(psn)
  12956. c.ServeSuccessJSON(map[string]interface{}{
  12957. "patient": patient,
  12958. "number": basNumber,
  12959. "insutype": insutype,
  12960. })
  12961. }
  12962. } else {
  12963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12964. return
  12965. }
  12966. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12967. fmt.Println(initFlag)
  12968. fmt.Println("initFlag")
  12969. if initFlag == 0 {
  12970. c.TestGetHnBasBaseInit()
  12971. }
  12972. basStr := c.GetBasBaseInfo()
  12973. if len(basStr) == 0 {
  12974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12975. return
  12976. }
  12977. fmt.Println(basStr)
  12978. bas := strings.Split(basStr, "|")
  12979. basNumber := bas[1]
  12980. fmt.Println(basNumber)
  12981. card_sn := bas[3]
  12982. card_no := bas[2]
  12983. fmt.Println(card_sn)
  12984. name := bas[4]
  12985. name = ConvertToString(name, "gbk", "utf-8")
  12986. 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)
  12987. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  12988. var dat map[string]interface{}
  12989. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12990. fmt.Println(dat)
  12991. } else {
  12992. fmt.Println(err)
  12993. }
  12994. userJSONBytes, _ := json.Marshal(dat)
  12995. var res ResultTwo
  12996. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12997. utils.ErrorLog("解析失败:%v", err)
  12998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12999. return
  13000. }
  13001. if res.Infcode == 0 {
  13002. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13003. if err == gorm.ErrRecordNotFound {
  13004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13005. return
  13006. } else if err != nil {
  13007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13008. return
  13009. } else {
  13010. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13011. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13012. infoStr := string(Iinfos)
  13013. idetinfoStr := string(Idetinfos)
  13014. psn := &models.HisPsn{
  13015. PsnNo: res.Output.Baseinfo.PsnNo,
  13016. PatientId: patient.ID,
  13017. Certno: res.Output.Baseinfo.Certno,
  13018. Gend: res.Output.Baseinfo.Gend,
  13019. Naty: res.Output.Baseinfo.Naty,
  13020. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13021. PsnName: res.Output.Baseinfo.PsnName,
  13022. Idetinfo: idetinfoStr,
  13023. Insuinfo: infoStr,
  13024. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13025. CardInfo: basStr,
  13026. VerifyNumber: "",
  13027. }
  13028. service.CreateHisPsn(psn)
  13029. var rf []*ResultFive
  13030. json.Unmarshal([]byte(infoStr), &rf)
  13031. var insutypes []*ResultFive
  13032. var insutype string
  13033. var is390 int = 0
  13034. var is310 int = 0
  13035. for _, item := range rf {
  13036. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13037. insutypes = append(insutypes, item)
  13038. }
  13039. }
  13040. if len(insutypes) == 1 {
  13041. insutype = insutypes[0].Insutype
  13042. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13043. } else {
  13044. for _, i := range insutypes {
  13045. if i.Insutype == "390" {
  13046. is390 = 1
  13047. }
  13048. if i.Insutype == "310" {
  13049. is310 = 1
  13050. }
  13051. }
  13052. }
  13053. if is390 == 1 {
  13054. insutype = "390"
  13055. }
  13056. if is310 == 1 {
  13057. insutype = "310"
  13058. }
  13059. if len(insutypes) == 0 {
  13060. insutype = "310"
  13061. }
  13062. c.ServeSuccessJSON(map[string]interface{}{
  13063. "patient": patient,
  13064. "number": basNumber,
  13065. "insutype": insutype,
  13066. })
  13067. }
  13068. } else {
  13069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13070. return
  13071. }
  13072. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13073. var api string
  13074. 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 +
  13075. "&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
  13076. fmt.Println(api)
  13077. resp, requestErr := http.Get(api)
  13078. if requestErr != nil {
  13079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13080. return
  13081. }
  13082. body, ioErr := ioutil.ReadAll(resp.Body)
  13083. if ioErr != nil {
  13084. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13086. return
  13087. }
  13088. var respJSON map[string]interface{}
  13089. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13092. return
  13093. }
  13094. var res ResultTwo //1101结果
  13095. var res10265 ResultTwo10265 //1101结果
  13096. var card_info string //卡信息
  13097. token := respJSON["data"].(map[string]interface{})["token"].(string)
  13098. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13099. result, _ := json.Marshal(respJSON)
  13100. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13101. utils.ErrorLog("解析失败:%v", err)
  13102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13103. return
  13104. }
  13105. res.ErrMsg = res10265.ErrMsg
  13106. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13107. res.Infcode = infocode
  13108. res.Output = res10265.Output
  13109. res.InfRefmsgid = res10265.InfRefmsgid
  13110. if res.Infcode == 0 {
  13111. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13112. if err == gorm.ErrRecordNotFound {
  13113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13114. return
  13115. } else if err != nil {
  13116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13117. return
  13118. } else {
  13119. bas := strings.Split(card_info, "|")
  13120. basNumber := bas[2]
  13121. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13122. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13123. infoStr := string(Iinfos)
  13124. idetinfoStr := string(Idetinfos)
  13125. psn := &models.HisPsn{
  13126. PsnNo: res.Output.Baseinfo.PsnNo,
  13127. PatientId: patient.ID,
  13128. Certno: res.Output.Baseinfo.Certno,
  13129. Gend: res.Output.Baseinfo.Gend,
  13130. Naty: res.Output.Baseinfo.Naty,
  13131. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13132. PsnName: res.Output.Baseinfo.PsnName,
  13133. Idetinfo: idetinfoStr,
  13134. Insuinfo: infoStr,
  13135. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13136. CardInfo: card_info,
  13137. VerifyNumber: token,
  13138. }
  13139. service.CreateHisPsn(psn)
  13140. var rf []*ResultFive
  13141. json.Unmarshal([]byte(infoStr), &rf)
  13142. var insutypes []*ResultFive
  13143. var insutype string
  13144. var is390 int = 0
  13145. var is310 int = 0
  13146. for _, item := range rf {
  13147. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13148. insutypes = append(insutypes, item)
  13149. }
  13150. }
  13151. if len(insutypes) == 1 {
  13152. insutype = insutypes[0].Insutype
  13153. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13154. } else {
  13155. for _, i := range insutypes {
  13156. if i.Insutype == "390" {
  13157. is390 = 1
  13158. }
  13159. if i.Insutype == "310" {
  13160. is310 = 1
  13161. }
  13162. }
  13163. }
  13164. if is390 == 1 {
  13165. insutype = "390"
  13166. }
  13167. if is310 == 1 {
  13168. insutype = "310"
  13169. }
  13170. if len(insutypes) == 0 {
  13171. insutype = "310"
  13172. }
  13173. c.ServeSuccessJSON(map[string]interface{}{
  13174. "patient": patient,
  13175. "number": basNumber,
  13176. "insutype": insutype,
  13177. })
  13178. }
  13179. } else {
  13180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13181. return
  13182. }
  13183. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13184. res := c.GetoleInfo()
  13185. if res.Infcode == 0 {
  13186. var result string
  13187. if res.Output.MdtrtCertType == "01" {
  13188. 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)
  13189. } else if res.Output.MdtrtCertType == "02" {
  13190. 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)
  13191. } else if res.Output.MdtrtCertType == "03" {
  13192. 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)
  13193. }
  13194. var dat map[string]interface{}
  13195. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13196. fmt.Println(dat)
  13197. } else {
  13198. fmt.Println(err)
  13199. }
  13200. userJSONBytes, _ := json.Marshal(dat)
  13201. var res2 ResultTwo
  13202. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13203. utils.ErrorLog("解析失败:%v", err)
  13204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13205. return
  13206. }
  13207. if res2.Infcode == 0 {
  13208. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13209. if err == gorm.ErrRecordNotFound {
  13210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13211. return
  13212. } else if err != nil {
  13213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13214. return
  13215. } else {
  13216. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13217. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13218. infoStr := string(Iinfos)
  13219. idetinfoStr := string(Idetinfos)
  13220. var rf []*ResultFive
  13221. json.Unmarshal([]byte(infoStr), &rf)
  13222. var insutypes []*ResultFive
  13223. var insutype string
  13224. var is390 int = 0
  13225. var is310 int = 0
  13226. //var insuplc_admdvs string
  13227. for _, item := range rf {
  13228. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13229. insutypes = append(insutypes, item)
  13230. }
  13231. }
  13232. if len(insutypes) == 1 {
  13233. insutype = insutypes[0].Insutype
  13234. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13235. } else {
  13236. for _, i := range insutypes {
  13237. if i.Insutype == "390" {
  13238. is390 = 1
  13239. }
  13240. if i.Insutype == "310" {
  13241. is310 = 1
  13242. }
  13243. }
  13244. }
  13245. if is390 == 1 {
  13246. insutype = "390"
  13247. }
  13248. if is310 == 1 {
  13249. insutype = "310"
  13250. }
  13251. if len(insutypes) == 0 {
  13252. insutype = "310"
  13253. }
  13254. psn := &models.HisPsn{
  13255. PsnNo: res2.Output.Baseinfo.PsnNo,
  13256. PatientId: patient.ID,
  13257. Certno: res2.Output.Baseinfo.Certno,
  13258. Gend: res2.Output.Baseinfo.Gend,
  13259. Naty: res2.Output.Baseinfo.Naty,
  13260. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  13261. PsnName: res2.Output.Baseinfo.PsnName,
  13262. Idetinfo: idetinfoStr,
  13263. Insuinfo: infoStr,
  13264. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13265. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  13266. VerifyNumber: res.Output.EcToken,
  13267. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  13268. }
  13269. if res.Output.MdtrtCertType == "01" {
  13270. psn.VerifyNumber = res.Output.EcToken
  13271. //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)
  13272. } else if res.Output.MdtrtCertType == "02" {
  13273. psn.VerifyNumber = res.Output.MdtrtCertNo
  13274. //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)
  13275. } else if res.Output.MdtrtCertType == "03" {
  13276. psn.VerifyNumber = res.Output.MdtrtCertNo
  13277. //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)
  13278. }
  13279. var balc float64
  13280. for _, item := range rf {
  13281. if item.Insutype == insutype {
  13282. balc = item.Balc
  13283. }
  13284. }
  13285. service.CreateHisPsn(psn)
  13286. c.ServeSuccessJSON(map[string]interface{}{
  13287. "patient": patient,
  13288. "number": res.Output.CardNo,
  13289. "insutype": insutype,
  13290. "blac": balc,
  13291. "desc": idetinfoStr,
  13292. })
  13293. }
  13294. } else {
  13295. c.ServeSuccessJSON(map[string]interface{}{
  13296. "failed_code": -10,
  13297. "msg": res2.ErrMsg,
  13298. })
  13299. }
  13300. } else {
  13301. c.ServeSuccessJSON(map[string]interface{}{
  13302. "failed_code": -10,
  13303. "msg": res.ErrMsg,
  13304. })
  13305. }
  13306. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13307. var api string
  13308. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13309. "&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
  13310. fmt.Println(api)
  13311. resp, requestErr := http.Get(api)
  13312. if requestErr != nil {
  13313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13314. return
  13315. }
  13316. body, ioErr := ioutil.ReadAll(resp.Body)
  13317. if ioErr != nil {
  13318. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13320. return
  13321. }
  13322. var respJSON map[string]interface{}
  13323. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13324. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13326. return
  13327. }
  13328. var status string
  13329. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13330. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13331. //console.log()
  13332. fmt.Println("type===")
  13333. fmt.Println(card_type)
  13334. var token string
  13335. var res ResultTwo //1101结果
  13336. //var res10265 ResultTwoesultTwo10265 //1101结果
  13337. var card_info string //卡信息
  13338. var busi_card_info string
  13339. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13340. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13341. if status == "0" { //读卡成功
  13342. if card_type == "1" {
  13343. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13344. result, _ := json.Marshal(respJSON)
  13345. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13346. utils.ErrorLog("解析失败:%v", err)
  13347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13348. return
  13349. }
  13350. } else {
  13351. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13352. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13353. result, _ := json.Marshal(respJSON)
  13354. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13355. utils.ErrorLog("解析失败:%v", err)
  13356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13357. return
  13358. }
  13359. }
  13360. if res.Infcode == 0 {
  13361. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13362. if err == gorm.ErrRecordNotFound {
  13363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13364. return
  13365. } else if err != nil {
  13366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13367. return
  13368. } else {
  13369. if card_type == "1" {
  13370. bas := strings.Split(card_info, "|")
  13371. basNumber := bas[2]
  13372. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13373. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13374. infoStr := string(Iinfos)
  13375. idetinfoStr := string(Idetinfos)
  13376. psn := &models.HisPsn{
  13377. PsnNo: res.Output.Baseinfo.PsnNo,
  13378. PatientId: patient.ID,
  13379. Certno: res.Output.Baseinfo.Certno,
  13380. Gend: res.Output.Baseinfo.Gend,
  13381. Naty: res.Output.Baseinfo.Naty,
  13382. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13383. PsnName: res.Output.Baseinfo.PsnName,
  13384. Idetinfo: idetinfoStr,
  13385. Insuinfo: infoStr,
  13386. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13387. CardInfo: card_info,
  13388. VerifyNumber: busi_card_info,
  13389. }
  13390. service.CreateHisPsn(psn)
  13391. var rf []*ResultFive
  13392. json.Unmarshal([]byte(infoStr), &rf)
  13393. var insutypes []*ResultFive
  13394. var insutype string
  13395. var is390 int = 0
  13396. var is310 int = 0
  13397. for _, item := range rf {
  13398. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13399. insutypes = append(insutypes, item)
  13400. }
  13401. }
  13402. if len(insutypes) == 1 {
  13403. insutype = insutypes[0].Insutype
  13404. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13405. } else {
  13406. for _, i := range insutypes {
  13407. if i.Insutype == "390" {
  13408. is390 = 1
  13409. }
  13410. if i.Insutype == "310" {
  13411. is310 = 1
  13412. }
  13413. }
  13414. }
  13415. if is390 == 1 {
  13416. insutype = "390"
  13417. }
  13418. if is310 == 1 {
  13419. insutype = "310"
  13420. }
  13421. if len(insutypes) == 0 {
  13422. insutype = "310"
  13423. }
  13424. c.ServeSuccessJSON(map[string]interface{}{
  13425. "patient": patient,
  13426. "number": basNumber,
  13427. "insutype": insutype,
  13428. })
  13429. } else {
  13430. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13431. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13432. infoStr := string(Iinfos)
  13433. idetinfoStr := string(Idetinfos)
  13434. psn := &models.HisPsn{
  13435. PsnNo: res.Output.Baseinfo.PsnNo,
  13436. PatientId: patient.ID,
  13437. Certno: res.Output.Baseinfo.Certno,
  13438. Gend: res.Output.Baseinfo.Gend,
  13439. Naty: res.Output.Baseinfo.Naty,
  13440. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13441. PsnName: res.Output.Baseinfo.PsnName,
  13442. Idetinfo: idetinfoStr,
  13443. Insuinfo: infoStr,
  13444. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13445. CardInfo: card_info,
  13446. VerifyNumber: token,
  13447. }
  13448. service.CreateHisPsn(psn)
  13449. c.ServeSuccessJSON(map[string]interface{}{
  13450. "patient": patient,
  13451. "number": token,
  13452. })
  13453. }
  13454. }
  13455. } else {
  13456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13457. return
  13458. }
  13459. } else { //读卡失败
  13460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13461. return
  13462. }
  13463. } else if miConfig.MdtrtareaAdmvs == "340699" {
  13464. var api string
  13465. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13466. "&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
  13467. fmt.Println(api)
  13468. resp, requestErr := http.Get(api)
  13469. if requestErr != nil {
  13470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13471. return
  13472. }
  13473. body, ioErr := ioutil.ReadAll(resp.Body)
  13474. if ioErr != nil {
  13475. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13477. return
  13478. }
  13479. var respJSON map[string]interface{}
  13480. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13481. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13483. return
  13484. }
  13485. var status string
  13486. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13487. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13488. //console.log()
  13489. fmt.Println("type===")
  13490. fmt.Println(card_type)
  13491. var token string
  13492. var res ResultTwo //1101结果
  13493. //var res10265 ResultTwoesultTwo10265 //1101结果
  13494. var card_info string //卡信息
  13495. var busi_card_info string
  13496. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13497. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13498. if status == "0" { //读卡成功
  13499. if card_type == "1" {
  13500. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13501. result, _ := json.Marshal(respJSON)
  13502. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13503. utils.ErrorLog("解析失败:%v", err)
  13504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13505. return
  13506. }
  13507. } else {
  13508. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13509. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13510. result, _ := json.Marshal(respJSON)
  13511. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13512. utils.ErrorLog("解析失败:%v", err)
  13513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13514. return
  13515. }
  13516. }
  13517. if res.Infcode == 0 {
  13518. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13519. if err == gorm.ErrRecordNotFound {
  13520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13521. return
  13522. } else if err != nil {
  13523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13524. return
  13525. } else {
  13526. if card_type == "1" {
  13527. bas := strings.Split(card_info, "|")
  13528. basNumber := bas[2]
  13529. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13530. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13531. infoStr := string(Iinfos)
  13532. idetinfoStr := string(Idetinfos)
  13533. psn := &models.HisPsn{
  13534. PsnNo: res.Output.Baseinfo.PsnNo,
  13535. PatientId: patient.ID,
  13536. Certno: res.Output.Baseinfo.Certno,
  13537. Gend: res.Output.Baseinfo.Gend,
  13538. Naty: res.Output.Baseinfo.Naty,
  13539. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13540. PsnName: res.Output.Baseinfo.PsnName,
  13541. Idetinfo: idetinfoStr,
  13542. Insuinfo: infoStr,
  13543. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13544. CardInfo: card_info,
  13545. VerifyNumber: busi_card_info,
  13546. }
  13547. service.CreateHisPsn(psn)
  13548. var rf []*ResultFive
  13549. json.Unmarshal([]byte(infoStr), &rf)
  13550. var insutypes []*ResultFive
  13551. var insutype string
  13552. var is390 int = 0
  13553. var is310 int = 0
  13554. for _, item := range rf {
  13555. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13556. insutypes = append(insutypes, item)
  13557. }
  13558. }
  13559. if len(insutypes) == 1 {
  13560. insutype = insutypes[0].Insutype
  13561. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13562. } else {
  13563. for _, i := range insutypes {
  13564. if i.Insutype == "390" {
  13565. is390 = 1
  13566. }
  13567. if i.Insutype == "310" {
  13568. is310 = 1
  13569. }
  13570. }
  13571. }
  13572. if is390 == 1 {
  13573. insutype = "390"
  13574. }
  13575. if is310 == 1 {
  13576. insutype = "310"
  13577. }
  13578. if len(insutypes) == 0 {
  13579. insutype = "310"
  13580. }
  13581. c.ServeSuccessJSON(map[string]interface{}{
  13582. "patient": patient,
  13583. "number": basNumber,
  13584. "insutype": insutype,
  13585. })
  13586. } else {
  13587. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13588. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13589. infoStr := string(Iinfos)
  13590. idetinfoStr := string(Idetinfos)
  13591. psn := &models.HisPsn{
  13592. PsnNo: res.Output.Baseinfo.PsnNo,
  13593. PatientId: patient.ID,
  13594. Certno: res.Output.Baseinfo.Certno,
  13595. Gend: res.Output.Baseinfo.Gend,
  13596. Naty: res.Output.Baseinfo.Naty,
  13597. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13598. PsnName: res.Output.Baseinfo.PsnName,
  13599. Idetinfo: idetinfoStr,
  13600. Insuinfo: infoStr,
  13601. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13602. CardInfo: card_info,
  13603. VerifyNumber: token,
  13604. }
  13605. service.CreateHisPsn(psn)
  13606. c.ServeSuccessJSON(map[string]interface{}{
  13607. "patient": patient,
  13608. "number": token,
  13609. })
  13610. }
  13611. }
  13612. } else {
  13613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13614. return
  13615. }
  13616. } else { //读卡失败
  13617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13618. return
  13619. }
  13620. } else {
  13621. if initFlag == 0 {
  13622. c.TestGetBasBaseInit()
  13623. }
  13624. basStr := c.GetBasBaseInfo()
  13625. if len(basStr) == 0 {
  13626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13627. return
  13628. }
  13629. fmt.Println(basStr)
  13630. bas := strings.Split(basStr, "|")
  13631. basNumber := bas[1]
  13632. fmt.Println(basNumber)
  13633. card_sn := bas[3]
  13634. fmt.Println(card_sn)
  13635. cardNumber := bas[2]
  13636. fmt.Println(cardNumber)
  13637. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  13638. var result string
  13639. if bas[0][:2] == "44" {
  13640. 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)
  13641. } else {
  13642. 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)
  13643. }
  13644. var dat map[string]interface{}
  13645. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13646. fmt.Println(dat)
  13647. } else {
  13648. fmt.Println(err)
  13649. }
  13650. userJSONBytes, _ := json.Marshal(dat)
  13651. var res ResultTwo
  13652. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13653. utils.ErrorLog("解析失败:%v", err)
  13654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13655. return
  13656. }
  13657. if res.Infcode == 0 {
  13658. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13659. if err == gorm.ErrRecordNotFound {
  13660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13661. return
  13662. } else if err != nil {
  13663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13664. return
  13665. } else {
  13666. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13667. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13668. infoStr := string(Iinfos)
  13669. idetinfoStr := string(Idetinfos)
  13670. var rf []*ResultFive
  13671. json.Unmarshal([]byte(infoStr), &rf)
  13672. var insutypes []*ResultFive
  13673. var insutype string
  13674. var is390 int = 0
  13675. var is310 int = 0
  13676. var insuplc_admdvs string
  13677. for _, item := range rf {
  13678. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13679. insutypes = append(insutypes, item)
  13680. }
  13681. }
  13682. if len(insutypes) == 1 {
  13683. insutype = insutypes[0].Insutype
  13684. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13685. } else {
  13686. for _, i := range insutypes {
  13687. if i.Insutype == "390" {
  13688. is390 = 1
  13689. }
  13690. if i.Insutype == "310" {
  13691. is310 = 1
  13692. }
  13693. }
  13694. }
  13695. if is390 == 1 {
  13696. insutype = "390"
  13697. }
  13698. if is310 == 1 {
  13699. insutype = "310"
  13700. }
  13701. if len(insutypes) == 0 {
  13702. insutype = "310"
  13703. }
  13704. for _, item := range rf {
  13705. if item.Insutype == insutype {
  13706. insuplc_admdvs = item.InsuplcAdmdvs
  13707. }
  13708. }
  13709. psn := &models.HisPsn{
  13710. PsnNo: res.Output.Baseinfo.PsnNo,
  13711. PatientId: patient.ID,
  13712. Certno: res.Output.Baseinfo.Certno,
  13713. Gend: res.Output.Baseinfo.Gend,
  13714. Naty: res.Output.Baseinfo.Naty,
  13715. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13716. PsnName: res.Output.Baseinfo.PsnName,
  13717. Idetinfo: idetinfoStr,
  13718. Insuinfo: infoStr,
  13719. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13720. CardInfo: basStr,
  13721. VerifyNumber: "",
  13722. InsuplcAdmdvs: insuplc_admdvs,
  13723. }
  13724. service.CreateHisPsn(psn)
  13725. c.ServeSuccessJSON(map[string]interface{}{
  13726. "patient": patient,
  13727. "number": basNumber,
  13728. })
  13729. }
  13730. } else {
  13731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13732. return
  13733. }
  13734. break
  13735. }
  13736. case 2:
  13737. if miConfig.MdtrtareaAdmvs == "430800" {
  13738. if initFlag == 0 {
  13739. c.TestGetHnBasBaseInit()
  13740. }
  13741. SFZStr := c.GetSFZBaseInfo()
  13742. if len(SFZStr) == 0 {
  13743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13744. return
  13745. }
  13746. fmt.Println(SFZStr)
  13747. id_card_str := strings.Split(SFZStr, "^")
  13748. card_no := id_card_str[0]
  13749. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  13750. //name := id_card_str[1]
  13751. //name = ConvertToString(name, "gbk", "utf-8")
  13752. 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)
  13753. var dat map[string]interface{}
  13754. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13755. fmt.Println(dat)
  13756. } else {
  13757. fmt.Println(err)
  13758. }
  13759. userJSONBytes, _ := json.Marshal(dat)
  13760. var res ResultTwo
  13761. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13762. utils.ErrorLog("解析失败:%v", err)
  13763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13764. return
  13765. }
  13766. if res.Infcode == 0 {
  13767. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  13768. if err == gorm.ErrRecordNotFound {
  13769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13770. return
  13771. } else if err != nil {
  13772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13773. return
  13774. } else {
  13775. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13776. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13777. infoStr := string(Iinfos)
  13778. idetinfoStr := string(Idetinfos)
  13779. var rf []*ResultFive
  13780. json.Unmarshal([]byte(infoStr), &rf)
  13781. var insutypes []*ResultFive
  13782. var insutype string
  13783. var is390 int = 0
  13784. var is310 int = 0
  13785. for _, item := range rf {
  13786. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13787. insutypes = append(insutypes, item)
  13788. }
  13789. }
  13790. if len(insutypes) == 1 {
  13791. insutype = insutypes[0].Insutype
  13792. } else {
  13793. for _, i := range insutypes {
  13794. if i.Insutype == "390" {
  13795. is390 = 1
  13796. }
  13797. if i.Insutype == "310" {
  13798. is310 = 1
  13799. }
  13800. }
  13801. }
  13802. if is390 == 1 {
  13803. insutype = "390"
  13804. }
  13805. if is310 == 1 {
  13806. insutype = "310"
  13807. }
  13808. if len(insutypes) == 0 {
  13809. insutype = "310"
  13810. }
  13811. var InsuplcAdmdvs string
  13812. for _, item := range rf {
  13813. if item.Insutype == insutype {
  13814. InsuplcAdmdvs = item.InsuplcAdmdvs
  13815. }
  13816. }
  13817. psn := &models.HisPsn{
  13818. PsnNo: res.Output.Baseinfo.PsnNo,
  13819. PatientId: patient.ID,
  13820. Certno: res.Output.Baseinfo.Certno,
  13821. Gend: res.Output.Baseinfo.Gend,
  13822. Naty: res.Output.Baseinfo.Naty,
  13823. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13824. PsnName: res.Output.Baseinfo.PsnName,
  13825. Idetinfo: idetinfoStr,
  13826. Insuinfo: infoStr,
  13827. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13828. CardInfo: SFZStr,
  13829. VerifyNumber: "",
  13830. InsuplcAdmdvs: InsuplcAdmdvs,
  13831. }
  13832. service.CreateHisPsn(psn)
  13833. c.ServeSuccessJSON(map[string]interface{}{
  13834. "patient": patient,
  13835. "number": card_no,
  13836. "insutype": insutype,
  13837. })
  13838. }
  13839. } else {
  13840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13841. return
  13842. }
  13843. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13844. var res ResultTwo
  13845. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13846. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13847. "&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)
  13848. resp, requestErr := http.Get(api)
  13849. if requestErr != nil {
  13850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13851. return
  13852. }
  13853. body, ioErr := ioutil.ReadAll(resp.Body)
  13854. if ioErr != nil {
  13855. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13857. return
  13858. }
  13859. var respJSON map[string]interface{}
  13860. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13863. return
  13864. }
  13865. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13866. result, _ := json.Marshal(respJSON)
  13867. fmt.Println("log")
  13868. fmt.Println(string(result))
  13869. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13870. utils.ErrorLog("解析失败:%v", err)
  13871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13872. return
  13873. }
  13874. if res.Infcode == 0 {
  13875. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13876. if err == gorm.ErrRecordNotFound {
  13877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13878. return
  13879. } else if err != nil {
  13880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13881. return
  13882. } else {
  13883. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13884. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13885. infoStr := string(Iinfos)
  13886. idetinfoStr := string(Idetinfos)
  13887. psn := &models.HisPsn{
  13888. PsnNo: res.Output.Baseinfo.PsnNo,
  13889. PatientId: patient.ID,
  13890. Certno: res.Output.Baseinfo.Certno,
  13891. Gend: res.Output.Baseinfo.Gend,
  13892. Naty: res.Output.Baseinfo.Naty,
  13893. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13894. PsnName: res.Output.Baseinfo.PsnName,
  13895. Idetinfo: idetinfoStr,
  13896. Insuinfo: infoStr,
  13897. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13898. }
  13899. service.CreateHisPsn(psn)
  13900. c.ServeSuccessJSON(map[string]interface{}{
  13901. "patient": patient,
  13902. "number": res.Output.Baseinfo.Certno,
  13903. })
  13904. }
  13905. } else {
  13906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13907. return
  13908. }
  13909. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13910. var res ResultTwo
  13911. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13912. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13913. "&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)
  13914. resp, requestErr := http.Get(api)
  13915. if requestErr != nil {
  13916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13917. return
  13918. }
  13919. body, ioErr := ioutil.ReadAll(resp.Body)
  13920. if ioErr != nil {
  13921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13923. return
  13924. }
  13925. var respJSON map[string]interface{}
  13926. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13929. return
  13930. }
  13931. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13932. result, _ := json.Marshal(respJSON)
  13933. fmt.Println("log")
  13934. fmt.Println(string(result))
  13935. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13936. utils.ErrorLog("解析失败:%v", err)
  13937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13938. return
  13939. }
  13940. if res.Infcode == 0 {
  13941. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13942. if err == gorm.ErrRecordNotFound {
  13943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13944. return
  13945. } else if err != nil {
  13946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13947. return
  13948. } else {
  13949. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13950. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13951. infoStr := string(Iinfos)
  13952. idetinfoStr := string(Idetinfos)
  13953. psn := &models.HisPsn{
  13954. PsnNo: res.Output.Baseinfo.PsnNo,
  13955. PatientId: patient.ID,
  13956. Certno: res.Output.Baseinfo.Certno,
  13957. Gend: res.Output.Baseinfo.Gend,
  13958. Naty: res.Output.Baseinfo.Naty,
  13959. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13960. PsnName: res.Output.Baseinfo.PsnName,
  13961. Idetinfo: idetinfoStr,
  13962. Insuinfo: infoStr,
  13963. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13964. }
  13965. service.CreateHisPsn(psn)
  13966. c.ServeSuccessJSON(map[string]interface{}{
  13967. "patient": patient,
  13968. "number": res.Output.Baseinfo.Certno,
  13969. })
  13970. }
  13971. } else {
  13972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13973. return
  13974. }
  13975. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13976. var res ResultTwo
  13977. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13978. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13979. "&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)
  13980. resp, requestErr := http.Get(api)
  13981. if requestErr != nil {
  13982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13983. return
  13984. }
  13985. body, ioErr := ioutil.ReadAll(resp.Body)
  13986. if ioErr != nil {
  13987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13989. return
  13990. }
  13991. var respJSON map[string]interface{}
  13992. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13995. return
  13996. }
  13997. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13998. result, _ := json.Marshal(respJSON)
  13999. fmt.Println("log")
  14000. fmt.Println(string(result))
  14001. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14002. utils.ErrorLog("解析失败:%v", err)
  14003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14004. return
  14005. }
  14006. if res.Infcode == 0 {
  14007. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14008. if err == gorm.ErrRecordNotFound {
  14009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14010. return
  14011. } else if err != nil {
  14012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14013. return
  14014. } else {
  14015. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14016. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14017. infoStr := string(Iinfos)
  14018. idetinfoStr := string(Idetinfos)
  14019. var rf []*ResultFive
  14020. json.Unmarshal([]byte(infoStr), &rf)
  14021. var insutypes []*ResultFive
  14022. var insutype string
  14023. var is390 int = 0
  14024. var is310 int = 0
  14025. for _, item := range rf {
  14026. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14027. insutypes = append(insutypes, item)
  14028. }
  14029. }
  14030. if len(insutypes) == 1 {
  14031. insutype = insutypes[0].Insutype
  14032. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14033. } else {
  14034. for _, i := range insutypes {
  14035. if i.Insutype == "390" {
  14036. is390 = 1
  14037. }
  14038. if i.Insutype == "310" {
  14039. is310 = 1
  14040. }
  14041. }
  14042. }
  14043. if is390 == 1 {
  14044. insutype = "390"
  14045. }
  14046. if is310 == 1 {
  14047. insutype = "310"
  14048. }
  14049. if len(insutypes) == 0 {
  14050. insutype = "390"
  14051. }
  14052. var insuplc_admdvs string
  14053. for _, item := range rf {
  14054. if item.Insutype == insutype {
  14055. insuplc_admdvs = item.InsuplcAdmdvs
  14056. }
  14057. }
  14058. psn := &models.HisPsn{
  14059. PsnNo: res.Output.Baseinfo.PsnNo,
  14060. PatientId: patient.ID,
  14061. Certno: res.Output.Baseinfo.Certno,
  14062. Gend: res.Output.Baseinfo.Gend,
  14063. Naty: res.Output.Baseinfo.Naty,
  14064. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14065. PsnName: res.Output.Baseinfo.PsnName,
  14066. Idetinfo: idetinfoStr,
  14067. Insuinfo: infoStr,
  14068. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14069. InsuplcAdmdvs: insuplc_admdvs,
  14070. }
  14071. service.CreateHisPsn(psn)
  14072. c.ServeSuccessJSON(map[string]interface{}{
  14073. "patient": patient,
  14074. "number": res.Output.Baseinfo.Certno,
  14075. })
  14076. }
  14077. } else {
  14078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14079. return
  14080. }
  14081. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14082. res := c.GetoleInfo()
  14083. if res.Infcode == 0 {
  14084. var result string
  14085. if res.Output.MdtrtCertType == "01" {
  14086. 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)
  14087. } else if res.Output.MdtrtCertType == "02" {
  14088. 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)
  14089. } else if res.Output.MdtrtCertType == "03" {
  14090. 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)
  14091. }
  14092. var dat map[string]interface{}
  14093. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14094. fmt.Println(dat)
  14095. } else {
  14096. fmt.Println(err)
  14097. }
  14098. userJSONBytes, _ := json.Marshal(dat)
  14099. var res2 ResultTwo
  14100. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14101. utils.ErrorLog("解析失败:%v", err)
  14102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14103. return
  14104. }
  14105. if res2.Infcode == 0 {
  14106. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14107. if err == gorm.ErrRecordNotFound {
  14108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14109. return
  14110. } else if err != nil {
  14111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14112. return
  14113. } else {
  14114. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14115. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14116. infoStr := string(Iinfos)
  14117. idetinfoStr := string(Idetinfos)
  14118. var rf []*ResultFive
  14119. json.Unmarshal([]byte(infoStr), &rf)
  14120. var insutypes []*ResultFive
  14121. var insutype string
  14122. var is390 int = 0
  14123. var is310 int = 0
  14124. //var insuplc_admdvs string
  14125. for _, item := range rf {
  14126. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14127. insutypes = append(insutypes, item)
  14128. }
  14129. }
  14130. if len(insutypes) == 1 {
  14131. insutype = insutypes[0].Insutype
  14132. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14133. } else {
  14134. for _, i := range insutypes {
  14135. if i.Insutype == "390" {
  14136. is390 = 1
  14137. }
  14138. if i.Insutype == "310" {
  14139. is310 = 1
  14140. }
  14141. }
  14142. }
  14143. if is390 == 1 {
  14144. insutype = "390"
  14145. }
  14146. if is310 == 1 {
  14147. insutype = "310"
  14148. }
  14149. if len(insutypes) == 0 {
  14150. insutype = "310"
  14151. }
  14152. psn := &models.HisPsn{
  14153. PsnNo: res2.Output.Baseinfo.PsnNo,
  14154. PatientId: patient.ID,
  14155. //Brdy: res2.Output.Baseinfo.Brdy,
  14156. Certno: res2.Output.Baseinfo.Certno,
  14157. Gend: res2.Output.Baseinfo.Gend,
  14158. Naty: res2.Output.Baseinfo.Naty,
  14159. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14160. PsnName: res2.Output.Baseinfo.PsnName,
  14161. Idetinfo: idetinfoStr,
  14162. Insuinfo: infoStr,
  14163. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14164. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14165. VerifyNumber: res.Output.EcToken,
  14166. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14167. }
  14168. service.CreateHisPsn(psn)
  14169. var balc float64
  14170. for _, item := range rf {
  14171. if item.Insutype == insutype {
  14172. balc = item.Balc
  14173. }
  14174. }
  14175. c.ServeSuccessJSON(map[string]interface{}{
  14176. "patient": patient,
  14177. "number": res.Output.CardNo,
  14178. "insutype": insutype,
  14179. "blac": balc,
  14180. "desc": idetinfoStr,
  14181. })
  14182. }
  14183. } else {
  14184. c.ServeSuccessJSON(map[string]interface{}{
  14185. "failed_code": -10,
  14186. "msg": res2.ErrMsg,
  14187. })
  14188. }
  14189. } else {
  14190. c.ServeSuccessJSON(map[string]interface{}{
  14191. "failed_code": -10,
  14192. "msg": res.ErrMsg,
  14193. })
  14194. }
  14195. } else {
  14196. SFZStr := c.GetSFZBaseInfo()
  14197. id_card_str := strings.Split(SFZStr, "^")
  14198. id_card_number := id_card_str[0]
  14199. card_sn := ""
  14200. 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)
  14201. var dat map[string]interface{}
  14202. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14203. fmt.Println(dat)
  14204. } else {
  14205. fmt.Println(err)
  14206. }
  14207. userJSONBytes, _ := json.Marshal(dat)
  14208. var res ResultTwo
  14209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14210. utils.ErrorLog("解析失败:%v", err)
  14211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14212. return
  14213. }
  14214. if res.Infcode == 0 {
  14215. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  14216. if err == gorm.ErrRecordNotFound {
  14217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14218. return
  14219. } else if err != nil {
  14220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14221. return
  14222. } else {
  14223. c.ServeSuccessJSON(map[string]interface{}{
  14224. "patient": patient,
  14225. "number": id_card_number,
  14226. })
  14227. }
  14228. } else {
  14229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14230. return
  14231. }
  14232. }
  14233. break
  14234. case 3:
  14235. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14236. var api string
  14237. if miConfig.MdtrtareaAdmvs == "320921" {
  14238. 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 +
  14239. "&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
  14240. fmt.Println(api)
  14241. } else {
  14242. 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 +
  14243. "&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)
  14244. }
  14245. resp, requestErr := http.Get(api)
  14246. if requestErr != nil {
  14247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14248. return
  14249. }
  14250. body, ioErr := ioutil.ReadAll(resp.Body)
  14251. if ioErr != nil {
  14252. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14254. return
  14255. }
  14256. var respJSON map[string]interface{}
  14257. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14260. return
  14261. }
  14262. var status string
  14263. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14264. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14265. var token string
  14266. var res ResultTwo //1101结果
  14267. var res10265 ResultTwo10265 //1101结果
  14268. var card_info string //卡信息
  14269. var busi_card_info string
  14270. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14271. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14272. if status == "0" { //读卡成功
  14273. if card_type == "1" {
  14274. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14275. result, _ := json.Marshal(respJSON)
  14276. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14277. utils.ErrorLog("解析失败:%v", err)
  14278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14279. return
  14280. }
  14281. res.ErrMsg = res10265.ErrMsg
  14282. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14283. res.Infcode = infocode
  14284. res.Output = res10265.Output
  14285. res.InfRefmsgid = res10265.InfRefmsgid
  14286. } else {
  14287. //var card_info string //卡信息
  14288. //var busi_card_info string
  14289. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14290. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14291. //fmt.Println(card_info)
  14292. //fmt.Println(busi_card_info)
  14293. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14294. result, _ := json.Marshal(respJSON)
  14295. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14296. utils.ErrorLog("解析失败:%v", err)
  14297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14298. return
  14299. }
  14300. res.ErrMsg = res10265.ErrMsg
  14301. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14302. res.Infcode = infocode
  14303. res.Output = res10265.Output
  14304. res.InfRefmsgid = res10265.InfRefmsgid
  14305. }
  14306. if res.Infcode == 0 {
  14307. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14308. if err == gorm.ErrRecordNotFound {
  14309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14310. return
  14311. } else if err != nil {
  14312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14313. return
  14314. } else {
  14315. if card_type == "1" {
  14316. bas := strings.Split(card_info, "|")
  14317. basNumber := bas[2]
  14318. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14319. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14320. infoStr := string(Iinfos)
  14321. idetinfoStr := string(Idetinfos)
  14322. psn := &models.HisPsn{
  14323. PsnNo: res.Output.Baseinfo.PsnNo,
  14324. PatientId: patient.ID,
  14325. Certno: res.Output.Baseinfo.Certno,
  14326. //Brdy: res.Output.Baseinfo.Brdy,
  14327. Gend: res.Output.Baseinfo.Gend,
  14328. Naty: res.Output.Baseinfo.Naty,
  14329. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14330. PsnName: res.Output.Baseinfo.PsnName,
  14331. Idetinfo: idetinfoStr,
  14332. Insuinfo: infoStr,
  14333. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14334. CardInfo: card_info,
  14335. VerifyNumber: busi_card_info,
  14336. }
  14337. service.CreateHisPsn(psn)
  14338. c.ServeSuccessJSON(map[string]interface{}{
  14339. "patient": patient,
  14340. "number": basNumber,
  14341. })
  14342. } else {
  14343. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14344. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14345. infoStr := string(Iinfos)
  14346. idetinfoStr := string(Idetinfos)
  14347. psn := &models.HisPsn{
  14348. PsnNo: res.Output.Baseinfo.PsnNo,
  14349. PatientId: patient.ID,
  14350. Certno: res.Output.Baseinfo.Certno,
  14351. Gend: res.Output.Baseinfo.Gend,
  14352. Naty: res.Output.Baseinfo.Naty,
  14353. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14354. PsnName: res.Output.Baseinfo.PsnName,
  14355. Idetinfo: idetinfoStr,
  14356. Insuinfo: infoStr,
  14357. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14358. CardInfo: card_info,
  14359. VerifyNumber: token,
  14360. }
  14361. service.CreateHisPsn(psn)
  14362. var rf []*ResultFive
  14363. json.Unmarshal([]byte(infoStr), &rf)
  14364. var insutypes []*ResultFive
  14365. var insutype string
  14366. var is390 int = 0
  14367. var is310 int = 0
  14368. for _, item := range rf {
  14369. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14370. insutypes = append(insutypes, item)
  14371. }
  14372. }
  14373. if len(insutypes) == 1 {
  14374. insutype = insutypes[0].Insutype
  14375. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14376. } else {
  14377. for _, i := range insutypes {
  14378. if i.Insutype == "390" {
  14379. is390 = 1
  14380. }
  14381. if i.Insutype == "310" {
  14382. is310 = 1
  14383. }
  14384. }
  14385. }
  14386. if is390 == 1 {
  14387. insutype = "390"
  14388. }
  14389. if is310 == 1 {
  14390. insutype = "310"
  14391. }
  14392. if len(insutypes) == 0 {
  14393. insutype = "310"
  14394. }
  14395. c.ServeSuccessJSON(map[string]interface{}{
  14396. "patient": patient,
  14397. "number": token,
  14398. "insutype": insutype,
  14399. })
  14400. }
  14401. }
  14402. } else {
  14403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14404. return
  14405. }
  14406. } else { //读卡失败
  14407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14408. return
  14409. }
  14410. }
  14411. break
  14412. case 4:
  14413. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14414. var api string
  14415. if miConfig.MdtrtareaAdmvs == "320921" {
  14416. 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 +
  14417. "&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
  14418. fmt.Println(api)
  14419. } else {
  14420. 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 +
  14421. "&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)
  14422. }
  14423. resp, requestErr := http.Get(api)
  14424. if requestErr != nil {
  14425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14426. return
  14427. }
  14428. body, ioErr := ioutil.ReadAll(resp.Body)
  14429. if ioErr != nil {
  14430. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14432. return
  14433. }
  14434. var respJSON map[string]interface{}
  14435. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14438. return
  14439. }
  14440. var status string
  14441. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14442. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14443. var token string
  14444. var res ResultTwo //1101结果
  14445. var res10265 ResultTwo10265 //1101结果
  14446. if status == "0" { //读卡成功
  14447. var card_info string //卡信息
  14448. var busi_card_info string
  14449. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14450. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14451. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14452. fmt.Println(card_info)
  14453. fmt.Println(busi_card_info)
  14454. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14455. result, _ := json.Marshal(respJSON)
  14456. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14457. utils.ErrorLog("解析失败:%v", err)
  14458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14459. return
  14460. }
  14461. res.ErrMsg = res10265.ErrMsg
  14462. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14463. res.Infcode = infocode
  14464. res.Output = res10265.Output
  14465. res.InfRefmsgid = res10265.InfRefmsgid
  14466. if res.Infcode == 0 {
  14467. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14468. if err == gorm.ErrRecordNotFound {
  14469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14470. return
  14471. } else if err != nil {
  14472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14473. return
  14474. } else {
  14475. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14476. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14477. infoStr := string(Iinfos)
  14478. idetinfoStr := string(Idetinfos)
  14479. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14480. psn := &models.HisPsn{
  14481. PsnNo: res.Output.Baseinfo.PsnNo,
  14482. PatientId: patient.ID,
  14483. Certno: res.Output.Baseinfo.Certno,
  14484. Brdy: b,
  14485. Age: float64(age),
  14486. //Brdy: res.Output.Baseinfo.Brdy,
  14487. Gend: res.Output.Baseinfo.Gend,
  14488. Naty: res.Output.Baseinfo.Naty,
  14489. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14490. PsnName: res.Output.Baseinfo.PsnName,
  14491. Idetinfo: idetinfoStr,
  14492. Insuinfo: infoStr,
  14493. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14494. CardInfo: card_info,
  14495. VerifyNumber: token,
  14496. }
  14497. var rf []*ResultFive
  14498. json.Unmarshal([]byte(infoStr), &rf)
  14499. var insutypes []*ResultFive
  14500. var insutype string
  14501. var is390 int = 0
  14502. var is310 int = 0
  14503. for _, item := range rf {
  14504. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14505. insutypes = append(insutypes, item)
  14506. }
  14507. }
  14508. if len(insutypes) == 1 {
  14509. insutype = insutypes[0].Insutype
  14510. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14511. } else {
  14512. for _, i := range insutypes {
  14513. if i.Insutype == "390" {
  14514. is390 = 1
  14515. }
  14516. if i.Insutype == "310" {
  14517. is310 = 1
  14518. }
  14519. }
  14520. }
  14521. if is390 == 1 {
  14522. insutype = "390"
  14523. }
  14524. if is310 == 1 {
  14525. insutype = "310"
  14526. }
  14527. if len(insutypes) == 0 {
  14528. insutype = "310"
  14529. }
  14530. service.CreateHisPsn(psn)
  14531. c.ServeSuccessJSON(map[string]interface{}{
  14532. "patient": patient,
  14533. "number": token,
  14534. "insutype": insutype,
  14535. })
  14536. }
  14537. } else {
  14538. c.ServeSuccessJSON(map[string]interface{}{
  14539. "failed_code": -10,
  14540. "msg": res.ErrMsg,
  14541. })
  14542. }
  14543. } else { //读卡失败
  14544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14545. return
  14546. }
  14547. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14548. var api string
  14549. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14550. "&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
  14551. resp, requestErr := http.Get(api)
  14552. if requestErr != nil {
  14553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14554. return
  14555. }
  14556. body, ioErr := ioutil.ReadAll(resp.Body)
  14557. if ioErr != nil {
  14558. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14560. return
  14561. }
  14562. var respJSON map[string]interface{}
  14563. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14566. return
  14567. }
  14568. var status string
  14569. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14570. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14571. var token string
  14572. var res ResultTwo //1101结果
  14573. if status == "1" { //读卡成功
  14574. var card_info string //卡信息
  14575. var busi_card_info string
  14576. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14577. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14578. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14579. fmt.Println(card_info)
  14580. fmt.Println(busi_card_info)
  14581. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14582. result, _ := json.Marshal(respJSON)
  14583. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14584. utils.ErrorLog("解析失败:%v", err)
  14585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14586. return
  14587. }
  14588. if res.Infcode == 0 {
  14589. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14590. if err == gorm.ErrRecordNotFound {
  14591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14592. return
  14593. } else if err != nil {
  14594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14595. return
  14596. } else {
  14597. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14598. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14599. infoStr := string(Iinfos)
  14600. idetinfoStr := string(Idetinfos)
  14601. psn := &models.HisPsn{
  14602. PsnNo: res.Output.Baseinfo.PsnNo,
  14603. PatientId: patient.ID,
  14604. Certno: res.Output.Baseinfo.Certno,
  14605. Gend: res.Output.Baseinfo.Gend,
  14606. Naty: res.Output.Baseinfo.Naty,
  14607. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14608. PsnName: res.Output.Baseinfo.PsnName,
  14609. Idetinfo: idetinfoStr,
  14610. Insuinfo: infoStr,
  14611. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14612. CardInfo: card_info,
  14613. VerifyNumber: token,
  14614. }
  14615. var rf []*ResultFive
  14616. json.Unmarshal([]byte(infoStr), &rf)
  14617. var insutypes []*ResultFive
  14618. var insutype string
  14619. var is390 int = 0
  14620. var is310 int = 0
  14621. for _, item := range rf {
  14622. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14623. insutypes = append(insutypes, item)
  14624. }
  14625. }
  14626. if len(insutypes) == 1 {
  14627. insutype = insutypes[0].Insutype
  14628. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14629. } else {
  14630. for _, i := range insutypes {
  14631. if i.Insutype == "390" {
  14632. is390 = 1
  14633. }
  14634. if i.Insutype == "310" {
  14635. is310 = 1
  14636. }
  14637. }
  14638. }
  14639. if is390 == 1 {
  14640. insutype = "390"
  14641. }
  14642. if is310 == 1 {
  14643. insutype = "310"
  14644. }
  14645. if len(insutypes) == 0 {
  14646. insutype = "310"
  14647. }
  14648. service.CreateHisPsn(psn)
  14649. c.ServeSuccessJSON(map[string]interface{}{
  14650. "patient": patient,
  14651. "number": token,
  14652. "insutype": insutype,
  14653. })
  14654. }
  14655. } else {
  14656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14657. return
  14658. }
  14659. } else { //读卡失败
  14660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14661. return
  14662. }
  14663. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14664. var api string
  14665. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14666. "&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
  14667. resp, requestErr := http.Get(api)
  14668. if requestErr != nil {
  14669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14670. return
  14671. }
  14672. body, ioErr := ioutil.ReadAll(resp.Body)
  14673. if ioErr != nil {
  14674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14676. return
  14677. }
  14678. var respJSON map[string]interface{}
  14679. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14682. return
  14683. }
  14684. var status string
  14685. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14686. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14687. var token string
  14688. var res ResultTwo //1101结果
  14689. if status == "1" { //读卡成功
  14690. var card_info string //卡信息
  14691. var busi_card_info string
  14692. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14693. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14694. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14695. fmt.Println(card_info)
  14696. fmt.Println(busi_card_info)
  14697. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14698. result, _ := json.Marshal(respJSON)
  14699. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14700. utils.ErrorLog("解析失败:%v", err)
  14701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14702. return
  14703. }
  14704. if res.Infcode == 0 {
  14705. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14706. if err == gorm.ErrRecordNotFound {
  14707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14708. return
  14709. } else if err != nil {
  14710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14711. return
  14712. } else {
  14713. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14714. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14715. infoStr := string(Iinfos)
  14716. idetinfoStr := string(Idetinfos)
  14717. psn := &models.HisPsn{
  14718. PsnNo: res.Output.Baseinfo.PsnNo,
  14719. PatientId: patient.ID,
  14720. Certno: res.Output.Baseinfo.Certno,
  14721. Gend: res.Output.Baseinfo.Gend,
  14722. Naty: res.Output.Baseinfo.Naty,
  14723. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14724. PsnName: res.Output.Baseinfo.PsnName,
  14725. Idetinfo: idetinfoStr,
  14726. Insuinfo: infoStr,
  14727. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14728. CardInfo: card_info,
  14729. VerifyNumber: token,
  14730. }
  14731. var rf []*ResultFive
  14732. json.Unmarshal([]byte(infoStr), &rf)
  14733. var insutypes []*ResultFive
  14734. var insutype string
  14735. var is390 int = 0
  14736. var is310 int = 0
  14737. for _, item := range rf {
  14738. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14739. insutypes = append(insutypes, item)
  14740. }
  14741. }
  14742. if len(insutypes) == 1 {
  14743. insutype = insutypes[0].Insutype
  14744. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14745. } else {
  14746. for _, i := range insutypes {
  14747. if i.Insutype == "390" {
  14748. is390 = 1
  14749. }
  14750. if i.Insutype == "310" {
  14751. is310 = 1
  14752. }
  14753. }
  14754. }
  14755. if is390 == 1 {
  14756. insutype = "390"
  14757. }
  14758. if is310 == 1 {
  14759. insutype = "310"
  14760. }
  14761. if len(insutypes) == 0 {
  14762. insutype = "310"
  14763. }
  14764. service.CreateHisPsn(psn)
  14765. c.ServeSuccessJSON(map[string]interface{}{
  14766. "patient": patient,
  14767. "number": token,
  14768. "insutype": insutype,
  14769. })
  14770. }
  14771. } else {
  14772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14773. return
  14774. }
  14775. } else { //读卡失败
  14776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14777. return
  14778. }
  14779. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14780. //idNo := c.GetString("idNo")
  14781. //userName := c.GetString("userName")
  14782. //ecToken := c.GetString("ecToken")
  14783. //insuOrg := c.GetString("insuOrg")
  14784. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  14785. utils.ErrorLog("解析失败:%v", json_result)
  14786. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  14787. type ELeData struct {
  14788. Data struct {
  14789. IdNo string `json:"idNo"`
  14790. IdType string `json:"idType"`
  14791. UserName string `json:"userName"`
  14792. EcToken string `json:"ecToken"`
  14793. InsuOrg string `json:"insuOrg"`
  14794. Gender string `json:"gender"`
  14795. Birthday string `json:"birthday"`
  14796. Nationality string `json:"nationality"`
  14797. Email string `json:"email"`
  14798. Extra string `json:"extra"`
  14799. } `json:"data"`
  14800. Code int `json:"code"`
  14801. Message string `json:"message"`
  14802. }
  14803. var ele ELeData
  14804. err := json.Unmarshal([]byte(json_result), &ele)
  14805. if err != nil {
  14806. utils.ErrorLog("解析失败:%v", err)
  14807. }
  14808. token := ele.Data.EcToken
  14809. token = Remove0000(token)
  14810. 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)
  14811. saveLog(result2, requestLog2, "1101", "获取人员信息")
  14812. var res ResultTwo
  14813. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14814. utils.ErrorLog("解析失败:%v", err)
  14815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14816. return
  14817. }
  14818. if res.Infcode == 0 {
  14819. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14820. if err == gorm.ErrRecordNotFound {
  14821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14822. return
  14823. } else if err != nil {
  14824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14825. return
  14826. } else {
  14827. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14828. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14829. infoStr := string(Iinfos)
  14830. idetinfoStr := string(Idetinfos)
  14831. psn := &models.HisPsn{
  14832. PsnNo: res.Output.Baseinfo.PsnNo,
  14833. PatientId: patient.ID,
  14834. Certno: res.Output.Baseinfo.Certno,
  14835. Gend: res.Output.Baseinfo.Gend,
  14836. Naty: res.Output.Baseinfo.Naty,
  14837. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14838. PsnName: res.Output.Baseinfo.PsnName,
  14839. Idetinfo: idetinfoStr,
  14840. Insuinfo: infoStr,
  14841. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14842. CardInfo: "",
  14843. Stage: "1",
  14844. VerifyNumber: token,
  14845. InsuplcAdmdvs: ele.Data.InsuOrg,
  14846. }
  14847. service.CreateHisPsn(psn)
  14848. var rf []*ResultFive
  14849. json.Unmarshal([]byte(infoStr), &rf)
  14850. var insutypes []*ResultFive
  14851. var insutype string
  14852. var is390 int = 0
  14853. var is310 int = 0
  14854. for _, item := range rf {
  14855. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14856. insutypes = append(insutypes, item)
  14857. }
  14858. }
  14859. if len(insutypes) == 1 {
  14860. insutype = insutypes[0].Insutype
  14861. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14862. } else {
  14863. for _, i := range insutypes {
  14864. if i.Insutype == "390" {
  14865. is390 = 1
  14866. }
  14867. if i.Insutype == "310" {
  14868. is310 = 1
  14869. }
  14870. }
  14871. }
  14872. if is390 == 1 {
  14873. insutype = "390"
  14874. }
  14875. if is310 == 1 {
  14876. insutype = "310"
  14877. }
  14878. if len(insutypes) == 0 {
  14879. insutype = "310"
  14880. }
  14881. c.ServeSuccessJSON(map[string]interface{}{
  14882. "patient": patient,
  14883. "number": token,
  14884. "insutype": insutype,
  14885. })
  14886. }
  14887. } else {
  14888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14889. return
  14890. }
  14891. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14892. //if initFlag == 0 {
  14893. //c.TestGetJiangXiBasBaseInit()
  14894. //}
  14895. //if initEleFlag == 0 {
  14896. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  14897. //}
  14898. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  14899. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  14900. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  14901. type ELeData struct {
  14902. Data struct {
  14903. IdNo string `json:"idNo"`
  14904. IdType string `json:"idType"`
  14905. UserName string `json:"userName"`
  14906. EcToken string `json:"ecToken"`
  14907. InsuOrg string `json:"insuOrg"`
  14908. Gender string `json:"gender"`
  14909. Birthday string `json:"birthday"`
  14910. Nationality string `json:"nationality"`
  14911. Email string `json:"email"`
  14912. Extra string `json:"extra"`
  14913. } `json:"data"`
  14914. Code int `json:"code"`
  14915. Message string `json:"message"`
  14916. }
  14917. var ele ELeData
  14918. err := json.Unmarshal([]byte(result), &ele)
  14919. if err != nil {
  14920. utils.ErrorLog("解析失败:%v", err)
  14921. }
  14922. token := ele.Data.EcToken
  14923. token = Remove0000(token)
  14924. 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)
  14925. saveLog(result2, requestLog2, "1101", "获取人员信息")
  14926. var res ResultTwo
  14927. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14928. utils.ErrorLog("解析失败:%v", err)
  14929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14930. return
  14931. }
  14932. if res.Infcode == 0 {
  14933. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14934. if err == gorm.ErrRecordNotFound {
  14935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14936. return
  14937. } else if err != nil {
  14938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14939. return
  14940. } else {
  14941. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14942. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14943. infoStr := string(Iinfos)
  14944. idetinfoStr := string(Idetinfos)
  14945. psn := &models.HisPsn{
  14946. PsnNo: res.Output.Baseinfo.PsnNo,
  14947. PatientId: patient.ID,
  14948. Certno: res.Output.Baseinfo.Certno,
  14949. Gend: res.Output.Baseinfo.Gend,
  14950. Naty: res.Output.Baseinfo.Naty,
  14951. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14952. PsnName: res.Output.Baseinfo.PsnName,
  14953. Idetinfo: idetinfoStr,
  14954. Insuinfo: infoStr,
  14955. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14956. CardInfo: "",
  14957. VerifyNumber: token,
  14958. InsuplcAdmdvs: ele.Data.InsuOrg,
  14959. }
  14960. service.CreateHisPsn(psn)
  14961. var rf []*ResultFive
  14962. json.Unmarshal([]byte(infoStr), &rf)
  14963. var insutypes []*ResultFive
  14964. var insutype string
  14965. var is390 int = 0
  14966. var is310 int = 0
  14967. for _, item := range rf {
  14968. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14969. insutypes = append(insutypes, item)
  14970. }
  14971. }
  14972. if len(insutypes) == 1 {
  14973. insutype = insutypes[0].Insutype
  14974. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14975. } else {
  14976. for _, i := range insutypes {
  14977. if i.Insutype == "390" {
  14978. is390 = 1
  14979. }
  14980. if i.Insutype == "310" {
  14981. is310 = 1
  14982. }
  14983. }
  14984. }
  14985. if is390 == 1 {
  14986. insutype = "390"
  14987. }
  14988. if is310 == 1 {
  14989. insutype = "310"
  14990. }
  14991. if len(insutypes) == 0 {
  14992. insutype = "310"
  14993. }
  14994. c.ServeSuccessJSON(map[string]interface{}{
  14995. "patient": patient,
  14996. "number": token,
  14997. "insutype": insutype,
  14998. })
  14999. }
  15000. } else {
  15001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15002. return
  15003. }
  15004. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15005. //if initFlag == 0 {
  15006. c.TestGetJiangXiBasBaseInit()
  15007. //}
  15008. //if initEleFlag == 0 {
  15009. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15010. //}
  15011. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15012. type ELeData struct {
  15013. Data struct {
  15014. IdNo string `json:"idNo"`
  15015. IdType string `json:"idType"`
  15016. UserName string `json:"userName"`
  15017. EcToken string `json:"ecToken"`
  15018. InsuOrg string `json:"insuOrg"`
  15019. Gender string `json:"gender"`
  15020. Birthday string `json:"birthday"`
  15021. Nationality string `json:"nationality"`
  15022. Email string `json:"email"`
  15023. Extra string `json:"extra"`
  15024. } `json:"data"`
  15025. Code int `json:"code"`
  15026. Message string `json:"message"`
  15027. }
  15028. var ele ELeData
  15029. err := json.Unmarshal([]byte(json_result), &ele)
  15030. if err != nil {
  15031. utils.ErrorLog("解析失败:%v", err)
  15032. }
  15033. token := ele.Data.EcToken
  15034. token = Remove0000(token)
  15035. 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)
  15036. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15037. var res ResultTwo
  15038. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15039. utils.ErrorLog("解析失败:%v", err)
  15040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15041. return
  15042. }
  15043. if res.Infcode == 0 {
  15044. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15045. if err == gorm.ErrRecordNotFound {
  15046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15047. return
  15048. } else if err != nil {
  15049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15050. return
  15051. } else {
  15052. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15053. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15054. infoStr := string(Iinfos)
  15055. idetinfoStr := string(Idetinfos)
  15056. psn := &models.HisPsn{
  15057. PsnNo: res.Output.Baseinfo.PsnNo,
  15058. PatientId: patient.ID,
  15059. Certno: res.Output.Baseinfo.Certno,
  15060. Gend: res.Output.Baseinfo.Gend,
  15061. Naty: res.Output.Baseinfo.Naty,
  15062. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15063. PsnName: res.Output.Baseinfo.PsnName,
  15064. Idetinfo: idetinfoStr,
  15065. Insuinfo: infoStr,
  15066. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15067. CardInfo: "",
  15068. VerifyNumber: token,
  15069. }
  15070. service.CreateHisPsn(psn)
  15071. var rf []*ResultFive
  15072. json.Unmarshal([]byte(infoStr), &rf)
  15073. var insutypes []*ResultFive
  15074. var insutype string
  15075. var is390 int = 0
  15076. var is310 int = 0
  15077. for _, item := range rf {
  15078. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15079. insutypes = append(insutypes, item)
  15080. }
  15081. }
  15082. if len(insutypes) == 1 {
  15083. insutype = insutypes[0].Insutype
  15084. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15085. } else {
  15086. for _, i := range insutypes {
  15087. if i.Insutype == "390" {
  15088. is390 = 1
  15089. }
  15090. if i.Insutype == "310" {
  15091. is310 = 1
  15092. }
  15093. }
  15094. }
  15095. if is390 == 1 {
  15096. insutype = "390"
  15097. }
  15098. if is310 == 1 {
  15099. insutype = "310"
  15100. }
  15101. if len(insutypes) == 0 {
  15102. insutype = "310"
  15103. }
  15104. c.ServeSuccessJSON(map[string]interface{}{
  15105. "patient": patient,
  15106. "number": token,
  15107. "insutype": insutype,
  15108. })
  15109. }
  15110. } else {
  15111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15112. return
  15113. }
  15114. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15115. type ELeData struct {
  15116. Code string `json:"code"`
  15117. Data struct {
  15118. Aac002 string `json:"aac002"`
  15119. Aaz500 string `json:"aaz500"`
  15120. ActCardNo string `json:"actCardNo"`
  15121. Bab520 string `json:"bab520"`
  15122. Bkz543 string `json:"bkz543"`
  15123. BusinessType string `json:"businessType"`
  15124. CertfCodg string `json:"certfCodg"`
  15125. EcIndexNo string `json:"ecIndexNo"`
  15126. EcToken string `json:"ecToken"`
  15127. ID0000 string `json:"id0000"`
  15128. IDNo string `json:"idNo"`
  15129. IDType string `json:"idType"`
  15130. Idcode string `json:"idcode"`
  15131. IdentityToken string `json:"identity_token"`
  15132. InsuOrg string `json:"insuOrg"`
  15133. OfficeID string `json:"officeId"`
  15134. OfficeName string `json:"officeName"`
  15135. OperatorID string `json:"operatorId"`
  15136. OperatorName string `json:"operatorName"`
  15137. OrgID string `json:"orgId"`
  15138. UserName string `json:"userName"`
  15139. } `json:"data"`
  15140. Infno interface{} `json:"infno"`
  15141. Message string `json:"message"`
  15142. OrgID string `json:"orgId"`
  15143. TransType string `json:"transType"`
  15144. }
  15145. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  15146. outPutInfo = Remove0000(outPutInfo)
  15147. if len(outPutInfo) > 0 {
  15148. var ele ELeData
  15149. err := json.Unmarshal([]byte(outPutInfo), &ele)
  15150. if err != nil {
  15151. utils.ErrorLog("解析失败:%v", err)
  15152. }
  15153. token := ele.Data.EcToken
  15154. fmt.Println(inputInfo)
  15155. fmt.Println(outPutInfo)
  15156. 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)
  15157. saveLog(result, requestLog, "1101", "获取人员信息")
  15158. var dat map[string]interface{}
  15159. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15160. fmt.Println(dat)
  15161. } else {
  15162. fmt.Println(err)
  15163. }
  15164. userJSONBytes, _ := json.Marshal(dat)
  15165. var res ResultTwo
  15166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15167. utils.ErrorLog("解析失败:%v", err)
  15168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15169. return
  15170. }
  15171. res.ErrMsg = errMsgLog
  15172. if res.Infcode == 0 {
  15173. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  15174. if err == gorm.ErrRecordNotFound {
  15175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15176. return
  15177. } else if err != nil {
  15178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15179. return
  15180. } else {
  15181. fmt.Println(res)
  15182. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15183. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15184. infoStr := string(Iinfos)
  15185. idetinfoStr := string(Idetinfos)
  15186. psn := &models.HisPsn{
  15187. PsnNo: res.Output.Baseinfo.PsnNo,
  15188. PatientId: patient.ID,
  15189. Certno: res.Output.Baseinfo.Certno,
  15190. Gend: res.Output.Baseinfo.Gend,
  15191. Naty: res.Output.Baseinfo.Naty,
  15192. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15193. PsnName: res.Output.Baseinfo.PsnName,
  15194. Idetinfo: idetinfoStr,
  15195. Insuinfo: infoStr,
  15196. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15197. CardInfo: outPutInfo,
  15198. VerifyNumber: token,
  15199. InsuplcAdmdvs: ele.Data.InsuOrg,
  15200. }
  15201. service.CreateHisPsn(psn)
  15202. var rf []*ResultFive
  15203. json.Unmarshal([]byte(infoStr), &rf)
  15204. var insutypes []*ResultFive
  15205. var insutype string
  15206. var is390 int = 0
  15207. var is310 int = 0
  15208. for _, item := range rf {
  15209. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15210. insutypes = append(insutypes, item)
  15211. }
  15212. }
  15213. if len(insutypes) == 1 {
  15214. insutype = insutypes[0].Insutype
  15215. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15216. } else {
  15217. for _, i := range insutypes {
  15218. if i.Insutype == "390" {
  15219. is390 = 1
  15220. }
  15221. if i.Insutype == "310" {
  15222. is310 = 1
  15223. }
  15224. }
  15225. }
  15226. if is390 == 1 {
  15227. insutype = "390"
  15228. }
  15229. if is310 == 1 {
  15230. insutype = "310"
  15231. }
  15232. if len(insutypes) == 0 {
  15233. insutype = "310"
  15234. }
  15235. c.ServeSuccessJSON(map[string]interface{}{
  15236. "patient": patient,
  15237. "number": token,
  15238. "insutype": insutype,
  15239. })
  15240. }
  15241. } else {
  15242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15243. return
  15244. }
  15245. }
  15246. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15247. var api string
  15248. 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 +
  15249. "&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
  15250. resp, requestErr := http.Get(api)
  15251. if requestErr != nil {
  15252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15253. return
  15254. }
  15255. body, ioErr := ioutil.ReadAll(resp.Body)
  15256. if ioErr != nil {
  15257. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15259. return
  15260. }
  15261. var respJSON map[string]interface{}
  15262. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15265. return
  15266. }
  15267. var status string
  15268. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15269. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15270. var token string
  15271. var res ResultTwo //1101结果
  15272. var res10265 ResultTwo10265 //1101结果
  15273. if status == "0" { //读卡成功
  15274. var card_info string //卡信息
  15275. var busi_card_info string
  15276. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15277. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15278. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15279. fmt.Println(card_info)
  15280. fmt.Println(busi_card_info)
  15281. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15282. result, _ := json.Marshal(respJSON)
  15283. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15284. utils.ErrorLog("解析失败:%v", err)
  15285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15286. return
  15287. }
  15288. res.ErrMsg = res10265.ErrMsg
  15289. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15290. res.Infcode = infocode
  15291. res.Output = res10265.Output
  15292. res.InfRefmsgid = res10265.InfRefmsgid
  15293. if res.Infcode == 0 {
  15294. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15295. if err == gorm.ErrRecordNotFound {
  15296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15297. return
  15298. } else if err != nil {
  15299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15300. return
  15301. } else {
  15302. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15303. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15304. infoStr := string(Iinfos)
  15305. idetinfoStr := string(Idetinfos)
  15306. psn := &models.HisPsn{
  15307. PsnNo: res.Output.Baseinfo.PsnNo,
  15308. PatientId: patient.ID,
  15309. Certno: res.Output.Baseinfo.Certno,
  15310. Gend: res.Output.Baseinfo.Gend,
  15311. Naty: res.Output.Baseinfo.Naty,
  15312. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15313. PsnName: res.Output.Baseinfo.PsnName,
  15314. Idetinfo: idetinfoStr,
  15315. Insuinfo: infoStr,
  15316. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15317. CardInfo: card_info,
  15318. VerifyNumber: token,
  15319. }
  15320. var rf []*ResultFive
  15321. json.Unmarshal([]byte(infoStr), &rf)
  15322. var insutypes []*ResultFive
  15323. var insutype string
  15324. var is390 int = 0
  15325. var is310 int = 0
  15326. for _, item := range rf {
  15327. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15328. insutypes = append(insutypes, item)
  15329. }
  15330. }
  15331. if len(insutypes) == 1 {
  15332. insutype = insutypes[0].Insutype
  15333. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15334. } else {
  15335. for _, i := range insutypes {
  15336. if i.Insutype == "390" {
  15337. is390 = 1
  15338. }
  15339. if i.Insutype == "310" {
  15340. is310 = 1
  15341. }
  15342. }
  15343. }
  15344. if is390 == 1 {
  15345. insutype = "390"
  15346. }
  15347. if is310 == 1 {
  15348. insutype = "310"
  15349. }
  15350. if len(insutypes) == 0 {
  15351. insutype = "310"
  15352. }
  15353. service.CreateHisPsn(psn)
  15354. c.ServeSuccessJSON(map[string]interface{}{
  15355. "patient": patient,
  15356. "number": token,
  15357. "insutype": insutype,
  15358. })
  15359. }
  15360. } else {
  15361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15362. return
  15363. }
  15364. } else { //读卡失败
  15365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15366. return
  15367. }
  15368. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15369. res := c.GetoleInfo()
  15370. if res.Infcode == 0 {
  15371. var result string
  15372. if res.Output.MdtrtCertType == "01" {
  15373. 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)
  15374. } else if res.Output.MdtrtCertType == "02" {
  15375. 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)
  15376. } else if res.Output.MdtrtCertType == "03" {
  15377. 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)
  15378. }
  15379. var dat map[string]interface{}
  15380. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15381. fmt.Println(dat)
  15382. } else {
  15383. fmt.Println(err)
  15384. }
  15385. userJSONBytes, _ := json.Marshal(dat)
  15386. var res2 ResultTwo
  15387. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15388. utils.ErrorLog("解析失败:%v", err)
  15389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15390. return
  15391. }
  15392. if res2.Infcode == 0 {
  15393. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15394. if err == gorm.ErrRecordNotFound {
  15395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15396. return
  15397. } else if err != nil {
  15398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15399. return
  15400. } else {
  15401. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15402. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15403. infoStr := string(Iinfos)
  15404. idetinfoStr := string(Idetinfos)
  15405. var rf []*ResultFive
  15406. json.Unmarshal([]byte(infoStr), &rf)
  15407. var insutypes []*ResultFive
  15408. var insutype string
  15409. var is390 int = 0
  15410. var is310 int = 0
  15411. //var insuplc_admdvs string
  15412. for _, item := range rf {
  15413. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15414. insutypes = append(insutypes, item)
  15415. }
  15416. }
  15417. if len(insutypes) == 1 {
  15418. insutype = insutypes[0].Insutype
  15419. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15420. } else {
  15421. for _, i := range insutypes {
  15422. if i.Insutype == "390" {
  15423. is390 = 1
  15424. }
  15425. if i.Insutype == "310" {
  15426. is310 = 1
  15427. }
  15428. }
  15429. }
  15430. if is390 == 1 {
  15431. insutype = "390"
  15432. }
  15433. if is310 == 1 {
  15434. insutype = "310"
  15435. }
  15436. if len(insutypes) == 0 {
  15437. insutype = "310"
  15438. }
  15439. psn := &models.HisPsn{
  15440. PsnNo: res2.Output.Baseinfo.PsnNo,
  15441. PatientId: patient.ID,
  15442. Certno: res2.Output.Baseinfo.Certno,
  15443. Gend: res2.Output.Baseinfo.Gend,
  15444. Naty: res2.Output.Baseinfo.Naty,
  15445. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15446. PsnName: res2.Output.Baseinfo.PsnName,
  15447. Idetinfo: idetinfoStr,
  15448. Insuinfo: infoStr,
  15449. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15450. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15451. VerifyNumber: res.Output.EcToken,
  15452. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15453. }
  15454. if res.Output.MdtrtCertType == "01" {
  15455. psn.VerifyNumber = res.Output.EcToken
  15456. //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)
  15457. } else if res.Output.MdtrtCertType == "02" {
  15458. psn.VerifyNumber = res.Output.CardNo
  15459. //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)
  15460. } else if res.Output.MdtrtCertType == "03" {
  15461. psn.VerifyNumber = res.Output.MdtrtCertNo
  15462. //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)
  15463. }
  15464. service.CreateHisPsn(psn)
  15465. var balc float64
  15466. for _, item := range rf {
  15467. if item.Insutype == insutype {
  15468. balc = item.Balc
  15469. }
  15470. }
  15471. c.ServeSuccessJSON(map[string]interface{}{
  15472. "patient": patient,
  15473. "number": res.Output.CardNo,
  15474. "insutype": insutype,
  15475. "blac": balc,
  15476. "desc": idetinfoStr,
  15477. })
  15478. }
  15479. } else {
  15480. c.ServeSuccessJSON(map[string]interface{}{
  15481. "failed_code": -10,
  15482. "msg": res2.ErrMsg,
  15483. })
  15484. }
  15485. } else {
  15486. c.ServeSuccessJSON(map[string]interface{}{
  15487. "failed_code": -10,
  15488. "msg": res.ErrMsg,
  15489. })
  15490. }
  15491. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15492. var res ResultTwo
  15493. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15494. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15495. "&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)
  15496. resp, requestErr := http.Get(api)
  15497. if requestErr != nil {
  15498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15499. return
  15500. }
  15501. body, ioErr := ioutil.ReadAll(resp.Body)
  15502. if ioErr != nil {
  15503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15505. return
  15506. }
  15507. var respJSON map[string]interface{}
  15508. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15511. return
  15512. }
  15513. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15514. result, _ := json.Marshal(respJSON)
  15515. fmt.Println("log")
  15516. fmt.Println(string(result))
  15517. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15518. utils.ErrorLog("解析失败:%v", err)
  15519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15520. return
  15521. }
  15522. if res.Infcode == 0 {
  15523. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15524. if err == gorm.ErrRecordNotFound {
  15525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15526. return
  15527. } else if err != nil {
  15528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15529. return
  15530. } else {
  15531. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15532. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15533. infoStr := string(Iinfos)
  15534. idetinfoStr := string(Idetinfos)
  15535. var rf []*ResultFive
  15536. json.Unmarshal([]byte(infoStr), &rf)
  15537. var insutypes []*ResultFive
  15538. var insutype string
  15539. var is390 int = 0
  15540. var is310 int = 0
  15541. for _, item := range rf {
  15542. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15543. insutypes = append(insutypes, item)
  15544. }
  15545. }
  15546. if len(insutypes) == 1 {
  15547. insutype = insutypes[0].Insutype
  15548. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15549. } else {
  15550. for _, i := range insutypes {
  15551. if i.Insutype == "390" {
  15552. is390 = 1
  15553. }
  15554. if i.Insutype == "310" {
  15555. is310 = 1
  15556. }
  15557. }
  15558. }
  15559. if is390 == 1 {
  15560. insutype = "390"
  15561. }
  15562. if is310 == 1 {
  15563. insutype = "310"
  15564. }
  15565. if len(insutypes) == 0 {
  15566. insutype = "390"
  15567. }
  15568. var insuplc_admdvs string
  15569. for _, item := range rf {
  15570. if item.Insutype == insutype {
  15571. insuplc_admdvs = item.InsuplcAdmdvs
  15572. }
  15573. }
  15574. psn := &models.HisPsn{
  15575. PsnNo: res.Output.Baseinfo.PsnNo,
  15576. PatientId: patient.ID,
  15577. Certno: res.Output.Baseinfo.Certno,
  15578. Gend: res.Output.Baseinfo.Gend,
  15579. Naty: res.Output.Baseinfo.Naty,
  15580. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15581. PsnName: res.Output.Baseinfo.PsnName,
  15582. Idetinfo: idetinfoStr,
  15583. Insuinfo: infoStr,
  15584. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15585. InsuplcAdmdvs: insuplc_admdvs,
  15586. }
  15587. service.CreateHisPsn(psn)
  15588. c.ServeSuccessJSON(map[string]interface{}{
  15589. "patient": patient,
  15590. "number": res.Output.Baseinfo.Certno,
  15591. })
  15592. }
  15593. } else {
  15594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15595. return
  15596. }
  15597. } else {
  15598. type ELeData struct {
  15599. Code string `json:"code"`
  15600. Data struct {
  15601. Aac002 string `json:"aac002"`
  15602. Aaz500 string `json:"aaz500"`
  15603. ActCardNo string `json:"actCardNo"`
  15604. Bab520 string `json:"bab520"`
  15605. Bkz543 string `json:"bkz543"`
  15606. BusinessType string `json:"businessType"`
  15607. CertfCodg string `json:"certfCodg"`
  15608. EcIndexNo string `json:"ecIndexNo"`
  15609. EcToken string `json:"ecToken"`
  15610. ID0000 string `json:"id0000"`
  15611. IDNo string `json:"idNo"`
  15612. IDType string `json:"idType"`
  15613. Idcode string `json:"idcode"`
  15614. IdentityToken string `json:"identity_token"`
  15615. InsuOrg string `json:"insuOrg"`
  15616. OfficeID string `json:"officeId"`
  15617. OfficeName string `json:"officeName"`
  15618. OperatorID string `json:"operatorId"`
  15619. OperatorName string `json:"operatorName"`
  15620. OrgID string `json:"orgId"`
  15621. UserName string `json:"userName"`
  15622. } `json:"data"`
  15623. Infno interface{} `json:"infno"`
  15624. Message string `json:"message"`
  15625. OrgID string `json:"orgId"`
  15626. TransType string `json:"transType"`
  15627. }
  15628. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  15629. fmt.Println(result)
  15630. outPutInfo := Remove0000(result)
  15631. fmt.Println(outPutInfo)
  15632. if len(outPutInfo) > 0 {
  15633. var ele ELeData
  15634. err := json.Unmarshal([]byte(outPutInfo), &ele)
  15635. if err != nil {
  15636. utils.ErrorLog("解析失败:%v", err)
  15637. }
  15638. token := ele.Data.EcToken
  15639. fmt.Println(outPutInfo)
  15640. 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)
  15641. saveLog(result, requestLog, "1101", "获取人员信息")
  15642. var dat map[string]interface{}
  15643. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15644. fmt.Println(dat)
  15645. } else {
  15646. fmt.Println(err)
  15647. }
  15648. userJSONBytes, _ := json.Marshal(dat)
  15649. var res ResultTwo
  15650. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15651. utils.ErrorLog("解析失败:%v", err)
  15652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15653. return
  15654. }
  15655. if res.Infcode == 0 {
  15656. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  15657. if err == gorm.ErrRecordNotFound {
  15658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15659. return
  15660. } else if err != nil {
  15661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15662. return
  15663. } else {
  15664. fmt.Println(res)
  15665. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15666. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15667. infoStr := string(Iinfos)
  15668. idetinfoStr := string(Idetinfos)
  15669. psn := &models.HisPsn{
  15670. PsnNo: res.Output.Baseinfo.PsnNo,
  15671. PatientId: patient.ID,
  15672. Certno: res.Output.Baseinfo.Certno,
  15673. Gend: res.Output.Baseinfo.Gend,
  15674. Naty: res.Output.Baseinfo.Naty,
  15675. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15676. PsnName: res.Output.Baseinfo.PsnName,
  15677. Idetinfo: idetinfoStr,
  15678. Insuinfo: infoStr,
  15679. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15680. CardInfo: outPutInfo,
  15681. VerifyNumber: token,
  15682. InsuplcAdmdvs: ele.Data.InsuOrg,
  15683. }
  15684. service.CreateHisPsn(psn)
  15685. var rf []*ResultFive
  15686. json.Unmarshal([]byte(infoStr), &rf)
  15687. var insutypes []*ResultFive
  15688. var insutype string
  15689. var is390 int = 0
  15690. var is310 int = 0
  15691. for _, item := range rf {
  15692. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15693. insutypes = append(insutypes, item)
  15694. }
  15695. }
  15696. if len(insutypes) == 1 {
  15697. insutype = insutypes[0].Insutype
  15698. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15699. } else {
  15700. for _, i := range insutypes {
  15701. if i.Insutype == "390" {
  15702. is390 = 1
  15703. }
  15704. if i.Insutype == "310" {
  15705. is310 = 1
  15706. }
  15707. }
  15708. }
  15709. if is390 == 1 {
  15710. insutype = "390"
  15711. }
  15712. if is310 == 1 {
  15713. insutype = "310"
  15714. }
  15715. if len(insutypes) == 0 {
  15716. insutype = "310"
  15717. }
  15718. c.ServeSuccessJSON(map[string]interface{}{
  15719. "patient": patient,
  15720. "number": token,
  15721. "insutype": insutype,
  15722. })
  15723. }
  15724. } else {
  15725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15726. return
  15727. }
  15728. }
  15729. //fmt.Println(result)
  15730. //
  15731. //if initFlag == 0 {
  15732. // c.TestGetBasBaseInit()
  15733. //}
  15734. //token := c.GetEleBaseInfo()
  15735. //
  15736. //token = Remove0000(token)
  15737. //
  15738. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  15739. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  15740. ////
  15741. //var res ResultTwo
  15742. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15743. // utils.ErrorLog("解析失败:%v", err)
  15744. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15745. // return
  15746. //}
  15747. //
  15748. //if res.Infcode == 0 {
  15749. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15750. // if err == gorm.ErrRecordNotFound {
  15751. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15752. // return
  15753. // } else if err != nil {
  15754. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15755. // return
  15756. //
  15757. // } else {
  15758. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15759. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15760. // infoStr := string(Iinfos)
  15761. // idetinfoStr := string(Idetinfos)
  15762. //
  15763. //
  15764. //
  15765. //
  15766. // var rf []*ResultFive
  15767. // json.Unmarshal([]byte(infoStr), &rf)
  15768. //
  15769. // var insutypes []*ResultFive
  15770. // var insutype string
  15771. // var is390 int = 0
  15772. // var is310 int = 0
  15773. // var insuplc_admdvs string
  15774. //
  15775. // for _, item := range rf {
  15776. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15777. // insutypes = append(insutypes, item)
  15778. // }
  15779. // }
  15780. //
  15781. // if len(insutypes) == 1 {
  15782. // insutype = insutypes[0].Insutype
  15783. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15784. // } else {
  15785. // for _, i := range insutypes {
  15786. // if i.Insutype == "390" {
  15787. // is390 = 1
  15788. // }
  15789. //
  15790. // if i.Insutype == "310" {
  15791. // is310 = 1
  15792. // }
  15793. // }
  15794. // }
  15795. // if is390 == 1 {
  15796. // insutype = "390"
  15797. // }
  15798. //
  15799. // if is310 == 1 {
  15800. // insutype = "310"
  15801. // }
  15802. // if len(insutypes) == 0 {
  15803. // insutype = "310"
  15804. // }
  15805. // for _, item := range rf {
  15806. // if item.Insutype == insutype {
  15807. // insuplc_admdvs = item.InsuplcAdmdvs
  15808. // }
  15809. // }
  15810. // psn := &models.HisPsn{
  15811. // PsnNo: res.Output.Baseinfo.PsnNo,
  15812. // Age: res.Output.Baseinfo.Age,
  15813. // PatientId: patient.ID,
  15814. // Certno: res.Output.Baseinfo.Certno,
  15815. // Brdy: res.Output.Baseinfo.Brdy,
  15816. // Gend: res.Output.Baseinfo.Gend,
  15817. // Naty: res.Output.Baseinfo.Naty,
  15818. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  15819. // PsnName: res.Output.Baseinfo.PsnName,
  15820. // Idetinfo: idetinfoStr,
  15821. // Insuinfo: infoStr,
  15822. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15823. // CardInfo: "",
  15824. // VerifyNumber: token,
  15825. // InsuplcAdmdvs: insuplc_admdvs,
  15826. // }
  15827. // service.CreateHisPsn(psn)
  15828. //
  15829. // c.ServeSuccessJSON(map[string]interface{}{
  15830. // "patient": patient,
  15831. // "number": token,
  15832. // })
  15833. // }
  15834. //} else {
  15835. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15836. // return
  15837. //}
  15838. }
  15839. break
  15840. case 5:
  15841. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15842. var api string
  15843. if miConfig.MdtrtareaAdmvs == "320921" {
  15844. 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 +
  15845. "&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
  15846. fmt.Println(api)
  15847. } else {
  15848. 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 +
  15849. "&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)
  15850. }
  15851. resp, requestErr := http.Get(api)
  15852. if requestErr != nil {
  15853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15854. return
  15855. }
  15856. body, ioErr := ioutil.ReadAll(resp.Body)
  15857. if ioErr != nil {
  15858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15860. return
  15861. }
  15862. var respJSON map[string]interface{}
  15863. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15866. return
  15867. }
  15868. var status string
  15869. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15870. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15871. var token string
  15872. var res ResultTwo //1101结果
  15873. var res10265 ResultTwo10265 //1101结果
  15874. if status == "0" { //读卡成功
  15875. var card_info string //卡信息
  15876. //var busi_card_info string
  15877. var auth_info string
  15878. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15879. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15880. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15881. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  15882. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15883. result, _ := json.Marshal(respJSON)
  15884. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15885. utils.ErrorLog("解析失败:%v", err)
  15886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15887. return
  15888. }
  15889. res.ErrMsg = res10265.ErrMsg
  15890. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15891. res.Infcode = infocode
  15892. res.Output = res10265.Output
  15893. res.InfRefmsgid = res10265.InfRefmsgid
  15894. if res.Infcode == 0 {
  15895. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15896. if err == gorm.ErrRecordNotFound {
  15897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15898. return
  15899. } else if err != nil {
  15900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15901. return
  15902. } else {
  15903. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15904. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15905. infoStr := string(Iinfos)
  15906. idetinfoStr := string(Idetinfos)
  15907. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15908. psn := &models.HisPsn{
  15909. PsnNo: res.Output.Baseinfo.PsnNo,
  15910. PatientId: patient.ID,
  15911. Certno: res.Output.Baseinfo.Certno,
  15912. Gend: res.Output.Baseinfo.Gend,
  15913. Brdy: b,
  15914. Age: float64(age),
  15915. Naty: res.Output.Baseinfo.Naty,
  15916. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15917. PsnName: res.Output.Baseinfo.PsnName,
  15918. Idetinfo: idetinfoStr,
  15919. Insuinfo: infoStr,
  15920. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15921. CardInfo: card_info,
  15922. VerifyNumber: token,
  15923. AuthInfo: auth_info,
  15924. }
  15925. var rf []*ResultFive
  15926. json.Unmarshal([]byte(infoStr), &rf)
  15927. var insutypes []*ResultFive
  15928. var insutype string
  15929. var is390 int = 0
  15930. var is310 int = 0
  15931. for _, item := range rf {
  15932. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15933. insutypes = append(insutypes, item)
  15934. }
  15935. }
  15936. if len(insutypes) == 1 {
  15937. insutype = insutypes[0].Insutype
  15938. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15939. } else {
  15940. for _, i := range insutypes {
  15941. if i.Insutype == "390" {
  15942. is390 = 1
  15943. }
  15944. if i.Insutype == "310" {
  15945. is310 = 1
  15946. }
  15947. }
  15948. }
  15949. if is390 == 1 {
  15950. insutype = "390"
  15951. }
  15952. if is310 == 1 {
  15953. insutype = "310"
  15954. }
  15955. if len(insutypes) == 0 {
  15956. insutype = "310"
  15957. }
  15958. service.CreateHisPsn(psn)
  15959. c.ServeSuccessJSON(map[string]interface{}{
  15960. "patient": patient,
  15961. "number": token,
  15962. "insutype": insutype,
  15963. })
  15964. }
  15965. } else {
  15966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15967. return
  15968. }
  15969. } else { //读卡失败
  15970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15971. return
  15972. }
  15973. }
  15974. break
  15975. }
  15976. }
  15977. var initFlag int64 = 0
  15978. var initEleFlag int64 = 0
  15979. func (c *HisApiController) TestGetBasBaseInit() {
  15980. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15981. Iinit := DllDef.MustFindProc("Init")
  15982. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15983. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  15984. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  15985. if ret != 0 {
  15986. fmt.Println("SSCard的报错原因:", err)
  15987. fmt.Println("SSCard的运算结果为:", ret)
  15988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15989. return
  15990. }
  15991. result := int(ret)
  15992. fmt.Println("SSCard的运算结果为1:", result)
  15993. initFlag = 1
  15994. return
  15995. }
  15996. func (c *HisApiController) HandleJiangXiReadCard() {
  15997. fmt.Println("~~~~~~")
  15998. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15999. admin_user_id, _ := c.GetInt64("admin_user_id")
  16000. id_card_type, _ := c.GetInt64("id_card_type")
  16001. //certificates, _ := c.GetInt64("certificates")
  16002. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16003. if initFlag == 0 {
  16004. c.TestGetJiangXiBasBaseInit()
  16005. }
  16006. basStr := c.GetBasBaseInfo()
  16007. if len(basStr) == 0 {
  16008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16009. return
  16010. }
  16011. fmt.Println(basStr)
  16012. bas := strings.Split(basStr, "|")
  16013. basNumber := bas[1]
  16014. fmt.Println(basNumber)
  16015. card_sn := bas[3]
  16016. fmt.Println(card_sn)
  16017. 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, "")
  16018. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  16019. var dat map[string]interface{}
  16020. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16021. fmt.Println(dat)
  16022. } else {
  16023. fmt.Println(err)
  16024. }
  16025. userJSONBytes, _ := json.Marshal(dat)
  16026. var res ResultTwo
  16027. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16028. utils.ErrorLog("解析失败:%v", err)
  16029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16030. return
  16031. }
  16032. if res.Infcode == 0 {
  16033. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  16034. if err == gorm.ErrRecordNotFound {
  16035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16036. return
  16037. } else if err != nil {
  16038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16039. return
  16040. } else {
  16041. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16042. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16043. infoStr := string(Iinfos)
  16044. idetinfoStr := string(Idetinfos)
  16045. psn := &models.HisPsn{
  16046. PsnNo: res.Output.Baseinfo.PsnNo,
  16047. PatientId: patient.ID,
  16048. Certno: res.Output.Baseinfo.Certno,
  16049. Gend: res.Output.Baseinfo.Gend,
  16050. Naty: res.Output.Baseinfo.Naty,
  16051. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16052. PsnName: res.Output.Baseinfo.PsnName,
  16053. Idetinfo: idetinfoStr,
  16054. Insuinfo: infoStr,
  16055. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16056. CardInfo: basStr,
  16057. VerifyNumber: "",
  16058. }
  16059. service.CreateHisPsn(psn)
  16060. c.ServeSuccessJSON(map[string]interface{}{
  16061. "patient": patient,
  16062. "number": basNumber,
  16063. })
  16064. }
  16065. } else {
  16066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16067. return
  16068. }
  16069. }
  16070. func (c *HisApiController) TestGetHnBasBaseInit() {
  16071. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16072. Iinit := DllDef.MustFindProc("Init")
  16073. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16074. //http://10.77.211.236/CSB/hsa-fsi-1303
  16075. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  16076. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  16077. // 调用 Init 函数
  16078. 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"))))
  16079. //if ret != 0 {
  16080. fmt.Println("SSCard的报错原因:", err)
  16081. fmt.Println("SSCard的运算结果为:", ret)
  16082. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16083. // return
  16084. //}
  16085. result := int(ret)
  16086. fmt.Println("SSCard的运算结果为1:", result)
  16087. initFlag = 1
  16088. return
  16089. }
  16090. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  16091. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16092. Iinit := DllDef.MustFindProc("Init")
  16093. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16094. //http://10.77.211.236/CSB/hsa-fsi-1303
  16095. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  16096. if ret != 0 {
  16097. fmt.Println("SSCard的报错原因:", err)
  16098. fmt.Println("SSCard的运算结果为:", ret)
  16099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16100. return
  16101. }
  16102. result := int(ret)
  16103. fmt.Println("SSCard的运算结果为1:", result)
  16104. initFlag = 1
  16105. return
  16106. }
  16107. func (c *HisApiController) GetSFZBaseInfo() string {
  16108. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16109. readCard := DllDef.MustFindProc("ReadSFZ")
  16110. if readCard == nil {
  16111. fmt.Println("readcard is nil")
  16112. readCard = DllDef.MustFindProc("ReadSFZ")
  16113. }
  16114. str := make([]byte, 8096)
  16115. str1 := make([]byte, 8096)
  16116. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  16117. fmt.Println(r)
  16118. return Remove0000(string(str))
  16119. }
  16120. func (c *HisApiController) GetEleBaseInfo() string {
  16121. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16122. readCard := DllDef.MustFindProc("GetQRBase")
  16123. fmt.Println(readCard)
  16124. if readCard == nil {
  16125. fmt.Println("readcard is nil")
  16126. readCard = DllDef.MustFindProc("GetQRBase")
  16127. }
  16128. str := make([]byte, 1024)
  16129. str1 := make([]byte, 1024)
  16130. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  16131. fmt.Println(ret2)
  16132. fmt.Println(string(str1))
  16133. fmt.Println(string(str))
  16134. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16135. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  16136. if ret2 != 0 {
  16137. return ""
  16138. }
  16139. return string(str)
  16140. }
  16141. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  16142. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  16143. readCard := DllDef.MustFindProc("NationEcTrans")
  16144. fmt.Println(readCard)
  16145. fmt.Println("!!!!!")
  16146. pBusiCardInfo := make([]byte, 2048)
  16147. input := make(map[string]interface{})
  16148. inputData := make(map[string]interface{})
  16149. inputData["orgId"] = code
  16150. inputData["businessType"] = "01101"
  16151. inputData["operatorId"] = "1"
  16152. inputData["operatorName"] = "admin"
  16153. inputData["officeId"] = "001"
  16154. inputData["officeName"] = "血透室"
  16155. inputData["deviceType"] = ""
  16156. input["data"] = inputData
  16157. input["orgId"] = code
  16158. input["transType"] = "ec.query"
  16159. bytesData, _ := json.Marshal(input)
  16160. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  16161. fmt.Println(ret2)
  16162. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16163. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16164. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  16165. }
  16166. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  16167. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  16168. readCard := DllDef.MustFindProc("NationEcTrans")
  16169. fmt.Println(readCard)
  16170. fmt.Println("!!!!!")
  16171. pBusiCardInfo := make([]byte, 2048)
  16172. input := make(map[string]interface{})
  16173. inputData := make(map[string]interface{})
  16174. inputData["orgId"] = code
  16175. inputData["businessType"] = "01101"
  16176. inputData["operatorId"] = "9"
  16177. inputData["operatorName"] = "admin"
  16178. inputData["officeId"] = "001"
  16179. inputData["officeName"] = "血透室"
  16180. inputData["deviceType"] = ""
  16181. input["data"] = inputData
  16182. input["orgId"] = code
  16183. input["transType"] = "ec.query"
  16184. bytesData, _ := json.Marshal(input)
  16185. 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])))
  16186. fmt.Println(ret2)
  16187. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16188. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16189. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  16190. }
  16191. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  16192. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  16193. readCard := DllDef.MustFindProc("NationEcTrans")
  16194. fmt.Println(readCard)
  16195. fmt.Println("!!!!!")
  16196. pBusiCardInfo := make([]byte, 2048)
  16197. input := make(map[string]interface{})
  16198. inputData := make(map[string]interface{})
  16199. inputData["orgId"] = code
  16200. inputData["businessType"] = "01301"
  16201. inputData["operatorId"] = "9"
  16202. inputData["operatorName"] = "admin"
  16203. inputData["officeId"] = "001"
  16204. inputData["officeName"] = "血透室"
  16205. inputData["deviceType"] = ""
  16206. input["data"] = inputData
  16207. input["orgId"] = code
  16208. input["transType"] = "ec.query"
  16209. bytesData, _ := json.Marshal(input)
  16210. 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])))
  16211. fmt.Println(ret2)
  16212. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16213. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16214. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  16215. }
  16216. func GetJxEleBaseInfo(org_id int64) string {
  16217. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16218. readCard := DllDef.MustFindProc("NationEcTrans")
  16219. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16220. if readCard == nil {
  16221. fmt.Println("readcard is nil")
  16222. readCard = DllDef.MustFindProc("NationEcTrans")
  16223. }
  16224. str1 := make([]byte, 1024)
  16225. data := make(map[string]interface{})
  16226. inputData := make(map[string]interface{})
  16227. inputData["orgId"] = miConfig.Code
  16228. inputData["businessType"] = "01101"
  16229. inputData["operatorId"] = "test001"
  16230. inputData["operatorName"] = "cn"
  16231. inputData["officeId"] = "32760"
  16232. inputData["officeName"] = "waike"
  16233. inputData["deviceType"] = ""
  16234. data["data"] = inputData
  16235. data["transType"] = "ec.query"
  16236. data["extra "] = ""
  16237. data["orgId"] = miConfig.Code
  16238. bytesData, _ := json.Marshal(data)
  16239. //bytesData, _ := json.Marshal(data)
  16240. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  16241. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16242. fmt.Println(ret2)
  16243. fmt.Println(string(str1))
  16244. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16245. if ret2 != 0 {
  16246. return ""
  16247. }
  16248. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  16249. }
  16250. //func GetJxEleBaseInfoTWO(org_id int64) string {
  16251. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  16252. // readCard := DllDef.MustFindProc("NationEcTrans")
  16253. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16254. //
  16255. // if readCard == nil {
  16256. // fmt.Println("readcard is nil")
  16257. // readCard = DllDef.MustFindProc("NationEcTrans")
  16258. // }
  16259. // str1 := make([]byte, 1024)
  16260. //
  16261. // data := make(map[string]interface{})
  16262. //
  16263. // inputData := make(map[string]interface{})
  16264. // inputData["orgId"] = miConfig.Code
  16265. // inputData["businessType"] = "01101"
  16266. // inputData["operatorId"] = "test001"
  16267. // inputData["operatorName"] = "cn"
  16268. // inputData["officeId"] = "32760"
  16269. // inputData["officeName"] = "waike"
  16270. // inputData["deviceType"] = ""
  16271. //
  16272. // data["data"] = inputData
  16273. // data["transType"] = "ec.query"
  16274. // data["extra "] = ""
  16275. // data["orgId"] = miConfig.Code
  16276. // bytesData, _ := json.Marshal(data)
  16277. // //bytesData, _ := json.Marshal(data)
  16278. //
  16279. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  16280. //
  16281. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16282. // fmt.Println(ret2)
  16283. // fmt.Println(string(str1))
  16284. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16285. //
  16286. // if ret2 != 0 {
  16287. // return ""
  16288. // }
  16289. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  16290. //}
  16291. func GetJxEleBaseInitInfo(org_id int64) string {
  16292. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16293. readCard := DllDef.MustFindProc("NationEcTrans")
  16294. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16295. if readCard == nil {
  16296. fmt.Println("readcard is nil")
  16297. readCard = DllDef.MustFindProc("NationEcTrans")
  16298. }
  16299. str1 := make([]byte, 2048)
  16300. data := make(map[string]interface{})
  16301. inputData := make(map[string]interface{})
  16302. inputData["orgId"] = miConfig.Code
  16303. inputData["businessType"] = "01101"
  16304. inputData["operatorId"] = "1"
  16305. inputData["operatorName"] = "huangchuang"
  16306. inputData["officeId"] = "101"
  16307. inputData["officeName"] = "xuetou"
  16308. inputData["deviceType"] = ""
  16309. data["data"] = inputData
  16310. data["transType"] = "ec.query"
  16311. data["orgId"] = miConfig.Code
  16312. bytesData, _ := json.Marshal(data)
  16313. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  16314. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16315. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  16316. fmt.Println(ret2)
  16317. fmt.Println(string(str1))
  16318. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16319. if ret2 != 0 {
  16320. return ""
  16321. }
  16322. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  16323. initEleFlag = 1
  16324. }
  16325. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  16326. }
  16327. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  16328. // // 构建命令
  16329. // cmd := exec.Command("python", "b.py")
  16330. //
  16331. // // 执行命令并等待完成
  16332. // output, err := cmd.CombinedOutput()
  16333. // if err != nil {
  16334. // fmt.Println("Error executing Python script:", err)
  16335. // return
  16336. // }
  16337. //
  16338. // // 打印Python脚本的输出
  16339. // fmt.Println(string(output))
  16340. //}
  16341. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  16342. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  16343. readCard := DllDef.MustFindProc("gxyb_call")
  16344. if readCard == nil {
  16345. fmt.Println("readcard is nil")
  16346. readCard = DllDef.MustFindProc("gxyb_call")
  16347. }
  16348. str := make([]byte, 1024)
  16349. str1 := make([]byte, 1024)
  16350. //data := make(map[string]interface{})
  16351. currentTime := time.Now()
  16352. // 格式化时间为 "YYYYMMDDHH24MISS"
  16353. formattedTime := currentTime.Format("20060102150405")
  16354. inputData := make(map[string]interface{})
  16355. inputData2 := make(map[string]interface{})
  16356. inputData["transNo"] = "1401"
  16357. inputData["transType"] = "passwordCheck"
  16358. inputData["timestamp"] = formattedTime
  16359. inputData2["fixmedinsCode"] = code
  16360. inputData2["psnNo"] = ""
  16361. inputData["data"] = inputData2
  16362. jsonBytes, err := json.Marshal(inputData)
  16363. if err != nil {
  16364. fmt.Println("Error encoding map to JSON:", err)
  16365. }
  16366. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16367. fmt.Println(string(str1))
  16368. fmt.Println(string(str))
  16369. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16370. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  16371. if ret2 != 0 {
  16372. return ""
  16373. }
  16374. return string(str)
  16375. }
  16376. func (c *HisApiController) GetoleInfo() Response {
  16377. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  16378. defer ole.CoUninitialize()
  16379. // Replace with the ProgID or CLSID of your COM object
  16380. progID := "YinHai.XJ.Actual.Interface.New"
  16381. // Create COM object
  16382. unknown, err := oleutil.CreateObject(progID)
  16383. if err != nil {
  16384. fmt.Println("Unable to create COM object:", err)
  16385. }
  16386. defer unknown.Release()
  16387. // Query for the IDispatch interface
  16388. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  16389. if err != nil {
  16390. fmt.Println("Unable to get IDispatch interface:", err)
  16391. }
  16392. defer dispatch.Release()
  16393. // Prepare parameters
  16394. transNo := "1401"
  16395. transType := "passwordCheck"
  16396. timestamp := time.Now().Unix()
  16397. fixmedinsCode := "H45072101171"
  16398. psnNo := ""
  16399. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  16400. result2 := ""
  16401. // Call COM object's method using the IDispatch interface
  16402. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  16403. fmt.Println(resulr)
  16404. fmt.Println(result2)
  16405. if err != nil {
  16406. fmt.Println("调用COM对象方法失败:", err)
  16407. }
  16408. var response Response
  16409. err2 := json.Unmarshal([]byte(result2), &response)
  16410. if err2 != nil {
  16411. fmt.Println("解析JSON失败:", err)
  16412. }
  16413. return response
  16414. }
  16415. func (c *HisApiController) GetBasBaseInfo() string {
  16416. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16417. readCard := DllDef.MustFindProc("ReadCardBas")
  16418. if readCard == nil {
  16419. fmt.Println("readcard is nil")
  16420. readCard = DllDef.MustFindProc("ReadCardBas")
  16421. }
  16422. str := make([]byte, 1024)
  16423. str1 := make([]byte, 1024)
  16424. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  16425. fmt.Println(string(str1))
  16426. fmt.Println(string(str))
  16427. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16428. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  16429. if ret2 != 0 {
  16430. return ""
  16431. }
  16432. return string(str)
  16433. }
  16434. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  16435. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  16436. readCard := DllDef.MustFindProc("read_cardinfo")
  16437. if readCard == nil {
  16438. fmt.Println("readcard is nil")
  16439. readCard = DllDef.MustFindProc("read_cardinfo")
  16440. }
  16441. str := make([]byte, 1024) //卡号
  16442. str1 := make([]byte, 1024) //卡识别码
  16443. str2 := make([]byte, 1024) //身份证号
  16444. str3 := make([]byte, 1024) //姓名
  16445. str4 := make([]byte, 1024) //错误信息
  16446. 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])))
  16447. fmt.Println(string(str1))
  16448. fmt.Println(string(str))
  16449. fmt.Println(string(str2))
  16450. fmt.Println(string(str3))
  16451. fmt.Println(string(str4))
  16452. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16453. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  16454. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  16455. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  16456. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  16457. if ret2 != 0 {
  16458. return "", "", "", "", ""
  16459. }
  16460. return string(str), string(str1), string(str2), string(str3), string(str4)
  16461. }
  16462. type CustomFundPay struct {
  16463. FundPayType string `json:"fund_pay_type"`
  16464. FundPayamt float64 `json:"fund_payamt"`
  16465. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16466. }
  16467. //func (c *HisApiController) GetBatchSettleList() {
  16468. // start_time_str := c.GetString("start_time")
  16469. // //end_time_str := c.GetString("end_time")
  16470. // admin_user_id, _ := c.GetInt64("admin_user_id")
  16471. //
  16472. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  16473. //
  16474. // for _, item := range orders {
  16475. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  16476. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  16477. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  16478. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  16479. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16480. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  16481. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16482. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  16483. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  16484. //
  16485. // if order.ID == 0 {
  16486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  16487. // return
  16488. // }
  16489. //
  16490. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  16491. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  16492. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  16493. // //fmt.Println(count)
  16494. // //var zero string
  16495. // //number := count + 1
  16496. // //if number >= 1000 {
  16497. // // zero = "0000" + strconv.FormatInt(number, 10)
  16498. // //} else if number >= 10000 {
  16499. // // zero = "000" + strconv.FormatInt(number, 10)
  16500. // //} else if number >= 100000 {
  16501. // // zero = "00" + strconv.FormatInt(number, 10)
  16502. // //} else if number >= 1000000 {
  16503. // // zero = "0" + strconv.FormatInt(number, 10)
  16504. // //} else {
  16505. // // zero = strconv.FormatInt(number, 10)
  16506. // //}
  16507. // //fmt.Println(zero)
  16508. //
  16509. // struct4101 := service.Struct4101{
  16510. // PsnNo: order.PsnNo,
  16511. // MdtrtId: order.MdtrtId,
  16512. // SetlId: order.SetlId,
  16513. // PsnName: order.PsnName,
  16514. // Gend: order.Gend,
  16515. // Brdy: his.Brdy,
  16516. // Age: his.Age,
  16517. // Naty: order.Naty,
  16518. // PatnCertType: "01",
  16519. // Certno: order.Certno,
  16520. // Prfs: "90",
  16521. // ConerName: roles[0].UserName,
  16522. // PatnRlts: "99",
  16523. // ConerAddr: miConfig.OrgName,
  16524. // ConerTel: admin.Mobile,
  16525. // HiType: order.Insutype,
  16526. // Insuplc: miConfig.InsuplcAdmdvs,
  16527. // MaindiagFlag: "1",
  16528. // BillCode: order.SetlId,
  16529. // BillNo: order.SetlId,
  16530. // BizSn: order.Number,
  16531. // PsnSelfPay: order.PsnPartAmt,
  16532. // PsnOwnPay: order.PsnPartAmt,
  16533. // AcctPay: order.AcctPay,
  16534. // PsnCashpay: order.PsnCashPay,
  16535. // HiPaymtd: "1",
  16536. // Hsorg: miConfig.InsuplcAdmdvs,
  16537. // HsorgOpter: miConfig.InsuplcAdmdvs,
  16538. // MedinsFillPsn: curRoles.UserName,
  16539. // MedinsFillDept: miConfig.OrgName,
  16540. // IptMedType: "2",
  16541. // }
  16542. // struct4101.SetlBegnDate = order.SetlTime
  16543. // struct4101.SetlEndDate = order.SetlTime
  16544. // time_arr := strings.Split(order.SetlTime, " ")
  16545. // struct4101.AdmTime = time_arr[0]
  16546. // struct4101.AdmEndTime = time_arr[0]
  16547. //
  16548. // var rf []CustomFundPay
  16549. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  16550. //
  16551. // var tempFunPays []service.CustomStruct
  16552. // for _, item := range rf {
  16553. // var tempFunPay service.CustomStruct
  16554. // tempFunPay.FundPayamt = item.FundPayamt
  16555. // tempFunPay.FundPayType = item.FundPayType
  16556. // tempFunPays = append(tempFunPays, tempFunPay)
  16557. // }
  16558. // struct4101.CustomStruct = tempFunPays
  16559. //
  16560. // var tempDiaginfos []service.DiaginfoStructTwo
  16561. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  16562. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  16563. //
  16564. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  16565. // var config []*models.HisXtDiagnoseConfig
  16566. // for _, item := range diagnosis_ids {
  16567. // id, _ := strconv.ParseInt(item, 10, 64)
  16568. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  16569. // config = append(config, &diagnosisConfig)
  16570. // }
  16571. //
  16572. // for index, item := range config {
  16573. // if index == 0 {
  16574. // var tempDiaginfo service.DiaginfoStructTwo
  16575. // tempDiaginfo.DiagCode = item.CountryCode
  16576. // tempDiaginfo.DiagName = item.CountryContentName
  16577. // tempDiaginfo.DiagType = "1"
  16578. // tempDiaginfo.MaindiagFlag = "1"
  16579. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16580. // } else {
  16581. // var tempDiaginfo service.DiaginfoStructTwo
  16582. // tempDiaginfo.DiagCode = item.CountryCode
  16583. // tempDiaginfo.DiagName = item.CountryContentName
  16584. // tempDiaginfo.DiagType = "1"
  16585. // tempDiaginfo.MaindiagFlag = "0"
  16586. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16587. // }
  16588. // }
  16589. // struct4101.Diseinfo = tempDiaginfos
  16590. //
  16591. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  16592. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  16593. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  16594. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  16595. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  16596. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  16597. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  16598. //
  16599. // var iteminfo service.IteminfoStruct
  16600. //
  16601. // var bedCostTotal float64 = 0 //床位总费
  16602. // var bedCostSelfTotal float64 = 0 //床位自费
  16603. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  16604. //
  16605. // var operationCostTotal float64 = 0 //手术费
  16606. // var operationCostSelfTotal float64 = 0 //手术费
  16607. // var operationCostPartSelfTotal float64 = 0 //手术费
  16608. //
  16609. // var otherCostTotal float64 = 0 //其他费用
  16610. // var otherCostSelfTotal float64 = 0 //其他费用
  16611. // var otherCostPartSelfTotal float64 = 0 //其他费用
  16612. //
  16613. // var materialCostTotal float64 = 0 //材料费
  16614. // var materialCostSelfTotal float64 = 0 //材料费
  16615. // var materialCostPartSelfTotal float64 = 0 //材料费
  16616. //
  16617. // var westernMedicineCostTotal float64 = 0 //西药费
  16618. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  16619. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  16620. //
  16621. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  16622. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  16623. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  16624. //
  16625. // var checkCostTotal float64 = 0 //检查费
  16626. // var checkCostSelfTotal float64 = 0 //检查费
  16627. // var checkCostPartSelfTotal float64 = 0 //检查费
  16628. //
  16629. // var laboratoryCostTotal float64 = 0 //化验费
  16630. // var laboratoryCostSelfTotal float64 = 0 //化验费
  16631. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  16632. //
  16633. // var treatCostTotal float64 = 0 //治疗费用
  16634. // var treatCostSelfTotal float64 = 0 //治疗费用
  16635. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  16636. //
  16637. // decimal.DivisionPrecision = 2
  16638. //
  16639. // var bed_fulamt_ownpay_amt float64 = 0
  16640. // var operation_fulamt_ownpay_amt float64 = 0
  16641. // var other_fulamt_ownpay_amt float64 = 0
  16642. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  16643. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  16644. // var check_fulamt_ownpay_amt float64 = 0
  16645. // var material_fulamt_ownpay_amt float64 = 0
  16646. // var laboratory_fulamt_ownpay_amt float64 = 0
  16647. // var treat_fulamt_ownpay_amt float64 = 0
  16648. //
  16649. // var bed_claa_sunmfee float64 = 0
  16650. // var bed_clab_amt float64 = 0
  16651. // var bed_other_amt float64 = 0
  16652. //
  16653. // var operation_claa_sunmfee float64 = 0
  16654. // var operation_clab_amt float64 = 0
  16655. // var operation_other_amt float64 = 0
  16656. //
  16657. // var other_claa_sunmfee float64 = 0
  16658. // var other_clab_amt float64 = 0
  16659. // var other_other_amt float64 = 0
  16660. //
  16661. // var westernMedicine_claa_sunmfee float64 = 0
  16662. // var westernMedicine_clab_amt float64 = 0
  16663. // var westernMedicine_other_amt float64 = 0
  16664. //
  16665. // var chineseTraditional_claa_sunmfee float64 = 0
  16666. // var chineseTraditional_clab_amt float64 = 0
  16667. // var chineseTraditional_other_amt float64 = 0
  16668. //
  16669. // var check_claa_sunmfee float64 = 0
  16670. // var check_clab_amt float64 = 0
  16671. // var check_other_amt float64 = 0
  16672. //
  16673. // var material_claa_sunmfee float64 = 0
  16674. // var material_clab_amt float64 = 0
  16675. // var material_other_amt float64 = 0
  16676. //
  16677. // var laboratory_claa_sunmfee float64 = 0
  16678. // var laboratory_clab_amt float64 = 0
  16679. // var laboratory_other_amt float64 = 0
  16680. //
  16681. // var treat_claa_sunmfee float64 = 0
  16682. // var treat_clab_amt float64 = 0
  16683. // var treat_other_amt float64 = 0
  16684. //
  16685. // for _, item := range order.HisOrderInfo {
  16686. // if item.MedChrgitmType == "01" { //床位费
  16687. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16688. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16689. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16690. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16691. // if item.ChrgitmLv == "1" {
  16692. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16693. // }
  16694. // if item.ChrgitmLv == "2" {
  16695. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16696. //
  16697. // }
  16698. // if item.ChrgitmLv == "3" {
  16699. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16700. // }
  16701. //
  16702. // }
  16703. //
  16704. // if item.MedChrgitmType == "03" { //检查费
  16705. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16706. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16707. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16708. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16709. // if item.ChrgitmLv == "1" {
  16710. //
  16711. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16712. //
  16713. // }
  16714. // if item.ChrgitmLv == "2" {
  16715. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16716. //
  16717. // }
  16718. // if item.ChrgitmLv == "3" {
  16719. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16720. // }
  16721. // }
  16722. //
  16723. // if item.MedChrgitmType == "04" { //化验费
  16724. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16725. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16726. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16727. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16728. // if item.ChrgitmLv == "1" {
  16729. //
  16730. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16731. //
  16732. // }
  16733. // if item.ChrgitmLv == "2" {
  16734. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16735. //
  16736. // }
  16737. // if item.ChrgitmLv == "3" {
  16738. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16739. // }
  16740. // }
  16741. //
  16742. // if item.MedChrgitmType == "05" { //治疗费
  16743. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16744. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16745. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16746. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16747. // if item.ChrgitmLv == "1" {
  16748. //
  16749. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16750. //
  16751. // }
  16752. // if item.ChrgitmLv == "2" {
  16753. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16754. //
  16755. // }
  16756. // if item.ChrgitmLv == "3" {
  16757. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16758. // }
  16759. // }
  16760. //
  16761. // if item.MedChrgitmType == "06" { //手术费
  16762. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16763. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16764. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16765. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16766. //
  16767. // if item.ChrgitmLv == "1" {
  16768. //
  16769. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16770. //
  16771. // }
  16772. // if item.ChrgitmLv == "2" {
  16773. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16774. //
  16775. // }
  16776. // if item.ChrgitmLv == "3" {
  16777. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16778. // }
  16779. // }
  16780. //
  16781. // if item.MedChrgitmType == "08" { //材料费
  16782. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16783. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16784. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16785. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16786. // if item.ChrgitmLv == "1" {
  16787. //
  16788. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16789. //
  16790. // }
  16791. // if item.ChrgitmLv == "2" {
  16792. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16793. //
  16794. // }
  16795. // if item.ChrgitmLv == "3" {
  16796. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16797. // }
  16798. // }
  16799. //
  16800. // if item.MedChrgitmType == "09" { //西药费
  16801. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16802. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16803. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16804. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16805. // if item.ChrgitmLv == "1" {
  16806. //
  16807. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16808. //
  16809. // }
  16810. // if item.ChrgitmLv == "2" {
  16811. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16812. //
  16813. // }
  16814. // if item.ChrgitmLv == "3" {
  16815. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16816. // }
  16817. // }
  16818. //
  16819. // if item.MedChrgitmType == "11" { //中成费
  16820. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16821. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16822. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16823. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16824. // if item.ChrgitmLv == "1" {
  16825. //
  16826. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16827. //
  16828. // }
  16829. // if item.ChrgitmLv == "2" {
  16830. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16831. //
  16832. // }
  16833. // if item.ChrgitmLv == "3" {
  16834. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16835. // }
  16836. // }
  16837. //
  16838. // if item.MedChrgitmType == "14" { //其他费
  16839. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16840. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16841. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16842. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16843. // if item.ChrgitmLv == "1" {
  16844. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16845. //
  16846. // }
  16847. // if item.ChrgitmLv == "2" {
  16848. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16849. //
  16850. // }
  16851. // if item.ChrgitmLv == "3" {
  16852. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16853. // }
  16854. // }
  16855. //
  16856. // }
  16857. //
  16858. // var iteminfoStructs []service.IteminfoStruct
  16859. //
  16860. // if bedCostTotal != 0 {
  16861. // iteminfo.MedChrgitm = "01"
  16862. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  16863. // iteminfo.Amt = bedCostTotal
  16864. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  16865. // iteminfo.ClabAmt = bed_clab_amt
  16866. // iteminfo.OthAmt = bed_other_amt
  16867. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16868. // }
  16869. //
  16870. // if checkCostTotal != 0 {
  16871. // iteminfo.MedChrgitm = "03"
  16872. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  16873. // iteminfo.Amt = checkCostTotal
  16874. // iteminfo.ClaaSumfee = check_claa_sunmfee
  16875. // iteminfo.ClabAmt = check_clab_amt
  16876. // iteminfo.OthAmt = check_other_amt
  16877. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16878. //
  16879. // }
  16880. //
  16881. // if laboratoryCostTotal != 0 {
  16882. // iteminfo.MedChrgitm = "04"
  16883. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  16884. // iteminfo.Amt = laboratoryCostTotal
  16885. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  16886. // iteminfo.ClabAmt = laboratory_clab_amt
  16887. // iteminfo.OthAmt = laboratory_other_amt
  16888. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16889. //
  16890. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16891. //
  16892. // }
  16893. //
  16894. // if treatCostTotal != 0 {
  16895. // iteminfo.MedChrgitm = "05"
  16896. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  16897. // iteminfo.Amt = treatCostTotal
  16898. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  16899. // iteminfo.ClabAmt = treat_clab_amt
  16900. // iteminfo.OthAmt = treat_other_amt
  16901. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16902. // //(struct4101.IteminfoStruct, iteminfo)
  16903. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16904. // }
  16905. //
  16906. // if operationCostTotal != 0 {
  16907. // iteminfo.MedChrgitm = "06"
  16908. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  16909. // iteminfo.Amt = operationCostTotal
  16910. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  16911. // iteminfo.ClabAmt = operation_clab_amt
  16912. // iteminfo.OthAmt = operation_other_amt
  16913. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16914. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16915. // }
  16916. //
  16917. // if materialCostTotal != 0 {
  16918. // iteminfo.MedChrgitm = "08"
  16919. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  16920. // iteminfo.Amt = materialCostTotal
  16921. // iteminfo.ClaaSumfee = material_claa_sunmfee
  16922. // iteminfo.ClabAmt = material_clab_amt
  16923. // iteminfo.OthAmt = material_other_amt
  16924. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16925. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16926. // }
  16927. //
  16928. // if westernMedicineCostTotal != 0 {
  16929. // iteminfo.MedChrgitm = "09"
  16930. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  16931. // iteminfo.Amt = westernMedicineCostTotal
  16932. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  16933. // iteminfo.ClabAmt = westernMedicine_clab_amt
  16934. // iteminfo.OthAmt = westernMedicine_other_amt
  16935. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16936. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16937. //
  16938. // }
  16939. // if chineseTraditionalMedicineCostTotal != 0 {
  16940. // iteminfo.MedChrgitm = "11"
  16941. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  16942. // iteminfo.Amt = westernMedicineCostTotal
  16943. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  16944. // iteminfo.ClabAmt = westernMedicine_clab_amt
  16945. // iteminfo.OthAmt = westernMedicine_other_amt
  16946. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16947. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16948. //
  16949. // }
  16950. // if otherCostTotal != 0 {
  16951. // iteminfo.MedChrgitm = "14"
  16952. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  16953. // iteminfo.Amt = otherCostTotal
  16954. // iteminfo.ClaaSumfee = other_claa_sunmfee
  16955. // iteminfo.ClabAmt = other_clab_amt
  16956. // iteminfo.OthAmt = other_other_amt
  16957. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16958. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16959. //
  16960. // }
  16961. // struct4101.IteminfoStruct = iteminfoStructs
  16962. // struct4101.Ntly = "中国"
  16963. // struct4101.AdmCaty = "A03.06"
  16964. //
  16965. // struct4101.DoctorName = doctor.UserName
  16966. // struct4101.DoctorCode = doctor.DoctorNumber
  16967. //
  16968. // var res ResultSeventeen
  16969. //
  16970. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16971. // struct4101.BillCode = order.Number
  16972. // struct4101.BillNo = order.SetlId
  16973. // var resOther ResultSeventeenOther
  16974. // var pp models.PublicParams
  16975. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16976. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16977. // pp.FixmedinsName = miConfig.OrgName
  16978. // pp.FixmedinsCode = miConfig.Code
  16979. // pp.RequestUrl = miConfig.Url
  16980. // pp.Cainfo = miConfig.Cainfo
  16981. // pp.SecretKey = miConfig.SecretKey
  16982. // pp.AccessKey = miConfig.AccessKey
  16983. // pp.OpterName = curRoles.UserName
  16984. //
  16985. // client := &http.Client{}
  16986. // var req *http.Request
  16987. // data := make(map[string]interface{})
  16988. // data["struct4101"] = struct4101
  16989. // data["pp"] = pp
  16990. // bytesData, _ := json.Marshal(data)
  16991. // if miConfig.MdtrtareaAdmvs == "320921" {
  16992. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  16993. // } else {
  16994. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  16995. // }
  16996. // resp, _ := client.Do(req)
  16997. // defer resp.Body.Close()
  16998. // body, ioErr := ioutil.ReadAll(resp.Body)
  16999. // if ioErr != nil {
  17000. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17001. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17002. // return
  17003. // }
  17004. // var respJSON map[string]interface{}
  17005. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17006. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17007. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17008. // return
  17009. // }
  17010. //
  17011. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17012. // userJSONBytes, _ := json.Marshal(respJSON)
  17013. // fmt.Println("log")
  17014. // fmt.Println(string(userJSONBytes))
  17015. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17016. // utils.ErrorLog("解析失败:%v", err)
  17017. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17018. // return
  17019. // }
  17020. // res.InfRefmsgid = resOther.InfRefmsgid
  17021. // res.Output = resOther.Output
  17022. // res.ErrMsg = resOther.ErrMsg
  17023. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17024. // res.Infcode = infocode
  17025. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  17026. //
  17027. // var pp models.PublicParams
  17028. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17029. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17030. // pp.FixmedinsName = miConfig.OrgName
  17031. // pp.FixmedinsCode = miConfig.Code
  17032. // pp.RequestUrl = miConfig.Url
  17033. // pp.Cainfo = miConfig.Cainfo
  17034. // pp.SecretKey = miConfig.SecretKey
  17035. // pp.AccessKey = miConfig.AccessKey
  17036. // pp.OpterName = curRoles.UserName
  17037. // result, _ := service.Jxyb4101(struct4101, pp)
  17038. // var dat map[string]interface{}
  17039. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17040. // fmt.Println(dat)
  17041. // } else {
  17042. // fmt.Println(err)
  17043. // }
  17044. // userJSONBytes, _ := json.Marshal(dat)
  17045. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17046. // utils.ErrorLog("解析失败:%v", err)
  17047. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17048. // return
  17049. // }
  17050. //
  17051. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  17052. // var pp models.PublicParams
  17053. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17054. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17055. // pp.FixmedinsName = miConfig.OrgName
  17056. // pp.FixmedinsCode = miConfig.Code
  17057. // pp.RequestUrl = miConfig.Url
  17058. // pp.Cainfo = miConfig.Cainfo
  17059. // pp.SecretKey = miConfig.SecretKey
  17060. // pp.AccessKey = miConfig.AccessKey
  17061. // pp.OpterName = curRoles.UserName
  17062. // result, _ := service.Hnyb4101(struct4101, pp)
  17063. // var dat map[string]interface{}
  17064. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17065. // fmt.Println(dat)
  17066. // } else {
  17067. // fmt.Println(err)
  17068. // }
  17069. // userJSONBytes, _ := json.Marshal(dat)
  17070. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17071. // utils.ErrorLog("解析失败:%v", err)
  17072. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17073. // return
  17074. // }
  17075. //
  17076. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  17077. // var resOther ResultSeventeenOther
  17078. //
  17079. // var pp models.PublicParams
  17080. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17081. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17082. // pp.FixmedinsName = miConfig.OrgName
  17083. // pp.FixmedinsCode = miConfig.Code
  17084. // pp.RequestUrl = miConfig.Url
  17085. // pp.Cainfo = miConfig.Cainfo
  17086. // pp.SecretKey = miConfig.SecretKey
  17087. // pp.AccessKey = miConfig.AccessKey
  17088. // pp.OpterName = curRoles.UserName
  17089. // client := &http.Client{}
  17090. // var req *http.Request
  17091. // data := make(map[string]interface{})
  17092. // data["struct4101"] = struct4101
  17093. // data["pp"] = pp
  17094. // bytesData, _ := json.Marshal(data)
  17095. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  17096. // resp, _ := client.Do(req)
  17097. // defer resp.Body.Close()
  17098. // body, ioErr := ioutil.ReadAll(resp.Body)
  17099. // if ioErr != nil {
  17100. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17101. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17102. // return
  17103. // }
  17104. // var respJSON map[string]interface{}
  17105. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17106. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17107. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17108. // return
  17109. // }
  17110. //
  17111. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17112. // userJSONBytes, _ := json.Marshal(respJSON)
  17113. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17114. // utils.ErrorLog("解析失败:%v", err)
  17115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17116. // return
  17117. // }
  17118. // res.InfRefmsgid = resOther.InfRefmsgid
  17119. // res.Output = resOther.Output
  17120. // res.ErrMsg = resOther.ErrMsg
  17121. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17122. // res.Infcode = infocode
  17123. //
  17124. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  17125. // var pp models.PublicParams
  17126. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17127. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17128. // pp.FixmedinsName = miConfig.OrgName
  17129. // pp.FixmedinsCode = miConfig.Code
  17130. // pp.RequestUrl = miConfig.Url
  17131. // pp.Cainfo = miConfig.Cainfo
  17132. // pp.SecretKey = miConfig.SecretKey
  17133. // pp.AccessKey = miConfig.AccessKey
  17134. // pp.OpterName = curRoles.UserName
  17135. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  17136. // fmt.Println(requestLog)
  17137. // fmt.Println(errMsgLog)
  17138. //
  17139. // saveLog(result, requestLog, "4101a", "上传清单")
  17140. //
  17141. // var dat map[string]interface{}
  17142. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17143. // fmt.Println(dat)
  17144. // } else {
  17145. // fmt.Println(err)
  17146. // }
  17147. // userJSONBytes, _ := json.Marshal(dat)
  17148. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17149. // utils.ErrorLog("解析失败:%v", err)
  17150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17151. // return
  17152. // }
  17153. //
  17154. // } else {
  17155. //
  17156. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  17157. // var dat map[string]interface{}
  17158. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17159. // fmt.Println(dat)
  17160. // } else {
  17161. // fmt.Println(err)
  17162. // }
  17163. // userJSONBytes, _ := json.Marshal(dat)
  17164. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17165. // utils.ErrorLog("解析失败:%v", err)
  17166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17167. // return
  17168. // }
  17169. // }
  17170. //
  17171. // if res.Infcode != 0 {
  17172. // adminUser := c.GetAdminUserInfo()
  17173. // errlog := &models.HisOrderError{
  17174. // UserOrgId: adminUser.CurrentOrgId,
  17175. // Ctime: time.Now().Unix(),
  17176. // Mtime: time.Now().Unix(),
  17177. // ErrMsg: res.ErrMsg,
  17178. // Status: 1,
  17179. // PatientId: order.ID,
  17180. // Stage: 10265,
  17181. // }
  17182. // service.CreateErrMsgLog(errlog)
  17183. // continue
  17184. // } else {
  17185. // //order.FaPiaoNumber = zero
  17186. // //order.FaPiaoCode = last_order.FaPiaoCode
  17187. // //service.UpdateOrder(order)
  17188. // hisFundSettleListResult := &models.HisFundSettleListResult{
  17189. // Number: res.Output.SetlListId,
  17190. // Status: 1,
  17191. // Ctime: time.Now().Unix(),
  17192. // Mtime: time.Now().Unix(),
  17193. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17194. // IsUpload: 1,
  17195. // OrderId: order.ID,
  17196. // }
  17197. // service.CreateUploadRecord(hisFundSettleListResult)
  17198. // c.ServeSuccessJSON(map[string]interface{}{
  17199. // "msg": "上传成功",
  17200. // "result": hisFundSettleListResult,
  17201. // })
  17202. // continue
  17203. // }
  17204. // }
  17205. //}
  17206. func (c *HisApiController) GetbatchSettleList() {
  17207. //order_id, _ := c.GetInt64("order_id")
  17208. admin_user_id, _ := c.GetInt64("admin_user_id")
  17209. orders, _ := service.GetAllHisOrderTwo10485()
  17210. for _, item := range orders {
  17211. order, _ := service.GetHisOrderByIDTwo(item.ID)
  17212. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17213. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17214. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17215. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17216. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17217. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17218. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17219. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17220. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17221. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17222. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17223. //fmt.Println(count)
  17224. //var zero string
  17225. //number := count + 1
  17226. //if number >= 1000 {
  17227. // zero = "0000" + strconv.FormatInt(number, 10)
  17228. //} else if number >= 10000 {
  17229. // zero = "000" + strconv.FormatInt(number, 10)
  17230. //} else if number >= 100000 {
  17231. // zero = "00" + strconv.FormatInt(number, 10)
  17232. //} else if number >= 1000000 {
  17233. // zero = "0" + strconv.FormatInt(number, 10)
  17234. //} else {
  17235. // zero = strconv.FormatInt(number, 10)
  17236. //}
  17237. //fmt.Println(zero)
  17238. struct4101 := service.Struct4101{
  17239. PsnNo: order.PsnNo,
  17240. MdtrtId: order.MdtrtId,
  17241. SetlId: order.SetlId,
  17242. PsnName: order.PsnName,
  17243. Gend: order.Gend,
  17244. Brdy: his.Brdy,
  17245. Age: his.Age,
  17246. Naty: order.Naty,
  17247. PatnCertType: "01",
  17248. Certno: order.Certno,
  17249. Prfs: "90",
  17250. ConerName: roles[0].UserName,
  17251. PatnRlts: "99",
  17252. ConerAddr: miConfig.OrgName,
  17253. ConerTel: admin.Mobile,
  17254. HiType: order.Insutype,
  17255. Insuplc: miConfig.InsuplcAdmdvs,
  17256. MaindiagFlag: "1",
  17257. BillCode: order.SetlId,
  17258. BillNo: order.SetlId,
  17259. BizSn: order.Number,
  17260. PsnSelfPay: order.PsnPartAmt,
  17261. PsnOwnPay: order.PsnPartAmt,
  17262. AcctPay: order.AcctPay,
  17263. PsnCashpay: order.PsnCashPay,
  17264. HiPaymtd: "1",
  17265. Hsorg: miConfig.InsuplcAdmdvs,
  17266. HsorgOpter: miConfig.InsuplcAdmdvs,
  17267. MedinsFillPsn: curRoles.UserName,
  17268. MedinsFillDept: miConfig.OrgName,
  17269. IptMedType: "2",
  17270. }
  17271. struct4101.SetlBegnDate = order.SetlTime
  17272. struct4101.SetlEndDate = order.SetlTime
  17273. time_arr := strings.Split(order.SetlTime, " ")
  17274. struct4101.AdmTime = time_arr[0]
  17275. struct4101.AdmEndTime = time_arr[0]
  17276. //var rf []CustomFundPay
  17277. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  17278. //
  17279. //var tempFunPays []service.CustomStruct
  17280. //for _, item := range rf {
  17281. // var tempFunPay service.CustomStruct
  17282. // tempFunPay.FundPayamt = item.FundPayamt
  17283. // tempFunPay.FundPayType = item.FundPayType
  17284. // tempFunPays = append(tempFunPays, tempFunPay)
  17285. //}
  17286. //struct4101.CustomStruct = tempFunPays
  17287. var tempDiaginfos []service.DiaginfoStructTwo
  17288. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17289. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17290. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17291. var config []*models.HisXtDiagnoseConfig
  17292. for _, item := range diagnosis_ids {
  17293. id, _ := strconv.ParseInt(item, 10, 64)
  17294. diagnosisConfig, _ := service.FindDiagnoseById(id)
  17295. config = append(config, &diagnosisConfig)
  17296. }
  17297. for index, item := range config {
  17298. if index == 0 {
  17299. var tempDiaginfo service.DiaginfoStructTwo
  17300. tempDiaginfo.DiagCode = item.CountryCode
  17301. tempDiaginfo.DiagName = item.CountryContentName
  17302. tempDiaginfo.DiagType = "1"
  17303. tempDiaginfo.MaindiagFlag = "1"
  17304. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17305. } else {
  17306. var tempDiaginfo service.DiaginfoStructTwo
  17307. tempDiaginfo.DiagCode = item.CountryCode
  17308. tempDiaginfo.DiagName = item.CountryContentName
  17309. tempDiaginfo.DiagType = "1"
  17310. tempDiaginfo.MaindiagFlag = "0"
  17311. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17312. }
  17313. }
  17314. struct4101.Diseinfo = tempDiaginfos
  17315. sickConfigTwo, _ := service.FindSickById(his.SickType)
  17316. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17317. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17318. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17319. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17320. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17321. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17322. var iteminfo service.IteminfoStruct
  17323. var bedCostTotal float64 = 0 //床位总费
  17324. var bedCostSelfTotal float64 = 0 //床位自费
  17325. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17326. var operationCostTotal float64 = 0 //手术费
  17327. var operationCostSelfTotal float64 = 0 //手术费
  17328. var operationCostPartSelfTotal float64 = 0 //手术费
  17329. var otherCostTotal float64 = 0 //其他费用
  17330. var otherCostSelfTotal float64 = 0 //其他费用
  17331. var otherCostPartSelfTotal float64 = 0 //其他费用
  17332. var materialCostTotal float64 = 0 //材料费
  17333. var materialCostSelfTotal float64 = 0 //材料费
  17334. var materialCostPartSelfTotal float64 = 0 //材料费
  17335. var westernMedicineCostTotal float64 = 0 //西药费
  17336. var westernMedicineCostSelfTotal float64 = 0 //西药费
  17337. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17338. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17339. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17340. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17341. var checkCostTotal float64 = 0 //检查费
  17342. var checkCostSelfTotal float64 = 0 //检查费
  17343. var checkCostPartSelfTotal float64 = 0 //检查费
  17344. var laboratoryCostTotal float64 = 0 //化验费
  17345. var laboratoryCostSelfTotal float64 = 0 //化验费
  17346. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17347. var treatCostTotal float64 = 0 //治疗费用
  17348. var treatCostSelfTotal float64 = 0 //治疗费用
  17349. var treatCostPartSelfTotal float64 = 0 //治疗费用
  17350. decimal.DivisionPrecision = 2
  17351. var bed_fulamt_ownpay_amt float64 = 0
  17352. var operation_fulamt_ownpay_amt float64 = 0
  17353. var other_fulamt_ownpay_amt float64 = 0
  17354. var westernMedicine_fulamt_ownpay_amt float64 = 0
  17355. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17356. var check_fulamt_ownpay_amt float64 = 0
  17357. var material_fulamt_ownpay_amt float64 = 0
  17358. var laboratory_fulamt_ownpay_amt float64 = 0
  17359. var treat_fulamt_ownpay_amt float64 = 0
  17360. var bed_claa_sunmfee float64 = 0
  17361. var bed_clab_amt float64 = 0
  17362. var bed_other_amt float64 = 0
  17363. var operation_claa_sunmfee float64 = 0
  17364. var operation_clab_amt float64 = 0
  17365. var operation_other_amt float64 = 0
  17366. var other_claa_sunmfee float64 = 0
  17367. var other_clab_amt float64 = 0
  17368. var other_other_amt float64 = 0
  17369. var westernMedicine_claa_sunmfee float64 = 0
  17370. var westernMedicine_clab_amt float64 = 0
  17371. var westernMedicine_other_amt float64 = 0
  17372. var chineseTraditional_claa_sunmfee float64 = 0
  17373. var chineseTraditional_clab_amt float64 = 0
  17374. var chineseTraditional_other_amt float64 = 0
  17375. var check_claa_sunmfee float64 = 0
  17376. var check_clab_amt float64 = 0
  17377. var check_other_amt float64 = 0
  17378. var material_claa_sunmfee float64 = 0
  17379. var material_clab_amt float64 = 0
  17380. var material_other_amt float64 = 0
  17381. var laboratory_claa_sunmfee float64 = 0
  17382. var laboratory_clab_amt float64 = 0
  17383. var laboratory_other_amt float64 = 0
  17384. var treat_claa_sunmfee float64 = 0
  17385. var treat_clab_amt float64 = 0
  17386. var treat_other_amt float64 = 0
  17387. for _, item := range order.HisOrderInfo {
  17388. if item.MedChrgitmType == "01" { //床位费
  17389. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17390. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17391. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17392. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17393. if item.ChrgitmLv == "1" {
  17394. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17395. }
  17396. if item.ChrgitmLv == "2" {
  17397. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17398. }
  17399. if item.ChrgitmLv == "3" {
  17400. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17401. }
  17402. }
  17403. if item.MedChrgitmType == "03" { //检查费
  17404. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17405. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17406. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17407. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17408. if item.ChrgitmLv == "1" {
  17409. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17410. }
  17411. if item.ChrgitmLv == "2" {
  17412. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17413. }
  17414. if item.ChrgitmLv == "3" {
  17415. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17416. }
  17417. }
  17418. if item.MedChrgitmType == "04" { //化验费
  17419. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17420. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17421. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17422. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17423. if item.ChrgitmLv == "1" {
  17424. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17425. }
  17426. if item.ChrgitmLv == "2" {
  17427. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17428. }
  17429. if item.ChrgitmLv == "3" {
  17430. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17431. }
  17432. }
  17433. if item.MedChrgitmType == "05" { //治疗费
  17434. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17435. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17436. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17437. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17438. if item.ChrgitmLv == "1" {
  17439. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17440. }
  17441. if item.ChrgitmLv == "2" {
  17442. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17443. }
  17444. if item.ChrgitmLv == "3" {
  17445. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17446. }
  17447. }
  17448. if item.MedChrgitmType == "06" { //手术费
  17449. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17450. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17451. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17452. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17453. if item.ChrgitmLv == "1" {
  17454. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17455. }
  17456. if item.ChrgitmLv == "2" {
  17457. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17458. }
  17459. if item.ChrgitmLv == "3" {
  17460. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17461. }
  17462. }
  17463. if item.MedChrgitmType == "08" { //材料费
  17464. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17465. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17466. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17467. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17468. if item.ChrgitmLv == "1" {
  17469. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17470. }
  17471. if item.ChrgitmLv == "2" {
  17472. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17473. }
  17474. if item.ChrgitmLv == "3" {
  17475. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17476. }
  17477. }
  17478. if item.MedChrgitmType == "09" { //西药费
  17479. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17480. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17481. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17482. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17483. if item.ChrgitmLv == "1" {
  17484. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17485. }
  17486. if item.ChrgitmLv == "2" {
  17487. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17488. }
  17489. if item.ChrgitmLv == "3" {
  17490. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17491. }
  17492. }
  17493. if item.MedChrgitmType == "11" { //中成费
  17494. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17495. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17496. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17497. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17498. if item.ChrgitmLv == "1" {
  17499. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17500. }
  17501. if item.ChrgitmLv == "2" {
  17502. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17503. }
  17504. if item.ChrgitmLv == "3" {
  17505. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17506. }
  17507. }
  17508. if item.MedChrgitmType == "14" { //其他费
  17509. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17510. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17511. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17512. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17513. if item.ChrgitmLv == "1" {
  17514. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17515. }
  17516. if item.ChrgitmLv == "2" {
  17517. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17518. }
  17519. if item.ChrgitmLv == "3" {
  17520. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17521. }
  17522. }
  17523. }
  17524. var iteminfoStructs []service.IteminfoStruct
  17525. if bedCostTotal != 0 {
  17526. iteminfo.MedChrgitm = "01"
  17527. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17528. iteminfo.Amt = bedCostTotal
  17529. iteminfo.ClaaSumfee = bed_claa_sunmfee
  17530. iteminfo.ClabAmt = bed_clab_amt
  17531. iteminfo.OthAmt = bed_other_amt
  17532. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17533. }
  17534. if checkCostTotal != 0 {
  17535. iteminfo.MedChrgitm = "03"
  17536. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  17537. iteminfo.Amt = checkCostTotal
  17538. iteminfo.ClaaSumfee = check_claa_sunmfee
  17539. iteminfo.ClabAmt = check_clab_amt
  17540. iteminfo.OthAmt = check_other_amt
  17541. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17542. }
  17543. if laboratoryCostTotal != 0 {
  17544. iteminfo.MedChrgitm = "04"
  17545. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  17546. iteminfo.Amt = laboratoryCostTotal
  17547. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  17548. iteminfo.ClabAmt = laboratory_clab_amt
  17549. iteminfo.OthAmt = laboratory_other_amt
  17550. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17551. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17552. }
  17553. if treatCostTotal != 0 {
  17554. iteminfo.MedChrgitm = "05"
  17555. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  17556. iteminfo.Amt = treatCostTotal
  17557. iteminfo.ClaaSumfee = treat_claa_sunmfee
  17558. iteminfo.ClabAmt = treat_clab_amt
  17559. iteminfo.OthAmt = treat_other_amt
  17560. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17561. //(struct4101.IteminfoStruct, iteminfo)
  17562. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17563. }
  17564. if operationCostTotal != 0 {
  17565. iteminfo.MedChrgitm = "06"
  17566. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17567. iteminfo.Amt = operationCostTotal
  17568. iteminfo.ClaaSumfee = operation_claa_sunmfee
  17569. iteminfo.ClabAmt = operation_clab_amt
  17570. iteminfo.OthAmt = operation_other_amt
  17571. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17572. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17573. }
  17574. if materialCostTotal != 0 {
  17575. iteminfo.MedChrgitm = "08"
  17576. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  17577. iteminfo.Amt = materialCostTotal
  17578. iteminfo.ClaaSumfee = material_claa_sunmfee
  17579. iteminfo.ClabAmt = material_clab_amt
  17580. iteminfo.OthAmt = material_other_amt
  17581. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17582. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17583. }
  17584. if westernMedicineCostTotal != 0 {
  17585. iteminfo.MedChrgitm = "09"
  17586. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17587. iteminfo.Amt = westernMedicineCostTotal
  17588. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17589. iteminfo.ClabAmt = westernMedicine_clab_amt
  17590. iteminfo.OthAmt = westernMedicine_other_amt
  17591. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17592. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17593. }
  17594. if chineseTraditionalMedicineCostTotal != 0 {
  17595. iteminfo.MedChrgitm = "11"
  17596. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17597. iteminfo.Amt = westernMedicineCostTotal
  17598. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17599. iteminfo.ClabAmt = westernMedicine_clab_amt
  17600. iteminfo.OthAmt = westernMedicine_other_amt
  17601. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17602. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17603. }
  17604. if otherCostTotal != 0 {
  17605. iteminfo.MedChrgitm = "14"
  17606. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  17607. iteminfo.Amt = otherCostTotal
  17608. iteminfo.ClaaSumfee = other_claa_sunmfee
  17609. iteminfo.ClabAmt = other_clab_amt
  17610. iteminfo.OthAmt = other_other_amt
  17611. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17612. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17613. }
  17614. struct4101.IteminfoStruct = iteminfoStructs
  17615. struct4101.Ntly = "中国"
  17616. struct4101.AdmCaty = "A03.06"
  17617. struct4101.DoctorName = doctor.UserName
  17618. struct4101.DoctorCode = doctor.DoctorNumber
  17619. var res ResultSeventeen
  17620. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17621. struct4101.BillCode = order.Number
  17622. struct4101.BillNo = order.SetlId
  17623. var resOther ResultSeventeenOther
  17624. var pp models.PublicParams
  17625. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17626. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17627. pp.FixmedinsName = miConfig.OrgName
  17628. pp.FixmedinsCode = miConfig.Code
  17629. pp.RequestUrl = miConfig.Url
  17630. pp.Cainfo = miConfig.Cainfo
  17631. pp.SecretKey = miConfig.SecretKey
  17632. pp.AccessKey = miConfig.AccessKey
  17633. pp.OpterName = curRoles.UserName
  17634. client := &http.Client{}
  17635. var req *http.Request
  17636. data := make(map[string]interface{})
  17637. data["struct4101"] = struct4101
  17638. data["pp"] = pp
  17639. bytesData, _ := json.Marshal(data)
  17640. if miConfig.MdtrtareaAdmvs == "320921" {
  17641. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17642. } else {
  17643. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17644. }
  17645. resp, _ := client.Do(req)
  17646. defer resp.Body.Close()
  17647. body, ioErr := ioutil.ReadAll(resp.Body)
  17648. if ioErr != nil {
  17649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17651. return
  17652. }
  17653. var respJSON map[string]interface{}
  17654. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17657. return
  17658. }
  17659. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17660. userJSONBytes, _ := json.Marshal(respJSON)
  17661. fmt.Println("log")
  17662. fmt.Println(string(userJSONBytes))
  17663. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17664. utils.ErrorLog("解析失败:%v", err)
  17665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17666. return
  17667. }
  17668. res.InfRefmsgid = resOther.InfRefmsgid
  17669. res.Output = resOther.Output
  17670. res.ErrMsg = resOther.ErrMsg
  17671. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17672. res.Infcode = infocode
  17673. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17674. var pp models.PublicParams
  17675. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  17676. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17677. pp.FixmedinsName = miConfig.OrgName
  17678. pp.FixmedinsCode = miConfig.Code
  17679. pp.RequestUrl = miConfig.Url
  17680. pp.Cainfo = miConfig.Cainfo
  17681. pp.SecretKey = miConfig.SecretKey
  17682. pp.AccessKey = miConfig.AccessKey
  17683. pp.OpterName = curRoles.UserName
  17684. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  17685. result, _ := service.Jxyb4101(struct4101, pp)
  17686. var dat map[string]interface{}
  17687. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17688. fmt.Println(dat)
  17689. } else {
  17690. fmt.Println(err)
  17691. }
  17692. userJSONBytes, _ := json.Marshal(dat)
  17693. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17694. utils.ErrorLog("解析失败:%v", err)
  17695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17696. return
  17697. }
  17698. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17699. var pp models.PublicParams
  17700. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17701. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17702. pp.FixmedinsName = miConfig.OrgName
  17703. pp.FixmedinsCode = miConfig.Code
  17704. pp.RequestUrl = miConfig.Url
  17705. pp.Cainfo = miConfig.Cainfo
  17706. pp.SecretKey = miConfig.SecretKey
  17707. pp.AccessKey = miConfig.AccessKey
  17708. pp.OpterName = curRoles.UserName
  17709. result, _ := service.Hnyb4101(struct4101, pp)
  17710. var dat map[string]interface{}
  17711. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17712. fmt.Println(dat)
  17713. } else {
  17714. fmt.Println(err)
  17715. }
  17716. userJSONBytes, _ := json.Marshal(dat)
  17717. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17718. utils.ErrorLog("解析失败:%v", err)
  17719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17720. return
  17721. }
  17722. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17723. var resOther ResultSeventeenOther
  17724. var pp models.PublicParams
  17725. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17726. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17727. pp.FixmedinsName = miConfig.OrgName
  17728. pp.FixmedinsCode = miConfig.Code
  17729. pp.RequestUrl = miConfig.Url
  17730. pp.Cainfo = miConfig.Cainfo
  17731. pp.SecretKey = miConfig.SecretKey
  17732. pp.AccessKey = miConfig.AccessKey
  17733. pp.OpterName = curRoles.UserName
  17734. client := &http.Client{}
  17735. var req *http.Request
  17736. data := make(map[string]interface{})
  17737. data["struct4101"] = struct4101
  17738. data["pp"] = pp
  17739. bytesData, _ := json.Marshal(data)
  17740. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  17741. resp, _ := client.Do(req)
  17742. defer resp.Body.Close()
  17743. body, ioErr := ioutil.ReadAll(resp.Body)
  17744. if ioErr != nil {
  17745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17747. return
  17748. }
  17749. var respJSON map[string]interface{}
  17750. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17753. return
  17754. }
  17755. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17756. userJSONBytes, _ := json.Marshal(respJSON)
  17757. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17758. utils.ErrorLog("解析失败:%v", err)
  17759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17760. return
  17761. }
  17762. res.InfRefmsgid = resOther.InfRefmsgid
  17763. res.Output = resOther.Output
  17764. res.ErrMsg = resOther.ErrMsg
  17765. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17766. res.Infcode = infocode
  17767. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17768. var pp models.PublicParams
  17769. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17770. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17771. pp.FixmedinsName = miConfig.OrgName
  17772. pp.FixmedinsCode = miConfig.Code
  17773. pp.RequestUrl = miConfig.Url
  17774. pp.Cainfo = miConfig.Cainfo
  17775. pp.SecretKey = miConfig.SecretKey
  17776. pp.AccessKey = miConfig.AccessKey
  17777. pp.OpterName = curRoles.UserName
  17778. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  17779. fmt.Println(requestLog)
  17780. fmt.Println(errMsgLog)
  17781. saveLog(result, requestLog, "4101a", "上传清单")
  17782. var dat map[string]interface{}
  17783. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17784. fmt.Println(dat)
  17785. } else {
  17786. fmt.Println(err)
  17787. }
  17788. userJSONBytes, _ := json.Marshal(dat)
  17789. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17790. utils.ErrorLog("解析失败:%v", err)
  17791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17792. return
  17793. }
  17794. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17795. var pp models.PublicParams
  17796. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17797. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17798. pp.FixmedinsName = miConfig.OrgName
  17799. pp.FixmedinsCode = miConfig.Code
  17800. pp.RequestUrl = miConfig.Url
  17801. pp.Cainfo = miConfig.Cainfo
  17802. pp.SecretKey = miConfig.SecretKey
  17803. pp.AccessKey = miConfig.AccessKey
  17804. pp.OpterName = curRoles.UserName
  17805. client := &http.Client{}
  17806. var req *http.Request
  17807. data := make(map[string]interface{})
  17808. data["struct4101"] = struct4101
  17809. data["pp"] = pp
  17810. bytesData, _ := json.Marshal(data)
  17811. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  17812. resp, _ := client.Do(req)
  17813. defer resp.Body.Close()
  17814. body, ioErr := ioutil.ReadAll(resp.Body)
  17815. if ioErr != nil {
  17816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17818. return
  17819. }
  17820. var respJSON map[string]interface{}
  17821. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17824. return
  17825. }
  17826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17827. userJSONBytes, _ := json.Marshal(respJSON)
  17828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17829. utils.ErrorLog("解析失败:%v", err)
  17830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17831. return
  17832. }
  17833. } else {
  17834. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  17835. var dat map[string]interface{}
  17836. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17837. fmt.Println(dat)
  17838. } else {
  17839. fmt.Println(err)
  17840. }
  17841. userJSONBytes, _ := json.Marshal(dat)
  17842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17843. utils.ErrorLog("解析失败:%v", err)
  17844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17845. return
  17846. }
  17847. }
  17848. if res.Infcode != 0 {
  17849. errlog := &models.HisOrderError{
  17850. UserOrgId: order.UserOrgId,
  17851. Ctime: time.Now().Unix(),
  17852. Mtime: time.Now().Unix(),
  17853. ErrMsg: res.ErrMsg + "解析失败",
  17854. Status: 1,
  17855. PatientId: order.ID,
  17856. Stage: 10485,
  17857. }
  17858. service.CreateErrMsgLog(errlog)
  17859. continue
  17860. //c.ServeSuccessJSON(map[string]interface{}{
  17861. // "failed_code": -10,
  17862. // "msg": res.ErrMsg,
  17863. //})
  17864. } else {
  17865. //order.FaPiaoNumber = zero
  17866. //order.FaPiaoCode = last_order.FaPiaoCode
  17867. //service.UpdateOrder(order)
  17868. hisFundSettleListResult := &models.HisFundSettleListResult{
  17869. Number: res.Output.SetlListId,
  17870. Status: 1,
  17871. Ctime: time.Now().Unix(),
  17872. Mtime: time.Now().Unix(),
  17873. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17874. IsUpload: 1,
  17875. OrderId: order.ID,
  17876. }
  17877. service.CreateUploadRecord(hisFundSettleListResult)
  17878. continue
  17879. }
  17880. }
  17881. }
  17882. func (c *HisApiController) GetSettleList() {
  17883. order_id, _ := c.GetInt64("order_id")
  17884. admin_user_id, _ := c.GetInt64("admin_user_id")
  17885. order, _ := service.GetHisOrderByIDTwo(order_id)
  17886. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17887. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17888. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17889. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17890. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17891. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17892. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17893. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17894. if order.ID == 0 {
  17895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17896. return
  17897. }
  17898. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17899. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17900. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17901. //fmt.Println(count)
  17902. //var zero string
  17903. //number := count + 1
  17904. //if number >= 1000 {
  17905. // zero = "0000" + strconv.FormatInt(number, 10)
  17906. //} else if number >= 10000 {
  17907. // zero = "000" + strconv.FormatInt(number, 10)
  17908. //} else if number >= 100000 {
  17909. // zero = "00" + strconv.FormatInt(number, 10)
  17910. //} else if number >= 1000000 {
  17911. // zero = "0" + strconv.FormatInt(number, 10)
  17912. //} else {
  17913. // zero = strconv.FormatInt(number, 10)
  17914. //}
  17915. //fmt.Println(zero)
  17916. struct4101 := service.Struct4101{
  17917. PsnNo: order.PsnNo,
  17918. MdtrtId: order.MdtrtId,
  17919. SetlId: order.SetlId,
  17920. PsnName: order.PsnName,
  17921. Gend: order.Gend,
  17922. Brdy: his.Brdy,
  17923. Age: his.Age,
  17924. Naty: order.Naty,
  17925. PatnCertType: "01",
  17926. Certno: order.Certno,
  17927. Prfs: "90",
  17928. ConerName: roles[0].UserName,
  17929. PatnRlts: "99",
  17930. ConerAddr: miConfig.OrgName,
  17931. ConerTel: admin.Mobile,
  17932. HiType: order.Insutype,
  17933. Insuplc: miConfig.InsuplcAdmdvs,
  17934. MaindiagFlag: "1",
  17935. BillCode: order.SetlId,
  17936. BillNo: order.SetlId,
  17937. BizSn: order.Number,
  17938. PsnSelfPay: order.PsnPartAmt,
  17939. PsnOwnPay: order.PsnPartAmt,
  17940. AcctPay: order.AcctPay,
  17941. PsnCashpay: order.PsnCashPay,
  17942. HiPaymtd: "1",
  17943. Hsorg: miConfig.InsuplcAdmdvs,
  17944. HsorgOpter: miConfig.InsuplcAdmdvs,
  17945. MedinsFillPsn: curRoles.UserName,
  17946. MedinsFillDept: miConfig.OrgName,
  17947. IptMedType: "2",
  17948. }
  17949. struct4101.SetlBegnDate = order.SetlTime
  17950. struct4101.SetlEndDate = order.SetlTime
  17951. time_arr := strings.Split(order.SetlTime, " ")
  17952. struct4101.AdmTime = time_arr[0]
  17953. struct4101.AdmEndTime = time_arr[0]
  17954. //
  17955. //var rf []CustomFundPay
  17956. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  17957. //
  17958. //var tempFunPays []service.CustomStruct
  17959. //for _, item := range rf {
  17960. // var tempFunPay service.CustomStruct
  17961. // tempFunPay.FundPayamt = item.FundPayamt
  17962. // tempFunPay.FundPayType = item.FundPayType
  17963. // tempFunPays = append(tempFunPays, tempFunPay)
  17964. //}
  17965. //struct4101.CustomStruct = tempFunPays
  17966. var tempDiaginfos []service.DiaginfoStructTwo
  17967. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17968. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17969. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  17970. var config []*models.HisXtDiagnoseConfig
  17971. for _, item := range diagnosis_ids {
  17972. id, _ := strconv.ParseInt(item, 10, 64)
  17973. diagnosisConfig, _ := service.FindDiagnoseById(id)
  17974. config = append(config, &diagnosisConfig)
  17975. }
  17976. if miConfig.Code == "H15049901371" {
  17977. //for _, item := range config {
  17978. // if item.ID == 138 {
  17979. diagnosisConfig, _ := service.FindDiagnoseById(138)
  17980. var tempDiaginfo service.DiaginfoStructTwo
  17981. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  17982. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  17983. tempDiaginfo.DiagType = "1"
  17984. tempDiaginfo.MaindiagFlag = "1"
  17985. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17986. //}
  17987. //}
  17988. for _, item := range config {
  17989. if item.ID != 138 {
  17990. var tempDiaginfo service.DiaginfoStructTwo
  17991. tempDiaginfo.DiagCode = item.CountryCode
  17992. tempDiaginfo.DiagName = item.CountryContentName
  17993. tempDiaginfo.DiagType = "1"
  17994. tempDiaginfo.MaindiagFlag = "0"
  17995. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17996. }
  17997. }
  17998. } else {
  17999. for index, item := range config {
  18000. if index == 0 {
  18001. var tempDiaginfo service.DiaginfoStructTwo
  18002. tempDiaginfo.DiagCode = item.CountryCode
  18003. tempDiaginfo.DiagName = item.CountryContentName
  18004. tempDiaginfo.DiagType = "1"
  18005. tempDiaginfo.MaindiagFlag = "1"
  18006. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18007. } else {
  18008. var tempDiaginfo service.DiaginfoStructTwo
  18009. tempDiaginfo.DiagCode = item.CountryCode
  18010. tempDiaginfo.DiagName = item.CountryContentName
  18011. tempDiaginfo.DiagType = "1"
  18012. tempDiaginfo.MaindiagFlag = "0"
  18013. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18014. }
  18015. }
  18016. }
  18017. struct4101.Diseinfo = tempDiaginfos
  18018. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18019. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18020. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18021. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18022. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18023. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18024. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18025. var iteminfo service.IteminfoStruct
  18026. var bedCostTotal float64 = 0 //床位总费
  18027. var bedCostSelfTotal float64 = 0 //床位自费
  18028. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18029. var operationCostTotal float64 = 0 //手术费
  18030. var operationCostSelfTotal float64 = 0 //手术费
  18031. var operationCostPartSelfTotal float64 = 0 //手术费
  18032. var otherCostTotal float64 = 0 //其他费用
  18033. var otherCostSelfTotal float64 = 0 //其他费用
  18034. var otherCostPartSelfTotal float64 = 0 //其他费用
  18035. var materialCostTotal float64 = 0 //材料费
  18036. var materialCostSelfTotal float64 = 0 //材料费
  18037. var materialCostPartSelfTotal float64 = 0 //材料费
  18038. var westernMedicineCostTotal float64 = 0 //西药费
  18039. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18040. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18041. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18042. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18043. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18044. var checkCostTotal float64 = 0 //检查费
  18045. var checkCostSelfTotal float64 = 0 //检查费
  18046. var checkCostPartSelfTotal float64 = 0 //检查费
  18047. var laboratoryCostTotal float64 = 0 //化验费
  18048. var laboratoryCostSelfTotal float64 = 0 //化验费
  18049. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18050. var treatCostTotal float64 = 0 //治疗费用
  18051. var treatCostSelfTotal float64 = 0 //治疗费用
  18052. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18053. decimal.DivisionPrecision = 2
  18054. var bed_fulamt_ownpay_amt float64 = 0
  18055. var operation_fulamt_ownpay_amt float64 = 0
  18056. var other_fulamt_ownpay_amt float64 = 0
  18057. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18058. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18059. var check_fulamt_ownpay_amt float64 = 0
  18060. var material_fulamt_ownpay_amt float64 = 0
  18061. var laboratory_fulamt_ownpay_amt float64 = 0
  18062. var treat_fulamt_ownpay_amt float64 = 0
  18063. var bed_claa_sunmfee float64 = 0
  18064. var bed_clab_amt float64 = 0
  18065. var bed_other_amt float64 = 0
  18066. var operation_claa_sunmfee float64 = 0
  18067. var operation_clab_amt float64 = 0
  18068. var operation_other_amt float64 = 0
  18069. var other_claa_sunmfee float64 = 0
  18070. var other_clab_amt float64 = 0
  18071. var other_other_amt float64 = 0
  18072. var westernMedicine_claa_sunmfee float64 = 0
  18073. var westernMedicine_clab_amt float64 = 0
  18074. var westernMedicine_other_amt float64 = 0
  18075. var chineseTraditional_claa_sunmfee float64 = 0
  18076. var chineseTraditional_clab_amt float64 = 0
  18077. var chineseTraditional_other_amt float64 = 0
  18078. var check_claa_sunmfee float64 = 0
  18079. var check_clab_amt float64 = 0
  18080. var check_other_amt float64 = 0
  18081. var material_claa_sunmfee float64 = 0
  18082. var material_clab_amt float64 = 0
  18083. var material_other_amt float64 = 0
  18084. var laboratory_claa_sunmfee float64 = 0
  18085. var laboratory_clab_amt float64 = 0
  18086. var laboratory_other_amt float64 = 0
  18087. var treat_claa_sunmfee float64 = 0
  18088. var treat_clab_amt float64 = 0
  18089. var treat_other_amt float64 = 0
  18090. for _, item := range order.HisOrderInfo {
  18091. if item.MedChrgitmType == "01" { //床位费
  18092. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18093. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18094. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18095. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18096. if item.ChrgitmLv == "1" {
  18097. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18098. }
  18099. if item.ChrgitmLv == "2" {
  18100. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18101. }
  18102. if item.ChrgitmLv == "3" {
  18103. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18104. }
  18105. }
  18106. if item.MedChrgitmType == "03" { //检查费
  18107. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18108. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18109. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18110. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18111. if item.ChrgitmLv == "1" {
  18112. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18113. }
  18114. if item.ChrgitmLv == "2" {
  18115. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18116. }
  18117. if item.ChrgitmLv == "3" {
  18118. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18119. }
  18120. }
  18121. if item.MedChrgitmType == "04" { //化验费
  18122. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18123. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18124. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18125. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18126. if item.ChrgitmLv == "1" {
  18127. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18128. }
  18129. if item.ChrgitmLv == "2" {
  18130. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18131. }
  18132. if item.ChrgitmLv == "3" {
  18133. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18134. }
  18135. }
  18136. if item.MedChrgitmType == "05" { //治疗费
  18137. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18138. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18139. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18140. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18141. if item.ChrgitmLv == "1" {
  18142. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18143. }
  18144. if item.ChrgitmLv == "2" {
  18145. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18146. }
  18147. if item.ChrgitmLv == "3" {
  18148. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18149. }
  18150. }
  18151. if item.MedChrgitmType == "06" { //手术费
  18152. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18153. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18154. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18155. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18156. if item.ChrgitmLv == "1" {
  18157. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18158. }
  18159. if item.ChrgitmLv == "2" {
  18160. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18161. }
  18162. if item.ChrgitmLv == "3" {
  18163. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18164. }
  18165. }
  18166. if item.MedChrgitmType == "08" { //材料费
  18167. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18168. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18169. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18170. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18171. if item.ChrgitmLv == "1" {
  18172. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18173. }
  18174. if item.ChrgitmLv == "2" {
  18175. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18176. }
  18177. if item.ChrgitmLv == "3" {
  18178. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18179. }
  18180. }
  18181. if item.MedChrgitmType == "09" { //西药费
  18182. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18183. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18184. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18185. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18186. if item.ChrgitmLv == "1" {
  18187. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18188. }
  18189. if item.ChrgitmLv == "2" {
  18190. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18191. }
  18192. if item.ChrgitmLv == "3" {
  18193. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18194. }
  18195. }
  18196. if item.MedChrgitmType == "11" { //中成费
  18197. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18198. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18199. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18200. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18201. if item.ChrgitmLv == "1" {
  18202. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18203. }
  18204. if item.ChrgitmLv == "2" {
  18205. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18206. }
  18207. if item.ChrgitmLv == "3" {
  18208. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18209. }
  18210. }
  18211. if item.MedChrgitmType == "14" { //其他费
  18212. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18213. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18214. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18215. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18216. if item.ChrgitmLv == "1" {
  18217. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18218. }
  18219. if item.ChrgitmLv == "2" {
  18220. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18221. }
  18222. if item.ChrgitmLv == "3" {
  18223. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18224. }
  18225. }
  18226. }
  18227. var iteminfoStructs []service.IteminfoStruct
  18228. if bedCostTotal != 0 {
  18229. iteminfo.MedChrgitm = "01"
  18230. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18231. iteminfo.Amt = bedCostTotal
  18232. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18233. iteminfo.ClabAmt = bed_clab_amt
  18234. iteminfo.OthAmt = bed_other_amt
  18235. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18236. }
  18237. if checkCostTotal != 0 {
  18238. iteminfo.MedChrgitm = "03"
  18239. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18240. iteminfo.Amt = checkCostTotal
  18241. iteminfo.ClaaSumfee = check_claa_sunmfee
  18242. iteminfo.ClabAmt = check_clab_amt
  18243. iteminfo.OthAmt = check_other_amt
  18244. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18245. }
  18246. if laboratoryCostTotal != 0 {
  18247. iteminfo.MedChrgitm = "04"
  18248. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18249. iteminfo.Amt = laboratoryCostTotal
  18250. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18251. iteminfo.ClabAmt = laboratory_clab_amt
  18252. iteminfo.OthAmt = laboratory_other_amt
  18253. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18254. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18255. }
  18256. if treatCostTotal != 0 {
  18257. iteminfo.MedChrgitm = "05"
  18258. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18259. iteminfo.Amt = treatCostTotal
  18260. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18261. iteminfo.ClabAmt = treat_clab_amt
  18262. iteminfo.OthAmt = treat_other_amt
  18263. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18264. //(struct4101.IteminfoStruct, iteminfo)
  18265. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18266. }
  18267. if operationCostTotal != 0 {
  18268. iteminfo.MedChrgitm = "06"
  18269. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18270. iteminfo.Amt = operationCostTotal
  18271. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18272. iteminfo.ClabAmt = operation_clab_amt
  18273. iteminfo.OthAmt = operation_other_amt
  18274. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18275. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18276. }
  18277. if materialCostTotal != 0 {
  18278. iteminfo.MedChrgitm = "08"
  18279. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18280. iteminfo.Amt = materialCostTotal
  18281. iteminfo.ClaaSumfee = material_claa_sunmfee
  18282. iteminfo.ClabAmt = material_clab_amt
  18283. iteminfo.OthAmt = material_other_amt
  18284. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18285. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18286. }
  18287. if westernMedicineCostTotal != 0 {
  18288. iteminfo.MedChrgitm = "09"
  18289. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18290. iteminfo.Amt = westernMedicineCostTotal
  18291. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18292. iteminfo.ClabAmt = westernMedicine_clab_amt
  18293. iteminfo.OthAmt = westernMedicine_other_amt
  18294. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18295. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18296. }
  18297. if chineseTraditionalMedicineCostTotal != 0 {
  18298. iteminfo.MedChrgitm = "11"
  18299. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18300. iteminfo.Amt = westernMedicineCostTotal
  18301. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18302. iteminfo.ClabAmt = westernMedicine_clab_amt
  18303. iteminfo.OthAmt = westernMedicine_other_amt
  18304. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18305. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18306. }
  18307. if otherCostTotal != 0 {
  18308. iteminfo.MedChrgitm = "14"
  18309. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18310. iteminfo.Amt = otherCostTotal
  18311. iteminfo.ClaaSumfee = other_claa_sunmfee
  18312. iteminfo.ClabAmt = other_clab_amt
  18313. iteminfo.OthAmt = other_other_amt
  18314. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18315. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18316. }
  18317. struct4101.IteminfoStruct = iteminfoStructs
  18318. struct4101.Ntly = "中国"
  18319. struct4101.AdmCaty = "A03.06"
  18320. struct4101.DoctorName = doctor.UserName
  18321. struct4101.DoctorCode = doctor.DoctorNumber
  18322. var res ResultSeventeen
  18323. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18324. struct4101.BillCode = order.Number
  18325. struct4101.BillNo = order.SetlId
  18326. var resOther ResultSeventeenOther
  18327. var pp models.PublicParams
  18328. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18329. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18330. pp.FixmedinsName = miConfig.OrgName
  18331. pp.FixmedinsCode = miConfig.Code
  18332. pp.RequestUrl = miConfig.Url
  18333. pp.Cainfo = miConfig.Cainfo
  18334. pp.SecretKey = miConfig.SecretKey
  18335. pp.AccessKey = miConfig.AccessKey
  18336. pp.OpterName = curRoles.UserName
  18337. client := &http.Client{}
  18338. var req *http.Request
  18339. data := make(map[string]interface{})
  18340. data["struct4101"] = struct4101
  18341. data["pp"] = pp
  18342. bytesData, _ := json.Marshal(data)
  18343. if miConfig.MdtrtareaAdmvs == "320921" {
  18344. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18345. } else {
  18346. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18347. }
  18348. resp, _ := client.Do(req)
  18349. defer resp.Body.Close()
  18350. body, ioErr := ioutil.ReadAll(resp.Body)
  18351. if ioErr != nil {
  18352. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18354. return
  18355. }
  18356. var respJSON map[string]interface{}
  18357. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18360. return
  18361. }
  18362. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18363. userJSONBytes, _ := json.Marshal(respJSON)
  18364. fmt.Println("log")
  18365. fmt.Println(string(userJSONBytes))
  18366. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18367. utils.ErrorLog("解析失败:%v", err)
  18368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18369. return
  18370. }
  18371. res.InfRefmsgid = resOther.InfRefmsgid
  18372. res.Output = resOther.Output
  18373. res.ErrMsg = resOther.ErrMsg
  18374. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18375. res.Infcode = infocode
  18376. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18377. var pp models.PublicParams
  18378. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18379. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18380. pp.FixmedinsName = miConfig.OrgName
  18381. pp.FixmedinsCode = miConfig.Code
  18382. pp.RequestUrl = miConfig.Url
  18383. pp.Cainfo = miConfig.Cainfo
  18384. pp.SecretKey = miConfig.SecretKey
  18385. pp.AccessKey = miConfig.AccessKey
  18386. pp.OpterName = curRoles.UserName
  18387. result, _ := service.Jxyb4101(struct4101, pp)
  18388. var dat map[string]interface{}
  18389. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18390. fmt.Println(dat)
  18391. } else {
  18392. fmt.Println(err)
  18393. }
  18394. userJSONBytes, _ := json.Marshal(dat)
  18395. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18396. utils.ErrorLog("解析失败:%v", err)
  18397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18398. return
  18399. }
  18400. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18401. var pp models.PublicParams
  18402. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18403. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18404. pp.FixmedinsName = miConfig.OrgName
  18405. pp.FixmedinsCode = miConfig.Code
  18406. pp.RequestUrl = miConfig.Url
  18407. pp.Cainfo = miConfig.Cainfo
  18408. pp.SecretKey = miConfig.SecretKey
  18409. pp.AccessKey = miConfig.AccessKey
  18410. pp.OpterName = curRoles.UserName
  18411. result, _ := service.Hnyb4101(struct4101, pp)
  18412. var dat map[string]interface{}
  18413. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18414. fmt.Println(dat)
  18415. } else {
  18416. fmt.Println(err)
  18417. }
  18418. userJSONBytes, _ := json.Marshal(dat)
  18419. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18420. utils.ErrorLog("解析失败:%v", err)
  18421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18422. return
  18423. }
  18424. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18425. var resOther ResultSeventeenOther
  18426. var pp models.PublicParams
  18427. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18428. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18429. pp.FixmedinsName = miConfig.OrgName
  18430. pp.FixmedinsCode = miConfig.Code
  18431. pp.RequestUrl = miConfig.Url
  18432. pp.Cainfo = miConfig.Cainfo
  18433. pp.SecretKey = miConfig.SecretKey
  18434. pp.AccessKey = miConfig.AccessKey
  18435. pp.OpterName = curRoles.UserName
  18436. client := &http.Client{}
  18437. var req *http.Request
  18438. data := make(map[string]interface{})
  18439. data["struct4101"] = struct4101
  18440. data["pp"] = pp
  18441. bytesData, _ := json.Marshal(data)
  18442. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18443. resp, _ := client.Do(req)
  18444. defer resp.Body.Close()
  18445. body, ioErr := ioutil.ReadAll(resp.Body)
  18446. if ioErr != nil {
  18447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18449. return
  18450. }
  18451. var respJSON map[string]interface{}
  18452. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18455. return
  18456. }
  18457. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18458. userJSONBytes, _ := json.Marshal(respJSON)
  18459. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18460. utils.ErrorLog("解析失败:%v", err)
  18461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18462. return
  18463. }
  18464. res.InfRefmsgid = resOther.InfRefmsgid
  18465. res.Output = resOther.Output
  18466. res.ErrMsg = resOther.ErrMsg
  18467. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18468. res.Infcode = infocode
  18469. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18470. var pp models.PublicParams
  18471. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18472. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18473. pp.FixmedinsName = miConfig.OrgName
  18474. pp.FixmedinsCode = miConfig.Code
  18475. pp.RequestUrl = miConfig.Url
  18476. pp.Cainfo = miConfig.Cainfo
  18477. pp.SecretKey = miConfig.SecretKey
  18478. pp.AccessKey = miConfig.AccessKey
  18479. pp.OpterName = curRoles.UserName
  18480. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18481. fmt.Println(requestLog)
  18482. fmt.Println(errMsgLog)
  18483. saveLog(result, requestLog, "4101a", "上传清单")
  18484. var dat map[string]interface{}
  18485. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18486. fmt.Println(dat)
  18487. } else {
  18488. fmt.Println(err)
  18489. }
  18490. userJSONBytes, _ := json.Marshal(dat)
  18491. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18492. utils.ErrorLog("解析失败:%v", err)
  18493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18494. return
  18495. }
  18496. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18497. var pp models.PublicParams
  18498. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18499. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18500. pp.FixmedinsName = miConfig.OrgName
  18501. pp.FixmedinsCode = miConfig.Code
  18502. pp.RequestUrl = miConfig.Url
  18503. pp.Cainfo = miConfig.Cainfo
  18504. pp.SecretKey = miConfig.SecretKey
  18505. pp.AccessKey = miConfig.AccessKey
  18506. pp.OpterName = curRoles.UserName
  18507. client := &http.Client{}
  18508. var req *http.Request
  18509. data := make(map[string]interface{})
  18510. data["struct4101"] = struct4101
  18511. data["pp"] = pp
  18512. bytesData, _ := json.Marshal(data)
  18513. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  18514. resp, _ := client.Do(req)
  18515. defer resp.Body.Close()
  18516. body, ioErr := ioutil.ReadAll(resp.Body)
  18517. if ioErr != nil {
  18518. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18520. return
  18521. }
  18522. var respJSON map[string]interface{}
  18523. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18526. return
  18527. }
  18528. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18529. userJSONBytes, _ := json.Marshal(respJSON)
  18530. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18531. utils.ErrorLog("解析失败:%v", err)
  18532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18533. return
  18534. }
  18535. } else {
  18536. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  18537. var dat map[string]interface{}
  18538. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18539. fmt.Println(dat)
  18540. } else {
  18541. fmt.Println(err)
  18542. }
  18543. userJSONBytes, _ := json.Marshal(dat)
  18544. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18545. utils.ErrorLog("解析失败:%v", err)
  18546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18547. return
  18548. }
  18549. }
  18550. if res.Infcode != 0 {
  18551. c.ServeSuccessJSON(map[string]interface{}{
  18552. "failed_code": -10,
  18553. "msg": res.ErrMsg,
  18554. })
  18555. return
  18556. } else {
  18557. //order.FaPiaoNumber = zero
  18558. //order.FaPiaoCode = last_order.FaPiaoCode
  18559. //service.UpdateOrder(order)
  18560. hisFundSettleListResult := &models.HisFundSettleListResult{
  18561. Number: res.Output.SetlListId,
  18562. Status: 1,
  18563. Ctime: time.Now().Unix(),
  18564. Mtime: time.Now().Unix(),
  18565. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18566. IsUpload: 1,
  18567. OrderId: order_id,
  18568. }
  18569. service.CreateUploadRecord(hisFundSettleListResult)
  18570. c.ServeSuccessJSON(map[string]interface{}{
  18571. "msg": "上传成功",
  18572. "result": hisFundSettleListResult,
  18573. })
  18574. return
  18575. }
  18576. }
  18577. func (c *HisApiController) GetSettleListHospital() {
  18578. order_id, _ := c.GetInt64("order_id")
  18579. admin_user_id, _ := c.GetInt64("admin_user_id")
  18580. order, _ := service.GetHisOrderByIDTwo(order_id)
  18581. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18582. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  18583. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18584. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18585. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18586. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18587. if order.ID == 0 {
  18588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18589. return
  18590. }
  18591. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18592. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18593. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18594. fmt.Println(count)
  18595. var zero string
  18596. number := count + 1
  18597. if number >= 1000 {
  18598. zero = "0000" + strconv.FormatInt(number, 10)
  18599. } else if number >= 10000 {
  18600. zero = "000" + strconv.FormatInt(number, 10)
  18601. } else if number >= 100000 {
  18602. zero = "00" + strconv.FormatInt(number, 10)
  18603. } else if number >= 1000000 {
  18604. zero = "0" + strconv.FormatInt(number, 10)
  18605. } else {
  18606. zero = strconv.FormatInt(number, 10)
  18607. }
  18608. fmt.Println(zero)
  18609. struct4101 := service.Struct4101{
  18610. PsnNo: order.PsnNo,
  18611. MdtrtId: order.MdtrtId,
  18612. SetlId: order.SetlId,
  18613. PsnName: order.PsnName,
  18614. Gend: order.Gend,
  18615. Brdy: his.Brdy,
  18616. Age: int64(order.Age),
  18617. Naty: order.Naty,
  18618. PatnCertType: "01",
  18619. Certno: order.Certno,
  18620. Prfs: "90",
  18621. ConerName: roles[0].UserName,
  18622. PatnRlts: "99",
  18623. ConerAddr: miConfig.OrgName,
  18624. ConerTel: admin.Mobile,
  18625. HiType: order.Insutype,
  18626. Insuplc: miConfig.InsuplcAdmdvs,
  18627. MaindiagFlag: "1",
  18628. BillCode: order.SetlId,
  18629. BillNo: order.SetlId,
  18630. BizSn: order.Number,
  18631. PsnSelfPay: order.PsnPartAmt,
  18632. PsnOwnPay: order.PsnPartAmt,
  18633. AcctPay: order.AcctPay,
  18634. PsnCashpay: order.PsnCashPay,
  18635. HiPaymtd: "1",
  18636. Hsorg: miConfig.InsuplcAdmdvs,
  18637. HsorgOpter: miConfig.InsuplcAdmdvs,
  18638. MedinsFillPsn: curRoles.UserName,
  18639. MedinsFillDept: depart.Name,
  18640. IptMedType: "2",
  18641. AdmTime: his.InHosptialTime,
  18642. AdmEndTime: his.OutHosptialTime,
  18643. }
  18644. struct4101.SetlBegnDate = order.SetlTime
  18645. struct4101.SetlEndDate = order.SetlTime
  18646. //var rf []CustomFundPay
  18647. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18648. //
  18649. //var tempFunPays []service.CustomStruct
  18650. //for _, item := range rf {
  18651. // var tempFunPay service.CustomStruct
  18652. // tempFunPay.FundPayamt = item.FundPayamt
  18653. // tempFunPay.FundPayType = item.FundPayType
  18654. // tempFunPays = append(tempFunPays, tempFunPay)
  18655. //}
  18656. //struct4101.CustomStruct = tempFunPays
  18657. var tempDiaginfos []service.DiaginfoStructTwo
  18658. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18659. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18660. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  18661. //for _, item := range infos {
  18662. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  18663. //}
  18664. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  18665. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  18666. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18667. fmt.Println(diagnosis_ids_arr)
  18668. if order.UserOrgId == 10210 {
  18669. var diagnosis_ids_arr_two []int64
  18670. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  18671. var config []*models.HisXtDiagnoseConfig
  18672. for _, id := range diagnosis_ids_arr_two {
  18673. //id, _ := strconv.ParseInt(item, 10, 64)
  18674. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18675. if diagnosisConfig.ID > 0 {
  18676. config = append(config, &diagnosisConfig)
  18677. }
  18678. }
  18679. for index, item := range config {
  18680. if item.ID > 0 {
  18681. if index == 0 {
  18682. var tempDiaginfo service.DiaginfoStructTwo
  18683. tempDiaginfo.DiagCode = item.CountryCode
  18684. tempDiaginfo.DiagName = item.CountryContentName
  18685. tempDiaginfo.DiagType = "1"
  18686. tempDiaginfo.MaindiagFlag = "1"
  18687. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18688. } else {
  18689. var tempDiaginfo service.DiaginfoStructTwo
  18690. tempDiaginfo.DiagCode = item.CountryCode
  18691. tempDiaginfo.DiagName = item.CountryContentName
  18692. tempDiaginfo.DiagType = "1"
  18693. tempDiaginfo.MaindiagFlag = "0"
  18694. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18695. }
  18696. }
  18697. }
  18698. struct4101.Diseinfo = tempDiaginfos
  18699. } else {
  18700. var config []*models.HisXtDiagnoseConfig
  18701. for _, item := range diagnosis_ids_arr {
  18702. id, _ := strconv.ParseInt(item, 10, 64)
  18703. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18704. if diagnosisConfig.ID > 0 {
  18705. config = append(config, &diagnosisConfig)
  18706. }
  18707. }
  18708. for index, item := range config {
  18709. if item.ID > 0 {
  18710. if index == 0 {
  18711. var tempDiaginfo service.DiaginfoStructTwo
  18712. tempDiaginfo.DiagCode = item.CountryCode
  18713. tempDiaginfo.DiagName = item.CountryContentName
  18714. tempDiaginfo.DiagType = "1"
  18715. tempDiaginfo.MaindiagFlag = "1"
  18716. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18717. } else {
  18718. var tempDiaginfo service.DiaginfoStructTwo
  18719. tempDiaginfo.DiagCode = item.CountryCode
  18720. tempDiaginfo.DiagName = item.CountryContentName
  18721. tempDiaginfo.DiagType = "1"
  18722. tempDiaginfo.MaindiagFlag = "0"
  18723. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18724. }
  18725. }
  18726. }
  18727. struct4101.Diseinfo = tempDiaginfos
  18728. }
  18729. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18730. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18731. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18732. tempOpspdiseinfo2.OprnOprtCode = ""
  18733. tempOpspdiseinfo2.OprnOprtName = ""
  18734. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18735. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18736. var iteminfo service.IteminfoStruct
  18737. var bedCostTotal float64 = 0 //床位总费
  18738. var bedCostSelfTotal float64 = 0 //床位自费
  18739. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18740. var operationCostTotal float64 = 0 //手术费
  18741. var operationCostSelfTotal float64 = 0 //手术费
  18742. var operationCostPartSelfTotal float64 = 0 //手术费
  18743. var otherCostTotal float64 = 0 //其他费用
  18744. var otherCostSelfTotal float64 = 0 //其他费用
  18745. var otherCostPartSelfTotal float64 = 0 //其他费用
  18746. var materialCostTotal float64 = 0 //材料费
  18747. var materialCostSelfTotal float64 = 0 //材料费
  18748. var materialCostPartSelfTotal float64 = 0 //材料费
  18749. var westernMedicineCostTotal float64 = 0 //西药费
  18750. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18751. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18752. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18753. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18754. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18755. var checkCostTotal float64 = 0 //检查费
  18756. var checkCostSelfTotal float64 = 0 //检查费
  18757. var checkCostPartSelfTotal float64 = 0 //检查费
  18758. var laboratoryCostTotal float64 = 0 //化验费
  18759. var laboratoryCostSelfTotal float64 = 0 //化验费
  18760. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18761. var treatCostTotal float64 = 0 //治疗费用
  18762. var treatCostSelfTotal float64 = 0 //治疗费用
  18763. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18764. decimal.DivisionPrecision = 2
  18765. var bed_fulamt_ownpay_amt float64 = 0
  18766. var operation_fulamt_ownpay_amt float64 = 0
  18767. var other_fulamt_ownpay_amt float64 = 0
  18768. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18769. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18770. var check_fulamt_ownpay_amt float64 = 0
  18771. var material_fulamt_ownpay_amt float64 = 0
  18772. var laboratory_fulamt_ownpay_amt float64 = 0
  18773. var treat_fulamt_ownpay_amt float64 = 0
  18774. var bed_claa_sunmfee float64 = 0
  18775. var bed_clab_amt float64 = 0
  18776. var bed_other_amt float64 = 0
  18777. var operation_claa_sunmfee float64 = 0
  18778. var operation_clab_amt float64 = 0
  18779. var operation_other_amt float64 = 0
  18780. var other_claa_sunmfee float64 = 0
  18781. var other_clab_amt float64 = 0
  18782. var other_other_amt float64 = 0
  18783. var westernMedicine_claa_sunmfee float64 = 0
  18784. var westernMedicine_clab_amt float64 = 0
  18785. var westernMedicine_other_amt float64 = 0
  18786. var chineseTraditional_claa_sunmfee float64 = 0
  18787. var chineseTraditional_clab_amt float64 = 0
  18788. var chineseTraditional_other_amt float64 = 0
  18789. var check_claa_sunmfee float64 = 0
  18790. var check_clab_amt float64 = 0
  18791. var check_other_amt float64 = 0
  18792. var material_claa_sunmfee float64 = 0
  18793. var material_clab_amt float64 = 0
  18794. var material_other_amt float64 = 0
  18795. var laboratory_claa_sunmfee float64 = 0
  18796. var laboratory_clab_amt float64 = 0
  18797. var laboratory_other_amt float64 = 0
  18798. var treat_claa_sunmfee float64 = 0
  18799. var treat_clab_amt float64 = 0
  18800. var treat_other_amt float64 = 0
  18801. for _, item := range order.HisOrderInfo {
  18802. if item.MedChrgitmType == "01" { //床位费
  18803. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18804. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18805. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18806. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18807. if item.ChrgitmLv == "1" {
  18808. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18809. }
  18810. if item.ChrgitmLv == "2" {
  18811. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18812. }
  18813. if item.ChrgitmLv == "3" {
  18814. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18815. }
  18816. }
  18817. if item.MedChrgitmType == "03" { //检查费
  18818. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18819. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18820. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18821. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18822. if item.ChrgitmLv == "1" {
  18823. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18824. }
  18825. if item.ChrgitmLv == "2" {
  18826. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18827. }
  18828. if item.ChrgitmLv == "3" {
  18829. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18830. }
  18831. }
  18832. if item.MedChrgitmType == "04" { //化验费
  18833. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18834. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18835. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18836. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18837. if item.ChrgitmLv == "1" {
  18838. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18839. }
  18840. if item.ChrgitmLv == "2" {
  18841. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18842. }
  18843. if item.ChrgitmLv == "3" {
  18844. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18845. }
  18846. }
  18847. if item.MedChrgitmType == "05" { //治疗费
  18848. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18849. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18850. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18851. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18852. if item.ChrgitmLv == "1" {
  18853. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18854. }
  18855. if item.ChrgitmLv == "2" {
  18856. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18857. }
  18858. if item.ChrgitmLv == "3" {
  18859. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18860. }
  18861. }
  18862. if item.MedChrgitmType == "06" { //手术费
  18863. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18864. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18865. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18866. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18867. if item.ChrgitmLv == "1" {
  18868. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18869. }
  18870. if item.ChrgitmLv == "2" {
  18871. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18872. }
  18873. if item.ChrgitmLv == "3" {
  18874. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18875. }
  18876. }
  18877. if item.MedChrgitmType == "08" { //材料费
  18878. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18879. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18880. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18881. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18882. if item.ChrgitmLv == "1" {
  18883. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18884. }
  18885. if item.ChrgitmLv == "2" {
  18886. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18887. }
  18888. if item.ChrgitmLv == "3" {
  18889. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18890. }
  18891. }
  18892. if item.MedChrgitmType == "09" { //西药费
  18893. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18894. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18895. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18896. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18897. if item.ChrgitmLv == "1" {
  18898. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18899. }
  18900. if item.ChrgitmLv == "2" {
  18901. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18902. }
  18903. if item.ChrgitmLv == "3" {
  18904. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18905. }
  18906. }
  18907. if item.MedChrgitmType == "11" { //中成费
  18908. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18909. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18910. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18911. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18912. if item.ChrgitmLv == "1" {
  18913. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18914. }
  18915. if item.ChrgitmLv == "2" {
  18916. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18917. }
  18918. if item.ChrgitmLv == "3" {
  18919. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18920. }
  18921. }
  18922. if item.MedChrgitmType == "14" { //其他费
  18923. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18924. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18925. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18926. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18927. if item.ChrgitmLv == "1" {
  18928. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18929. }
  18930. if item.ChrgitmLv == "2" {
  18931. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18932. }
  18933. if item.ChrgitmLv == "3" {
  18934. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18935. }
  18936. }
  18937. }
  18938. var iteminfoStructs []service.IteminfoStruct
  18939. if bedCostTotal != 0 {
  18940. iteminfo.MedChrgitm = "01"
  18941. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18942. iteminfo.Amt = bedCostTotal
  18943. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18944. iteminfo.ClabAmt = bed_clab_amt
  18945. iteminfo.OthAmt = bed_other_amt
  18946. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18947. }
  18948. if checkCostTotal != 0 {
  18949. iteminfo.MedChrgitm = "03"
  18950. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18951. iteminfo.Amt = checkCostTotal
  18952. iteminfo.ClaaSumfee = check_claa_sunmfee
  18953. iteminfo.ClabAmt = check_clab_amt
  18954. iteminfo.OthAmt = check_other_amt
  18955. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18956. }
  18957. if laboratoryCostTotal != 0 {
  18958. iteminfo.MedChrgitm = "04"
  18959. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18960. iteminfo.Amt = laboratoryCostTotal
  18961. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18962. iteminfo.ClabAmt = laboratory_clab_amt
  18963. iteminfo.OthAmt = laboratory_other_amt
  18964. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18965. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18966. }
  18967. if treatCostTotal != 0 {
  18968. iteminfo.MedChrgitm = "05"
  18969. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18970. iteminfo.Amt = treatCostTotal
  18971. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18972. iteminfo.ClabAmt = treat_clab_amt
  18973. iteminfo.OthAmt = treat_other_amt
  18974. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18975. //(struct4101.IteminfoStruct, iteminfo)
  18976. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18977. }
  18978. if operationCostTotal != 0 {
  18979. iteminfo.MedChrgitm = "06"
  18980. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18981. iteminfo.Amt = operationCostTotal
  18982. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18983. iteminfo.ClabAmt = operation_clab_amt
  18984. iteminfo.OthAmt = operation_other_amt
  18985. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18986. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18987. }
  18988. if materialCostTotal != 0 {
  18989. iteminfo.MedChrgitm = "08"
  18990. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18991. iteminfo.Amt = materialCostTotal
  18992. iteminfo.ClaaSumfee = material_claa_sunmfee
  18993. iteminfo.ClabAmt = material_clab_amt
  18994. iteminfo.OthAmt = material_other_amt
  18995. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18996. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18997. }
  18998. if westernMedicineCostTotal != 0 {
  18999. iteminfo.MedChrgitm = "09"
  19000. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19001. iteminfo.Amt = westernMedicineCostTotal
  19002. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19003. iteminfo.ClabAmt = westernMedicine_clab_amt
  19004. iteminfo.OthAmt = westernMedicine_other_amt
  19005. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19006. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19007. }
  19008. if chineseTraditionalMedicineCostTotal != 0 {
  19009. iteminfo.MedChrgitm = "11"
  19010. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19011. iteminfo.Amt = westernMedicineCostTotal
  19012. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19013. iteminfo.ClabAmt = westernMedicine_clab_amt
  19014. iteminfo.OthAmt = westernMedicine_other_amt
  19015. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19016. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19017. }
  19018. if otherCostTotal != 0 {
  19019. iteminfo.MedChrgitm = "14"
  19020. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19021. iteminfo.Amt = otherCostTotal
  19022. iteminfo.ClaaSumfee = other_claa_sunmfee
  19023. iteminfo.ClabAmt = other_clab_amt
  19024. iteminfo.OthAmt = other_other_amt
  19025. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19026. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19027. }
  19028. struct4101.IteminfoStruct = iteminfoStructs
  19029. struct4101.Ntly = "中国"
  19030. struct4101.AdmCaty = "A03.06"
  19031. var resOther ResultSeventeenOther
  19032. var res ResultSeventeen
  19033. if miConfig.MdtrtareaAdmvs == "150499" {
  19034. var pp models.PublicParams
  19035. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19036. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19037. pp.FixmedinsName = miConfig.OrgName
  19038. pp.FixmedinsCode = miConfig.Code
  19039. pp.RequestUrl = miConfig.Url
  19040. pp.Cainfo = miConfig.Cainfo
  19041. pp.SecretKey = miConfig.SecretKey
  19042. pp.AccessKey = miConfig.AccessKey
  19043. pp.OpterName = curRoles.UserName
  19044. client := &http.Client{}
  19045. var req *http.Request
  19046. data := make(map[string]interface{})
  19047. data["struct4101"] = struct4101
  19048. data["pp"] = pp
  19049. bytesData, _ := json.Marshal(data)
  19050. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19051. resp, _ := client.Do(req)
  19052. defer resp.Body.Close()
  19053. body, ioErr := ioutil.ReadAll(resp.Body)
  19054. if ioErr != nil {
  19055. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19057. return
  19058. }
  19059. var respJSON map[string]interface{}
  19060. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19061. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19063. return
  19064. }
  19065. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19066. userJSONBytes, _ := json.Marshal(respJSON)
  19067. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19068. utils.ErrorLog("解析失败:%v", err)
  19069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19070. return
  19071. }
  19072. res.InfRefmsgid = resOther.InfRefmsgid
  19073. res.Output = resOther.Output
  19074. res.ErrMsg = resOther.ErrMsg
  19075. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19076. res.Infcode = infocode
  19077. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19078. var pp models.PublicParams
  19079. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19080. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19081. pp.FixmedinsName = miConfig.OrgName
  19082. pp.FixmedinsCode = miConfig.Code
  19083. pp.RequestUrl = miConfig.Url
  19084. pp.Cainfo = miConfig.Cainfo
  19085. pp.SecretKey = miConfig.SecretKey
  19086. pp.AccessKey = miConfig.AccessKey
  19087. pp.OpterName = curRoles.UserName
  19088. result, _ := service.Jxyb4101(struct4101, pp)
  19089. var dat map[string]interface{}
  19090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19091. fmt.Println(dat)
  19092. } else {
  19093. fmt.Println(err)
  19094. }
  19095. userJSONBytes, _ := json.Marshal(dat)
  19096. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19097. utils.ErrorLog("解析失败:%v", err)
  19098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19099. return
  19100. }
  19101. } else {
  19102. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19103. var dat map[string]interface{}
  19104. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19105. fmt.Println(dat)
  19106. } else {
  19107. fmt.Println(err)
  19108. }
  19109. userJSONBytes, _ := json.Marshal(dat)
  19110. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19111. utils.ErrorLog("解析失败:%v", err)
  19112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19113. return
  19114. }
  19115. }
  19116. if res.Infcode != 0 {
  19117. c.ServeSuccessJSON(map[string]interface{}{
  19118. "failed_code": -10,
  19119. "msg": res.ErrMsg,
  19120. })
  19121. return
  19122. } else {
  19123. if miConfig.MdtrtareaAdmvs != "150499" {
  19124. order.FaPiaoNumber = zero
  19125. order.FaPiaoCode = last_order.FaPiaoCode
  19126. service.UpdateOrder(order)
  19127. }
  19128. hisFundSettleListResult := &models.HisFundSettleListResult{
  19129. Number: res.Output.SetlListId,
  19130. Status: 1,
  19131. Ctime: time.Now().Unix(),
  19132. Mtime: time.Now().Unix(),
  19133. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19134. IsUpload: 1,
  19135. OrderId: order_id,
  19136. }
  19137. service.CreateUploadRecord(hisFundSettleListResult)
  19138. c.ServeSuccessJSON(map[string]interface{}{
  19139. "msg": "上传成功",
  19140. "result": hisFundSettleListResult,
  19141. })
  19142. return
  19143. }
  19144. }
  19145. //func (c *HisApiController) GetBatchSettleList() {
  19146. // orders, _ := service.GetAllHisOrder(10106)
  19147. // for _, item := range orders {
  19148. // order_id := item.ID
  19149. // order, _ := service.GetHisOrderByIDTwo(order_id)
  19150. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19151. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19152. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19153. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  19154. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19155. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19156. //
  19157. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19158. //
  19159. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19160. //
  19161. // if order.ID == 0 {
  19162. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19163. // return
  19164. // }
  19165. // if his.BalanceAccountsType == 2 {
  19166. // continue
  19167. // }
  19168. // struct4101 := service.Struct4101{
  19169. // PsnNo: order.PsnNo,
  19170. // MdtrtId: order.MdtrtId,
  19171. // SetlId: order.SetlId,
  19172. // PsnName: order.PsnName,
  19173. // Gend: order.Gend,
  19174. // Brdy: his.Brdy,
  19175. // Age: his.Age,
  19176. // Naty: order.Naty,
  19177. // PatnCertType: "01",
  19178. // Certno: order.Certno,
  19179. // Prfs: "90",
  19180. // ConerName: roles[0].UserName,
  19181. // PatnRlts: "99",
  19182. // ConerAddr: miConfig.OrgName,
  19183. // ConerTel: admin.Mobile,
  19184. // HiType: order.Insutype,
  19185. // Insuplc: his.InsuplcAdmdvs,
  19186. // MaindiagFlag: "1",
  19187. // BillCode: order.SetlId,
  19188. // BillNo: order.SetlId,
  19189. // BizSn: order.Number,
  19190. // PsnSelfPay: order.PsnPartAmt,
  19191. // PsnOwnPay: order.PsnPartAmt,
  19192. // AcctPay: order.AcctPay,
  19193. // PsnCashpay: order.PsnCashPay,
  19194. // HiPaymtd: "1",
  19195. // Hsorg: his.InsuplcAdmdvs,
  19196. // HsorgOpter: his.InsuplcAdmdvs,
  19197. // MedinsFillPsn: curRoles.UserName,
  19198. // MedinsFillDept: depart.Name,
  19199. // IptMedType: "2",
  19200. // }
  19201. // struct4101.SetlBegnDate = order.SetlTime
  19202. // struct4101.SetlEndDate = order.SetlTime
  19203. // //if order.SettleType == 1 {
  19204. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  19205. // // dateStr := t.Format("2006-01-02")
  19206. // // struct4101.SetlBegnDate = dateStr
  19207. // // struct4101.SetlEndDate = dateStr
  19208. // //} else {
  19209. // // t := time.Unix(int64(order.SettleStartTime), 0)
  19210. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  19211. // // dateStartStr := t.Format("2006-01-02")
  19212. // // dateEndStr := t2.Format("2006-01-02")
  19213. // // struct4101.SetlBegnDate = dateStartStr
  19214. // // struct4101.SetlEndDate = dateEndStr
  19215. // //}
  19216. //
  19217. // var rf []CustomFundPay
  19218. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  19219. //
  19220. // var tempFunPays []service.CustomStruct
  19221. // var tempFunPay610100 service.CustomStruct
  19222. //
  19223. // for _, item := range rf {
  19224. // if item.FundPayType == "610100" {
  19225. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  19226. // tempFunPay610100.FundPayType = item.FundPayType
  19227. // } else {
  19228. // var tempFunPay service.CustomStruct
  19229. // tempFunPay.FundPayamt = item.FundPayamt
  19230. // tempFunPay.FundPayType = item.FundPayType
  19231. // tempFunPays = append(tempFunPays, tempFunPay)
  19232. // }
  19233. // }
  19234. // tempFunPays = append(tempFunPays, tempFunPay610100)
  19235. // struct4101.CustomStruct = tempFunPays
  19236. //
  19237. // var tempDiaginfos []service.DiaginfoStructTwo
  19238. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19239. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19240. //
  19241. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19242. // var config []*models.HisXtDiagnoseConfig
  19243. // for _, item := range diagnosis_ids {
  19244. // id, _ := strconv.ParseInt(item, 10, 64)
  19245. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  19246. // config = append(config, &diagnosisConfig)
  19247. // }
  19248. //
  19249. // for index, item := range config {
  19250. // if index == 0 {
  19251. // var tempDiaginfo service.DiaginfoStructTwo
  19252. // tempDiaginfo.DiagCode = item.CountryCode
  19253. // tempDiaginfo.DiagName = item.CountryContentName
  19254. // tempDiaginfo.DiagType = "1"
  19255. // tempDiaginfo.MaindiagFlag = "1"
  19256. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19257. // } else {
  19258. //
  19259. // var tempDiaginfo service.DiaginfoStructTwo
  19260. // tempDiaginfo.DiagCode = item.CountryCode
  19261. // tempDiaginfo.DiagName = item.CountryContentName
  19262. // tempDiaginfo.DiagType = "2"
  19263. // tempDiaginfo.MaindiagFlag = "0"
  19264. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19265. // }
  19266. // }
  19267. // struct4101.Diseinfo = tempDiaginfos
  19268. //
  19269. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  19270. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19271. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19272. // tempOpspdiseinfo2.OprnOprtCode = ""
  19273. // tempOpspdiseinfo2.OprnOprtName = ""
  19274. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19275. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19276. //
  19277. // var iteminfo service.IteminfoStruct
  19278. //
  19279. // var bedCostTotal float64 = 0 //床位总费
  19280. // var bedCostSelfTotal float64 = 0 //床位自费
  19281. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19282. //
  19283. // var examineCostTotal float64 = 0 //诊查总费
  19284. // var examineCostSelfTotal float64 = 0 //诊查自费
  19285. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  19286. //
  19287. // var nursingCostTotal float64 = 0 //护理总费
  19288. // var nursingCostSelfTotal float64 = 0 //护理自费
  19289. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  19290. //
  19291. // var chineseMedicineCostTotal float64 = 0 //中成药
  19292. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  19293. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  19294. //
  19295. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  19296. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  19297. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  19298. //
  19299. // var registerCostTotal float64 = 0 //一般诊疗费
  19300. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  19301. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  19302. //
  19303. // var operationCostTotal float64 = 0 //手术费
  19304. // var operationCostSelfTotal float64 = 0 //手术费
  19305. // var operationCostPartSelfTotal float64 = 0 //手术费
  19306. //
  19307. // var otherCostTotal float64 = 0 //其他费用
  19308. // var otherCostSelfTotal float64 = 0 //其他费用
  19309. // var otherCostPartSelfTotal float64 = 0 //其他费用
  19310. //
  19311. // var materialCostTotal float64 = 0 //材料费
  19312. // var materialCostSelfTotal float64 = 0 //材料费
  19313. // var materialCostPartSelfTotal float64 = 0 //材料费
  19314. //
  19315. // var westernMedicineCostTotal float64 = 0 //西药费
  19316. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  19317. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19318. //
  19319. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19320. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19321. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19322. //
  19323. // var checkCostTotal float64 = 0 //检查费
  19324. // var checkCostSelfTotal float64 = 0 //检查费
  19325. // var checkCostPartSelfTotal float64 = 0 //检查费
  19326. //
  19327. // var laboratoryCostTotal float64 = 0 //化验费
  19328. // var laboratoryCostSelfTotal float64 = 0 //化验费
  19329. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19330. //
  19331. // var treatCostTotal float64 = 0 //治疗费用
  19332. // var treatCostSelfTotal float64 = 0 //治疗费用
  19333. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  19334. //
  19335. // decimal.DivisionPrecision = 2
  19336. //
  19337. // var bed_fulamt_ownpay_amt float64 = 0
  19338. //
  19339. // var examine_fulamt_ownpay_amt float64 = 0
  19340. //
  19341. // var nursing_fulamt_ownpay_amt float64 = 0
  19342. //
  19343. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  19344. //
  19345. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  19346. //
  19347. // var register_fulamt_ownpay_amt float64 = 0
  19348. //
  19349. // var operation_fulamt_ownpay_amt float64 = 0
  19350. // var other_fulamt_ownpay_amt float64 = 0
  19351. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  19352. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19353. // var check_fulamt_ownpay_amt float64 = 0
  19354. // var material_fulamt_ownpay_amt float64 = 0
  19355. // var laboratory_fulamt_ownpay_amt float64 = 0
  19356. // var treat_fulamt_ownpay_amt float64 = 0
  19357. //
  19358. // var bed_claa_sunmfee float64 = 0
  19359. // var bed_clab_amt float64 = 0
  19360. // var bed_other_amt float64 = 0
  19361. //
  19362. // var examine_claa_sunmfee float64 = 0
  19363. // var examine_clab_amt float64 = 0
  19364. // var examine_other_amt float64 = 0
  19365. //
  19366. // var nursing_claa_sunmfee float64 = 0
  19367. // var nursing_clab_amt float64 = 0
  19368. // var nursing_other_amt float64 = 0
  19369. //
  19370. // var chinese_medicine_claa_sunmfee float64 = 0
  19371. // var chinese_medicine_clab_amt float64 = 0
  19372. // var chinese_medicine_other_amt float64 = 0
  19373. //
  19374. // var commonly_treatment_claa_sunmfee float64 = 0
  19375. // var commonly_treatment_clab_amt float64 = 0
  19376. // var commonly_treatment_other_amt float64 = 0
  19377. //
  19378. // var operation_claa_sunmfee float64 = 0
  19379. // var operation_clab_amt float64 = 0
  19380. // var operation_other_amt float64 = 0
  19381. //
  19382. // var other_claa_sunmfee float64 = 0
  19383. // var other_clab_amt float64 = 0
  19384. // var other_other_amt float64 = 0
  19385. //
  19386. // var westernMedicine_claa_sunmfee float64 = 0
  19387. // var westernMedicine_clab_amt float64 = 0
  19388. // var westernMedicine_other_amt float64 = 0
  19389. //
  19390. // var chineseTraditional_claa_sunmfee float64 = 0
  19391. // var chineseTraditional_clab_amt float64 = 0
  19392. // var chineseTraditional_other_amt float64 = 0
  19393. //
  19394. // var check_claa_sunmfee float64 = 0
  19395. // var check_clab_amt float64 = 0
  19396. // var check_other_amt float64 = 0
  19397. //
  19398. // var material_claa_sunmfee float64 = 0
  19399. // var material_clab_amt float64 = 0
  19400. // var material_other_amt float64 = 0
  19401. //
  19402. // var laboratory_claa_sunmfee float64 = 0
  19403. // var laboratory_clab_amt float64 = 0
  19404. // var laboratory_other_amt float64 = 0
  19405. //
  19406. // var treat_claa_sunmfee float64 = 0
  19407. // var treat_clab_amt float64 = 0
  19408. // var treat_other_amt float64 = 0
  19409. //
  19410. // var register_claa_sunmfee float64 = 0
  19411. // var register_clab_amt float64 = 0
  19412. // var register_other_amt float64 = 0
  19413. //
  19414. // for _, item := range order.HisOrderInfo {
  19415. // if item.MedChrgitmType == "01" { //床位费
  19416. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19417. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19418. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19419. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19420. // if item.ChrgitmLv == "1" {
  19421. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19422. // }
  19423. // if item.ChrgitmLv == "2" {
  19424. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19425. //
  19426. // }
  19427. // if item.ChrgitmLv == "3" {
  19428. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19429. // }
  19430. //
  19431. // }
  19432. //
  19433. // if item.MedChrgitmType == "02" { //诊查
  19434. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19435. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19436. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19437. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19438. // if item.ChrgitmLv == "1" {
  19439. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19440. // }
  19441. // if item.ChrgitmLv == "2" {
  19442. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19443. //
  19444. // }
  19445. // if item.ChrgitmLv == "3" {
  19446. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19447. // }
  19448. //
  19449. // }
  19450. //
  19451. // if item.MedChrgitmType == "03" { //检查费
  19452. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19453. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19454. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19455. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19456. // if item.ChrgitmLv == "1" {
  19457. //
  19458. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19459. //
  19460. // }
  19461. // if item.ChrgitmLv == "2" {
  19462. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19463. //
  19464. // }
  19465. // if item.ChrgitmLv == "3" {
  19466. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19467. // }
  19468. // }
  19469. //
  19470. // if item.MedChrgitmType == "04" { //化验费
  19471. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19472. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19473. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19474. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19475. // if item.ChrgitmLv == "1" {
  19476. //
  19477. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19478. //
  19479. // }
  19480. // if item.ChrgitmLv == "2" {
  19481. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19482. //
  19483. // }
  19484. // if item.ChrgitmLv == "3" {
  19485. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19486. // }
  19487. // }
  19488. //
  19489. // if item.MedChrgitmType == "05" { //治疗费
  19490. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19491. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19492. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19493. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19494. // if item.ChrgitmLv == "1" {
  19495. //
  19496. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19497. //
  19498. // }
  19499. // if item.ChrgitmLv == "2" {
  19500. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19501. //
  19502. // }
  19503. // if item.ChrgitmLv == "3" {
  19504. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19505. // }
  19506. // }
  19507. //
  19508. // if item.MedChrgitmType == "06" { //手术费
  19509. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19510. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19511. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19512. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19513. //
  19514. // if item.ChrgitmLv == "1" {
  19515. //
  19516. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19517. //
  19518. // }
  19519. // if item.ChrgitmLv == "2" {
  19520. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19521. //
  19522. // }
  19523. // if item.ChrgitmLv == "3" {
  19524. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19525. // }
  19526. // }
  19527. //
  19528. // if item.MedChrgitmType == "07" { //手术费
  19529. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19530. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19531. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19532. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19533. //
  19534. // if item.ChrgitmLv == "1" {
  19535. //
  19536. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19537. //
  19538. // }
  19539. // if item.ChrgitmLv == "2" {
  19540. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19541. //
  19542. // }
  19543. // if item.ChrgitmLv == "3" {
  19544. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19545. // }
  19546. // }
  19547. //
  19548. // if item.MedChrgitmType == "08" { //材料费
  19549. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19550. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19551. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19552. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19553. // if item.ChrgitmLv == "1" {
  19554. //
  19555. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19556. //
  19557. // }
  19558. // if item.ChrgitmLv == "2" {
  19559. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19560. //
  19561. // }
  19562. // if item.ChrgitmLv == "3" {
  19563. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19564. // }
  19565. // }
  19566. // if item.MedChrgitmType == "09" { //西药费
  19567. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19568. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19569. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19570. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19571. // if item.ChrgitmLv == "1" {
  19572. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19573. // }
  19574. // if item.ChrgitmLv == "2" {
  19575. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19576. // }
  19577. // if item.ChrgitmLv == "3" {
  19578. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19579. // }
  19580. // }
  19581. // if item.MedChrgitmType == "10" { //中药饮片
  19582. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19583. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19584. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19585. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19586. // if item.ChrgitmLv == "1" {
  19587. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19588. // }
  19589. // if item.ChrgitmLv == "2" {
  19590. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19591. // }
  19592. // if item.ChrgitmLv == "3" {
  19593. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19594. // }
  19595. // }
  19596. //
  19597. // if item.MedChrgitmType == "11" { //中成费
  19598. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19599. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19600. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19601. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19602. // if item.ChrgitmLv == "1" {
  19603. //
  19604. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19605. //
  19606. // }
  19607. // if item.ChrgitmLv == "2" {
  19608. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19609. //
  19610. // }
  19611. // if item.ChrgitmLv == "3" {
  19612. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19613. // }
  19614. // }
  19615. //
  19616. // if item.MedChrgitmType == "12" { //中成费
  19617. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19618. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19619. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19620. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19621. // if item.ChrgitmLv == "1" {
  19622. //
  19623. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19624. //
  19625. // }
  19626. // if item.ChrgitmLv == "2" {
  19627. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19628. //
  19629. // }
  19630. // if item.ChrgitmLv == "3" {
  19631. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19632. // }
  19633. // }
  19634. //
  19635. // if item.MedChrgitmType == "13" { //中成费
  19636. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19637. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19638. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19639. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19640. // if item.ChrgitmLv == "1" {
  19641. //
  19642. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19643. //
  19644. // }
  19645. // if item.ChrgitmLv == "2" {
  19646. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19647. //
  19648. // }
  19649. // if item.ChrgitmLv == "3" {
  19650. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19651. // }
  19652. // }
  19653. //
  19654. // if item.MedChrgitmType == "14" { //其他费
  19655. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19656. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19657. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19658. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19659. // if item.ChrgitmLv == "1" {
  19660. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19661. //
  19662. // }
  19663. // if item.ChrgitmLv == "2" {
  19664. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19665. //
  19666. // }
  19667. // if item.ChrgitmLv == "3" {
  19668. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19669. // }
  19670. // }
  19671. //
  19672. // }
  19673. //
  19674. // var iteminfoStructs []service.IteminfoStruct
  19675. //
  19676. // if bedCostTotal != 0 {
  19677. // iteminfo.MedChrgitm = "01"
  19678. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19679. // iteminfo.Amt = bedCostTotal
  19680. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  19681. // iteminfo.ClabAmt = bed_clab_amt
  19682. // iteminfo.OthAmt = bed_other_amt
  19683. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19684. // }
  19685. //
  19686. // if examineCostTotal != 0 {
  19687. // iteminfo.MedChrgitm = "02"
  19688. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  19689. // iteminfo.Amt = examineCostTotal
  19690. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  19691. // iteminfo.ClabAmt = examine_clab_amt
  19692. // iteminfo.OthAmt = examine_other_amt
  19693. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19694. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19695. // }
  19696. //
  19697. // if checkCostTotal != 0 {
  19698. // iteminfo.MedChrgitm = "03"
  19699. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19700. // iteminfo.Amt = checkCostTotal
  19701. // iteminfo.ClaaSumfee = check_claa_sunmfee
  19702. // iteminfo.ClabAmt = check_clab_amt
  19703. // iteminfo.OthAmt = check_other_amt
  19704. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19705. //
  19706. // }
  19707. //
  19708. // if laboratoryCostTotal != 0 {
  19709. // iteminfo.MedChrgitm = "04"
  19710. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19711. // iteminfo.Amt = laboratoryCostTotal
  19712. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19713. // iteminfo.ClabAmt = laboratory_clab_amt
  19714. // iteminfo.OthAmt = laboratory_other_amt
  19715. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19716. //
  19717. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19718. //
  19719. // }
  19720. //
  19721. // if treatCostTotal != 0 {
  19722. // iteminfo.MedChrgitm = "05"
  19723. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19724. // iteminfo.Amt = treatCostTotal
  19725. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  19726. // iteminfo.ClabAmt = treat_clab_amt
  19727. // iteminfo.OthAmt = treat_other_amt
  19728. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19729. // //(struct4101.IteminfoStruct, iteminfo)
  19730. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19731. // }
  19732. //
  19733. // if operationCostTotal != 0 {
  19734. // iteminfo.MedChrgitm = "06"
  19735. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19736. // iteminfo.Amt = operationCostTotal
  19737. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  19738. // iteminfo.ClabAmt = operation_clab_amt
  19739. // iteminfo.OthAmt = operation_other_amt
  19740. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19741. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19742. // }
  19743. //
  19744. // if nursingCostTotal != 0 {
  19745. // iteminfo.MedChrgitm = "07"
  19746. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  19747. // iteminfo.Amt = nursingCostTotal
  19748. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  19749. // iteminfo.ClabAmt = nursing_clab_amt
  19750. // iteminfo.OthAmt = nursing_other_amt
  19751. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19752. // }
  19753. //
  19754. // if materialCostTotal != 0 {
  19755. // iteminfo.MedChrgitm = "08"
  19756. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19757. // iteminfo.Amt = materialCostTotal
  19758. // iteminfo.ClaaSumfee = material_claa_sunmfee
  19759. // iteminfo.ClabAmt = material_clab_amt
  19760. // iteminfo.OthAmt = material_other_amt
  19761. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19762. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19763. // }
  19764. //
  19765. // if westernMedicineCostTotal != 0 {
  19766. // iteminfo.MedChrgitm = "09"
  19767. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19768. // iteminfo.Amt = westernMedicineCostTotal
  19769. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19770. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19771. // iteminfo.OthAmt = westernMedicine_other_amt
  19772. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19773. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19774. //
  19775. // }
  19776. //
  19777. // if chineseMedicineCostTotal != 0 {
  19778. // iteminfo.MedChrgitm = "10"
  19779. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  19780. // iteminfo.Amt = chineseMedicineCostTotal
  19781. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  19782. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  19783. // iteminfo.OthAmt = chinese_medicine_other_amt
  19784. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19785. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19786. //
  19787. // }
  19788. //
  19789. // if chineseTraditionalMedicineCostTotal != 0 {
  19790. // iteminfo.MedChrgitm = "11"
  19791. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19792. // iteminfo.Amt = westernMedicineCostTotal
  19793. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19794. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19795. // iteminfo.OthAmt = westernMedicine_other_amt
  19796. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19797. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19798. //
  19799. // }
  19800. //
  19801. // if commonlyTreatmentCostTotal != 0 {
  19802. // iteminfo.MedChrgitm = "12"
  19803. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  19804. // iteminfo.Amt = commonlyTreatmentCostTotal
  19805. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  19806. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  19807. // iteminfo.OthAmt = commonly_treatment_other_amt
  19808. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19809. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19810. //
  19811. // }
  19812. //
  19813. // if registerCostTotal != 0 {
  19814. // iteminfo.MedChrgitm = "13"
  19815. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  19816. // iteminfo.Amt = registerCostTotal
  19817. // iteminfo.ClaaSumfee = register_claa_sunmfee
  19818. // iteminfo.ClabAmt = register_clab_amt
  19819. // iteminfo.OthAmt = register_other_amt
  19820. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19821. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19822. //
  19823. // }
  19824. //
  19825. // if otherCostTotal != 0 {
  19826. // iteminfo.MedChrgitm = "14"
  19827. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19828. // iteminfo.Amt = otherCostTotal
  19829. // iteminfo.ClaaSumfee = other_claa_sunmfee
  19830. // iteminfo.ClabAmt = other_clab_amt
  19831. // iteminfo.OthAmt = other_other_amt
  19832. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19833. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19834. //
  19835. // }
  19836. // struct4101.IteminfoStruct = iteminfoStructs
  19837. // time_arr := strings.Split(order.SetlTime, " ")
  19838. // struct4101.AdmTime = time_arr[0]
  19839. // struct4101.AdmEndTime = time_arr[0]
  19840. //
  19841. // struct4101.DoctorName = doctor.UserName
  19842. // struct4101.DoctorCode = doctor.DoctorNumber
  19843. //
  19844. // struct4101.Ntly = "中国"
  19845. // struct4101.AdmCaty = "A03.06"
  19846. // var res ResultSeventeen
  19847. // if miConfig.MdtrtareaAdmvs == "421300" {
  19848. // data := make(map[string]interface{})
  19849. // data["struct4101"] = struct4101
  19850. // data["secret_key"] = miConfig.SecretKey
  19851. // data["org_name"] = miConfig.OrgName
  19852. // data["opera"] = curRoles.UserName
  19853. // data["code"] = miConfig.Code
  19854. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  19855. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19856. //
  19857. // client := &http.Client{}
  19858. // bytesData, _ := json.Marshal(data)
  19859. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  19860. // resp, _ := client.Do(req)
  19861. // defer resp.Body.Close()
  19862. // body, ioErr := ioutil.ReadAll(resp.Body)
  19863. // if ioErr != nil {
  19864. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19865. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19866. // return
  19867. // }
  19868. // var respJSON map[string]interface{}
  19869. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19870. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19871. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19872. // return
  19873. // }
  19874. //
  19875. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19876. // userJSONBytes, _ := json.Marshal(respJSON)
  19877. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19878. // utils.ErrorLog("解析失败:%v", err)
  19879. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19880. // adminUser := c.GetAdminUserInfo()
  19881. // errlog := &models.HisOrderError{
  19882. // UserOrgId: adminUser.CurrentOrgId,
  19883. // Ctime: time.Now().Unix(),
  19884. // Mtime: time.Now().Unix(),
  19885. // ErrMsg: res.ErrMsg + "解析失败",
  19886. // Status: 1,
  19887. // PatientId: order_id,
  19888. // Stage: 10088,
  19889. // }
  19890. // service.CreateErrMsgLog(errlog)
  19891. // continue
  19892. // }
  19893. //
  19894. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  19895. // data := make(map[string]interface{})
  19896. // data["struct4101"] = struct4101
  19897. // data["secret_key"] = miConfig.SecretKey
  19898. // data["org_name"] = miConfig.OrgName
  19899. // data["opera"] = curRoles.UserName
  19900. // data["code"] = miConfig.Code
  19901. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  19902. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19903. //
  19904. // client := &http.Client{}
  19905. // bytesData, _ := json.Marshal(data)
  19906. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  19907. // resp, _ := client.Do(req)
  19908. // defer resp.Body.Close()
  19909. // body, ioErr := ioutil.ReadAll(resp.Body)
  19910. // if ioErr != nil {
  19911. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19913. // return
  19914. // }
  19915. // var respJSON map[string]interface{}
  19916. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19917. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19919. // return
  19920. // }
  19921. //
  19922. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19923. // userJSONBytes, _ := json.Marshal(respJSON)
  19924. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19925. // utils.ErrorLog("解析失败:%v", err)
  19926. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19927. // adminUser := c.GetAdminUserInfo()
  19928. // errlog := &models.HisOrderError{
  19929. // UserOrgId: adminUser.CurrentOrgId,
  19930. // Ctime: time.Now().Unix(),
  19931. // Mtime: time.Now().Unix(),
  19932. // ErrMsg: res.ErrMsg + "解析失败",
  19933. // Status: 1,
  19934. // PatientId: order_id,
  19935. // Stage: 10088,
  19936. // }
  19937. // service.CreateErrMsgLog(errlog)
  19938. // continue
  19939. // }
  19940. //
  19941. // } else {
  19942. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  19943. // fmt.Println(result)
  19944. //
  19945. // var dat map[string]interface{}
  19946. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19947. // fmt.Println(dat)
  19948. // } else {
  19949. // fmt.Println(err)
  19950. // }
  19951. // userJSONBytes, _ := json.Marshal(dat)
  19952. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19953. // utils.ErrorLog("解析失败:%v", err)
  19954. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19955. // adminUser := c.GetAdminUserInfo()
  19956. // errlog := &models.HisOrderError{
  19957. // UserOrgId: adminUser.CurrentOrgId,
  19958. // Ctime: time.Now().Unix(),
  19959. // Mtime: time.Now().Unix(),
  19960. // ErrMsg: res.ErrMsg + "解析失败",
  19961. // Status: 1,
  19962. // PatientId: order_id,
  19963. // Stage: 10106,
  19964. // }
  19965. // service.CreateErrMsgLog(errlog)
  19966. // continue
  19967. // }
  19968. // }
  19969. //
  19970. // if res.Infcode != 0 {
  19971. // adminUser := c.GetAdminUserInfo()
  19972. // errlog := &models.HisOrderError{
  19973. // UserOrgId: adminUser.CurrentOrgId,
  19974. // Ctime: time.Now().Unix(),
  19975. // Mtime: time.Now().Unix(),
  19976. // ErrMsg: res.ErrMsg,
  19977. // Status: 1,
  19978. // PatientId: order_id,
  19979. // Stage: 10106,
  19980. // }
  19981. // service.CreateErrMsgLog(errlog)
  19982. // continue
  19983. // } else {
  19984. // hisFundSettleListResult := &models.HisFundSettleListResult{
  19985. // Number: res.Output.SetlListId,
  19986. // Status: 1,
  19987. // Ctime: time.Now().Unix(),
  19988. // Mtime: time.Now().Unix(),
  19989. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19990. // IsUpload: 1,
  19991. // OrderId: order_id,
  19992. // }
  19993. // service.CreateUploadRecord(hisFundSettleListResult)
  19994. // continue
  19995. // }
  19996. // }
  19997. //}
  19998. func (c *HisApiController) GetOrgInfo() {
  19999. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  20000. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  20001. }
  20002. func (c *HisApiController) GetHisPatientInfo() {
  20003. medical_insurance_card := c.GetString("medical_insurance_card")
  20004. id_card_type, _ := c.GetInt64("id_card_type")
  20005. id_card := c.GetString("id_card")
  20006. adminInfo := c.GetAdminUserInfo()
  20007. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  20008. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  20009. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  20010. IdCardNo := ""
  20011. if id_card_type == 1 {
  20012. IdCardNo = medical_insurance_card
  20013. } else if id_card_type == 2 {
  20014. IdCardNo = id_card
  20015. }
  20016. if config.IsOpen == 1 {
  20017. 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
  20018. resp, requestErr := http.Get(api)
  20019. if requestErr != nil {
  20020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20021. return
  20022. }
  20023. defer resp.Body.Close()
  20024. body, ioErr := ioutil.ReadAll(resp.Body)
  20025. if ioErr != nil {
  20026. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20028. return
  20029. }
  20030. var respJSON map[string]interface{}
  20031. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20032. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20034. return
  20035. }
  20036. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20037. userJSONBytes, _ := json.Marshal(userJSON)
  20038. var res ResultTwo
  20039. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20040. utils.ErrorLog("解析失败:%v", err)
  20041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20042. return
  20043. }
  20044. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  20045. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  20046. infoStr := string(Iinfos)
  20047. idetinfoStr := string(Idetinfos)
  20048. if res.Infcode == 0 {
  20049. his := models.VMHisPatient{
  20050. Status: 1,
  20051. Ctime: time.Now().Unix(),
  20052. Mtime: time.Now().Unix(),
  20053. PsnNo: res.Output.Baseinfo.PsnNo,
  20054. PsnCertType: res.Output.Baseinfo.PsnCertType,
  20055. Certno: res.Output.Baseinfo.Certno,
  20056. PsnName: res.Output.Baseinfo.PsnName,
  20057. Gend: res.Output.Baseinfo.Gend,
  20058. Naty: res.Output.Baseinfo.Naty,
  20059. Iinfo: infoStr,
  20060. Idetinfo: idetinfoStr,
  20061. UserOrgId: adminInfo.CurrentOrgId,
  20062. IsReturn: 1,
  20063. IdCardType: id_card_type,
  20064. }
  20065. c.ServeSuccessJSON(map[string]interface{}{
  20066. "info": his,
  20067. })
  20068. } else {
  20069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  20070. return
  20071. }
  20072. }
  20073. }
  20074. //func GetBasBaseInfo() (jsonStr string, err error) {
  20075. //
  20076. // handle := syscall.NewLazyDLL("SSCard.dll")
  20077. // add := handle.NewProc("ReadCardBas")
  20078. // str := make([]byte, 1024)
  20079. // str1 := make([]byte, 1024)
  20080. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  20081. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  20082. //
  20083. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  20084. //
  20085. // fmt.Println("> Add(4,5)的结果为:", ret)
  20086. // handle.Release()
  20087. //
  20088. // return "", nil
  20089. //
  20090. //}
  20091. //func GetQRBaseInfo() (jsonStr string, err error) {
  20092. // handle := syscall.LoadDLL("SSCard.dll")
  20093. // ReadCardBas := handle.FindProc("GetQRBase")
  20094. //
  20095. // str := make([]byte, 256)
  20096. // str1 := make([]byte, 256)
  20097. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  20098. //
  20099. // fmt.Println(string(str))
  20100. // fmt.Println(r)
  20101. // return string(str), nil
  20102. //}
  20103. //func CardInit() int {
  20104. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  20105. // add := DllTestDef.MustFindProc("Init")
  20106. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  20107. // if err != nil {
  20108. // fmt.Println("SSCard的运算结果为:", ret)
  20109. // }
  20110. // result := int(ret)
  20111. // return result
  20112. //}
  20113. //func CardInit() int {
  20114. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  20115. // if err != nil {
  20116. // fmt.Println("SSCard的运算结果为:", ret)
  20117. // }
  20118. // fmt.Println(err)
  20119. // result := int(ret)
  20120. // return result
  20121. //}
  20122. func IntPtr(n int) uintptr {
  20123. return uintptr(n)
  20124. }
  20125. func StrPtr(s string) uintptr {
  20126. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  20127. }
  20128. type Result2001 struct {
  20129. Cainfo interface{} `json:"cainfo"`
  20130. ErrMsg string `json:"err_msg"`
  20131. InfRefmsgid string `json:"inf_refmsgid"`
  20132. Infcode int64 `json:"infcode"`
  20133. Output struct {
  20134. Trtinfo struct {
  20135. PsnNo string `json:"psn_no"`
  20136. TrtChkType string `json:"trt_chk_type"`
  20137. FundPayType string `json:"fund_pay_type"`
  20138. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  20139. Begndate string `json:"begndate"`
  20140. Enddate string `json:"enddate"`
  20141. TrtChkRslt string `json:"trt_chk_rslt"`
  20142. } `json:"trtinfo"`
  20143. } `json:"output"`
  20144. RefmsgTime string `json:"refmsg_time"`
  20145. RespondTime string `json:"respond_time"`
  20146. Signtype interface{} `json:"signtype"`
  20147. WarnMsg interface{} `json:"warn_msg"`
  20148. }
  20149. type Result2001Org10265 struct {
  20150. Cainfo interface{} `json:"cainfo"`
  20151. ErrMsg string `json:"err_msg"`
  20152. InfRefmsgid string `json:"inf_refmsgid"`
  20153. Infcode string `json:"infcode"`
  20154. Output struct {
  20155. Trtinfo struct {
  20156. PsnNo string `json:"psn_no"`
  20157. TrtChkType string `json:"trt_chk_type"`
  20158. FundPayType string `json:"fund_pay_type"`
  20159. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  20160. Begndate string `json:"begndate"`
  20161. Enddate string `json:"enddate"`
  20162. TrtChkRslt string `json:"trt_chk_rslt"`
  20163. } `json:"trtinfo"`
  20164. } `json:"output"`
  20165. RefmsgTime string `json:"refmsg_time"`
  20166. RespondTime string `json:"respond_time"`
  20167. Signtype interface{} `json:"signtype"`
  20168. WarnMsg interface{} `json:"warn_msg"`
  20169. }
  20170. type ResultTwo struct {
  20171. ErrMsg string `json:"err_msg"`
  20172. InfRefmsgid string `json:"inf_refmsgid"`
  20173. Infcode int64 `json:"infcode"`
  20174. Output struct {
  20175. Baseinfo struct {
  20176. //Brdy string `json:"brdy"`
  20177. Certno string `json:"certno"`
  20178. Gend string `json:"gend"`
  20179. Naty string `json:"naty"`
  20180. PsnCertType string `json:"psn_cert_type"`
  20181. PsnName string `json:"psn_name"`
  20182. PsnNo string `json:"psn_no"`
  20183. } `json:"baseinfo"`
  20184. Idetinfo []interface{} `json:"idetinfo"`
  20185. Iinfo []struct {
  20186. Balc float64 `json:"balc"`
  20187. CvlservFlag string `json:"cvlserv_flag"`
  20188. EmpName string `json:"emp_name"`
  20189. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  20190. Insutype string `json:"insutype"`
  20191. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  20192. //PausInsuDate string `json:"paus_insu_date"`
  20193. //PsnInsuDate string `json:"psn_insu_date"`
  20194. PsnInsuStas string `json:"psn_insu_stas"`
  20195. PsnType string `json:"psn_type"`
  20196. } `json:"insuinfo"`
  20197. } `json:"output"`
  20198. RefmsgTime string `json:"refmsg_time"`
  20199. RespondTime string `json:"respond_time"`
  20200. Signtype interface{} `json:"signtype"`
  20201. WarnInfo interface{} `json:"warn_info"`
  20202. }
  20203. type ResultTwo10265 struct {
  20204. ErrMsg string `json:"err_msg"`
  20205. InfRefmsgid string `json:"inf_refmsgid"`
  20206. Infcode string `json:"infcode"`
  20207. Output struct {
  20208. Baseinfo struct {
  20209. //Brdy string `json:"brdy"`
  20210. Certno string `json:"certno"`
  20211. Gend string `json:"gend"`
  20212. Naty string `json:"naty"`
  20213. PsnCertType string `json:"psn_cert_type"`
  20214. PsnName string `json:"psn_name"`
  20215. PsnNo string `json:"psn_no"`
  20216. } `json:"baseinfo"`
  20217. Idetinfo []interface{} `json:"idetinfo"`
  20218. Iinfo []struct {
  20219. Balc float64 `json:"balc"`
  20220. CvlservFlag string `json:"cvlserv_flag"`
  20221. EmpName string `json:"emp_name"`
  20222. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  20223. Insutype string `json:"insutype"`
  20224. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  20225. PsnInsuStas string `json:"psn_insu_stas"`
  20226. PsnType string `json:"psn_type"`
  20227. } `json:"insuinfo"`
  20228. } `json:"output"`
  20229. RefmsgTime string `json:"refmsg_time"`
  20230. RespondTime string `json:"respond_time"`
  20231. Signtype interface{} `json:"signtype"`
  20232. WarnInfo interface{} `json:"warn_info"`
  20233. }
  20234. type ResultThree struct {
  20235. Cainfo interface{} `json:"cainfo"`
  20236. ErrMsg string `json:"err_msg"`
  20237. InfRefmsgid string `json:"inf_refmsgid"`
  20238. Infcode int64 `json:"infcode"`
  20239. Output struct {
  20240. Data struct {
  20241. IptOtpNo string `json:"ipt_otp_no"`
  20242. MdtrtID string `json:"mdtrt_id"`
  20243. PsnNo string `json:"psn_no"`
  20244. } `json:"data"`
  20245. } `json:"output"`
  20246. RefmsgTime string `json:"refmsg_time"`
  20247. RespondTime string `json:"respond_time"`
  20248. Signtype interface{} `json:"signtype"`
  20249. WarnMsg interface{} `json:"warn_msg"`
  20250. }
  20251. type ResultThree10265 struct {
  20252. Cainfo interface{} `json:"cainfo"`
  20253. ErrMsg string `json:"err_msg"`
  20254. InfRefmsgid string `json:"inf_refmsgid"`
  20255. Infcode string `json:"infcode"`
  20256. Output struct {
  20257. Data struct {
  20258. IptOtpNo string `json:"ipt_otp_no"`
  20259. MdtrtID string `json:"mdtrt_id"`
  20260. PsnNo string `json:"psn_no"`
  20261. } `json:"data"`
  20262. } `json:"output"`
  20263. RefmsgTime string `json:"refmsg_time"`
  20264. RespondTime string `json:"respond_time"`
  20265. Signtype interface{} `json:"signtype"`
  20266. WarnMsg interface{} `json:"warn_msg"`
  20267. }
  20268. type ResultFour struct {
  20269. Cainfo string `json:"cainfo"`
  20270. ErrMsg string `json:"err_msg"`
  20271. InfRefmsgid string `json:"inf_refmsgid"`
  20272. Infcode int64 `json:"infcode"`
  20273. Output struct {
  20274. Result []struct {
  20275. BasMednFlag string `json:"bas_medn_flag"`
  20276. ChldMedcFlag string `json:"chld_medc_flag"`
  20277. ChrgitmLv string `json:"chrgitm_lv"`
  20278. Cnt float64 `json:"cnt"`
  20279. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  20280. DrtReimFlag string `json:"drt_reim_flag"`
  20281. FeedetlSn string `json:"feedetl_sn"`
  20282. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20283. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  20284. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20285. ListSpItemFlag string `json:"list_sp_item_flag"`
  20286. LmtUsedFlag string `json:"lmt_used_flag"`
  20287. MedChrgitmType string `json:"med_chrgitm_type"`
  20288. Memo string `json:"memo"`
  20289. OverlmtAmt float64 `json:"overlmt_amt"`
  20290. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20291. Pric float64 `json:"pric"`
  20292. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  20293. SelfpayProp float64 `json:"selfpay_prop"`
  20294. } `json:"result"`
  20295. } `json:"output"`
  20296. RefmsgTime string `json:"refmsg_time"`
  20297. RespondTime string `json:"respond_time"`
  20298. Signtype string `json:"signtype"`
  20299. WarnMsg string `json:"warn_msg"`
  20300. }
  20301. type ResultFour10265 struct {
  20302. Cainfo string `json:"cainfo"`
  20303. ErrMsg string `json:"err_msg"`
  20304. InfRefmsgid string `json:"inf_refmsgid"`
  20305. Infcode string `json:"infcode"`
  20306. Output struct {
  20307. Result []struct {
  20308. BasMednFlag string `json:"bas_medn_flag"`
  20309. ChldMedcFlag string `json:"chld_medc_flag"`
  20310. ChrgitmLv string `json:"chrgitm_lv"`
  20311. Cnt float64 `json:"cnt"`
  20312. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  20313. DrtReimFlag string `json:"drt_reim_flag"`
  20314. FeedetlSn string `json:"feedetl_sn"`
  20315. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20316. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  20317. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20318. ListSpItemFlag string `json:"list_sp_item_flag"`
  20319. LmtUsedFlag string `json:"lmt_used_flag"`
  20320. MedChrgitmType string `json:"med_chrgitm_type"`
  20321. Memo string `json:"memo"`
  20322. OverlmtAmt float64 `json:"overlmt_amt"`
  20323. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20324. Pric float64 `json:"pric"`
  20325. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  20326. SelfpayProp float64 `json:"selfpay_prop"`
  20327. } `json:"result"`
  20328. } `json:"output"`
  20329. RefmsgTime string `json:"refmsg_time"`
  20330. RespondTime string `json:"respond_time"`
  20331. Signtype string `json:"signtype"`
  20332. WarnMsg string `json:"warn_msg"`
  20333. }
  20334. type ResultMemo struct {
  20335. InsuAdmdvs string `json:"insuAdmdvs"`
  20336. }
  20337. // [{"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}]
  20338. type ResultIDInfo struct {
  20339. Begntime string `json:"begntime"`
  20340. Endtime string `json:"endtime"`
  20341. Memo string `json:"memo"`
  20342. }
  20343. type ResultFive struct {
  20344. Balc float64 `json:"balc"`
  20345. CvlservFlag string `json:"cvlserv_flag"`
  20346. EmpName string `json:"emp_name"`
  20347. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  20348. Insutype string `json:"insutype"`
  20349. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  20350. PausInsuDate string `json:"paus_insu_date"`
  20351. PsnInsuDate string `json:"psn_insu_date"`
  20352. PsnInsuStas string `json:"psn_insu_stas"`
  20353. PsnType string `json:"psn_type"`
  20354. }
  20355. type ResultSix struct {
  20356. Cainfo interface{} `json:"cainfo"`
  20357. ErrMsg string `json:"err_msg"`
  20358. InfRefmsgid string `json:"inf_refmsgid"`
  20359. Infcode int64 `json:"infcode"`
  20360. Output struct {
  20361. } `json:"output"`
  20362. RefmsgTime string `json:"refmsg_time"`
  20363. RespondTime string `json:"respond_time"`
  20364. Signtype interface{} `json:"signtype"`
  20365. WarnMsg interface{} `json:"warn_msg"`
  20366. }
  20367. type FJ3507Result struct {
  20368. Cainfo interface{} `json:"cainfo"`
  20369. ErrMsg string `json:"err_msg"`
  20370. InfRefmsgid string `json:"inf_refmsgid"`
  20371. Infcode int64 `json:"infcode"`
  20372. Output struct {
  20373. retRslt string `json:"retRslt"`
  20374. msgRslt string `json:"msgRslt"`
  20375. } `json:"output"`
  20376. RefmsgTime string `json:"refmsg_time"`
  20377. RespondTime string `json:"respond_time"`
  20378. Signtype interface{} `json:"signtype"`
  20379. WarnMsg interface{} `json:"warn_msg"`
  20380. }
  20381. type FJ3507ResultFor10188 struct {
  20382. Cainfo interface{} `json:"cainfo"`
  20383. ErrMsg string `json:"err_msg"`
  20384. InfRefmsgid string `json:"inf_refmsgid"`
  20385. Infcode string `json:"infcode"`
  20386. RefmsgTime string `json:"refmsg_time"`
  20387. RespondTime string `json:"respond_time"`
  20388. Signtype interface{} `json:"signtype"`
  20389. WarnMsg interface{} `json:"warn_msg"`
  20390. }
  20391. type Result2406 struct {
  20392. Cainfo interface{} `json:"cainfo"`
  20393. ErrMsg string `json:"err_msg"`
  20394. InfRefmsgid string `json:"inf_refmsgid"`
  20395. Infcode int64 `json:"infcode"`
  20396. Output struct {
  20397. Result struct {
  20398. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  20399. } `json:"result"`
  20400. } `json:"output"`
  20401. RefmsgTime string `json:"refmsg_time"`
  20402. RespondTime string `json:"respond_time"`
  20403. Signtype interface{} `json:"signtype"`
  20404. WarnMsg interface{} `json:"warn_msg"`
  20405. }
  20406. type GZResultSix struct {
  20407. Cainfo interface{} `json:"cainfo"`
  20408. ErrMsg string `json:"err_msg"`
  20409. InfRefmsgid string `json:"inf_refmsgid"`
  20410. Infcode int64 `json:"infcode"`
  20411. Output string `json:"output"`
  20412. RefmsgTime string `json:"refmsg_time"`
  20413. RespondTime string `json:"respond_time"`
  20414. Signtype interface{} `json:"signtype"`
  20415. WarnMsg interface{} `json:"warn_msg"`
  20416. }
  20417. type ResultSix10265 struct {
  20418. Cainfo interface{} `json:"cainfo"`
  20419. ErrMsg string `json:"err_msg"`
  20420. InfRefmsgid string `json:"inf_refmsgid"`
  20421. Infcode string `json:"infcode"`
  20422. Output struct {
  20423. } `json:"output"`
  20424. RefmsgTime string `json:"refmsg_time"`
  20425. RespondTime string `json:"respond_time"`
  20426. Signtype interface{} `json:"signtype"`
  20427. WarnMsg interface{} `json:"warn_msg"`
  20428. }
  20429. type ResultSeven struct {
  20430. Cainfo string `json:"cainfo"`
  20431. ErrMsg string `json:"err_msg"`
  20432. InfRefmsgid string `json:"inf_refmsgid"`
  20433. Infcode int64 `json:"infcode"`
  20434. Output struct {
  20435. Setlinfo struct {
  20436. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  20437. AcctPay float64 `json:"acct_pay"`
  20438. ActPayDedc float64 `json:"act_pay_dedc"`
  20439. Age float64 `json:"age"`
  20440. Balc float64 `json:"balc"`
  20441. Certno string `json:"certno"`
  20442. ClrOptins string `json:"clr_optins"`
  20443. ClrType string `json:"clr_type"`
  20444. ClrWay string `json:"clr_way"`
  20445. CvlservFlag string `json:"cvlserv_flag"`
  20446. CvlservPay float64 `json:"cvlserv_pay"`
  20447. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20448. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20449. Gend string `json:"gend"`
  20450. HifesPay float64 `json:"hifes_pay"`
  20451. HifmiPay float64 `json:"hifmi_pay"`
  20452. HifpPay float64 `json:"hifp_pay"`
  20453. HospPartAmt float64 `json:"hosp_part_amt"`
  20454. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20455. Insutype string `json:"insutype"`
  20456. MafPay float64 `json:"maf_pay"`
  20457. MdtrtCertType string `json:"mdtrt_cert_type"`
  20458. HifobPay float64 `json:"hifob_pay"`
  20459. MdtrtID string `json:"mdtrt_id"`
  20460. MedType string `json:"med_type"`
  20461. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20462. MedinsSetlID string `json:"medins_setl_id"`
  20463. Naty string `json:"naty"`
  20464. OthPay float64 `json:"oth_pay"`
  20465. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20466. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20467. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20468. PsnCashPay float64 `json:"psn_cash_pay"`
  20469. PsnCertType string `json:"psn_cert_type"`
  20470. PsnName string `json:"psn_name"`
  20471. PsnNo string `json:"psn_no"`
  20472. PsnPartAmt float64 `json:"psn_part_amt"`
  20473. PsnType string `json:"psn_type"`
  20474. SetlID string `json:"setl_id"`
  20475. SetlTime string `json:"setl_time"`
  20476. } `json:"setlinfo"`
  20477. Setldetail interface{} `json:"setldetail"`
  20478. } `json:"output"`
  20479. RefmsgTime string `json:"refmsg_time"`
  20480. RespondTime string `json:"respond_time"`
  20481. Signtype interface{} `json:"signtype"`
  20482. WarnMsg interface{} `json:"warn_msg"`
  20483. }
  20484. type ResultSevenAH struct {
  20485. Cainfo string `json:"cainfo"`
  20486. ErrMsg string `json:"err_msg"`
  20487. InfRefmsgid string `json:"inf_refmsgid"`
  20488. Infcode int64 `json:"infcode"`
  20489. Output struct {
  20490. Setlinfo struct {
  20491. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  20492. AcctPay float64 `json:"acct_pay"`
  20493. ActPayDedc float64 `json:"act_pay_dedc"`
  20494. Age float64 `json:"age"`
  20495. Balc float64 `json:"balc"`
  20496. Certno string `json:"certno"`
  20497. ClrOptins string `json:"clr_optins"`
  20498. ClrType string `json:"clr_type"`
  20499. ClrWay string `json:"clr_way"`
  20500. CvlservFlag string `json:"cvlserv_flag"`
  20501. CvlservPay float64 `json:"cvlserv_pay"`
  20502. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20503. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20504. Gend string `json:"gend"`
  20505. HifesPay float64 `json:"hifes_pay"`
  20506. HifmiPay float64 `json:"hifmi_pay"`
  20507. HifpPay float64 `json:"hifp_pay"`
  20508. HospPartAmt float64 `json:"hosp_part_amt"`
  20509. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20510. Insutype string `json:"insutype"`
  20511. MafPay float64 `json:"maf_pay"`
  20512. MdtrtCertType string `json:"mdtrt_cert_type"`
  20513. HifobPay float64 `json:"hifob_pay"`
  20514. MdtrtID string `json:"mdtrt_id"`
  20515. MedType string `json:"med_type"`
  20516. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20517. MedinsSetlID string `json:"medins_setl_id"`
  20518. Naty string `json:"naty"`
  20519. OthPay float64 `json:"oth_pay"`
  20520. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20521. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20522. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20523. PsnCashPay float64 `json:"psn_cash_pay"`
  20524. PsnCertType string `json:"psn_cert_type"`
  20525. PsnName string `json:"psn_name"`
  20526. PsnNo string `json:"psn_no"`
  20527. PsnPartAmt float64 `json:"psn_part_amt"`
  20528. PsnType string `json:"psn_type"`
  20529. SetlID string `json:"setl_id"`
  20530. SetlTime int64 `json:"setl_time"`
  20531. } `json:"setlinfo"`
  20532. Setldetail interface{} `json:"setldetail"`
  20533. } `json:"output"`
  20534. RefmsgTime string `json:"refmsg_time"`
  20535. RespondTime string `json:"respond_time"`
  20536. Signtype interface{} `json:"signtype"`
  20537. WarnMsg interface{} `json:"warn_msg"`
  20538. }
  20539. type ResultSeven10265 struct {
  20540. Cainfo string `json:"cainfo"`
  20541. ErrMsg string `json:"err_msg"`
  20542. InfRefmsgid string `json:"inf_refmsgid"`
  20543. Infcode string `json:"infcode"`
  20544. Output struct {
  20545. Setlinfo struct {
  20546. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  20547. AcctPay float64 `json:"acct_pay"`
  20548. ActPayDedc float64 `json:"act_pay_dedc"`
  20549. Age float64 `json:"age"`
  20550. Balc float64 `json:"balc"`
  20551. Certno string `json:"certno"`
  20552. ClrOptins string `json:"clr_optins"`
  20553. ClrType string `json:"clr_type"`
  20554. ClrWay string `json:"clr_way"`
  20555. CvlservFlag string `json:"cvlserv_flag"`
  20556. CvlservPay float64 `json:"cvlserv_pay"`
  20557. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20558. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20559. Gend string `json:"gend"`
  20560. HifesPay float64 `json:"hifes_pay"`
  20561. HifmiPay float64 `json:"hifmi_pay"`
  20562. HifpPay float64 `json:"hifp_pay"`
  20563. HospPartAmt float64 `json:"hosp_part_amt"`
  20564. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20565. Insutype string `json:"insutype"`
  20566. MafPay float64 `json:"maf_pay"`
  20567. MdtrtCertType string `json:"mdtrt_cert_type"`
  20568. HifobPay float64 `json:"hifob_pay"`
  20569. MdtrtID string `json:"mdtrt_id"`
  20570. MedType string `json:"med_type"`
  20571. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20572. MedinsSetlID string `json:"medins_setl_id"`
  20573. Naty string `json:"naty"`
  20574. OthPay float64 `json:"oth_pay"`
  20575. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20576. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20577. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20578. PsnCashPay float64 `json:"psn_cash_pay"`
  20579. PsnCertType string `json:"psn_cert_type"`
  20580. PsnName string `json:"psn_name"`
  20581. PsnNo string `json:"psn_no"`
  20582. PsnPartAmt float64 `json:"psn_part_amt"`
  20583. PsnType string `json:"psn_type"`
  20584. SetlID string `json:"setl_id"`
  20585. SetlTime string `json:"setl_time"`
  20586. } `json:"setlinfo"`
  20587. Setldetail interface{} `json:"setldetail"`
  20588. } `json:"output"`
  20589. RefmsgTime string `json:"refmsg_time"`
  20590. RespondTime string `json:"respond_time"`
  20591. Signtype interface{} `json:"signtype"`
  20592. WarnMsg interface{} `json:"warn_msg"`
  20593. }
  20594. type ResultSeven10265Two struct {
  20595. Cainfo string `json:"cainfo"`
  20596. ErrMsg string `json:"err_msg"`
  20597. InfRefmsgid string `json:"inf_refmsgid"`
  20598. Infcode string `json:"infcode"`
  20599. Output struct {
  20600. Setlinfo struct {
  20601. AcctMulaidPay string `json:"acct_mulaid_pay"`
  20602. AcctPay float64 `json:"acct_pay"`
  20603. ActPayDedc float64 `json:"act_pay_dedc"`
  20604. Age float64 `json:"age"`
  20605. Balc float64 `json:"balc"`
  20606. Certno string `json:"certno"`
  20607. ClrOptins string `json:"clr_optins"`
  20608. ClrType string `json:"clr_type"`
  20609. ClrWay string `json:"clr_way"`
  20610. CvlservFlag string `json:"cvlserv_flag"`
  20611. CvlservPay float64 `json:"cvlserv_pay"`
  20612. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20613. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20614. Gend string `json:"gend"`
  20615. HifesPay float64 `json:"hifes_pay"`
  20616. HifmiPay float64 `json:"hifmi_pay"`
  20617. HifpPay float64 `json:"hifp_pay"`
  20618. HospPartAmt string `json:"hosp_part_amt"`
  20619. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20620. Insutype string `json:"insutype"`
  20621. MafPay float64 `json:"maf_pay"`
  20622. MdtrtCertType string `json:"mdtrt_cert_type"`
  20623. HifobPay float64 `json:"hifob_pay"`
  20624. MdtrtID string `json:"mdtrt_id"`
  20625. MedType string `json:"med_type"`
  20626. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20627. MedinsSetlID string `json:"medins_setl_id"`
  20628. Naty string `json:"naty"`
  20629. OthPay float64 `json:"oth_pay"`
  20630. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20631. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  20632. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20633. PsnCashPay float64 `json:"psn_cash_pay"`
  20634. PsnCertType string `json:"psn_cert_type"`
  20635. PsnName string `json:"psn_name"`
  20636. PsnNo string `json:"psn_no"`
  20637. PsnPartAmt float64 `json:"psn_part_amt"`
  20638. PsnType string `json:"psn_type"`
  20639. SetlID string `json:"setl_id"`
  20640. SetlTime string `json:"setl_time"`
  20641. } `json:"setlinfo"`
  20642. Setldetail interface{} `json:"setldetail"`
  20643. } `json:"output"`
  20644. RefmsgTime string `json:"refmsg_time"`
  20645. RespondTime string `json:"respond_time"`
  20646. Signtype interface{} `json:"signtype"`
  20647. WarnMsg interface{} `json:"warn_msg"`
  20648. }
  20649. type GZResultSeven10265Two struct {
  20650. Cainfo string `json:"cainfo"`
  20651. ErrMsg string `json:"err_msg"`
  20652. InfRefmsgid string `json:"inf_refmsgid"`
  20653. Infcode int64 `json:"infcode"`
  20654. Output struct {
  20655. Setlinfo struct {
  20656. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  20657. AcctPay float64 `json:"acct_pay"`
  20658. ActPayDedc float64 `json:"act_pay_dedc"`
  20659. Age float64 `json:"age"`
  20660. Balc float64 `json:"balc"`
  20661. Certno string `json:"certno"`
  20662. ClrOptins string `json:"clr_optins"`
  20663. ClrType string `json:"clr_type"`
  20664. ClrWay string `json:"clr_way"`
  20665. CvlservFlag string `json:"cvlserv_flag"`
  20666. CvlservPay float64 `json:"cvlserv_pay"`
  20667. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20668. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20669. Gend string `json:"gend"`
  20670. HifesPay float64 `json:"hifes_pay"`
  20671. HifmiPay float64 `json:"hifmi_pay"`
  20672. HifpPay float64 `json:"hifp_pay"`
  20673. HospPartAmt float64 `json:"hosp_part_amt"`
  20674. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20675. Insutype string `json:"insutype"`
  20676. MafPay float64 `json:"maf_pay"`
  20677. MdtrtCertType string `json:"mdtrt_cert_type"`
  20678. HifobPay float64 `json:"hifob_pay"`
  20679. MdtrtID string `json:"mdtrt_id"`
  20680. MedType string `json:"med_type"`
  20681. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20682. MedinsSetlID string `json:"medins_setl_id"`
  20683. Naty string `json:"naty"`
  20684. OthPay float64 `json:"oth_pay"`
  20685. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20686. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  20687. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20688. PsnCashPay float64 `json:"psn_cash_pay"`
  20689. PsnCertType string `json:"psn_cert_type"`
  20690. PsnName string `json:"psn_name"`
  20691. PsnNo string `json:"psn_no"`
  20692. PsnPartAmt float64 `json:"psn_part_amt"`
  20693. PsnType string `json:"psn_type"`
  20694. SetlID string `json:"setl_id"`
  20695. SetlTime string `json:"setl_time"`
  20696. } `json:"setlinfo"`
  20697. Setldetail interface{} `json:"setldetail"`
  20698. } `json:"output"`
  20699. RefmsgTime string `json:"refmsg_time"`
  20700. RespondTime string `json:"respond_time"`
  20701. Signtype interface{} `json:"signtype"`
  20702. WarnMsg interface{} `json:"warn_msg"`
  20703. }
  20704. type ResultEight struct {
  20705. Cainfo string `json:"cainfo"`
  20706. ErrMsg string `json:"err_msg"`
  20707. InfRefmsgid string `json:"inf_refmsgid"`
  20708. Infcode int64 `json:"infcode"`
  20709. Output struct {
  20710. Stmtinfo struct {
  20711. SetlOptins string `json:"setl_optins"`
  20712. StmtRslt string `json:"stmt_rslt"`
  20713. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  20714. } `json:"stmtinfo"`
  20715. } `json:"output"`
  20716. RefmsgTime string `json:"refmsg_time"`
  20717. RespondTime string `json:"respond_time"`
  20718. Signtype interface{} `json:"signtype"`
  20719. WarnMsg interface{} `json:"warn_msg"`
  20720. }
  20721. type ResultEightFor10188 struct {
  20722. Cainfo string `json:"cainfo"`
  20723. ErrMsg string `json:"err_msg"`
  20724. InfRefmsgid string `json:"inf_refmsgid"`
  20725. Infcode string `json:"infcode"`
  20726. Output struct {
  20727. Stmtinfo struct {
  20728. SetlOptins string `json:"setl_optins"`
  20729. StmtRslt string `json:"stmt_rslt"`
  20730. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  20731. } `json:"stmtinfo"`
  20732. } `json:"output"`
  20733. RefmsgTime string `json:"refmsg_time"`
  20734. RespondTime string `json:"respond_time"`
  20735. Signtype interface{} `json:"signtype"`
  20736. WarnMsg interface{} `json:"warn_msg"`
  20737. }
  20738. type ResultNine struct {
  20739. Cainfo string `json:"cainfo"`
  20740. ErrMsg string `json:"err_msg"`
  20741. InfRefmsgid string `json:"inf_refmsgid"`
  20742. Infcode int64 `json:"infcode"`
  20743. Output struct {
  20744. FileQuryNo string `json:"file_qury_no"`
  20745. } `json:"output"`
  20746. RefmsgTime string `json:"refmsg_time"`
  20747. RespondTime string `json:"respond_time"`
  20748. Signtype interface{} `json:"signtype"`
  20749. WarnMsg interface{} `json:"warn_msg"`
  20750. }
  20751. type ResultTen struct {
  20752. Cainfo string `json:"cainfo"`
  20753. ErrMsg string `json:"err_msg"`
  20754. InfRefmsgid string `json:"inf_refmsgid"`
  20755. Infcode int64 `json:"infcode"`
  20756. Output struct {
  20757. Fileinfo struct {
  20758. DldEndtime string `json:"dld_endtime"`
  20759. FileQuryNo string `json:"file_qury_no"`
  20760. Filename string `json:"filename"`
  20761. } `json:"fileinfo"`
  20762. } `json:"output"`
  20763. RefmsgTime string `json:"refmsg_time"`
  20764. RespondTime string `json:"respond_time"`
  20765. Signtype interface{} `json:"signtype"`
  20766. WarnMsg interface{} `json:"warn_msg"`
  20767. }
  20768. type Result5262 struct {
  20769. ErrMsg string `json:"err_msg"`
  20770. InfRefmsgid string `json:"inf_refmsgid"`
  20771. Infcode int64 `json:"infcode"`
  20772. Output struct {
  20773. PageInfo struct {
  20774. Size int `json:"size"`
  20775. RecordCounts int `json:"record_counts"`
  20776. } `json:"page_info"`
  20777. Idetinfo []interface{} `json:"idetinfo"`
  20778. Result []struct {
  20779. SetlID string `json:"setl_id"`
  20780. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  20781. MdtrtID string `json:"mdtrt_id"`
  20782. InitSetlID string `json:"init_setl_id,omitempty"`
  20783. PsnNo string `json:"psn_no"`
  20784. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  20785. PsnName string `json:"psn_name"`
  20786. PsnCertType string `json:"psn_cert_type"`
  20787. Certno string `json:"certno"`
  20788. Gend string `json:"gend,omitempty"`
  20789. Naty string `json:"naty,omitempty"`
  20790. Brdy string `json:"brdy,omitempty"`
  20791. Age float64 `json:"age,omitempty"`
  20792. Insutype string `json:"insutype,omitempty"`
  20793. PsnType string `json:"psn_type"`
  20794. CvlservFlag string `json:"cvlserv_flag"`
  20795. CvlservLv string `json:"cvlserv_lv,omitempty"`
  20796. SpPsnType string `json:"sp_psn_type,omitempty"`
  20797. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  20798. ClctGrde string `json:"clct_grde,omitempty"`
  20799. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  20800. NwbFlag string `json:"nwb_flag,omitempty"`
  20801. InsuAdmdvs string `json:"insu_admdvs"`
  20802. EmpNo string `json:"emp_no,omitempty"`
  20803. EmpName string `json:"emp_name,omitempty"`
  20804. EmpType string `json:"emp_type,omitempty"`
  20805. EconType string `json:"econ_type,omitempty"`
  20806. AfilIndu string `json:"afil_indu,omitempty"`
  20807. AfilRlts string `json:"afil_rlts,omitempty"`
  20808. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  20809. PayLoc string `json:"pay_loc,omitempty"`
  20810. FixmedinsCode string `json:"fixmedins_code"`
  20811. FixmedinsName string `json:"fixmedins_name"`
  20812. HospLv string `json:"hosp_lv,omitempty"`
  20813. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  20814. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  20815. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  20816. Begndate string `json:"begndate"`
  20817. Enddate string `json:"enddate"`
  20818. SetlTime string `json:"setl_time"`
  20819. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  20820. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  20821. MedType string `json:"med_type"`
  20822. SetlType string `json:"setl_type,omitempty"`
  20823. ClrType string `json:"clr_type,omitempty"`
  20824. ClrWay string `json:"clr_way,omitempty"`
  20825. PsnSetlway string `json:"psn_setlway,omitempty"`
  20826. ClrOptins string `json:"clr_optins,omitempty"`
  20827. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  20828. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  20829. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  20830. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  20831. InscpAmt float64 `json:"inscp_amt,omitempty"`
  20832. DedcStd float64 `json:"dedc_std,omitempty"`
  20833. CrtDedc float64 `json:"crt_dedc,omitempty"`
  20834. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  20835. HifpPay float64 `json:"hifp_pay,omitempty"`
  20836. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  20837. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  20838. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  20839. HifesPay float64 `json:"hifes_pay,omitempty"`
  20840. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  20841. HifobPay float64 `json:"hifob_pay,omitempty"`
  20842. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  20843. MafPay float64 `json:"maf_pay,omitempty"`
  20844. OthfundPay float64 `json:"othfund_pay,omitempty"`
  20845. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  20846. PsnPay float64 `json:"psn_pay,omitempty"`
  20847. AcctPay float64 `json:"acct_pay,omitempty"`
  20848. CashPayamt float64 `json:"cash_payamt,omitempty"`
  20849. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  20850. Balc float64 `json:"balc,omitempty"`
  20851. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  20852. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  20853. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  20854. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  20855. Year string `json:"year,omitempty"`
  20856. DiseNo string `json:"dise_no,omitempty"`
  20857. DiseName string `json:"dise_name,omitempty"`
  20858. Invono string `json:"invono,omitempty"`
  20859. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  20860. ValiFlag string `json:"vali_flag,omitempty"`
  20861. Memo string `json:"memo,omitempty"`
  20862. Rid string `json:"rid"`
  20863. UpdtTime string `json:"updt_time,omitempty"`
  20864. CrterID string `json:"crter_id,omitempty"`
  20865. CrterName string `json:"crter_name,omitempty"`
  20866. CrteTime string `json:"crte_time,omitempty"`
  20867. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  20868. OpterID string `json:"opter_id,omitempty"`
  20869. OpterName string `json:"opter_name,omitempty"`
  20870. OptTime string `json:"opt_time,omitempty"`
  20871. OptinsNo string `json:"optins_no,omitempty"`
  20872. PoolareaNo string `json:"poolarea_no,omitempty"`
  20873. } `json:"result"`
  20874. } `json:"output"`
  20875. RefmsgTime string `json:"refmsg_time"`
  20876. RespondTime string `json:"respond_time"`
  20877. Signtype interface{} `json:"signtype"`
  20878. WarnInfo interface{} `json:"warn_info"`
  20879. }
  20880. type Result5267 struct {
  20881. ErrMsg string `json:"err_msg"`
  20882. InfRefmsgid string `json:"inf_refmsgid"`
  20883. Infcode int64 `json:"infcode"`
  20884. Output struct {
  20885. PageInfo struct {
  20886. Size int `json:"size"`
  20887. RecordCounts int `json:"record_counts"`
  20888. } `json:"pageinfo"`
  20889. Result []struct {
  20890. SetlID string `json:"setl_id"`
  20891. ClrOptins string `json:"clr_optins"`
  20892. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  20893. MdtrtID string `json:"mdtrt_id"`
  20894. InitSetlID string `json:"init_setl_id,omitempty"`
  20895. PsnNo string `json:"psn_no"`
  20896. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  20897. PsnName string `json:"psn_name"`
  20898. PsnCertType string `json:"psn_cert_type"`
  20899. Certno string `json:"certno"`
  20900. Gend string `json:"gend,omitempty"`
  20901. Naty string `json:"naty,omitempty"`
  20902. Brdy string `json:"brdy,omitempty"`
  20903. Age float64 `json:"age,omitempty"`
  20904. Insutype string `json:"insutype,omitempty"`
  20905. PsnType string `json:"psn_type"`
  20906. CvlservFlag string `json:"cvlserv_flag"`
  20907. CvlservLv string `json:"cvlserv_lv,omitempty"`
  20908. SpPsnType string `json:"sp_psn_type,omitempty"`
  20909. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  20910. ClctGrde string `json:"clct_grde,omitempty"`
  20911. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  20912. NwbFlag string `json:"nwb_flag,omitempty"`
  20913. InsuAdmdvs string `json:"insu_admdvs"`
  20914. EmpNo string `json:"emp_no,omitempty"`
  20915. EmpName string `json:"emp_name,omitempty"`
  20916. EmpType string `json:"emp_type,omitempty"`
  20917. EconType string `json:"econ_type,omitempty"`
  20918. AfilIndu string `json:"afil_indu,omitempty"`
  20919. AfilRlts string `json:"afil_rlts,omitempty"`
  20920. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  20921. PayLoc string `json:"pay_loc,omitempty"`
  20922. FixmedinsCode string `json:"fixmedins_code"`
  20923. FixmedinsName string `json:"fixmedins_name"`
  20924. HospLv string `json:"hosp_lv,omitempty"`
  20925. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  20926. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  20927. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  20928. Begndate string `json:"begndate,omitempty"`
  20929. Enddate string `json:"enddate,omitempty"`
  20930. SetlTime string `json:"setl_time,omitempty"`
  20931. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  20932. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  20933. MedType string `json:"med_type"`
  20934. SetlType string `json:"setl_type,omitempty"`
  20935. ClrType string `json:"clr_type,omitempty"`
  20936. ClrWay string `json:"clr_way,omitempty"`
  20937. PsnSetlway string `json:"psn_setlway,omitempty"`
  20938. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  20939. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  20940. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  20941. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  20942. InscpAmt float64 `json:"inscp_amt,omitempty"`
  20943. DedcStd float64 `json:"dedc_std,omitempty"`
  20944. CrtDedc float64 `json:"crt_dedc,omitempty"`
  20945. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  20946. HifpPay float64 `json:"hifp_pay,omitempty"`
  20947. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  20948. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  20949. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  20950. HifesPay float64 `json:"hifes_pay,omitempty"`
  20951. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  20952. HifobPay float64 `json:"hifob_pay,omitempty"`
  20953. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  20954. MafPay float64 `json:"maf_pay,omitempty"`
  20955. OthfundPay float64 `json:"othfund_pay,omitempty"`
  20956. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  20957. PsnPay float64 `json:"psn_pay,omitempty"`
  20958. AcctPay float64 `json:"acct_pay,omitempty"`
  20959. CashPayamt float64 `json:"cash_payamt,omitempty"`
  20960. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  20961. Balc float64 `json:"balc,omitempty"`
  20962. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  20963. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  20964. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  20965. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  20966. Year string `json:"year,omitempty"`
  20967. DiseNo string `json:"dise_no,omitempty"`
  20968. DiseName string `json:"dise_name,omitempty"`
  20969. Invono string `json:"invono,omitempty"`
  20970. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  20971. Memo string `json:"memo,omitempty"`
  20972. UpdtTime string `json:"updt_time,omitempty"`
  20973. OpterID string `json:"opter_id,omitempty"`
  20974. OpterName string `json:"opter_name,omitempty"`
  20975. OptTime string `json:"opt_time,omitempty"`
  20976. OptinsNo string `json:"optins_no,omitempty"`
  20977. PoolareaNo string `json:"poolarea_no,omitempty"`
  20978. } `json:"result"`
  20979. } `json:"output"`
  20980. RefmsgTime string `json:"refmsg_time"`
  20981. RespondTime string `json:"respond_time"`
  20982. Signtype interface{} `json:"signtype"`
  20983. WarnInfo interface{} `json:"warn_info"`
  20984. }
  20985. // type Autogenerated struct {
  20986. // Output struct {
  20987. // Setlinfo struct {
  20988. // SetlTime string `json:"setl_time"`
  20989. // CvlservPay float64 `json:"cvlserv_pay"`
  20990. // Year string `json:"year"`
  20991. // MedType string `json:"med_type"`
  20992. // PsnPay float64 `json:"psn_pay"`
  20993. // OpterID string `json:"opter_id"`
  20994. // Begndate string `json:"begndate"`
  20995. // FlxempeFlag string `json:"flxempe_flag"`
  20996. // HifmiPay float64 `json:"hifmi_pay"`
  20997. // PsnNo string `json:"psn_no"`
  20998. // ActPayDedc float64 `json:"act_pay_dedc"`
  20999. // MedinsSetlID interface{} `json:"medins_setl_id"`
  21000. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  21001. // ClrWay string `json:"clr_way"`
  21002. // OthPay float64 `json:"oth_pay"`
  21003. // Gend string `json:"gend"`
  21004. // MdtrtID string `json:"mdtrt_id"`
  21005. // AcctPay float64 `json:"acct_pay"`
  21006. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  21007. // Insutype string `json:"insutype"`
  21008. // Invono interface{} `json:"invono"`
  21009. // Enddate string `json:"enddate"`
  21010. // CashPayamt float64 `json:"cash_payamt"`
  21011. // PsnType string `json:"psn_type"`
  21012. // FixmedinsName string `json:"fixmedins_name"`
  21013. // HifpPay float64 `json:"hifp_pay"`
  21014. // NewFlag interface{} `json:"new_flag"`
  21015. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21016. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  21017. // PayLoc string `json:"pay_loc"`
  21018. // ClrType string `json:"clr_type"`
  21019. // RefdSetlFlag string `json:"refd_setl_flag"`
  21020. // CvlservFlag string `json:"cvlserv_flag"`
  21021. // EmpName string `json:"emp_name"`
  21022. // Brdy string `json:"brdy"`
  21023. // Naty string `json:"naty"`
  21024. // Certno string `json:"certno"`
  21025. // DiseCode string `json:"dise_code"`
  21026. // FixmedinsCode string `json:"fixmedins_code"`
  21027. // DedcHospLv string `json:"dedc_hosp_lv"`
  21028. // OpterName string `json:"opter_name"`
  21029. // Balc float64 `json:"balc"`
  21030. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  21031. // PsnCertType string `json:"psn_cert_type"`
  21032. // HifobPay float64 `json:"hifob_pay"`
  21033. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  21034. // HifesPay float64 `json:"hifes_pay"`
  21035. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21036. // OptTime string `json:"opt_time"`
  21037. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21038. // SetlID string `json:"setl_id"`
  21039. // MafPay float64 `json:"maf_pay"`
  21040. // PsnName string `json:"psn_name"`
  21041. // InsuOptins interface{} `json:"insu_optins"`
  21042. // PrefFundPay interface{} `json:"pref_fund_pay"`
  21043. // ClrOptins string `json:"clr_optins"`
  21044. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21045. // DiseName string `json:"dise_name"`
  21046. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  21047. // Age float64 `json:"age"`
  21048. // DtrtCertType string `json:"dtrt_cert_type"`
  21049. // HospLv string `json:"hosp_lv"`
  21050. // } `json:"setlinfo"`
  21051. // Setldetail []struct {
  21052. // FundPayType string `json:"fund_pay_type"`
  21053. // FundPayamt float64 `json:"fund_payamt"`
  21054. // SetlProcInfo interface{} `json:"setl_proc_info"`
  21055. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  21056. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  21057. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  21058. // PrefFundPay interface{} `json:"pref_fund_pay"`
  21059. // } `json:"setldetail"`
  21060. // } `json:"output"`
  21061. // Infcode int `json:"infcode"`
  21062. // WarnMsg interface{} `json:"warn_msg"`
  21063. // Cainfo interface{} `json:"cainfo"`
  21064. // ErrMsg interface{} `json:"err_msg"`
  21065. // RefmsgTime string `json:"refmsg_time"`
  21066. // Signtype interface{} `json:"signtype"`
  21067. // RespondTime string `json:"respond_time"`
  21068. // InfRefmsgid string `json:"inf_refmsgid"`
  21069. // }
  21070. type Result002 struct {
  21071. Cainfo interface{} `json:"cainfo"`
  21072. ErrMsg string `json:"err_msg"`
  21073. InfRefmsgid string `json:"inf_refmsgid"`
  21074. Infcode int64 `json:"infcode"`
  21075. Output struct {
  21076. RxFile string `json:"rx_file"`
  21077. SignDigest string `json:"sign_digest"`
  21078. SignCertSn string `json:"sign_cert_sn"`
  21079. SignCertDn string `json:"sign_cert_dn"`
  21080. } `json:"output"`
  21081. RefmsgTime string `json:"refmsg_time"`
  21082. RespondTime string `json:"respond_time"`
  21083. Signtype interface{} `json:"signtype"`
  21084. WarnMsg interface{} `json:"warn_msg"`
  21085. }
  21086. type Result003 struct {
  21087. Cainfo interface{} `json:"cainfo"`
  21088. ErrMsg string `json:"err_msg"`
  21089. InfRefmsgid string `json:"inf_refmsgid"`
  21090. Infcode int64 `json:"infcode"`
  21091. Output struct {
  21092. HiRxno string `json:"hi_rxno"`
  21093. RxStasCodg string `json:"rx_stas_codg"`
  21094. RxStasName string `json:"rx_stas_name"`
  21095. } `json:"output"`
  21096. RefmsgTime string `json:"refmsg_time"`
  21097. RespondTime string `json:"respond_time"`
  21098. Signtype interface{} `json:"signtype"`
  21099. WarnMsg interface{} `json:"warn_msg"`
  21100. }
  21101. type ResultEleven struct {
  21102. Cainfo string `json:"cainfo"`
  21103. ErrMsg string `json:"err_msg"`
  21104. InfRefmsgid string `json:"inf_refmsgid"`
  21105. Infcode int64 `json:"infcode"`
  21106. Output struct {
  21107. Setlinfo struct {
  21108. SetlTime string `json:"setl_time"`
  21109. CvlservPay float64 `json:"cvlserv_pay"`
  21110. Year string `json:"year"`
  21111. MedType string `json:"med_type"`
  21112. PsnPay float64 `json:"psn_pay"`
  21113. OpterID string `json:"opter_id"`
  21114. Begndate string `json:"begndate"`
  21115. FlxempeFlag string `json:"flxempe_flag"`
  21116. HifmiPay float64 `json:"hifmi_pay"`
  21117. PsnNo string `json:"psn_no"`
  21118. ActPayDedc float64 `json:"act_pay_dedc"`
  21119. MedinsSetlID interface{} `json:"medins_setl_id"`
  21120. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  21121. ClrWay string `json:"clr_way"`
  21122. OthPay float64 `json:"oth_pay"`
  21123. Gend string `json:"gend"`
  21124. MdtrtID string `json:"mdtrt_id"`
  21125. AcctPay float64 `json:"acct_pay"`
  21126. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21127. Insutype string `json:"insutype"`
  21128. Invono interface{} `json:"invono"`
  21129. Enddate string `json:"enddate"`
  21130. CashPayamt float64 `json:"cash_payamt"`
  21131. PsnType string `json:"psn_type"`
  21132. FixmedinsName string `json:"fixmedins_name"`
  21133. HifpPay float64 `json:"hifp_pay"`
  21134. NewFlag interface{} `json:"new_flag"`
  21135. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21136. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21137. PayLoc string `json:"pay_loc"`
  21138. ClrType string `json:"clr_type"`
  21139. RefdSetlFlag string `json:"refd_setl_flag"`
  21140. CvlservFlag string `json:"cvlserv_flag"`
  21141. EmpName string `json:"emp_name"`
  21142. Brdy string `json:"brdy"`
  21143. Naty string `json:"naty"`
  21144. Certno string `json:"certno"`
  21145. DiseCode string `json:"dise_code"`
  21146. FixmedinsCode string `json:"fixmedins_code"`
  21147. DedcHospLv string `json:"dedc_hosp_lv"`
  21148. OpterName string `json:"opter_name"`
  21149. Balc float64 `json:"balc"`
  21150. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  21151. PsnCertType string `json:"psn_cert_type"`
  21152. HifobPay float64 `json:"hifob_pay"`
  21153. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21154. HifesPay float64 `json:"hifes_pay"`
  21155. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21156. OptTime string `json:"opt_time"`
  21157. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21158. SetlID string `json:"setl_id"`
  21159. MafPay float64 `json:"maf_pay"`
  21160. PsnName string `json:"psn_name"`
  21161. InsuOptins interface{} `json:"insu_optins"`
  21162. PrefFundPay interface{} `json:"pref_fund_pay"`
  21163. ClrOptins string `json:"clr_optins"`
  21164. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21165. DiseName string `json:"dise_name"`
  21166. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  21167. Age float64 `json:"age"`
  21168. DtrtCertType string `json:"dtrt_cert_type"`
  21169. HospLv string `json:"hosp_lv"`
  21170. PsnCashPay float64 `json:"psn_cash_pay"`
  21171. } `json:"setlinfo"`
  21172. } `json:"output"`
  21173. RefmsgTime string `json:"refmsg_time"`
  21174. RespondTime string `json:"respond_time"`
  21175. Signtype interface{} `json:"signtype"`
  21176. WarnMsg interface{} `json:"warn_msg"`
  21177. }
  21178. type ResultElevenah struct {
  21179. Cainfo string `json:"cainfo"`
  21180. ErrMsg string `json:"err_msg"`
  21181. InfRefmsgid string `json:"inf_refmsgid"`
  21182. Infcode int64 `json:"infcode"`
  21183. Output struct {
  21184. Setlinfo struct {
  21185. SetlTime int64 `json:"setl_time"`
  21186. CvlservPay float64 `json:"cvlserv_pay"`
  21187. Year string `json:"year"`
  21188. MedType string `json:"med_type"`
  21189. PsnPay float64 `json:"psn_pay"`
  21190. OpterID string `json:"opter_id"`
  21191. Begndate int64 `json:"begndate"`
  21192. FlxempeFlag string `json:"flxempe_flag"`
  21193. HifmiPay float64 `json:"hifmi_pay"`
  21194. PsnNo string `json:"psn_no"`
  21195. ActPayDedc float64 `json:"act_pay_dedc"`
  21196. MedinsSetlID interface{} `json:"medins_setl_id"`
  21197. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  21198. ClrWay string `json:"clr_way"`
  21199. OthPay float64 `json:"oth_pay"`
  21200. Gend string `json:"gend"`
  21201. MdtrtID string `json:"mdtrt_id"`
  21202. AcctPay float64 `json:"acct_pay"`
  21203. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21204. Insutype string `json:"insutype"`
  21205. Invono interface{} `json:"invono"`
  21206. Enddate int64 `json:"enddate"`
  21207. CashPayamt float64 `json:"cash_payamt"`
  21208. PsnType string `json:"psn_type"`
  21209. FixmedinsName string `json:"fixmedins_name"`
  21210. HifpPay float64 `json:"hifp_pay"`
  21211. NewFlag interface{} `json:"new_flag"`
  21212. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21213. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21214. PayLoc string `json:"pay_loc"`
  21215. ClrType string `json:"clr_type"`
  21216. RefdSetlFlag string `json:"refd_setl_flag"`
  21217. CvlservFlag string `json:"cvlserv_flag"`
  21218. EmpName string `json:"emp_name"`
  21219. Brdy int64 `json:"brdy"`
  21220. Naty string `json:"naty"`
  21221. Certno string `json:"certno"`
  21222. DiseCode string `json:"dise_code"`
  21223. FixmedinsCode string `json:"fixmedins_code"`
  21224. DedcHospLv string `json:"dedc_hosp_lv"`
  21225. OpterName string `json:"opter_name"`
  21226. Balc float64 `json:"balc"`
  21227. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  21228. PsnCertType string `json:"psn_cert_type"`
  21229. HifobPay float64 `json:"hifob_pay"`
  21230. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21231. HifesPay float64 `json:"hifes_pay"`
  21232. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21233. OptTime int64 `json:"opt_time"`
  21234. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21235. SetlID string `json:"setl_id"`
  21236. MafPay float64 `json:"maf_pay"`
  21237. PsnName string `json:"psn_name"`
  21238. InsuOptins interface{} `json:"insu_optins"`
  21239. PrefFundPay interface{} `json:"pref_fund_pay"`
  21240. ClrOptins string `json:"clr_optins"`
  21241. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21242. DiseName string `json:"dise_name"`
  21243. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  21244. Age float64 `json:"age"`
  21245. DtrtCertType string `json:"dtrt_cert_type"`
  21246. HospLv string `json:"hosp_lv"`
  21247. PsnCashPay float64 `json:"psn_cash_pay"`
  21248. } `json:"setlinfo"`
  21249. } `json:"output"`
  21250. RefmsgTime string `json:"refmsg_time"`
  21251. RespondTime string `json:"respond_time"`
  21252. Signtype interface{} `json:"signtype"`
  21253. WarnMsg interface{} `json:"warn_msg"`
  21254. }
  21255. type ResultEleven10265 struct {
  21256. Cainfo string `json:"cainfo"`
  21257. ErrMsg string `json:"err_msg"`
  21258. InfRefmsgid string `json:"inf_refmsgid"`
  21259. Infcode string `json:"infcode"`
  21260. Output struct {
  21261. Setlinfo struct {
  21262. SetlTime string `json:"setl_time"`
  21263. CvlservPay float64 `json:"cvlserv_pay"`
  21264. Year string `json:"year"`
  21265. MedType string `json:"med_type"`
  21266. PsnPay float64 `json:"psn_pay"`
  21267. OpterID string `json:"opter_id"`
  21268. Begndate string `json:"begndate"`
  21269. FlxempeFlag string `json:"flxempe_flag"`
  21270. HifmiPay float64 `json:"hifmi_pay"`
  21271. PsnNo string `json:"psn_no"`
  21272. ActPayDedc float64 `json:"act_pay_dedc"`
  21273. MedinsSetlID interface{} `json:"medins_setl_id"`
  21274. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  21275. ClrWay string `json:"clr_way"`
  21276. OthPay float64 `json:"oth_pay"`
  21277. Gend string `json:"gend"`
  21278. MdtrtID string `json:"mdtrt_id"`
  21279. AcctPay float64 `json:"acct_pay"`
  21280. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21281. Insutype string `json:"insutype"`
  21282. Invono interface{} `json:"invono"`
  21283. Enddate string `json:"enddate"`
  21284. CashPayamt float64 `json:"cash_payamt"`
  21285. PsnType string `json:"psn_type"`
  21286. FixmedinsName string `json:"fixmedins_name"`
  21287. HifpPay float64 `json:"hifp_pay"`
  21288. NewFlag interface{} `json:"new_flag"`
  21289. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21290. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21291. PayLoc string `json:"pay_loc"`
  21292. ClrType string `json:"clr_type"`
  21293. RefdSetlFlag string `json:"refd_setl_flag"`
  21294. CvlservFlag string `json:"cvlserv_flag"`
  21295. EmpName string `json:"emp_name"`
  21296. Brdy string `json:"brdy"`
  21297. Naty string `json:"naty"`
  21298. Certno string `json:"certno"`
  21299. DiseCode string `json:"dise_code"`
  21300. FixmedinsCode string `json:"fixmedins_code"`
  21301. DedcHospLv string `json:"dedc_hosp_lv"`
  21302. OpterName string `json:"opter_name"`
  21303. Balc float64 `json:"balc"`
  21304. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  21305. PsnCertType string `json:"psn_cert_type"`
  21306. HifobPay float64 `json:"hifob_pay"`
  21307. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21308. HifesPay float64 `json:"hifes_pay"`
  21309. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21310. OptTime string `json:"opt_time"`
  21311. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21312. SetlID string `json:"setl_id"`
  21313. MafPay float64 `json:"maf_pay"`
  21314. PsnName string `json:"psn_name"`
  21315. InsuOptins interface{} `json:"insu_optins"`
  21316. PrefFundPay interface{} `json:"pref_fund_pay"`
  21317. ClrOptins string `json:"clr_optins"`
  21318. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21319. DiseName string `json:"dise_name"`
  21320. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  21321. Age float64 `json:"age"`
  21322. DtrtCertType string `json:"dtrt_cert_type"`
  21323. HospLv string `json:"hosp_lv"`
  21324. PsnCashPay float64 `json:"psn_cash_pay"`
  21325. } `json:"setlinfo"`
  21326. } `json:"output"`
  21327. RefmsgTime string `json:"refmsg_time"`
  21328. RespondTime string `json:"respond_time"`
  21329. Signtype interface{} `json:"signtype"`
  21330. WarnMsg interface{} `json:"warn_msg"`
  21331. }
  21332. type ResultTwelve struct {
  21333. Cainfo string `json:"cainfo"`
  21334. ErrMsg string `json:"err_msg"`
  21335. InfRefmsgid string `json:"inf_refmsgid"`
  21336. Infcode int64 `json:"infcode"`
  21337. Output struct {
  21338. MdtrtId string `json:"mdtrt_id"`
  21339. ChrgBchno string `json:"chrg_bchno"`
  21340. PsnNo string `json:"psn_no"`
  21341. } `json:"output"`
  21342. RefmsgTime string `json:"refmsg_time"`
  21343. RespondTime string `json:"respond_time"`
  21344. Signtype interface{} `json:"signtype"`
  21345. WarnMsg interface{} `json:"warn_msg"`
  21346. }
  21347. type ResultThirteen struct {
  21348. ErrMsg string `json:"err_msg"`
  21349. InfRefmsgid string `json:"inf_refmsgid"`
  21350. Infcode int64 `json:"infcode"`
  21351. Output struct {
  21352. Result struct {
  21353. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  21354. } `json:"result"`
  21355. } `json:"output"`
  21356. RefmsgTime string `json:"refmsg_time"`
  21357. RespondTime string `json:"respond_time"`
  21358. Signtype interface{} `json:"signtype"`
  21359. WarnInfo interface{} `json:"warn_info"`
  21360. }
  21361. type ResultThirteen10265 struct {
  21362. ErrMsg string `json:"err_msg"`
  21363. InfRefmsgid string `json:"inf_refmsgid"`
  21364. Infcode string `json:"infcode"`
  21365. Output struct {
  21366. Result struct {
  21367. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  21368. } `json:"result"`
  21369. } `json:"output"`
  21370. RefmsgTime string `json:"refmsg_time"`
  21371. RespondTime string `json:"respond_time"`
  21372. Signtype interface{} `json:"signtype"`
  21373. WarnInfo interface{} `json:"warn_info"`
  21374. }
  21375. type ResultFourteen struct {
  21376. ErrMsg string `json:"err_msg"`
  21377. InfRefmsgid string `json:"inf_refmsgid"`
  21378. Infcode int64 `json:"infcode"`
  21379. Output struct {
  21380. } `json:"output"`
  21381. RefmsgTime string `json:"refmsg_time"`
  21382. RespondTime string `json:"respond_time"`
  21383. Signtype interface{} `json:"signtype"`
  21384. WarnInfo interface{} `json:"warn_info"`
  21385. }
  21386. type ResultCFYLJG001 struct {
  21387. ErrMsg string `json:"err_msg"`
  21388. InfRefmsgid string `json:"inf_refmsgid"`
  21389. Infcode int64 `json:"infcode"`
  21390. Output struct {
  21391. RxTraceCode string `json:"rx_trace_code"`
  21392. HiRxno string `json:"hi_rxno"`
  21393. } `json:"output"`
  21394. RefmsgTime string `json:"refmsg_time"`
  21395. RespondTime string `json:"respond_time"`
  21396. Signtype interface{} `json:"signtype"`
  21397. WarnInfo interface{} `json:"warn_info"`
  21398. }
  21399. type ResultCFYLJG007 struct {
  21400. ErrMsg string `json:"err_msg"`
  21401. InfRefmsgid string `json:"inf_refmsgid"`
  21402. Infcode int64 `json:"infcode"`
  21403. Output struct {
  21404. HiRxno string `json:"hi_rxno"`
  21405. RxStasName string `json:"rx_stas_name"`
  21406. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  21407. Seltdelts []interface{} `json:"seltdelts"`
  21408. RxUsedStasName string `json:"rx_used_stas_name"`
  21409. RxStasCodg string `json:"rx_stas_codg"`
  21410. } `json:"output"`
  21411. RefmsgTime string `json:"refmsg_time"`
  21412. RespondTime string `json:"respond_time"`
  21413. Signtype interface{} `json:"signtype"`
  21414. WarnInfo interface{} `json:"warn_info"`
  21415. }
  21416. type ResultCFYLJG002 struct {
  21417. ErrMsg string `json:"err_msg"`
  21418. InfRefmsgid string `json:"inf_refmsgid"`
  21419. Infcode int64 `json:"infcode"`
  21420. Output struct {
  21421. RxFile string `json:"rx_file"`
  21422. SignDigest string `json:"sign_digest"`
  21423. SignCertSn string `json:"sign_cert_sn"`
  21424. SignCertDn string `json:"sign_cert_dn"`
  21425. } `json:"output"`
  21426. RefmsgTime string `json:"refmsg_time"`
  21427. RespondTime string `json:"respond_time"`
  21428. Signtype interface{} `json:"signtype"`
  21429. WarnInfo interface{} `json:"warn_info"`
  21430. }
  21431. type ResultCFYLJG003 struct {
  21432. ErrMsg string `json:"err_msg"`
  21433. InfRefmsgid string `json:"inf_refmsgid"`
  21434. Infcode int64 `json:"infcode"`
  21435. Output struct {
  21436. HiRxno string `json:"hi_rxno"`
  21437. RxStasCodg string `json:"rx_stas_codg"`
  21438. RxStasName string `json:"rx_stas_name"`
  21439. } `json:"output"`
  21440. RefmsgTime string `json:"refmsg_time"`
  21441. RespondTime string `json:"respond_time"`
  21442. Signtype interface{} `json:"signtype"`
  21443. WarnInfo interface{} `json:"warn_info"`
  21444. }
  21445. type ResultCFYLJG004 struct {
  21446. ErrMsg string `json:"err_msg"`
  21447. InfRefmsgid string `json:"inf_refmsgid"`
  21448. Infcode int64 `json:"infcode"`
  21449. Output struct {
  21450. HiRxno string `json:"hi_rxno"`
  21451. RxStasCodg string `json:"rx_stas_codg"`
  21452. RxStasName string `json:"rx_stas_name"`
  21453. } `json:"output"`
  21454. RefmsgTime string `json:"refmsg_time"`
  21455. RespondTime string `json:"respond_time"`
  21456. Signtype interface{} `json:"signtype"`
  21457. WarnInfo interface{} `json:"warn_info"`
  21458. }
  21459. type ResultCFYLJG008 struct {
  21460. ErrMsg string `json:"err_msg"`
  21461. InfRefmsgid string `json:"inf_refmsgid"`
  21462. Infcode int64 `json:"infcode"`
  21463. Output struct {
  21464. PoolareaNo string `json:"poolareaNo"`
  21465. AdmdvsName string `json:"admdvsName"`
  21466. Count string `json:"count"`
  21467. } `json:"output"`
  21468. RefmsgTime string `json:"refmsg_time"`
  21469. RespondTime string `json:"respond_time"`
  21470. Signtype interface{} `json:"signtype"`
  21471. WarnInfo interface{} `json:"warn_info"`
  21472. }
  21473. type ResultCFYLJG005 struct {
  21474. ErrMsg string `json:"err_msg"`
  21475. InfRefmsgid string `json:"inf_refmsgid"`
  21476. Infcode int64 `json:"infcode"`
  21477. Output struct {
  21478. HiRxNo string `json:"hi_rxno"`
  21479. FixMedinsCode string `json:"fixmedins_code"`
  21480. FixMedinsName string `json:"fixmedins_name"`
  21481. RxStasCodg string `json:"rx_stas_codg"`
  21482. RxStasName string `json:"rx_stas_name"`
  21483. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  21484. RxUserdStasName string `json:"rx_userd_stas_name"`
  21485. PrscTime string `json:"prsc_time"`
  21486. RxDrugCnt float64 `json:"rx_drug_cnt"`
  21487. RxUsedWayCodg string `json:"rx_used_way_codg"`
  21488. RxUsedWayName string `json:"rx_used_way_name"`
  21489. RxFrquCodg string `json:"rx_frqu_codg"`
  21490. RxFrquName string `json:"rx_frqu_name"`
  21491. RxDosunt string `json:"rx_dosunt"`
  21492. RxDoscnt float64 `json:"rx_doscnt"`
  21493. RxDrordDscr string `json:"rx_drord_dscr"`
  21494. ValiDays int64 `json:"vali_days"`
  21495. ValiEndTime string `json:"vali_end_time"`
  21496. ReptFlag string `json:"rept_flag"`
  21497. MaxReptCnt int64 `json:"max_rept_cnt"`
  21498. ReptdCnt int64 `json:"reptd_cnt"`
  21499. MinInrvDays int64 `json:"min_inrv_days"`
  21500. RxTypeCode string `json:"rx_type_code"`
  21501. RxTypeName string `json:"rx_type_name"`
  21502. LongRxFlag string `json:"long_rx_flag"`
  21503. RxDetlList []struct {
  21504. MedListCodg string `json:"med_list_codg"`
  21505. MedinsListCodg string `json:"medins_list_codg"`
  21506. HospPrepFlag string `json:"hosp_prep_flag"`
  21507. RxItemTypeCode string `json:"rx_item_type_code"`
  21508. RxItemTypeName string `json:"rx_item_type_name"`
  21509. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  21510. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  21511. TcmHerbFoote string `json:"tcmherb_foote"`
  21512. MednTypeCode string `json:"medn_type_code"`
  21513. MednTypeName string `json:"medn_type_name"`
  21514. MainMedcFlag string `json:"main_medc_flag"`
  21515. UrgtFlag string `json:"urgt_flag"`
  21516. BasMednFlag string `json:"bas_medn_flag"`
  21517. ImpDrugFlag string `json:"imp_drug_flag"`
  21518. ProdBarc string `json:"prod_barc"`
  21519. DrugProdname string `json:"drug_prodname"`
  21520. GennameCodg string `json:"genname_codg"`
  21521. DrugGenname string `json:"drug_genname"`
  21522. DrugDosform string `json:"drug_dosform"`
  21523. DrugSpec string `json:"drug_spec"`
  21524. PrdrName string `json:"prdr_name"`
  21525. MedcWayCodg string `json:"medc_way_codg"`
  21526. MedcWayDscr string `json:"medc_way_dscr"`
  21527. MedcBegntime string `json:"medc_begntime"`
  21528. MedcEndtime string `json:"medc_endtime"`
  21529. MedcDays float64 `json:"medc_days"`
  21530. DrugPric float64 `json:"drug_pric"`
  21531. DrugSumamt float64 `json:"drug_sumamt"`
  21532. DrugCnt float64 `json:"drug_cnt"`
  21533. DrugDosunt string `json:"drug_dosunt"`
  21534. SinDoscnt float64 `json:"sin_doscnt"`
  21535. SinDosunt string `json:"sin_dosunt"`
  21536. UsedFrquCodg string `json:"used_frqu_codg"`
  21537. UsedFrquName string `json:"used_frqu_name"`
  21538. DrugTotlcnt string `json:"drug_totlcnt"`
  21539. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  21540. DiseCodg string `json:"dise_codg"`
  21541. HospApprFlag string `json:"hosp_appr_flag"`
  21542. } `json:"rx_detl_list"`
  21543. RxOtpinfo struct {
  21544. MedType string `json:"med_type"`
  21545. IptOtpNo string `json:"ipt_otp_no"`
  21546. OtpIptFlag string `json:"otp_ipt_flag"`
  21547. PatnName string `json:"patn_name"`
  21548. PatnAge float64 `json:"patn_age"`
  21549. PatnHgt float64 `json:"patn_hgt"`
  21550. PatnWt float64 `json:"patn_wt"`
  21551. Gend string `json:"gend"`
  21552. GesoVal float64 `json:"geso_val"`
  21553. NwbFlag string `json:"nwb_flag"`
  21554. NwbAge string `json:"nwb_age"`
  21555. SuckPrdFlag string `json:"suck_prd_flag"`
  21556. AlgsHis string `json:"algs_his"`
  21557. Insutype string `json:"insutype"`
  21558. PrscDeptName string `json:"prsc_dept_name"`
  21559. PrscDrName string `json:"prsc_dr_name"`
  21560. PharName string `json:"phar_name"`
  21561. PharChkTime string `json:"phar_chk_time"`
  21562. MdtrtTime string `json:"mdtrt_time"`
  21563. DiseCodg string `json:"dise_codg"`
  21564. DiseName string `json:"dise_name"`
  21565. SpDiseFlag string `json:"sp_dise_flag"`
  21566. MaindiagCode string `json:"maindiag_code"`
  21567. MaindiagName string `json:"maindiag_name"`
  21568. DiseCondDscr string `json:"dise_cond_dscr"`
  21569. FstdiagFlag string `json:"fstdiag_flag"`
  21570. } `json:"rx_otpinfo"`
  21571. RxDiseList []struct {
  21572. DiagType string `json:"diag_type"`
  21573. MaindiagFlag string `json:"maindiag_flag"`
  21574. DiagSrtNo string `json:"diag_srt_no"`
  21575. DiagCode string `json:"diag_code"`
  21576. DiagName string `json:"diag_name"`
  21577. DiagDept string `json:"diag_dept"`
  21578. DiagDrNo string `json:"diag_dr_no"`
  21579. DiagDrName string `json:"diag_dr_name"`
  21580. DiagTime string `json:"diag_time"`
  21581. TcmDiseCode string `json:"tcm_dise_code"`
  21582. TcmDiseName string `json:"tcm_dise_name"`
  21583. TcmSympCode string `json:"tcmsymp_code"`
  21584. TcmSymp string `json:"tcmsymp"`
  21585. } `json:"rx_dise_list"`
  21586. } `json:"output"`
  21587. RefmsgTime string `json:"refmsg_time"`
  21588. RespondTime string `json:"respond_time"`
  21589. Signtype interface{} `json:"signtype"`
  21590. WarnInfo interface{} `json:"warn_info"`
  21591. }
  21592. type ResultCFYLJG006 struct {
  21593. ErrMsg string `json:"err_msg"`
  21594. InfRefmsgid string `json:"inf_refmsgid"`
  21595. Infcode int64 `json:"infcode"`
  21596. Output struct {
  21597. HiRxNo string `json:"hi_rxno"`
  21598. PharCode string `json:"phar_code"`
  21599. PharName string `json:"phar_name"`
  21600. RxChkOpnn string `json:"rx_chk_opnn"`
  21601. RxChkTime string `json:"rx_chk_time"`
  21602. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  21603. RxChkStasName string `json:"rx_chk_stas_name"`
  21604. RxStasCodg string `json:"rx_stas_codg"`
  21605. RxStasName string `json:"rx_stas_name"`
  21606. } `json:"output"`
  21607. RefmsgTime string `json:"refmsg_time"`
  21608. RespondTime string `json:"respond_time"`
  21609. Signtype interface{} `json:"signtype"`
  21610. WarnInfo interface{} `json:"warn_info"`
  21611. }
  21612. type ResultFourteen10265 struct {
  21613. ErrMsg string `json:"err_msg"`
  21614. InfRefmsgid string `json:"inf_refmsgid"`
  21615. Infcode string `json:"infcode"`
  21616. Output struct {
  21617. } `json:"output"`
  21618. RefmsgTime string `json:"refmsg_time"`
  21619. RespondTime string `json:"respond_time"`
  21620. Signtype interface{} `json:"signtype"`
  21621. WarnInfo interface{} `json:"warn_info"`
  21622. }
  21623. type ResultSixteen struct {
  21624. Cainfo string `json:"cainfo"`
  21625. ErrMsg string `json:"err_msg"`
  21626. InfRefmsgid string `json:"inf_refmsgid"`
  21627. Infcode int64 `json:"infcode"`
  21628. Output struct {
  21629. Setlinfo struct {
  21630. MdtrtID string `json:"mdtrt_id"`
  21631. SetlID string `json:"setl_id"`
  21632. ClrOptins string `json:"clr_optins"`
  21633. SetlTime string `json:"setl_time"`
  21634. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21635. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21636. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21637. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21638. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21639. ActPayDedc float64 `json:"act_pay_dedc"`
  21640. HifpPay float64 `json:"hifp_pay"`
  21641. PoolPropSe float64 `json:"pool_prop_selfpay"`
  21642. Lfpay float64 `json:"selfpay"`
  21643. CvlservPay float64 `json:"cvlserv_pay"`
  21644. HifesPay float64 `json:"hifes_pay"`
  21645. HifmiPay float64 `json:"hifmi_pay"`
  21646. HifobPay float64 `json:"hifob_pay"`
  21647. MafPay float64 `json:"maf_pay"`
  21648. OthPay float64 `json:"oth_pay"`
  21649. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21650. PsnPartAmt float64 `json:"psn_part_amt"`
  21651. AcctPay float64 `json:"acct_pay"`
  21652. Balc float64 `json:"balc"`
  21653. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21654. HospPartAmt float64 `json:"hosp_part_amt"`
  21655. MedinsSetlID string `json:"medins_setl_id"`
  21656. PdnCashPay string `json:"pdn_cash_pay"`
  21657. } `json:"setlinfo"`
  21658. } `json:"output"`
  21659. RefmsgTime string `json:"refmsg_time"`
  21660. RespondTime string `json:"respond_time"`
  21661. Signtype interface{} `json:"signtype"`
  21662. WarnMsg interface{} `json:"warn_msg"`
  21663. }
  21664. type ResultSixteen10265 struct {
  21665. Cainfo string `json:"cainfo"`
  21666. ErrMsg string `json:"err_msg"`
  21667. InfRefmsgid string `json:"inf_refmsgid"`
  21668. Infcode string `json:"infcode"`
  21669. Output struct {
  21670. Setlinfo struct {
  21671. MdtrtID string `json:"mdtrt_id"`
  21672. SetlID string `json:"setl_id"`
  21673. ClrOptins string `json:"clr_optins"`
  21674. SetlTime string `json:"setl_time"`
  21675. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21676. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21677. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21678. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21679. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21680. ActPayDedc float64 `json:"act_pay_dedc"`
  21681. HifpPay float64 `json:"hifp_pay"`
  21682. PoolPropSe float64 `json:"pool_prop_selfpay"`
  21683. Lfpay float64 `json:"selfpay"`
  21684. CvlservPay float64 `json:"cvlserv_pay"`
  21685. HifesPay float64 `json:"hifes_pay"`
  21686. HifmiPay float64 `json:"hifmi_pay"`
  21687. HifobPay float64 `json:"hifob_pay"`
  21688. MafPay float64 `json:"maf_pay"`
  21689. OthPay float64 `json:"oth_pay"`
  21690. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21691. PsnPartAmt float64 `json:"psn_part_amt"`
  21692. AcctPay float64 `json:"acct_pay"`
  21693. Balc float64 `json:"balc"`
  21694. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21695. HospPartAmt float64 `json:"hosp_part_amt"`
  21696. MedinsSetlID string `json:"medins_setl_id"`
  21697. PdnCashPay string `json:"pdn_cash_pay"`
  21698. } `json:"setlinfo"`
  21699. } `json:"output"`
  21700. RefmsgTime string `json:"refmsg_time"`
  21701. RespondTime string `json:"respond_time"`
  21702. Signtype interface{} `json:"signtype"`
  21703. WarnMsg interface{} `json:"warn_msg"`
  21704. }
  21705. type ResultSixteen10265Two struct {
  21706. Cainfo string `json:"cainfo"`
  21707. ErrMsg string `json:"err_msg"`
  21708. InfRefmsgid string `json:"inf_refmsgid"`
  21709. Infcode string `json:"infcode"`
  21710. Output struct {
  21711. Setlinfo interface{} `json:"setlinfo"`
  21712. } `json:"output"`
  21713. RefmsgTime string `json:"refmsg_time"`
  21714. RespondTime string `json:"respond_time"`
  21715. Signtype interface{} `json:"signtype"`
  21716. WarnMsg interface{} `json:"warn_msg"`
  21717. }
  21718. type ResultgzSixteen10265Two struct {
  21719. Cainfo string `json:"cainfo"`
  21720. ErrMsg string `json:"err_msg"`
  21721. InfRefmsgid string `json:"inf_refmsgid"`
  21722. Infcode int64 `json:"infcode"`
  21723. Output struct {
  21724. Setlinfo interface{} `json:"setlinfo"`
  21725. } `json:"output"`
  21726. RefmsgTime string `json:"refmsg_time"`
  21727. RespondTime string `json:"respond_time"`
  21728. Signtype interface{} `json:"signtype"`
  21729. WarnMsg interface{} `json:"warn_msg"`
  21730. }
  21731. type ResultSeventeen struct {
  21732. ErrMsg string `json:"err_msg"`
  21733. InfRefmsgid string `json:"inf_refmsgid"`
  21734. Infcode int64 `json:"infcode"`
  21735. Output struct {
  21736. SetlListId string `json:"setl_list_id"`
  21737. } `json:"output"`
  21738. RefmsgTime string `json:"refmsg_time"`
  21739. RespondTime string `json:"respond_time"`
  21740. Signtype string `json:"signtype"`
  21741. WarnInfo string `json:"warn_info"`
  21742. }
  21743. type ResultSeventeenOther struct {
  21744. ErrMsg string `json:"err_msg"`
  21745. InfRefmsgid string `json:"inf_refmsgid"`
  21746. Infcode string `json:"infcode"`
  21747. Output struct {
  21748. SetlListId string `json:"setl_list_id"`
  21749. } `json:"output"`
  21750. RefmsgTime string `json:"refmsg_time"`
  21751. RespondTime string `json:"respond_time"`
  21752. Signtype string `json:"signtype"`
  21753. WarnInfo string `json:"warn_info"`
  21754. }
  21755. type Result90991 struct {
  21756. ErrMsg string `json:"err_msg"`
  21757. InfRefmsgid string `json:"inf_refmsgid"`
  21758. Infcode int64 `json:"infcode"`
  21759. Output struct {
  21760. Result struct {
  21761. PsnNo string `json:"psn_no"`
  21762. CardStat string `json:"card_stat"`
  21763. Certno string `json:"certno"`
  21764. PsnName string `json:"psn_name"`
  21765. CheckStat string `json:"check_stat"`
  21766. SscnoCheckStat string `json:"sscno_check_stat"`
  21767. } `json:"result"`
  21768. } `json:"output"`
  21769. RefmsgTime string `json:"refmsg_time"`
  21770. RespondTime string `json:"respond_time"`
  21771. Signtype interface{} `json:"signtype"`
  21772. WarnInfo interface{} `json:"warn_info"`
  21773. }
  21774. type Result90100 struct {
  21775. ErrMsg string `json:"err_msg"`
  21776. InfRefmsgid string `json:"inf_refmsgid"`
  21777. Infcode int64 `json:"infcode"`
  21778. Output struct {
  21779. PoolareaNo string `json:"poolarea_no"`
  21780. PoolareaNoName string `json:"poolarea_no_name"`
  21781. Insutype string `json:"insutype"`
  21782. InsutypeName string `json:"insutype_name"`
  21783. ClctType string `json:"clct_type"`
  21784. ClctTypeName string `json:"clct_type_name"`
  21785. ClctFlag string `json:"clct_flag"`
  21786. ClctFlagName string `json:"clct_flag_name"`
  21787. AccrymBegn string `json:"accrym_begn"`
  21788. AccrymEnd string `json:"accrym_end"`
  21789. ClctTime string `json:"clct_time"`
  21790. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  21791. } `json:"output"`
  21792. RefmsgTime string `json:"refmsg_time"`
  21793. RespondTime string `json:"respond_time"`
  21794. Signtype interface{} `json:"signtype"`
  21795. WarnInfo interface{} `json:"warn_info"`
  21796. }
  21797. type Custom struct {
  21798. DetItemFeeSumamt string
  21799. Cut string
  21800. FeedetlSn string
  21801. Price string
  21802. MedListCodg string
  21803. Type int64
  21804. AdviceId int64
  21805. ProjectId int64
  21806. ItemId int64
  21807. }
  21808. type Result5301 struct {
  21809. ErrMsg string `json:"err_msg"`
  21810. InfRefmsgid string `json:"inf_refmsgid"`
  21811. Infcode int64 `json:"infcode"`
  21812. Output struct {
  21813. Result []struct {
  21814. OpspDiseCode string `json:"opsp_dise_code"`
  21815. OpspDiseName string `json:"opsp_dise_name"`
  21816. Begndate string `json:"begndate"`
  21817. Enddate string `json:"enddate"`
  21818. } `json:"feedetail"`
  21819. } `json:"output"`
  21820. RefmsgTime string `json:"refmsg_time"`
  21821. RespondTime string `json:"respond_time"`
  21822. Signtype interface{} `json:"signtype"`
  21823. WarnInfo interface{} `json:"warn_info"`
  21824. }
  21825. type Result5301For10265 struct {
  21826. ErrMsg string `json:"err_msg"`
  21827. InfRefmsgid string `json:"inf_refmsgid"`
  21828. Infcode string `json:"infcode"`
  21829. Output struct {
  21830. Result []struct {
  21831. OpspDiseCode string `json:"opsp_dise_code"`
  21832. OpspDiseName string `json:"opsp_dise_name"`
  21833. Begndate string `json:"begndate"`
  21834. Enddate string `json:"enddate"`
  21835. } `json:"feedetail"`
  21836. } `json:"output"`
  21837. RefmsgTime string `json:"refmsg_time"`
  21838. RespondTime string `json:"respond_time"`
  21839. Signtype interface{} `json:"signtype"`
  21840. WarnInfo interface{} `json:"warn_info"`
  21841. }
  21842. //获取个人信息----挂号-----上传就诊信息
  21843. func (c *HisApiController) GetRegisterInfo() {
  21844. id, _ := c.GetInt64("id")
  21845. record_time := c.GetString("record_time")
  21846. settlementValue, _ := c.GetInt64("settlement_value")
  21847. medical_insurance_card := c.GetString("medical_insurance_card")
  21848. name := c.GetString("name")
  21849. id_card_type, _ := c.GetInt64("id_card_type")
  21850. certificates, _ := c.GetInt64("certificates")
  21851. medical_care, _ := c.GetInt64("medical_care")
  21852. birthday := c.GetString("birthday")
  21853. id_card := c.GetString("id_card")
  21854. register_type, _ := c.GetInt64("register")
  21855. doctor, _ := c.GetInt64("doctor")
  21856. department, _ := c.GetInt64("department")
  21857. gender, _ := c.GetInt64("sex")
  21858. registration_fee, _ := c.GetFloat("registration_fee")
  21859. medical_expenses, _ := c.GetFloat("medical_expenses")
  21860. social_type, _ := c.GetInt64("social_type")
  21861. admin_user_id, _ := c.GetInt64("admin_user_id")
  21862. insuplc_admdvs := c.GetString("insuplc_admdvs")
  21863. mdtrt_type := c.GetString("mdtrt_type")
  21864. if id_card_type == 5 {
  21865. id_card_type = 4
  21866. }
  21867. timeLayout := "2006-01-02"
  21868. loc, _ := time.LoadLocation("Local")
  21869. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  21870. birthUnix := birthdays.Unix()
  21871. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  21872. if err != nil {
  21873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21874. return
  21875. }
  21876. recordDateTime := theTime.Unix()
  21877. adminInfo := c.GetAdminUserInfo()
  21878. var patient service.Patients
  21879. if id == 0 {
  21880. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  21881. } else {
  21882. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  21883. }
  21884. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  21885. if patientPrescription.ID == 0 {
  21886. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  21887. }
  21888. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21889. if patient.ID == 0 {
  21890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  21891. return
  21892. }
  21893. if len(patient.IdCardNo) == 0 {
  21894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  21895. return
  21896. }
  21897. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21898. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  21899. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  21900. //就诊结算未完成,不能进行二次挂号
  21901. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  21902. if len(his) >= 1 {
  21903. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  21904. if len(his) >= 1 && order.ID == 0 {
  21905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  21906. return
  21907. }
  21908. }
  21909. //var register_log string
  21910. if config.IsOpen == 1 {
  21911. var res ResultTwo
  21912. var res10265 ResultTwo10265
  21913. var PsnNo string
  21914. var PsnCertType string
  21915. var Certno string
  21916. var PsnName string
  21917. var Gend string
  21918. var Naty string
  21919. var Brdy string
  21920. var Age float64
  21921. var infoStr string
  21922. var idetinfoStr string
  21923. var infocode int64
  21924. var verify_number string
  21925. fmt.Println(verify_number)
  21926. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  21927. psn_info, _ := service.GetPsnByPatientId(id)
  21928. PsnNo = psn_info.PsnNo
  21929. PsnCertType = psn_info.PsnCertType
  21930. Certno = psn_info.Certno
  21931. PsnName = psn_info.PsnName
  21932. Gend = psn_info.Gend
  21933. Naty = psn_info.Naty
  21934. Brdy = psn_info.Brdy
  21935. Age = psn_info.Age
  21936. infoStr = psn_info.Insuinfo
  21937. idetinfoStr = psn_info.Idetinfo
  21938. infocode = 0
  21939. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21940. psn_info, _ := service.GetPsnByPatientId(id)
  21941. PsnNo = psn_info.PsnNo
  21942. PsnCertType = psn_info.PsnCertType
  21943. Certno = psn_info.Certno
  21944. PsnName = psn_info.PsnName
  21945. Gend = psn_info.Gend
  21946. Naty = psn_info.Naty
  21947. Brdy = psn_info.Brdy
  21948. Age = psn_info.Age
  21949. infoStr = psn_info.Insuinfo
  21950. idetinfoStr = psn_info.Idetinfo
  21951. infocode = 0
  21952. verify_number = psn_info.VerifyNumber
  21953. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21954. if id_card_type == 2 {
  21955. //请求内网数据
  21956. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  21957. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21958. "&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
  21959. resp, requestErr := http.Get(api)
  21960. if requestErr != nil {
  21961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21962. return
  21963. }
  21964. body, ioErr := ioutil.ReadAll(resp.Body)
  21965. if ioErr != nil {
  21966. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21968. return
  21969. }
  21970. var respJSON map[string]interface{}
  21971. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21974. return
  21975. }
  21976. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21977. result_byte, _ := json.Marshal(respJSON)
  21978. result := string(result_byte)
  21979. var dat map[string]interface{}
  21980. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21981. fmt.Println(dat)
  21982. } else {
  21983. fmt.Println(err)
  21984. }
  21985. userJSONBytes, _ := json.Marshal(dat)
  21986. var res ResultTwo
  21987. var resTwo10265 ResultTwo10265
  21988. if miConfig.Code == "H15049901371" {
  21989. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  21990. utils.ErrorLog("解析失败:%v", err)
  21991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21992. return
  21993. }
  21994. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  21995. res.Infcode = Infcode
  21996. res.ErrMsg = resTwo10265.ErrMsg
  21997. res.Output = resTwo10265.Output
  21998. res.InfRefmsgid = resTwo10265.InfRefmsgid
  21999. res.RespondTime = resTwo10265.RespondTime
  22000. res.WarnInfo = resTwo10265.WarnInfo
  22001. } else {
  22002. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22003. utils.ErrorLog("解析失败:%v", err)
  22004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22005. return
  22006. }
  22007. }
  22008. //var insutypes []string
  22009. //var insutype string
  22010. //var is390 int = 0
  22011. //var is310 int = 0
  22012. //for _, item := range res.Output.Iinfo {
  22013. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22014. // insutypes = append(insutypes, item.Insutype)
  22015. // }
  22016. //}
  22017. //if len(insutypes) == 1 {
  22018. // insutype = insutypes[0]
  22019. //} else {
  22020. // for _, i := range insutypes {
  22021. // if i == "390" {
  22022. // is390 = 1
  22023. // }
  22024. //
  22025. // if i == "310" {
  22026. // is310 = 1
  22027. // }
  22028. // }
  22029. //}
  22030. //if is390 == 1 {
  22031. // insutype = "390"
  22032. //}
  22033. //if is310 == 1 {
  22034. // insutype = "310"
  22035. //}
  22036. //if len(insutypes) == 0 {
  22037. // insutype = "310"
  22038. //}
  22039. PsnNo = res.Output.Baseinfo.PsnNo
  22040. PsnCertType = res.Output.Baseinfo.PsnCertType
  22041. Certno = res.Output.Baseinfo.Certno
  22042. PsnName = res.Output.Baseinfo.PsnName
  22043. Gend = res.Output.Baseinfo.Gend
  22044. Naty = res.Output.Baseinfo.Naty
  22045. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22046. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22047. infoStr = string(Iinfos)
  22048. idetinfoStr = string(Idetinfos)
  22049. infocode = res.Infcode
  22050. //infocode = 0
  22051. //verify_number = psn_info.VerifyNumber
  22052. } else {
  22053. psn_info, _ := service.GetPsnByPatientId(id)
  22054. PsnNo = psn_info.PsnNo
  22055. PsnCertType = psn_info.PsnCertType
  22056. Certno = psn_info.Certno
  22057. PsnName = psn_info.PsnName
  22058. Gend = psn_info.Gend
  22059. Naty = psn_info.Naty
  22060. Brdy = psn_info.Brdy
  22061. Age = psn_info.Age
  22062. infoStr = psn_info.Insuinfo
  22063. idetinfoStr = psn_info.Idetinfo
  22064. infocode = 0
  22065. verify_number = psn_info.VerifyNumber
  22066. }
  22067. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22068. if id_card_type == 1 {
  22069. psn_info, _ := service.GetPsnByPatientId(id)
  22070. PsnNo = psn_info.PsnNo
  22071. PsnCertType = psn_info.PsnCertType
  22072. Certno = psn_info.Certno
  22073. PsnName = psn_info.PsnName
  22074. Gend = psn_info.Gend
  22075. Naty = psn_info.Naty
  22076. Brdy = psn_info.Brdy
  22077. Age = psn_info.Age
  22078. infoStr = psn_info.Insuinfo
  22079. idetinfoStr = psn_info.Idetinfo
  22080. infocode = 0
  22081. verify_number = psn_info.VerifyNumber
  22082. } else if id_card_type == 2 {
  22083. 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)
  22084. fmt.Println(errMsgLog)
  22085. saveLog(result, requestLog, "1101", "人员基本信息获取")
  22086. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22087. utils.ErrorLog("解析失败:%v", err)
  22088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22089. return
  22090. }
  22091. PsnNo = res.Output.Baseinfo.PsnNo
  22092. PsnCertType = res.Output.Baseinfo.PsnCertType
  22093. Certno = res.Output.Baseinfo.Certno
  22094. PsnName = res.Output.Baseinfo.PsnName
  22095. Gend = res.Output.Baseinfo.Gend
  22096. Naty = res.Output.Baseinfo.Naty
  22097. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22098. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22099. infoStr = string(Iinfos)
  22100. idetinfoStr = string(Idetinfos)
  22101. infocode = res.Infcode
  22102. }
  22103. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22104. if id_card_type == 1 {
  22105. psn_info, _ := service.GetPsnByPatientId(id)
  22106. PsnNo = psn_info.PsnNo
  22107. PsnCertType = psn_info.PsnCertType
  22108. Certno = psn_info.Certno
  22109. PsnName = psn_info.PsnName
  22110. Gend = psn_info.Gend
  22111. Naty = psn_info.Naty
  22112. Brdy = psn_info.Brdy
  22113. Age = psn_info.Age
  22114. infoStr = psn_info.Insuinfo
  22115. idetinfoStr = psn_info.Idetinfo
  22116. infocode = 0
  22117. verify_number = psn_info.VerifyNumber
  22118. } else if id_card_type == 2 {
  22119. 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, "")
  22120. saveLog(result, requestLog, "1101", "人员基本信息获取")
  22121. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22122. utils.ErrorLog("解析失败:%v", err)
  22123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22124. return
  22125. }
  22126. PsnNo = res.Output.Baseinfo.PsnNo
  22127. PsnCertType = res.Output.Baseinfo.PsnCertType
  22128. Certno = res.Output.Baseinfo.Certno
  22129. PsnName = res.Output.Baseinfo.PsnName
  22130. Gend = res.Output.Baseinfo.Gend
  22131. Naty = res.Output.Baseinfo.Naty
  22132. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22133. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22134. infoStr = string(Iinfos)
  22135. idetinfoStr = string(Idetinfos)
  22136. infocode = res.Infcode
  22137. } else {
  22138. psn_info, _ := service.GetPsnByPatientId(id)
  22139. PsnNo = psn_info.PsnNo
  22140. PsnCertType = psn_info.PsnCertType
  22141. Certno = psn_info.Certno
  22142. PsnName = psn_info.PsnName
  22143. Gend = psn_info.Gend
  22144. Naty = psn_info.Naty
  22145. Brdy = psn_info.Brdy
  22146. Age = psn_info.Age
  22147. infoStr = psn_info.Insuinfo
  22148. idetinfoStr = psn_info.Idetinfo
  22149. infocode = 0
  22150. verify_number = psn_info.VerifyNumber
  22151. }
  22152. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22153. psn_info, _ := service.GetPsnByPatientId(id)
  22154. PsnNo = psn_info.PsnNo
  22155. PsnCertType = psn_info.PsnCertType
  22156. Certno = psn_info.Certno
  22157. PsnName = psn_info.PsnName
  22158. Gend = psn_info.Gend
  22159. Naty = psn_info.Naty
  22160. Brdy = psn_info.Brdy
  22161. Age = psn_info.Age
  22162. infoStr = psn_info.Insuinfo
  22163. idetinfoStr = psn_info.Idetinfo
  22164. infocode = 0
  22165. verify_number = psn_info.VerifyNumber
  22166. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22167. if id_card_type == 1 {
  22168. psn_info, _ := service.GetPsnByPatientId(id)
  22169. PsnNo = psn_info.PsnNo
  22170. PsnCertType = psn_info.PsnCertType
  22171. Certno = psn_info.Certno
  22172. PsnName = psn_info.PsnName
  22173. Gend = psn_info.Gend
  22174. Naty = psn_info.Naty
  22175. Brdy = psn_info.Brdy
  22176. Age = psn_info.Age
  22177. infoStr = psn_info.Insuinfo
  22178. idetinfoStr = psn_info.Idetinfo
  22179. infocode = 0
  22180. verify_number = psn_info.VerifyNumber
  22181. } else if id_card_type == 2 {
  22182. 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)
  22183. saveLog(result, requestLog, "1101", "人员基本信息获取")
  22184. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22185. utils.ErrorLog("解析失败:%v", err)
  22186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22187. return
  22188. }
  22189. PsnNo = res.Output.Baseinfo.PsnNo
  22190. PsnCertType = res.Output.Baseinfo.PsnCertType
  22191. Certno = res.Output.Baseinfo.Certno
  22192. PsnName = res.Output.Baseinfo.PsnName
  22193. Gend = res.Output.Baseinfo.Gend
  22194. Naty = res.Output.Baseinfo.Naty
  22195. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22196. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22197. infoStr = string(Iinfos)
  22198. idetinfoStr = string(Idetinfos)
  22199. infocode = res.Infcode
  22200. } else if id_card_type == 4 {
  22201. psn_info, _ := service.GetPsnByPatientId(id)
  22202. PsnNo = psn_info.PsnNo
  22203. PsnCertType = psn_info.PsnCertType
  22204. Certno = psn_info.Certno
  22205. PsnName = psn_info.PsnName
  22206. Gend = psn_info.Gend
  22207. Naty = psn_info.Naty
  22208. Brdy = psn_info.Brdy
  22209. Age = psn_info.Age
  22210. infoStr = psn_info.Insuinfo
  22211. idetinfoStr = psn_info.Idetinfo
  22212. infocode = 0
  22213. verify_number = psn_info.VerifyNumber
  22214. }
  22215. } else if miConfig.MdtrtareaAdmvs == "131023" {
  22216. var result string
  22217. var requestLog string
  22218. 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), "")
  22219. if id_card_type == 4 {
  22220. psn_info, _ := service.GetPsnByPatientId(id)
  22221. PsnNo = psn_info.PsnNo
  22222. PsnCertType = psn_info.PsnCertType
  22223. Certno = psn_info.Certno
  22224. PsnName = psn_info.PsnName
  22225. Gend = psn_info.Gend
  22226. Naty = psn_info.Naty
  22227. Brdy = psn_info.Brdy
  22228. Age = psn_info.Age
  22229. infoStr = psn_info.Insuinfo
  22230. idetinfoStr = psn_info.Idetinfo
  22231. infocode = 0
  22232. verify_number = psn_info.VerifyNumber
  22233. } else {
  22234. saveLog(result, requestLog, "1101", "人员基本信息获取")
  22235. if miConfig.Code == "H15049901371" {
  22236. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  22237. utils.ErrorLog("解析失败:%v", err)
  22238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22239. return
  22240. }
  22241. res.ErrMsg = res10265.ErrMsg
  22242. res.Output = res10265.Output
  22243. res.InfRefmsgid = res10265.InfRefmsgid
  22244. } else {
  22245. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22246. utils.ErrorLog("解析失败:%v", err)
  22247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22248. return
  22249. }
  22250. }
  22251. PsnNo = res.Output.Baseinfo.PsnNo
  22252. PsnCertType = res.Output.Baseinfo.PsnCertType
  22253. Certno = res.Output.Baseinfo.Certno
  22254. PsnName = res.Output.Baseinfo.PsnName
  22255. Gend = res.Output.Baseinfo.Gend
  22256. Naty = res.Output.Baseinfo.Naty
  22257. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22258. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22259. infoStr = string(Iinfos)
  22260. idetinfoStr = string(Idetinfos)
  22261. if miConfig.Code == "H15049901371" {
  22262. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  22263. } else {
  22264. infocode = res.Infcode
  22265. }
  22266. }
  22267. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22268. psn_info, _ := service.GetPsnByPatientId(id)
  22269. PsnNo = psn_info.PsnNo
  22270. PsnCertType = psn_info.PsnCertType
  22271. Certno = psn_info.Certno
  22272. PsnName = psn_info.PsnName
  22273. Gend = psn_info.Gend
  22274. Naty = psn_info.Naty
  22275. Brdy = psn_info.Brdy
  22276. Age = psn_info.Age
  22277. infoStr = psn_info.Insuinfo
  22278. idetinfoStr = psn_info.Idetinfo
  22279. infocode = 0
  22280. verify_number = psn_info.VerifyNumber
  22281. } else if miConfig.MdtrtareaAdmvs == "450721" {
  22282. psn_info, _ := service.GetPsnByPatientId(id)
  22283. PsnNo = psn_info.PsnNo
  22284. PsnCertType = psn_info.PsnCertType
  22285. Certno = psn_info.Certno
  22286. PsnName = psn_info.PsnName
  22287. Gend = psn_info.Gend
  22288. Naty = psn_info.Naty
  22289. Brdy = psn_info.Brdy
  22290. Age = psn_info.Age
  22291. infoStr = psn_info.Insuinfo
  22292. idetinfoStr = psn_info.Idetinfo
  22293. infocode = 0
  22294. verify_number = psn_info.VerifyNumber
  22295. } else {
  22296. var result string
  22297. var requestLog string
  22298. //if miConfig.UserOrgId == 10138 {
  22299. if id_card_type != 4 || id_card_type != 1 {
  22300. var insa string
  22301. if len(patient.InsuplcAdmdvs) > 0 {
  22302. insa = patient.InsuplcAdmdvs
  22303. } else {
  22304. insa = miConfig.InsuplcAdmdvs
  22305. }
  22306. //psn_info, _ := service.GetPsnByPatientId(id)
  22307. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  22308. 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)
  22309. }
  22310. //}
  22311. //else {
  22312. // var insa string
  22313. // if len(patient.InsuplcAdmdvs) > 0 {
  22314. // insa = patient.InsuplcAdmdvs
  22315. // } else {
  22316. // insa = miConfig.InsuplcAdmdvs
  22317. // }
  22318. // 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)
  22319. //}
  22320. if id_card_type == 4 || id_card_type == 1 {
  22321. psn_info, _ := service.GetPsnByPatientId(id)
  22322. PsnNo = psn_info.PsnNo
  22323. PsnCertType = psn_info.PsnCertType
  22324. Certno = psn_info.Certno
  22325. PsnName = psn_info.PsnName
  22326. Gend = psn_info.Gend
  22327. Naty = psn_info.Naty
  22328. Brdy = psn_info.Brdy
  22329. Age = psn_info.Age
  22330. infoStr = psn_info.Insuinfo
  22331. idetinfoStr = psn_info.Idetinfo
  22332. infocode = 0
  22333. verify_number = psn_info.VerifyNumber
  22334. } else {
  22335. saveLog(result, requestLog, "1101", "人员基本信息获取")
  22336. if miConfig.Code == "H15049901371" {
  22337. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  22338. utils.ErrorLog("解析失败:%v", err)
  22339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22340. return
  22341. }
  22342. res.ErrMsg = res10265.ErrMsg
  22343. res.Output = res10265.Output
  22344. res.InfRefmsgid = res10265.InfRefmsgid
  22345. } else {
  22346. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22347. utils.ErrorLog("解析失败:%v", err)
  22348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22349. return
  22350. }
  22351. }
  22352. PsnNo = res.Output.Baseinfo.PsnNo
  22353. PsnCertType = res.Output.Baseinfo.PsnCertType
  22354. Certno = res.Output.Baseinfo.Certno
  22355. PsnName = res.Output.Baseinfo.PsnName
  22356. Gend = res.Output.Baseinfo.Gend
  22357. Naty = res.Output.Baseinfo.Naty
  22358. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22359. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22360. infoStr = string(Iinfos)
  22361. idetinfoStr = string(Idetinfos)
  22362. if miConfig.Code == "H15049901371" {
  22363. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  22364. } else {
  22365. infocode = res.Infcode
  22366. }
  22367. }
  22368. }
  22369. if infocode == 0 {
  22370. his := models.VMHisPatient{
  22371. Name: name,
  22372. Gender: gender,
  22373. Birthday: birthUnix,
  22374. MedicalTreatmentType: medical_care,
  22375. IdType: certificates,
  22376. IdCardNo: id_card,
  22377. BalanceAccountsType: settlementValue,
  22378. SocialType: social_type,
  22379. MedicalInsuranceNumber: medical_insurance_card,
  22380. RegisterType: register_type,
  22381. RegisterCost: registration_fee,
  22382. TreatmentCost: medical_expenses,
  22383. Status: 1,
  22384. Ctime: time.Now().Unix(),
  22385. Mtime: time.Now().Unix(),
  22386. PsnNo: PsnNo,
  22387. PsnCertType: PsnCertType,
  22388. Certno: Certno,
  22389. PsnName: PsnName,
  22390. Gend: Gend,
  22391. Naty: Naty,
  22392. Brdy: Brdy,
  22393. Age: Age,
  22394. Iinfo: infoStr,
  22395. Idetinfo: idetinfoStr,
  22396. PatientId: patient.ID,
  22397. RecordDate: theTime.Unix(),
  22398. UserOrgId: adminInfo.CurrentOrgId,
  22399. AdminUserId: admin_user_id,
  22400. IsReturn: 1,
  22401. IdCardType: id_card_type,
  22402. Doctor: doctor,
  22403. Departments: department,
  22404. MdtrtGrpType: mdtrt_type,
  22405. }
  22406. timestamp := time.Now().Unix()
  22407. tempTime := time.Unix(timestamp, 0)
  22408. timeFormat := tempTime.Format("20060102150405")
  22409. chrgBchno := rand.Intn(100000) + 10000
  22410. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  22411. his.Number = ipt_otp_no
  22412. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  22413. department, _ := service.GetDepartMentDetail(department)
  22414. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  22415. IdCardNo := ""
  22416. if id_card_type == 1 {
  22417. // IdCardNo = medical_insurance_card
  22418. IdCardNo = patient.IdCardNo
  22419. } else {
  22420. IdCardNo = patient.IdCardNo
  22421. }
  22422. var rf []*ResultFive
  22423. json.Unmarshal([]byte(his.Iinfo), &rf)
  22424. var insutypes []*ResultFive
  22425. var insutype string
  22426. var insuplc_admdvs_temp string
  22427. var is390 int = 0
  22428. var is310 int = 0
  22429. for _, item := range rf {
  22430. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22431. insutypes = append(insutypes, item)
  22432. }
  22433. }
  22434. if len(insutypes) == 1 {
  22435. insutype = insutypes[0].Insutype
  22436. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  22437. if insutype == "390" {
  22438. is390 = 1
  22439. }
  22440. if insutype == "310" {
  22441. is310 = 1
  22442. }
  22443. } else {
  22444. for _, i := range insutypes {
  22445. if i.Insutype == "390" {
  22446. is390 = 1
  22447. }
  22448. if i.Insutype == "310" {
  22449. is310 = 1
  22450. }
  22451. }
  22452. }
  22453. if is390 == 1 {
  22454. insutype = "390"
  22455. }
  22456. if is310 == 1 {
  22457. insutype = "310"
  22458. }
  22459. fmt.Println(social_type)
  22460. if social_type > 0 {
  22461. insutype = strconv.FormatInt(social_type, 10)
  22462. }
  22463. var infocode int64
  22464. var resThree ResultThree
  22465. var resThree10265 ResultThree10265
  22466. if len(insuplc_admdvs) == 0 {
  22467. psn_info, _ := service.GetPsnByPatientId(id)
  22468. //if len(psn_info.InsuplcAdmdvs) > 0 {
  22469. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22470. //}
  22471. } else {
  22472. insuplc_admdvs_temp = insuplc_admdvs
  22473. }
  22474. if miConfig.MdtrtareaAdmvs == "421300" {
  22475. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22476. psn_info, _ := service.GetPsnByPatientId(id)
  22477. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22478. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22479. "&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
  22480. resp, requestErr := http.Get(api)
  22481. if requestErr != nil {
  22482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22483. return
  22484. }
  22485. body, ioErr := ioutil.ReadAll(resp.Body)
  22486. if ioErr != nil {
  22487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22489. return
  22490. }
  22491. var respJSON map[string]interface{}
  22492. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22495. return
  22496. }
  22497. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22498. result, _ := json.Marshal(respJSON)
  22499. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22500. utils.ErrorLog("解析失败:%v", err)
  22501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22502. return
  22503. }
  22504. infocode = resThree.Infcode
  22505. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22506. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22507. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  22508. // insuplc_admdvs_temp =
  22509. //}
  22510. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  22511. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22512. //}
  22513. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22514. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22515. "&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
  22516. resp, requestErr := http.Get(api)
  22517. if requestErr != nil {
  22518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22519. return
  22520. }
  22521. body, ioErr := ioutil.ReadAll(resp.Body)
  22522. if ioErr != nil {
  22523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22525. return
  22526. }
  22527. var respJSON map[string]interface{}
  22528. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22531. return
  22532. }
  22533. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22534. result, _ := json.Marshal(respJSON)
  22535. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22536. utils.ErrorLog("解析失败:%v", err)
  22537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22538. return
  22539. }
  22540. infocode = resThree.Infcode
  22541. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22542. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22543. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  22544. // insuplc_admdvs_temp =
  22545. //}
  22546. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  22547. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22548. //}
  22549. utils.ErrorLog("解析失败:%v", insutype)
  22550. utils.ErrorLog("解析失败:%v", PsnNo)
  22551. utils.ErrorLog("解析失败:%v", Certno)
  22552. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  22553. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  22554. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  22555. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  22556. utils.ErrorLog("解析失败:%v", PsnNo)
  22557. utils.ErrorLog("解析失败:%v", department.Number)
  22558. utils.ErrorLog("解析失败:%v", department.Name)
  22559. utils.ErrorLog("解析失败:%v", roles.UserName)
  22560. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22561. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22562. "&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
  22563. resp, requestErr := http.Get(api)
  22564. if requestErr != nil {
  22565. utils.ErrorLog("解析失败:%v", requestErr)
  22566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22567. return
  22568. }
  22569. body, ioErr := ioutil.ReadAll(resp.Body)
  22570. if ioErr != nil {
  22571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22573. return
  22574. }
  22575. var respJSON map[string]interface{}
  22576. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22579. return
  22580. }
  22581. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22582. result, _ := json.Marshal(respJSON)
  22583. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22584. utils.ErrorLog("解析失败:%v", err)
  22585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22586. return
  22587. }
  22588. infocode = resThree.Infcode
  22589. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22590. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22591. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  22592. // insuplc_admdvs_temp =
  22593. //}
  22594. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  22595. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22596. //}
  22597. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22598. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22599. "&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
  22600. resp, requestErr := http.Get(api)
  22601. if requestErr != nil {
  22602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22603. return
  22604. }
  22605. body, ioErr := ioutil.ReadAll(resp.Body)
  22606. if ioErr != nil {
  22607. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22609. return
  22610. }
  22611. var respJSON map[string]interface{}
  22612. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22613. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22615. return
  22616. }
  22617. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22618. result, _ := json.Marshal(respJSON)
  22619. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22620. utils.ErrorLog("解析失败:%v", err)
  22621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22622. return
  22623. }
  22624. infocode = resThree.Infcode
  22625. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22626. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22627. psn_info, _ := service.GetPsnByPatientId(id)
  22628. var verify_number string
  22629. if id_card_type == 4 {
  22630. verify_number = psn_info.VerifyNumber
  22631. } else if id_card_type == 1 {
  22632. bas := strings.Split(psn_info.CardInfo, "|")
  22633. cardNumber := bas[2]
  22634. verify_number = cardNumber
  22635. }
  22636. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22637. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22638. "&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
  22639. resp, requestErr := http.Get(api)
  22640. if requestErr != nil {
  22641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22642. return
  22643. }
  22644. body, ioErr := ioutil.ReadAll(resp.Body)
  22645. if ioErr != nil {
  22646. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22648. return
  22649. }
  22650. var respJSON map[string]interface{}
  22651. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22652. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22654. return
  22655. }
  22656. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22657. result, _ := json.Marshal(respJSON)
  22658. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22659. // utils.ErrorLog("解析失败:%v", err)
  22660. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22661. // return
  22662. //}
  22663. //infocode = resThree.Infcode
  22664. //result, _ := json.Marshal(respJSON)
  22665. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22666. utils.ErrorLog("解析失败:%v", err)
  22667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22668. return
  22669. }
  22670. resThree.ErrMsg = resThree10265.ErrMsg
  22671. resThree.Output = resThree10265.Output
  22672. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22673. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22674. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22675. psn_info, _ := service.GetPsnByPatientId(id)
  22676. his.PsnNo = psn_info.PsnNo
  22677. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22678. var cert_no string
  22679. if id_card_type == 3 {
  22680. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  22681. cert_no = IdCardNo
  22682. } else if id_card_type == 4 {
  22683. cert_no = IdCardNo
  22684. psn_info.VerifyNumber = psn_info.VerifyNumber
  22685. } else {
  22686. bas := strings.Split(psn_info.CardInfo, "|")
  22687. cert_no = bas[2]
  22688. }
  22689. var hisPrescription []*models.HisPrescription
  22690. for _, item := range rf {
  22691. if item.Insutype == insutype {
  22692. //insuplc_admdvs = item.InsuplcAdmdvs
  22693. his.InsuplcAdmdvs = insuplc_admdvs
  22694. }
  22695. }
  22696. his.Insutype = insutype
  22697. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  22698. fmt.Println(res3101)
  22699. fmt.Println(res3101.Infcode)
  22700. if res3101.Infcode == "0" {
  22701. fmt.Println("33333333")
  22702. if len(res3101.Output.Result) > 0 {
  22703. fmt.Println("222222")
  22704. for _, item := range res3101.Output.Result {
  22705. if len(res3101.ErrMsg) == 0 {
  22706. res3101.ErrMsg = item.VolaCont
  22707. } else {
  22708. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  22709. }
  22710. }
  22711. c.ServeSuccessJSON(map[string]interface{}{
  22712. "failed_code": -10,
  22713. "msg": res3101.ErrMsg,
  22714. })
  22715. return
  22716. } else {
  22717. fmt.Println("11111")
  22718. var api string
  22719. if miConfig.MdtrtareaAdmvs == "320921" {
  22720. ipt_otp_no = timeFormat
  22721. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  22722. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22723. "&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
  22724. } else {
  22725. ipt_otp_no = timeFormat
  22726. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  22727. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22728. "&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
  22729. }
  22730. resp, requestErr := http.Get(api)
  22731. if requestErr != nil {
  22732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22733. return
  22734. }
  22735. body, ioErr := ioutil.ReadAll(resp.Body)
  22736. if ioErr != nil {
  22737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22739. return
  22740. }
  22741. var respJSON map[string]interface{}
  22742. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22745. return
  22746. }
  22747. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22748. result, _ := json.Marshal(respJSON)
  22749. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22750. utils.ErrorLog("解析失败:%v", err)
  22751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22752. return
  22753. }
  22754. resThree.ErrMsg = resThree10265.ErrMsg
  22755. resThree.Output = resThree10265.Output
  22756. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22757. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22758. }
  22759. } else if res3101.Infcode != "0" {
  22760. c.ServeSuccessJSON(map[string]interface{}{
  22761. "failed_code": -10,
  22762. "msg": res3101.ErrMsg,
  22763. })
  22764. return
  22765. }
  22766. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22767. psn_info, _ := service.GetPsnByPatientId(id)
  22768. var cert_no string
  22769. if id_card_type == 1 {
  22770. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  22771. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22772. } else if id_card_type == 4 {
  22773. cert_no = psn_info.VerifyNumber
  22774. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22775. } else {
  22776. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22777. cert_no = psn_info.VerifyNumber
  22778. }
  22779. 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)
  22780. saveLog(result, requestLog, "2201", "挂号")
  22781. if miConfig.Code == "H15049901371" {
  22782. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22783. utils.ErrorLog("解析失败:%v", err)
  22784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22785. return
  22786. }
  22787. resThree.ErrMsg = resThree10265.ErrMsg
  22788. resThree.Output = resThree10265.Output
  22789. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22790. } else {
  22791. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22792. utils.ErrorLog("解析失败:%v", err)
  22793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22794. return
  22795. }
  22796. }
  22797. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22798. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  22799. psn_info, _ := service.GetPsnByPatientId(id)
  22800. var result string
  22801. var requestLog string
  22802. if id_card_type == 1 {
  22803. bas := strings.Split(psn_info.CardInfo, "|")
  22804. basNumber := bas[2]
  22805. card_sn := bas[3]
  22806. 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)
  22807. saveLog(result, requestLog, "2201A", "挂号")
  22808. } else if id_card_type == 2 {
  22809. 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, "", "", "", "", "", "")
  22810. saveLog(result, requestLog, "2201A", "挂号")
  22811. } else {
  22812. 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)
  22813. saveLog(result, requestLog, "2201A", "挂号")
  22814. }
  22815. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22816. utils.ErrorLog("解析失败:%v", err)
  22817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22818. return
  22819. }
  22820. infocode = resThree.Infcode
  22821. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22822. psn_info, _ := service.GetPsnByPatientId(id)
  22823. his.PsnNo = psn_info.PsnNo
  22824. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22825. var cert_no string
  22826. if id_card_type == 1 {
  22827. bas := strings.Split(psn_info.CardInfo, "|")
  22828. cert_no = bas[2]
  22829. } else if id_card_type == 4 {
  22830. cert_no = IdCardNo
  22831. psn_info.VerifyNumber = psn_info.VerifyNumber
  22832. } else {
  22833. cert_no = IdCardNo
  22834. psn_info.VerifyNumber = cert_no
  22835. }
  22836. for _, item := range rf {
  22837. if item.Insutype == insutype {
  22838. his.InsuplcAdmdvs = insuplc_admdvs
  22839. }
  22840. }
  22841. his.Insutype = insutype
  22842. var api string
  22843. ipt_otp_no = timeFormat
  22844. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  22845. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22846. "&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
  22847. resp, requestErr := http.Get(api)
  22848. if requestErr != nil {
  22849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22850. return
  22851. }
  22852. body, ioErr := ioutil.ReadAll(resp.Body)
  22853. if ioErr != nil {
  22854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22856. return
  22857. }
  22858. var respJSON map[string]interface{}
  22859. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22862. return
  22863. }
  22864. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22865. if status == "0" {
  22866. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22867. c.ServeSuccessJSON(map[string]interface{}{
  22868. "failed_code": -10,
  22869. "msg": err_msg,
  22870. })
  22871. return
  22872. }
  22873. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22874. result, _ := json.Marshal(respJSON)
  22875. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22876. utils.ErrorLog("解析失败:%v", err)
  22877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22878. return
  22879. }
  22880. infocode = resThree.Infcode
  22881. } else if miConfig.MdtrtareaAdmvs == "340699" {
  22882. psn_info, _ := service.GetPsnByPatientId(id)
  22883. his.PsnNo = psn_info.PsnNo
  22884. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22885. var cert_no string
  22886. if id_card_type == 1 {
  22887. bas := strings.Split(psn_info.CardInfo, "|")
  22888. cert_no = bas[2]
  22889. } else if id_card_type == 4 {
  22890. cert_no = IdCardNo
  22891. psn_info.VerifyNumber = psn_info.VerifyNumber
  22892. } else {
  22893. cert_no = IdCardNo
  22894. psn_info.VerifyNumber = cert_no
  22895. }
  22896. for _, item := range rf {
  22897. if item.Insutype == insutype {
  22898. his.InsuplcAdmdvs = insuplc_admdvs
  22899. }
  22900. }
  22901. his.Insutype = insutype
  22902. var api string
  22903. ipt_otp_no = timeFormat
  22904. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  22905. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22906. "&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
  22907. resp, requestErr := http.Get(api)
  22908. if requestErr != nil {
  22909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22910. return
  22911. }
  22912. body, ioErr := ioutil.ReadAll(resp.Body)
  22913. if ioErr != nil {
  22914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22916. return
  22917. }
  22918. var respJSON map[string]interface{}
  22919. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22922. return
  22923. }
  22924. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22925. if status == "0" {
  22926. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22927. c.ServeSuccessJSON(map[string]interface{}{
  22928. "failed_code": -10,
  22929. "msg": err_msg,
  22930. })
  22931. return
  22932. }
  22933. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22934. result, _ := json.Marshal(respJSON)
  22935. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22936. utils.ErrorLog("解析失败:%v", err)
  22937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22938. return
  22939. }
  22940. infocode = resThree.Infcode
  22941. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22942. psn_info, _ := service.GetPsnByPatientId(id)
  22943. var result string
  22944. var requestLog string
  22945. if id_card_type == 1 {
  22946. bas := strings.Split(psn_info.CardInfo, "|")
  22947. basNumber := bas[2]
  22948. card_sn := bas[3]
  22949. 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)
  22950. saveLog(result, requestLog, "2201A", "挂号")
  22951. } else if id_card_type == 2 {
  22952. 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, "", "")
  22953. saveLog(result, requestLog, "2201A", "挂号")
  22954. } else {
  22955. 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, "", "")
  22956. saveLog(result, requestLog, "2201A", "挂号")
  22957. }
  22958. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22959. utils.ErrorLog("解析失败:%v", err)
  22960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22961. return
  22962. }
  22963. infocode = resThree.Infcode
  22964. } else if miConfig.MdtrtareaAdmvs == "131023" {
  22965. psn_info, _ := service.GetPsnByPatientId(id)
  22966. 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)
  22967. saveLog(result, requestLog, "2201A", "挂号")
  22968. if miConfig.Code == "H15049901371" {
  22969. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22970. utils.ErrorLog("解析失败:%v", err)
  22971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22972. return
  22973. }
  22974. resThree.ErrMsg = resThree10265.ErrMsg
  22975. resThree.Output = resThree10265.Output
  22976. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22977. } else {
  22978. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22979. utils.ErrorLog("解析失败:%v", err)
  22980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22981. return
  22982. }
  22983. }
  22984. if miConfig.Code == "H15049901371" {
  22985. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22986. } else {
  22987. infocode = resThree.Infcode
  22988. }
  22989. } else {
  22990. psn_info, _ := service.GetPsnByPatientId(id)
  22991. if id_card_type == 4 || id_card_type == 1 {
  22992. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22993. }
  22994. var rf []*ResultFive
  22995. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  22996. var insutypes []*ResultFive
  22997. var insutype string
  22998. var is390 int = 0
  22999. var is310 int = 0
  23000. for _, item := range rf {
  23001. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23002. insutypes = append(insutypes, item)
  23003. }
  23004. }
  23005. if len(insutypes) == 1 {
  23006. insutype = insutypes[0].Insutype
  23007. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23008. } else {
  23009. for _, i := range insutypes {
  23010. if i.Insutype == "390" {
  23011. is390 = 1
  23012. }
  23013. if i.Insutype == "310" {
  23014. is310 = 1
  23015. }
  23016. }
  23017. }
  23018. if is390 == 1 {
  23019. insutype = "390"
  23020. }
  23021. if is310 == 1 {
  23022. insutype = "310"
  23023. }
  23024. fmt.Println(len(insutypes))
  23025. if len(insutypes) == 0 {
  23026. for index, item := range rf {
  23027. if index == 0 {
  23028. insutype = item.Insutype
  23029. insuplc_admdvs = item.InsuplcAdmdvs
  23030. }
  23031. }
  23032. fmt.Println(insutype)
  23033. fmt.Println(insuplc_admdvs)
  23034. }
  23035. if social_type > 0 {
  23036. insutype = strconv.FormatInt(social_type, 10)
  23037. }
  23038. fmt.Println("--------")
  23039. fmt.Println(psn_info)
  23040. fmt.Println(psn_info.PsnNo)
  23041. if miConfig.MdtrtareaAdmvs == "441202" {
  23042. var hisPrescription []*models.HisPrescription
  23043. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  23044. if res3101.Infcode == 0 {
  23045. fmt.Println("33333333")
  23046. if len(res3101.Output.Result) > 0 {
  23047. fmt.Println("222222")
  23048. for _, item := range res3101.Output.Result {
  23049. if len(res3101.ErrMsg) == 0 {
  23050. res3101.ErrMsg = item.VolaCont
  23051. } else {
  23052. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  23053. }
  23054. }
  23055. c.ServeSuccessJSON(map[string]interface{}{
  23056. "failed_code": -10,
  23057. "msg": res3101.ErrMsg,
  23058. })
  23059. return
  23060. } else {
  23061. hour := time.Now().Format("15")
  23062. min := time.Now().Format("04")
  23063. sec := time.Now().Format("05")
  23064. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  23065. fmt.Println(record_time_two)
  23066. 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)
  23067. saveLog(result, requestLog, "2201A", "挂号")
  23068. if miConfig.Code == "H15049901371" {
  23069. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23070. utils.ErrorLog("解析失败:%v", err)
  23071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23072. return
  23073. }
  23074. resThree.ErrMsg = resThree10265.ErrMsg
  23075. resThree.Output = resThree10265.Output
  23076. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23077. } else {
  23078. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23079. utils.ErrorLog("解析失败:%v", err)
  23080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23081. return
  23082. }
  23083. }
  23084. if miConfig.Code == "H15049901371" {
  23085. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23086. } else {
  23087. infocode = resThree.Infcode
  23088. }
  23089. }
  23090. } else if res3101.Infcode != 0 {
  23091. c.ServeSuccessJSON(map[string]interface{}{
  23092. "failed_code": -10,
  23093. "msg": res3101.ErrMsg,
  23094. })
  23095. return
  23096. }
  23097. } else if miConfig.MdtrtareaAdmvs == "440205" {
  23098. var hisPrescription []*models.HisPrescription
  23099. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  23100. if res3101.Infcode == 0 {
  23101. fmt.Println("33333333")
  23102. if len(res3101.Output.Result) > 0 {
  23103. fmt.Println("222222")
  23104. for _, item := range res3101.Output.Result {
  23105. if len(res3101.ErrMsg) == 0 {
  23106. res3101.ErrMsg = item.VolaCont
  23107. } else {
  23108. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  23109. }
  23110. }
  23111. c.ServeSuccessJSON(map[string]interface{}{
  23112. "failed_code": -10,
  23113. "msg": res3101.ErrMsg,
  23114. })
  23115. return
  23116. } else {
  23117. hour := time.Now().Format("15")
  23118. min := time.Now().Format("04")
  23119. sec := time.Now().Format("05")
  23120. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  23121. fmt.Println(record_time_two)
  23122. 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)
  23123. saveLog(result, requestLog, "2201A", "挂号")
  23124. if miConfig.Code == "H15049901371" {
  23125. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23126. utils.ErrorLog("解析失败:%v", err)
  23127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23128. return
  23129. }
  23130. resThree.ErrMsg = resThree10265.ErrMsg
  23131. resThree.Output = resThree10265.Output
  23132. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23133. } else {
  23134. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23135. utils.ErrorLog("解析失败:%v", err)
  23136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23137. return
  23138. }
  23139. }
  23140. if miConfig.Code == "H15049901371" {
  23141. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23142. } else {
  23143. infocode = resThree.Infcode
  23144. }
  23145. }
  23146. } else if res3101.Infcode != 0 {
  23147. c.ServeSuccessJSON(map[string]interface{}{
  23148. "failed_code": -10,
  23149. "msg": res3101.ErrMsg,
  23150. })
  23151. return
  23152. }
  23153. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23154. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23155. psn_info, _ := service.GetPsnByPatientId(id)
  23156. var verify_number string
  23157. if id_card_type == 4 {
  23158. verify_number = psn_info.VerifyNumber
  23159. } else if id_card_type == 1 {
  23160. bas := strings.Split(psn_info.CardInfo, "|")
  23161. cardNumber := bas[2]
  23162. verify_number = cardNumber
  23163. } else {
  23164. verify_number = psn_info.Certno
  23165. }
  23166. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23167. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23168. "&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
  23169. resp, requestErr := http.Get(api)
  23170. if requestErr != nil {
  23171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23172. return
  23173. }
  23174. body, ioErr := ioutil.ReadAll(resp.Body)
  23175. if ioErr != nil {
  23176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23178. return
  23179. }
  23180. var respJSON map[string]interface{}
  23181. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23184. return
  23185. }
  23186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23187. result, _ := json.Marshal(respJSON)
  23188. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23189. utils.ErrorLog("解析失败:%v", err)
  23190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23191. return
  23192. }
  23193. infocode = resThree.Infcode
  23194. } else {
  23195. hour := time.Now().Format("15")
  23196. min := time.Now().Format("04")
  23197. sec := time.Now().Format("05")
  23198. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  23199. if id_card_type == 1 {
  23200. for _, item := range rf {
  23201. if item.Insutype == strconv.FormatInt(social_type, 10) {
  23202. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  23203. insuplc_admdvs_temp = item.InsuplcAdmdvs
  23204. } else if strconv.FormatInt(social_type, 10) == "390" {
  23205. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23206. } else {
  23207. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23208. }
  23209. }
  23210. }
  23211. }
  23212. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  23213. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23214. }
  23215. if id_card_type == 1 {
  23216. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  23217. bas := strings.Split(psn_info.CardInfo, "|")
  23218. basNumber := bas[1]
  23219. IdCardNo = basNumber
  23220. }
  23221. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  23222. IdCardNo = psn_info.VerifyNumber
  23223. }
  23224. if len(insuplc_admdvs_temp) == 0 {
  23225. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23226. }
  23227. 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)
  23228. saveLog(result, requestLog, "2201A", "挂号")
  23229. if miConfig.Code == "H15049901371" {
  23230. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23231. utils.ErrorLog("解析失败:%v", err)
  23232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23233. return
  23234. }
  23235. resThree.ErrMsg = resThree10265.ErrMsg
  23236. resThree.Output = resThree10265.Output
  23237. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23238. } else {
  23239. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23240. utils.ErrorLog("解析失败:%v", err)
  23241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23242. return
  23243. }
  23244. }
  23245. if miConfig.Code == "H15049901371" {
  23246. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23247. } else {
  23248. infocode = resThree.Infcode
  23249. }
  23250. }
  23251. }
  23252. if infocode == -1 {
  23253. adminUser := c.GetAdminUserInfo()
  23254. errlog := &models.HisOrderError{
  23255. UserOrgId: adminUser.CurrentOrgId,
  23256. Ctime: time.Now().Unix(),
  23257. Mtime: time.Now().Unix(),
  23258. ErrMsg: resThree.ErrMsg,
  23259. Status: 1,
  23260. PatientId: id,
  23261. RecordTime: recordDateTime,
  23262. Stage: 2,
  23263. }
  23264. service.CreateErrMsgLog(errlog)
  23265. c.ServeSuccessJSON(map[string]interface{}{
  23266. "failed_code": -10,
  23267. "msg": resThree.ErrMsg,
  23268. })
  23269. return
  23270. }
  23271. his.Number = resThree.Output.Data.MdtrtID
  23272. his.PsnNo = resThree.Output.Data.PsnNo
  23273. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  23274. his.IdCardNo = patient.IdCardNo
  23275. his.PhoneNumber = patient.Phone
  23276. his.UserOrgId = adminInfo.CurrentOrgId
  23277. his.Insutype = insutype
  23278. his.Ctime = time.Now().Unix()
  23279. his.Mtime = time.Now().Unix()
  23280. his.InsuplcAdmdvs = insuplc_admdvs_temp
  23281. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  23282. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  23283. }
  23284. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  23285. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  23286. }
  23287. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  23288. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  23289. }
  23290. his.Status = 1
  23291. his.MdtrtGrpType = mdtrt_type
  23292. service.UpdateHisPatientStatus(&his)
  23293. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  23294. c.ServeSuccessJSON(map[string]interface{}{
  23295. "his_info": his,
  23296. })
  23297. } else {
  23298. adminUser := c.GetAdminUserInfo()
  23299. errlog := &models.HisOrderError{
  23300. UserOrgId: adminUser.CurrentOrgId,
  23301. Ctime: time.Now().Unix(),
  23302. Mtime: time.Now().Unix(),
  23303. ErrMsg: res.ErrMsg,
  23304. Status: 1,
  23305. PatientId: id,
  23306. RecordTime: recordDateTime,
  23307. Stage: 1,
  23308. }
  23309. service.CreateErrMsgLog(errlog)
  23310. c.ServeSuccessJSON(map[string]interface{}{
  23311. "failed_code": -10,
  23312. "msg": res.ErrMsg,
  23313. })
  23314. return
  23315. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  23316. }
  23317. }
  23318. }
  23319. func (c *HisApiController) GetUploadInfo() {
  23320. id, _ := c.GetInt64("id")
  23321. record_time := c.GetString("record_time")
  23322. his_patient_id, _ := c.GetInt64("his_patient_id")
  23323. order_id, _ := c.GetInt64("order_id")
  23324. pay_way, _ := c.GetInt64("pay_way")
  23325. pay_ways := c.GetString("pay_ways")
  23326. oth_desc := c.GetString("oth_desc")
  23327. pay_price, _ := c.GetFloat("pay_price")
  23328. pay_card_no := c.GetString("pay_card_no")
  23329. discount_price, _ := c.GetFloat("discount_price")
  23330. preferential_price, _ := c.GetFloat("preferential_price")
  23331. reality_price, _ := c.GetFloat("reality_price")
  23332. found_price, _ := c.GetFloat("found_price")
  23333. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  23334. private_price, _ := c.GetFloat("private_price")
  23335. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  23336. admin_user_id, _ := c.GetInt64("admin_user_id")
  23337. fapiao_code := c.GetString("fapiao_code")
  23338. fapiao_number := c.GetString("fapiao_number")
  23339. diagnosis_id := c.GetString("diagnosis")
  23340. sick_type, _ := c.GetInt64("sick_type")
  23341. reg_type, _ := c.GetInt64("p_type")
  23342. begin_time := c.GetString("begin_time")
  23343. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  23344. cash_pay := c.GetString("cash_pay")
  23345. band_card_pay := c.GetString("band_card_pay")
  23346. wechat_pay := c.GetString("wechat_pay")
  23347. ali_pay := c.GetString("ali_pay")
  23348. jifen_pay := c.GetString("jifen_pay")
  23349. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  23350. fmt.Println(acct_used_flag)
  23351. id_str := c.GetString("ids")
  23352. ids_arr := strings.Split(id_str, ",")
  23353. timeLayout := "2006-01-02"
  23354. loc, _ := time.LoadLocation("Local")
  23355. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23356. if err != nil {
  23357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23358. return
  23359. }
  23360. recordDateTime := theTime.Unix()
  23361. adminUser := c.GetAdminUserInfo()
  23362. var tempOrder models.HisOrder
  23363. tempOrder, _ = service.GetHisOrderByID(order_id)
  23364. var prescriptions []*models.HisPrescription
  23365. var start_time int64
  23366. var end_time int64
  23367. //押金模块
  23368. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  23369. tmp_decimal := c.GetString("tmp_decimal")
  23370. var decimal float64 //本次使用的押金
  23371. var errmsg error
  23372. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  23373. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  23374. return
  23375. }
  23376. if len(tmp_decimal) > 0 {
  23377. if tmp_decimal[0] == 45 {
  23378. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  23379. return
  23380. }
  23381. }
  23382. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  23383. fmt.Println(errs)
  23384. decimal = tt
  23385. //if adminUser.CurrentOrgId == 10106{
  23386. // if len(fapiao_code) == 0{
  23387. // fapiao_code = "144072080589"
  23388. // }
  23389. // if len(fapiao_number) == 0{
  23390. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  23391. // if order.ID == 0{
  23392. // fapiao_number = "00001520"
  23393. // }else{
  23394. // //fapiao_code = "00001520"
  23395. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  23396. // var zero string
  23397. // if fpNumber >= 1000{
  23398. // zero = "0000" + strconv.Itoa(fpNumber)
  23399. // }else if fpNumber >= 10000{
  23400. // zero = "000" + strconv.Itoa(fpNumber)
  23401. // } else if fpNumber >= 100000{
  23402. // zero = "00" + strconv.Itoa(fpNumber)
  23403. // } else if fpNumber >= 1000000{
  23404. // zero = "0" + strconv.Itoa(fpNumber)
  23405. // }else {
  23406. // zero = strconv.Itoa(fpNumber)
  23407. // }
  23408. // fapiao_number = zero
  23409. // }
  23410. // }
  23411. //}
  23412. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23413. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  23414. var patientPrescription models.HisPrescriptionInfo
  23415. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  23416. if patientPrescription.ID == 0 {
  23417. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  23418. }
  23419. //if patientPrescription.Do
  23420. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23421. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  23422. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  23423. diagnosis_ids := strings.Split(diagnosis_id, ",")
  23424. var config []*models.HisXtDiagnoseConfig
  23425. for _, item := range diagnosis_ids {
  23426. id, _ := strconv.ParseInt(item, 10, 64)
  23427. diagnosisConfig, _ := service.FindDiagnoseById(id)
  23428. config = append(config, &diagnosisConfig)
  23429. }
  23430. sickConfig, _ := service.FindSickById(sick_type)
  23431. //if tempOrder.ID == 0 {
  23432. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  23433. //}
  23434. if tempOrder.ID == 0 {
  23435. var result string
  23436. var requestLog string
  23437. var res2 ResultSix
  23438. var res3 GZResultSix
  23439. var ressix10265 ResultSix10265
  23440. if miConfig.MdtrtareaAdmvs == "421300" {
  23441. data := make(map[string]interface{})
  23442. client := &http.Client{}
  23443. data["psn_no"] = his.PsnNo
  23444. data["mdtrt_id"] = his.Number
  23445. data["opter"] = roles.UserName
  23446. data["org_name"] = miConfig.OrgName
  23447. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23448. data["doctor_id"] = doctor_info.DoctorNumber
  23449. data["doctor_name"] = doctor_info.UserName
  23450. data["department"] = department.Name
  23451. data["fixmedins_code"] = miConfig.Code
  23452. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23453. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23454. data["secret_key"] = miConfig.SecretKey
  23455. data["sick_code"] = sickConfig.CountryCode
  23456. data["sick_name"] = sickConfig.ClassName
  23457. data["dept"] = strconv.FormatInt(department.ID, 10)
  23458. data["config"] = config
  23459. data["begin_time"] = begin_time
  23460. bytesData, _ := json.Marshal(data)
  23461. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  23462. resp, _ := client.Do(req)
  23463. defer resp.Body.Close()
  23464. body, ioErr := ioutil.ReadAll(resp.Body)
  23465. if ioErr != nil {
  23466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23468. return
  23469. }
  23470. var respJSON map[string]interface{}
  23471. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23474. return
  23475. }
  23476. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23477. userJSONBytes, _ := json.Marshal(respJSON)
  23478. fmt.Println("log")
  23479. fmt.Println(string(userJSONBytes))
  23480. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23481. utils.ErrorLog("解析失败:%v", err)
  23482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23483. return
  23484. }
  23485. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23486. data := make(map[string]interface{})
  23487. client := &http.Client{}
  23488. data["psn_no"] = his.PsnNo
  23489. data["mdtrt_id"] = his.Number
  23490. data["opter"] = roles.UserName
  23491. data["org_name"] = miConfig.OrgName
  23492. if reg_type == 11 && his.Insutype == "390" {
  23493. data["med_type"] = "110104"
  23494. } else {
  23495. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23496. }
  23497. data["doctor_id"] = doctor_info.DoctorNumber
  23498. data["doctor_name"] = doctor_info.UserName
  23499. data["department"] = department.Name
  23500. data["fixmedins_code"] = miConfig.Code
  23501. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23502. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23503. data["secret_key"] = miConfig.SecretKey
  23504. data["sick_code"] = sickConfig.CountryCode
  23505. data["sick_name"] = sickConfig.ClassName
  23506. data["dept"] = strconv.FormatInt(department.ID, 10)
  23507. data["config"] = config
  23508. data["begin_time"] = begin_time
  23509. bytesData, _ := json.Marshal(data)
  23510. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  23511. resp, _ := client.Do(req)
  23512. defer resp.Body.Close()
  23513. body, ioErr := ioutil.ReadAll(resp.Body)
  23514. if ioErr != nil {
  23515. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23517. return
  23518. }
  23519. var respJSON map[string]interface{}
  23520. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23523. return
  23524. }
  23525. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23526. userJSONBytes, _ := json.Marshal(respJSON)
  23527. fmt.Println("log")
  23528. fmt.Println(string(userJSONBytes))
  23529. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23530. utils.ErrorLog("解析失败:%v", err)
  23531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23532. return
  23533. }
  23534. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23535. data := make(map[string]interface{})
  23536. client := &http.Client{}
  23537. data["psn_no"] = his.PsnNo
  23538. data["mdtrt_id"] = his.Number
  23539. data["opter"] = roles.UserName
  23540. data["org_name"] = miConfig.OrgName
  23541. if reg_type == 11 && his.Insutype == "390" {
  23542. data["med_type"] = "110104"
  23543. } else {
  23544. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23545. }
  23546. data["doctor_id"] = doctor_info.DoctorNumber
  23547. data["doctor_name"] = doctor_info.UserName
  23548. data["department"] = department.Name
  23549. data["fixmedins_code"] = miConfig.Code
  23550. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23551. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23552. data["secret_key"] = miConfig.SecretKey
  23553. data["sick_code"] = sickConfig.CountryCode
  23554. data["sick_name"] = sickConfig.ClassName
  23555. data["dept"] = strconv.FormatInt(department.ID, 10)
  23556. data["config"] = config
  23557. data["begin_time"] = begin_time
  23558. bytesData, _ := json.Marshal(data)
  23559. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  23560. resp, _ := client.Do(req)
  23561. defer resp.Body.Close()
  23562. body, ioErr := ioutil.ReadAll(resp.Body)
  23563. if ioErr != nil {
  23564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23566. return
  23567. }
  23568. var respJSON map[string]interface{}
  23569. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23572. return
  23573. }
  23574. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23575. userJSONBytes, _ := json.Marshal(respJSON)
  23576. fmt.Println("log")
  23577. fmt.Println(string(userJSONBytes))
  23578. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23579. utils.ErrorLog("解析失败:%v", err)
  23580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23581. return
  23582. }
  23583. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23584. data := make(map[string]interface{})
  23585. client := &http.Client{}
  23586. data["psn_no"] = his.PsnNo
  23587. data["mdtrt_id"] = his.Number
  23588. data["opter"] = roles.UserName
  23589. data["org_name"] = miConfig.OrgName
  23590. if reg_type == 11 && his.Insutype == "390" {
  23591. data["med_type"] = "110104"
  23592. } else {
  23593. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23594. }
  23595. data["doctor_id"] = doctor_info.DoctorNumber
  23596. data["doctor_name"] = doctor_info.UserName
  23597. data["department"] = department.Name
  23598. data["fixmedins_code"] = miConfig.Code
  23599. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23600. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23601. data["secret_key"] = miConfig.SecretKey
  23602. data["sick_code"] = sickConfig.CountryCode
  23603. data["sick_name"] = sickConfig.ClassName
  23604. data["dept"] = strconv.FormatInt(department.ID, 10)
  23605. data["config"] = config
  23606. data["begin_time"] = begin_time
  23607. bytesData, _ := json.Marshal(data)
  23608. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  23609. resp, _ := client.Do(req)
  23610. defer resp.Body.Close()
  23611. body, ioErr := ioutil.ReadAll(resp.Body)
  23612. if ioErr != nil {
  23613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23615. return
  23616. }
  23617. var respJSON map[string]interface{}
  23618. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23621. return
  23622. }
  23623. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23624. userJSONBytes, _ := json.Marshal(respJSON)
  23625. fmt.Println("log")
  23626. fmt.Println(string(userJSONBytes))
  23627. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23628. utils.ErrorLog("解析失败:%v", err)
  23629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23630. return
  23631. }
  23632. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23633. data := make(map[string]interface{})
  23634. client := &http.Client{}
  23635. data["psn_no"] = his.PsnNo
  23636. data["mdtrt_id"] = his.Number
  23637. data["doctor"] = roles.UserName
  23638. data["department"] = department.Name
  23639. data["org_name"] = miConfig.OrgName
  23640. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23641. data["doctor_id"] = doctor_info.DoctorNumber
  23642. data["new_doctor_name"] = doctor_info.UserName
  23643. data["fixmedins_code"] = miConfig.Code
  23644. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23645. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23646. data["secret_key"] = miConfig.SecretKey
  23647. data["sick_code"] = sickConfig.CountryCode
  23648. data["sick_name"] = sickConfig.ClassName
  23649. data["url"] = miConfig.Url
  23650. data["ak"] = miConfig.AccessKey
  23651. data["begin_time"] = begin_time
  23652. data["cainfo"] = miConfig.Cainfo
  23653. data["dept"] = strconv.FormatInt(department.ID, 10)
  23654. data["config"] = config
  23655. bytesData, _ := json.Marshal(data)
  23656. var req *http.Request
  23657. if miConfig.MdtrtareaAdmvs == "320921" {
  23658. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  23659. //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 +
  23660. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  23661. } else {
  23662. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  23663. }
  23664. resp, _ := client.Do(req)
  23665. defer resp.Body.Close()
  23666. body, ioErr := ioutil.ReadAll(resp.Body)
  23667. if ioErr != nil {
  23668. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23670. return
  23671. }
  23672. var respJSON map[string]interface{}
  23673. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23676. return
  23677. }
  23678. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23679. userJSONBytes, _ := json.Marshal(respJSON)
  23680. fmt.Println("log")
  23681. fmt.Println(string(userJSONBytes))
  23682. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  23683. utils.ErrorLog("解析失败:%v", err)
  23684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23685. return
  23686. }
  23687. res2.InfRefmsgid = ressix10265.InfRefmsgid
  23688. res2.Output = ressix10265.Output
  23689. res2.ErrMsg = ressix10265.ErrMsg
  23690. res2.Cainfo = ressix10265.Cainfo
  23691. res2.WarnMsg = ressix10265.WarnMsg
  23692. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  23693. res2.Infcode = infocode
  23694. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23695. data := make(map[string]interface{})
  23696. client := &http.Client{}
  23697. data["psn_no"] = his.PsnNo
  23698. data["mdtrt_id"] = his.Number
  23699. data["doctor"] = roles.UserName
  23700. data["department"] = department.Name
  23701. data["org_name"] = miConfig.OrgName
  23702. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23703. data["doctor_id"] = doctor_info.DoctorNumber
  23704. data["new_doctor_name"] = doctor_info.UserName
  23705. data["fixmedins_code"] = miConfig.Code
  23706. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23707. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23708. data["secret_key"] = miConfig.SecretKey
  23709. data["sick_code"] = sickConfig.CountryCode
  23710. data["sick_name"] = sickConfig.ClassName
  23711. data["url"] = miConfig.Url
  23712. data["ak"] = miConfig.AccessKey
  23713. data["begin_time"] = begin_time
  23714. data["cainfo"] = miConfig.Cainfo
  23715. data["dept"] = strconv.FormatInt(department.ID, 10)
  23716. data["config"] = config
  23717. bytesData, _ := json.Marshal(data)
  23718. var req *http.Request
  23719. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  23720. resp, _ := client.Do(req)
  23721. defer resp.Body.Close()
  23722. body, ioErr := ioutil.ReadAll(resp.Body)
  23723. if ioErr != nil {
  23724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23726. return
  23727. }
  23728. var respJSON map[string]interface{}
  23729. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23732. return
  23733. }
  23734. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23735. userJSONBytes, _ := json.Marshal(respJSON)
  23736. fmt.Println("log")
  23737. fmt.Println(string(userJSONBytes))
  23738. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  23739. utils.ErrorLog("解析失败:%v", err)
  23740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23741. return
  23742. }
  23743. res2.InfRefmsgid = ressix10265.InfRefmsgid
  23744. res2.Output = ressix10265.Output
  23745. res2.ErrMsg = ressix10265.ErrMsg
  23746. res2.Cainfo = ressix10265.Cainfo
  23747. res2.WarnMsg = ressix10265.WarnMsg
  23748. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  23749. res2.Infcode = infocode
  23750. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23751. 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)
  23752. saveLog(result, requestLog, "2203", "上传就诊信息")
  23753. var respJSON2 map[string]interface{}
  23754. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  23755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23757. return
  23758. }
  23759. userJSONBytes2, _ := json.Marshal(respJSON2)
  23760. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  23761. utils.ErrorLog("解析失败:%v", err)
  23762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23763. return
  23764. }
  23765. 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)
  23766. fmt.Println(result2)
  23767. fmt.Println(src_request)
  23768. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23769. data := make(map[string]interface{})
  23770. client := &http.Client{}
  23771. data["psn_no"] = his.PsnNo
  23772. data["mdtrt_id"] = his.Number
  23773. data["doctor"] = roles.UserName
  23774. data["department"] = department.Name
  23775. data["org_name"] = miConfig.OrgName
  23776. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23777. data["doctor_id"] = doctor_info.DoctorNumber
  23778. data["new_doctor_name"] = doctor_info.UserName
  23779. data["fixmedins_code"] = miConfig.Code
  23780. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23781. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23782. data["secret_key"] = miConfig.SecretKey
  23783. data["sick_code"] = sickConfig.CountryCode
  23784. data["sick_name"] = sickConfig.ClassName
  23785. data["url"] = miConfig.Url
  23786. data["ak"] = miConfig.AccessKey
  23787. data["begin_time"] = begin_time
  23788. data["cainfo"] = miConfig.Cainfo
  23789. data["dept"] = strconv.FormatInt(department.ID, 10)
  23790. data["config"] = config
  23791. bytesData, _ := json.Marshal(data)
  23792. var req *http.Request
  23793. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  23794. resp, _ := client.Do(req)
  23795. defer resp.Body.Close()
  23796. body, ioErr := ioutil.ReadAll(resp.Body)
  23797. if ioErr != nil {
  23798. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23800. return
  23801. }
  23802. var respJSON map[string]interface{}
  23803. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23804. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23806. return
  23807. }
  23808. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23809. userJSONBytes, _ := json.Marshal(respJSON)
  23810. fmt.Println("log")
  23811. fmt.Println(string(userJSONBytes))
  23812. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23813. utils.ErrorLog("解析失败:%v", err)
  23814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23815. return
  23816. }
  23817. } else {
  23818. if miConfig.MdtrtareaAdmvs == "440781" { //
  23819. 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)
  23820. } else {
  23821. if miConfig.Code == "H15049901371" {
  23822. //赤峰地区国家医保医疗类别
  23823. //职工透析:医疗类别选特殊情况门诊990502
  23824. //居民定额血透门慢: 医疗类别选门诊慢病140104
  23825. var med_type string
  23826. if his.Insutype == "390" {
  23827. if reg_type == 14 {
  23828. med_type = "9933"
  23829. } else if reg_type == 11 {
  23830. med_type = "11"
  23831. }
  23832. } else if his.Insutype == "310" {
  23833. if reg_type == 14 {
  23834. med_type = "990502"
  23835. } else if reg_type == 11 {
  23836. med_type = "11"
  23837. }
  23838. }
  23839. 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)
  23840. } else {
  23841. 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)
  23842. }
  23843. }
  23844. saveLog(result, requestLog, "2203", "上传就诊信息")
  23845. var respJSON2 map[string]interface{}
  23846. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  23847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23849. return
  23850. }
  23851. userJSONBytes2, _ := json.Marshal(respJSON2)
  23852. if miConfig.Code == "H15049901371" {
  23853. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  23854. utils.ErrorLog("解析失败:%v", err)
  23855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23856. return
  23857. }
  23858. res2.InfRefmsgid = ressix10265.InfRefmsgid
  23859. res2.Output = ressix10265.Output
  23860. res2.ErrMsg = ressix10265.ErrMsg
  23861. res2.Cainfo = ressix10265.Cainfo
  23862. res2.WarnMsg = ressix10265.WarnMsg
  23863. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  23864. res2.Infcode = infocode
  23865. } else {
  23866. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23867. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  23868. utils.ErrorLog("解析失败:%v", err)
  23869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23870. return
  23871. }
  23872. res2.Infcode = res3.Infcode
  23873. } else {
  23874. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  23875. utils.ErrorLog("解析失败:%v", err)
  23876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23877. return
  23878. }
  23879. }
  23880. }
  23881. }
  23882. if res2.Infcode == -1 {
  23883. adminUser := c.GetAdminUserInfo()
  23884. errlog := &models.HisOrderError{
  23885. UserOrgId: adminUser.CurrentOrgId,
  23886. Ctime: time.Now().Unix(),
  23887. Mtime: time.Now().Unix(),
  23888. ErrMsg: res2.ErrMsg,
  23889. Status: 1,
  23890. PatientId: id,
  23891. RecordTime: recordDateTime,
  23892. Stage: 3,
  23893. }
  23894. service.CreateErrMsgLog(errlog)
  23895. c.ServeSuccessJSON(map[string]interface{}{
  23896. "failed_code": -10,
  23897. "msg": res2.ErrMsg,
  23898. })
  23899. return
  23900. } else {
  23901. his.Diagnosis = diagnosis_id
  23902. his.SickType = sickConfig.ID
  23903. //var p_type int64
  23904. //if reg_type == 1111 || reg_type == 1112 {
  23905. // p_type = 11
  23906. //
  23907. //}
  23908. his.PType = fmt.Sprintf("%d", reg_type)
  23909. service.UpdateHisPatientThree(&his)
  23910. data := make(map[string]interface{})
  23911. if settle_accounts_type == 1 { //日结
  23912. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  23913. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  23914. } else {
  23915. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  23916. }
  23917. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  23918. data["pre"] = prescriptions
  23919. } else { //月结
  23920. start_time_str := c.GetString("start_time")
  23921. end_time_str := c.GetString("end_time")
  23922. timeLayout := "2006-01-02"
  23923. loc, _ := time.LoadLocation("Local")
  23924. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  23925. if err != nil {
  23926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23927. return
  23928. }
  23929. recordStartTime := theStartTime.Unix()
  23930. start_time = recordStartTime
  23931. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  23932. if err != nil {
  23933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23934. return
  23935. }
  23936. recordEndTime := theEndTime.Unix()
  23937. end_time = recordEndTime
  23938. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  23939. data["pre"] = prescriptions
  23940. }
  23941. timestamp := time.Now().Unix()
  23942. tempTime := time.Unix(timestamp, 0)
  23943. timeFormat := tempTime.Format("20060102150405")
  23944. chrgBchno := rand.Intn(100000) + 10000
  23945. new_chrg_bchno := ""
  23946. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23947. new_chrg_bchno = chrg_bchno
  23948. strconv.FormatInt(his.PatientId, 10)
  23949. client := &http.Client{}
  23950. if adminUser.CurrentOrgId == 10265 {
  23951. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  23952. new_chrg_bchno = "0000"
  23953. }
  23954. }
  23955. data["psn_no"] = his.PsnNo
  23956. data["mdtrt_id"] = his.Number
  23957. data["chrg_bchno"] = new_chrg_bchno
  23958. data["org_name"] = miConfig.OrgName
  23959. data["doctor"] = doctor_info.UserName
  23960. data["doctor_id"] = doctor_info.DoctorNumber
  23961. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  23962. data["fixmedins_code"] = miConfig.Code
  23963. data["dept_code"] = department.Number
  23964. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23965. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23966. data["secret_key"] = miConfig.SecretKey
  23967. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  23968. data["url"] = miConfig.Url
  23969. data["ak"] = miConfig.AccessKey
  23970. data["new_doctor_name"] = patientPrescription.Doctor
  23971. data["diag_code"] = sickConfig.CountryCode
  23972. data["cainfo"] = miConfig.Cainfo
  23973. data["opter"] = roles.UserName
  23974. var ids []int64
  23975. for _, item := range prescriptions {
  23976. ids = append(ids, item.ID)
  23977. }
  23978. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23979. if config.IsOpen == 1 { //对接了医保,走医保流程
  23980. var res ResultFour
  23981. var resFour10265 ResultFour10265
  23982. if miConfig.MdtrtareaAdmvs == "421300" {
  23983. bytesData, _ := json.Marshal(data)
  23984. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  23985. resp, _ := client.Do(req)
  23986. defer resp.Body.Close()
  23987. body, ioErr := ioutil.ReadAll(resp.Body)
  23988. if ioErr != nil {
  23989. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23991. return
  23992. }
  23993. var respJSON map[string]interface{}
  23994. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23997. return
  23998. }
  23999. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24000. userJSONBytes, _ := json.Marshal(respJSON)
  24001. fmt.Println("log")
  24002. fmt.Println(string(userJSONBytes))
  24003. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24004. utils.ErrorLog("解析失败:%v", err)
  24005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24006. return
  24007. }
  24008. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24009. bytesData, _ := json.Marshal(data)
  24010. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  24011. resp, _ := client.Do(req)
  24012. defer resp.Body.Close()
  24013. body, ioErr := ioutil.ReadAll(resp.Body)
  24014. if ioErr != nil {
  24015. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24017. return
  24018. }
  24019. var respJSON map[string]interface{}
  24020. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24023. return
  24024. }
  24025. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24026. userJSONBytes, _ := json.Marshal(respJSON)
  24027. fmt.Println("log")
  24028. fmt.Println(string(userJSONBytes))
  24029. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24030. utils.ErrorLog("解析失败:%v", err)
  24031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24032. return
  24033. }
  24034. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24035. bytesData, _ := json.Marshal(data)
  24036. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  24037. resp, _ := client.Do(req)
  24038. defer resp.Body.Close()
  24039. body, ioErr := ioutil.ReadAll(resp.Body)
  24040. if ioErr != nil {
  24041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24043. return
  24044. }
  24045. var respJSON map[string]interface{}
  24046. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24047. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24049. return
  24050. }
  24051. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24052. userJSONBytes, _ := json.Marshal(respJSON)
  24053. fmt.Println("log")
  24054. fmt.Println(string(userJSONBytes))
  24055. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24056. utils.ErrorLog("解析失败:%v", err)
  24057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24058. return
  24059. }
  24060. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24061. bytesData, _ := json.Marshal(data)
  24062. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  24063. resp, _ := client.Do(req)
  24064. defer resp.Body.Close()
  24065. body, ioErr := ioutil.ReadAll(resp.Body)
  24066. if ioErr != nil {
  24067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24069. return
  24070. }
  24071. var respJSON map[string]interface{}
  24072. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24075. return
  24076. }
  24077. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24078. userJSONBytes, _ := json.Marshal(respJSON)
  24079. fmt.Println("log")
  24080. fmt.Println(string(userJSONBytes))
  24081. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24082. utils.ErrorLog("解析失败:%v", err)
  24083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24084. return
  24085. }
  24086. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24087. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  24088. if result3101.Infcode == "0" {
  24089. if len(result3101.Output.Result) > 0 {
  24090. var errMsgs []string
  24091. for _, item := range result3101.Output.Result {
  24092. errMsgs = append(errMsgs, item.VolaCont)
  24093. }
  24094. c.ServeSuccessJSON(map[string]interface{}{
  24095. "failed_code": -10,
  24096. "msg": errMsgs,
  24097. })
  24098. return
  24099. }
  24100. }
  24101. bytesData, _ := json.Marshal(data)
  24102. var req *http.Request
  24103. if miConfig.MdtrtareaAdmvs == "320921" {
  24104. data["diag_code"] = sickConfig.CountryCode
  24105. fmt.Println(data)
  24106. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24107. } else {
  24108. data["diag_code"] = sickConfig.CountryCode
  24109. fmt.Println(data)
  24110. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24111. }
  24112. resp, _ := client.Do(req)
  24113. defer resp.Body.Close()
  24114. body, ioErr := ioutil.ReadAll(resp.Body)
  24115. if ioErr != nil {
  24116. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24118. return
  24119. }
  24120. var respJSON map[string]interface{}
  24121. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24124. return
  24125. }
  24126. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24127. userJSONBytes, _ := json.Marshal(respJSON)
  24128. fmt.Println("log")
  24129. fmt.Println(string(userJSONBytes))
  24130. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  24131. utils.ErrorLog("解析失败:%v", err)
  24132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24133. return
  24134. }
  24135. res.InfRefmsgid = resFour10265.InfRefmsgid
  24136. res.Output = resFour10265.Output
  24137. res.ErrMsg = resFour10265.ErrMsg
  24138. res.Cainfo = resFour10265.Cainfo
  24139. res.WarnMsg = resFour10265.WarnMsg
  24140. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  24141. res.Infcode = infocode
  24142. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24143. var pagesize int = 2
  24144. var start int = 1
  24145. var stop int
  24146. var pagecount int
  24147. var curpage int
  24148. var isSuccess bool = true
  24149. data["doctor_id"] = doctor_info.DoctorNumber
  24150. //总页数,向上取整,注意除之前要先转换类型为float64
  24151. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  24152. for curpage = 1; curpage <= pagecount; curpage++ {
  24153. if curpage == 1 {
  24154. start = 1
  24155. } else {
  24156. start = (curpage-1)*pagesize + 1
  24157. }
  24158. stop = curpage * pagesize
  24159. if stop > len(prescriptions) {
  24160. stop = len(prescriptions)
  24161. }
  24162. //var requestLog string
  24163. data["pre"] = prescriptions[start-1 : stop]
  24164. fmt.Println(data["pre"])
  24165. bytesData, _ := json.Marshal(data)
  24166. var req *http.Request
  24167. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  24168. resp, _ := client.Do(req)
  24169. defer resp.Body.Close()
  24170. body, ioErr := ioutil.ReadAll(resp.Body)
  24171. if ioErr != nil {
  24172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24174. return
  24175. }
  24176. var respJSON map[string]interface{}
  24177. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24180. return
  24181. }
  24182. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24183. userJSONBytes, _ := json.Marshal(respJSON)
  24184. fmt.Println("log")
  24185. fmt.Println(string(userJSONBytes))
  24186. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  24187. utils.ErrorLog("解析失败:%v", err)
  24188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24189. return
  24190. }
  24191. res.InfRefmsgid = resFour10265.InfRefmsgid
  24192. res.Output = resFour10265.Output
  24193. res.ErrMsg = resFour10265.ErrMsg
  24194. res.Cainfo = resFour10265.Cainfo
  24195. res.WarnMsg = resFour10265.WarnMsg
  24196. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  24197. res.Infcode = infocode
  24198. if infocode == 0 {
  24199. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  24200. } else {
  24201. isSuccess = false
  24202. errlog := &models.HisOrderError{
  24203. UserOrgId: adminUser.CurrentOrgId,
  24204. Ctime: time.Now().Unix(),
  24205. Mtime: time.Now().Unix(),
  24206. Number: chrg_bchno,
  24207. ErrMsg: "",
  24208. Status: 1,
  24209. PatientId: id,
  24210. RecordTime: recordDateTime,
  24211. Stage: 4,
  24212. }
  24213. service.CreateErrMsgLog(errlog)
  24214. c.ServeSuccessJSON(map[string]interface{}{
  24215. "failed_code": -10,
  24216. "msg": res.ErrMsg,
  24217. })
  24218. return
  24219. }
  24220. }
  24221. if isSuccess {
  24222. res.Infcode = 0
  24223. }
  24224. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24225. 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)
  24226. var dat map[string]interface{}
  24227. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24228. fmt.Println(dat)
  24229. } else {
  24230. fmt.Println(err)
  24231. }
  24232. saveLog(result, request_log, "2204", "上传费用明细")
  24233. userJSONBytes, _ := json.Marshal(dat)
  24234. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  24235. utils.ErrorLog("解析失败:%v", err)
  24236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24237. return
  24238. }
  24239. res.InfRefmsgid = resFour10265.InfRefmsgid
  24240. res.Output = resFour10265.Output
  24241. res.ErrMsg = resFour10265.ErrMsg
  24242. res.Cainfo = resFour10265.Cainfo
  24243. res.WarnMsg = resFour10265.WarnMsg
  24244. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  24245. res.Infcode = infocode
  24246. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24247. bytesData, _ := json.Marshal(data)
  24248. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  24249. resp, _ := client.Do(req)
  24250. defer resp.Body.Close()
  24251. body, ioErr := ioutil.ReadAll(resp.Body)
  24252. if ioErr != nil {
  24253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24255. return
  24256. }
  24257. var respJSON map[string]interface{}
  24258. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24261. return
  24262. }
  24263. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24264. userJSONBytes, _ := json.Marshal(respJSON)
  24265. fmt.Println("log")
  24266. fmt.Println(string(userJSONBytes))
  24267. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24268. utils.ErrorLog("解析失败:%v", err)
  24269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24270. return
  24271. }
  24272. } else {
  24273. if miConfig.Code == "H15049901371" {
  24274. 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)
  24275. var dat map[string]interface{}
  24276. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24277. fmt.Println(dat)
  24278. } else {
  24279. fmt.Println(err)
  24280. }
  24281. saveLog(result, request_log, "2204", "上传费用明细")
  24282. userJSONBytes, _ := json.Marshal(dat)
  24283. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  24284. utils.ErrorLog("解析失败:%v", err)
  24285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24286. return
  24287. }
  24288. res.InfRefmsgid = resFour10265.InfRefmsgid
  24289. res.Output = resFour10265.Output
  24290. res.ErrMsg = resFour10265.ErrMsg
  24291. res.Cainfo = resFour10265.Cainfo
  24292. res.WarnMsg = resFour10265.WarnMsg
  24293. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  24294. res.Infcode = infocode
  24295. } else {
  24296. 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)
  24297. var dat map[string]interface{}
  24298. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24299. fmt.Println(dat)
  24300. } else {
  24301. fmt.Println(err)
  24302. }
  24303. saveLog(result, request_log, "2204", "上传费用明细")
  24304. userJSONBytes, _ := json.Marshal(dat)
  24305. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24306. utils.ErrorLog("解析失败:%v", err)
  24307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24308. return
  24309. }
  24310. }
  24311. }
  24312. if res.Infcode == 0 {
  24313. order := &models.HisOrder{
  24314. UserOrgId: adminUser.CurrentOrgId,
  24315. HisPatientId: his.ID,
  24316. PatientId: his.PatientId,
  24317. SettleAccountsDate: recordDateTime,
  24318. MdtrtId: his.Number,
  24319. PsnNo: his.PsnNo,
  24320. MedType: strconv.FormatInt(reg_type, 10),
  24321. Ctime: time.Now().Unix(),
  24322. Mtime: time.Now().Unix(),
  24323. Status: 1,
  24324. Number: chrg_bchno,
  24325. Infcode: res.Infcode,
  24326. WarnMsg: res.WarnMsg,
  24327. Cainfo: res.Cainfo,
  24328. ErrMsg: res.ErrMsg,
  24329. RespondTime: res.RefmsgTime,
  24330. InfRefmsgid: res.InfRefmsgid,
  24331. OrderStatus: 1,
  24332. PayWay: pay_way,
  24333. PayWays: pay_ways,
  24334. OthDesc: oth_desc,
  24335. PayPrice: pay_price,
  24336. PayCardNo: pay_card_no,
  24337. DiscountPrice: discount_price,
  24338. PreferentialPrice: preferential_price,
  24339. RealityPrice: reality_price,
  24340. FoundPrice: found_price,
  24341. MedicalInsurancePrice: medical_insurance_price,
  24342. PrivatePrice: private_price,
  24343. IsMedicineInsurance: 1,
  24344. SettleType: settle_accounts_type,
  24345. SettleStartTime: start_time,
  24346. SettleEndTime: end_time,
  24347. Creator: roles.AdminUserId,
  24348. Modify: roles.AdminUserId,
  24349. FaPiaoNumber: fapiao_number,
  24350. FaPiaoCode: fapiao_code,
  24351. PType: 2,
  24352. Diagnosis: diagnosis_id,
  24353. CashPay: cash_pay,
  24354. WechatPay: wechat_pay,
  24355. AliPay: ali_pay,
  24356. JifenPay: jifen_pay,
  24357. BandCardPay: band_card_pay,
  24358. }
  24359. err = service.CreateOrder(order)
  24360. if err != nil {
  24361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  24362. return
  24363. }
  24364. for _, item := range res.Output.Result {
  24365. temp := strings.Split(item.FeedetlSn, "-")
  24366. var advice_id int64 = 0
  24367. var project_id int64 = 0
  24368. var types int64 = 0
  24369. id, _ := strconv.ParseInt(temp[2], 10, 64)
  24370. types, _ = strconv.ParseInt(temp[1], 10, 64)
  24371. if temp[1] == "1" {
  24372. advice_id = id
  24373. project_id = 0
  24374. } else if temp[1] == "2" {
  24375. advice_id = 0
  24376. project_id = id
  24377. }
  24378. if item.MedChrgitmType == "9" {
  24379. item.MedChrgitmType = "09"
  24380. }
  24381. info := &models.HisOrderInfo{
  24382. OrderNumber: order.Number,
  24383. FeedetlSn: item.FeedetlSn,
  24384. UploadDate: time.Now().Unix(),
  24385. AdviceId: advice_id,
  24386. DetItemFeeSumamt: item.DetItemFeeSumamt,
  24387. Cnt: item.Cnt,
  24388. Pric: float64(item.Pric),
  24389. PatientId: his.PatientId,
  24390. PricUplmtAmt: item.PricUplmtAmt,
  24391. SelfpayProp: item.SelfpayProp,
  24392. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  24393. OverlmtAmt: item.OverlmtAmt,
  24394. PreselfpayAmt: item.PreselfpayAmt,
  24395. BasMednFlag: item.BasMednFlag,
  24396. MedChrgitmType: item.MedChrgitmType,
  24397. HiNegoDrugFlag: item.HiNegoDrugFlag,
  24398. Status: 1,
  24399. Memo: item.Memo,
  24400. Mtime: time.Now().Unix(),
  24401. InscpScpAmt: item.InscpScpAmt,
  24402. DrtReimFlag: item.DrtReimFlag,
  24403. Ctime: time.Now().Unix(),
  24404. ListSpItemFlag: item.ListSpItemFlag,
  24405. ChldMedcFlag: item.ChldMedcFlag,
  24406. LmtUsedFlag: item.LmtUsedFlag,
  24407. ChrgitmLv: item.ChrgitmLv,
  24408. UserOrgId: adminUser.CurrentOrgId,
  24409. HisPatientId: his.ID,
  24410. OrderId: order.ID,
  24411. ProjectId: project_id,
  24412. Type: types,
  24413. }
  24414. service.CreateOrderInfo(info)
  24415. }
  24416. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  24417. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  24418. var total float64
  24419. for _, item := range prescriptions {
  24420. if item.Type == 1 { //药品
  24421. for _, subItem := range item.HisDoctorAdviceInfo {
  24422. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  24423. total_one := price * subItem.PrescribingNumber
  24424. total = total + total_one
  24425. }
  24426. }
  24427. if item.Type == 2 { //项目
  24428. for _, subItem := range item.HisPrescriptionProject {
  24429. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  24430. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  24431. total_one := price * cnt
  24432. total = total + total_one
  24433. }
  24434. }
  24435. }
  24436. allTotal := fmt.Sprintf("%.2f", total)
  24437. //if adminUser.CurrentOrgId == 9919 {
  24438. //
  24439. // allTotal = fmt.Sprintf("%.2f", total)
  24440. //
  24441. //} else {
  24442. //
  24443. // allTotal = fmt.Sprintf("%.2f", total)
  24444. //
  24445. //}
  24446. if res.Infcode == 0 {
  24447. var rf []*ResultFive
  24448. json.Unmarshal([]byte(his.Iinfo), &rf)
  24449. chrg_bchno := chrg_bchno
  24450. cert_no := his.Certno
  24451. var insutypes []string
  24452. var insutype string
  24453. var is390 int = 0
  24454. var is310 int = 0
  24455. for _, item := range rf {
  24456. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24457. insutypes = append(insutypes, item.Insutype)
  24458. }
  24459. }
  24460. if len(insutypes) == 1 {
  24461. insutype = insutypes[0]
  24462. } else {
  24463. for _, i := range insutypes {
  24464. if i == "390" {
  24465. is390 = 1
  24466. }
  24467. if i == "310" {
  24468. is310 = 1
  24469. }
  24470. }
  24471. }
  24472. if is390 == 1 {
  24473. insutype = "390"
  24474. }
  24475. if is310 == 1 {
  24476. insutype = "310"
  24477. }
  24478. if len(insutypes) == 0 {
  24479. insutype = "310"
  24480. }
  24481. if len(insutypes) == 2 {
  24482. insutype = strconv.FormatInt(his.SocialType, 10)
  24483. }
  24484. insutype = strconv.FormatInt(his.SocialType, 10)
  24485. //insutype = "390"
  24486. if his.IdCardType == 1 {
  24487. // cert_no = his.MedicalInsuranceNumber
  24488. cert_no = his.Certno
  24489. } else {
  24490. cert_no = his.Certno
  24491. }
  24492. var res ResultSeven
  24493. var resSeven10265 ResultSeven10265
  24494. var gzresSeven10265Two GZResultSeven10265Two
  24495. var src_resquest string
  24496. var result2 string
  24497. if miConfig.MdtrtareaAdmvs == "421300" {
  24498. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24499. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24500. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24501. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24502. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24503. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24504. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24505. resp, requestErr := http.Get(api)
  24506. if requestErr != nil {
  24507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24508. return
  24509. }
  24510. body, ioErr := ioutil.ReadAll(resp.Body)
  24511. if ioErr != nil {
  24512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24514. return
  24515. }
  24516. var respJSON map[string]interface{}
  24517. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24520. return
  24521. }
  24522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24523. result, _ := json.Marshal(respJSON)
  24524. if miConfig.Code == "H15049901371" {
  24525. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24526. utils.ErrorLog("解析失败:%v", err)
  24527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24528. return
  24529. }
  24530. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24531. res.Output = resSeven10265.Output
  24532. res.ErrMsg = resSeven10265.ErrMsg
  24533. res.Cainfo = resSeven10265.Cainfo
  24534. res.WarnMsg = resSeven10265.WarnMsg
  24535. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24536. res.Infcode = infocode
  24537. } else {
  24538. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24539. utils.ErrorLog("解析失败:%v", err)
  24540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24541. return
  24542. }
  24543. }
  24544. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24545. if reg_type == 11 && his.Insutype == "390" {
  24546. reg_type = 110104
  24547. }
  24548. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24549. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24550. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24551. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24552. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24553. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24554. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24555. resp, requestErr := http.Get(api)
  24556. if requestErr != nil {
  24557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24558. return
  24559. }
  24560. body, ioErr := ioutil.ReadAll(resp.Body)
  24561. if ioErr != nil {
  24562. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24564. return
  24565. }
  24566. var respJSON map[string]interface{}
  24567. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24568. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24570. return
  24571. }
  24572. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24573. result, _ := json.Marshal(respJSON)
  24574. if miConfig.Code == "H15049901371" {
  24575. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24576. utils.ErrorLog("解析失败:%v", err)
  24577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24578. return
  24579. }
  24580. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24581. res.Output = resSeven10265.Output
  24582. res.ErrMsg = resSeven10265.ErrMsg
  24583. res.Cainfo = resSeven10265.Cainfo
  24584. res.WarnMsg = resSeven10265.WarnMsg
  24585. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24586. res.Infcode = infocode
  24587. } else {
  24588. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24589. utils.ErrorLog("解析失败:%v", err)
  24590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24591. return
  24592. }
  24593. }
  24594. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24595. if reg_type == 11 && his.Insutype == "390" {
  24596. reg_type = 110104
  24597. }
  24598. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24599. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24600. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24601. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24602. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24603. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24604. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24605. resp, requestErr := http.Get(api)
  24606. if requestErr != nil {
  24607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24608. return
  24609. }
  24610. body, ioErr := ioutil.ReadAll(resp.Body)
  24611. if ioErr != nil {
  24612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24614. return
  24615. }
  24616. var respJSON map[string]interface{}
  24617. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24620. return
  24621. }
  24622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24623. result, _ := json.Marshal(respJSON)
  24624. if miConfig.Code == "H15049901371" {
  24625. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24626. utils.ErrorLog("解析失败:%v", err)
  24627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24628. return
  24629. }
  24630. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24631. res.Output = resSeven10265.Output
  24632. res.ErrMsg = resSeven10265.ErrMsg
  24633. res.Cainfo = resSeven10265.Cainfo
  24634. res.WarnMsg = resSeven10265.WarnMsg
  24635. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24636. res.Infcode = infocode
  24637. } else {
  24638. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24639. utils.ErrorLog("解析失败:%v", err)
  24640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24641. return
  24642. }
  24643. }
  24644. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24645. if reg_type == 11 && his.Insutype == "390" {
  24646. reg_type = 110104
  24647. }
  24648. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24649. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24650. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24651. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24652. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24653. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24654. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24655. resp, requestErr := http.Get(api)
  24656. if requestErr != nil {
  24657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24658. return
  24659. }
  24660. body, ioErr := ioutil.ReadAll(resp.Body)
  24661. if ioErr != nil {
  24662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24664. return
  24665. }
  24666. var respJSON map[string]interface{}
  24667. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24670. return
  24671. }
  24672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24673. result, _ := json.Marshal(respJSON)
  24674. if miConfig.Code == "H15049901371" {
  24675. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24676. utils.ErrorLog("解析失败:%v", err)
  24677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24678. return
  24679. }
  24680. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24681. res.Output = resSeven10265.Output
  24682. res.ErrMsg = resSeven10265.ErrMsg
  24683. res.Cainfo = resSeven10265.Cainfo
  24684. res.WarnMsg = resSeven10265.WarnMsg
  24685. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24686. res.Infcode = infocode
  24687. } else {
  24688. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24689. utils.ErrorLog("解析失败:%v", err)
  24690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24691. return
  24692. }
  24693. }
  24694. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24695. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  24696. if result3101.Infcode == "0" {
  24697. if len(result3101.Output.Result) > 0 {
  24698. var errMsgs []string
  24699. for _, item := range result3101.Output.Result {
  24700. errMsgs = append(errMsgs, item.VolaCont)
  24701. }
  24702. c.ServeSuccessJSON(map[string]interface{}{
  24703. "failed_code": -10,
  24704. "msg": errMsgs,
  24705. })
  24706. return
  24707. } else {
  24708. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24709. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24710. bas := strings.Split(psn_info.CardInfo, "|")
  24711. if his.IdCardType == 1 {
  24712. cert_no = bas[2]
  24713. } else if his.IdCardType == 3 {
  24714. cert_no = his.Certno
  24715. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  24716. } else if his.IdCardType == 4 {
  24717. cert_no = his.Certno
  24718. psn_info.VerifyNumber = psn_info.VerifyNumber
  24719. }
  24720. var api string
  24721. if miConfig.MdtrtareaAdmvs == "320921" {
  24722. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24723. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24724. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24725. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24726. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24727. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24728. "&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
  24729. } else {
  24730. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24731. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24732. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24733. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24734. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24735. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24736. "&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
  24737. }
  24738. resp, requestErr := http.Get(api)
  24739. if requestErr != nil {
  24740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24741. return
  24742. }
  24743. body, ioErr := ioutil.ReadAll(resp.Body)
  24744. if ioErr != nil {
  24745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24747. return
  24748. }
  24749. var respJSON map[string]interface{}
  24750. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24753. return
  24754. }
  24755. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24756. result, _ := json.Marshal(respJSON)
  24757. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24758. utils.ErrorLog("解析失败:%v", err)
  24759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24760. return
  24761. }
  24762. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24763. res.Output = resSeven10265.Output
  24764. res.ErrMsg = resSeven10265.ErrMsg
  24765. res.Cainfo = resSeven10265.Cainfo
  24766. res.WarnMsg = resSeven10265.WarnMsg
  24767. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24768. res.Infcode = infocode
  24769. }
  24770. }
  24771. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24772. psn_info, _ := service.GetPsnByPatientId(id)
  24773. var verify_number string
  24774. if psn_info.IdCardType == 4 {
  24775. verify_number = psn_info.VerifyNumber
  24776. } else if psn_info.IdCardType == 1 {
  24777. bas := strings.Split(psn_info.CardInfo, "|")
  24778. cardNumber := bas[2]
  24779. verify_number = cardNumber
  24780. } else {
  24781. psn_info.IdCardType = 2
  24782. verify_number = psn_info.Certno
  24783. }
  24784. var api string
  24785. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24786. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24787. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24788. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24789. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24790. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24791. "&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
  24792. resp, requestErr := http.Get(api)
  24793. if requestErr != nil {
  24794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24795. return
  24796. }
  24797. body, ioErr := ioutil.ReadAll(resp.Body)
  24798. if ioErr != nil {
  24799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24801. return
  24802. }
  24803. var respJSON map[string]interface{}
  24804. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24807. return
  24808. }
  24809. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24810. result, _ := json.Marshal(respJSON)
  24811. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24812. utils.ErrorLog("解析失败:%v", err)
  24813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24814. return
  24815. }
  24816. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24817. res.Output = resSeven10265.Output
  24818. res.ErrMsg = resSeven10265.ErrMsg
  24819. res.Cainfo = resSeven10265.Cainfo
  24820. res.WarnMsg = resSeven10265.WarnMsg
  24821. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24822. res.Infcode = infocode
  24823. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24824. var cert_no string
  24825. if his.IdCardType == 4 {
  24826. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24827. cert_no = psn_info.VerifyNumber
  24828. 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)
  24829. } else if his.IdCardType == 1 {
  24830. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24831. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24832. 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)
  24833. }
  24834. //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)
  24835. var dat map[string]interface{}
  24836. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24837. fmt.Println(dat)
  24838. } else {
  24839. fmt.Println(err)
  24840. }
  24841. saveLog(result2, src_resquest, "2207", "结算")
  24842. userJSONBytes, _ := json.Marshal(dat)
  24843. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  24844. utils.ErrorLog("解析失败:%v", err)
  24845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24846. return
  24847. }
  24848. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24849. res.Output = resSeven10265.Output
  24850. res.ErrMsg = resSeven10265.ErrMsg
  24851. res.Cainfo = resSeven10265.Cainfo
  24852. res.WarnMsg = resSeven10265.WarnMsg
  24853. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24854. res.Infcode = infocode
  24855. } else if miConfig.MdtrtareaAdmvs == "450721" {
  24856. res2 := c.GetoleInfo()
  24857. if res2.Infcode == 0 {
  24858. var result string
  24859. var request_log string
  24860. var result_log string
  24861. if res2.Output.MdtrtCertType == "02" {
  24862. 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)
  24863. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24864. } else if res2.Output.MdtrtCertType == "01" {
  24865. 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)
  24866. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24867. } else {
  24868. 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)
  24869. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24870. }
  24871. var dat map[string]interface{}
  24872. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24873. fmt.Println(dat)
  24874. } else {
  24875. fmt.Println(err)
  24876. }
  24877. userJSONBytes, _ := json.Marshal(dat)
  24878. var res5 ResultTwo
  24879. //var resTwo10265 ResultTwo10265
  24880. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  24881. utils.ErrorLog("解析失败:%v", err)
  24882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24883. return
  24884. }
  24885. if res5.Infcode == -1 {
  24886. c.ServeSuccessJSON(map[string]interface{}{
  24887. "failed_code": -10,
  24888. "msg": res5.ErrMsg,
  24889. })
  24890. return
  24891. }
  24892. var insutypes []string
  24893. var insutype string
  24894. var is390 int = 0
  24895. var is310 int = 0
  24896. for _, item := range res5.Output.Iinfo {
  24897. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24898. insutypes = append(insutypes, item.Insutype)
  24899. }
  24900. }
  24901. if len(insutypes) == 1 {
  24902. insutype = insutypes[0]
  24903. } else {
  24904. for _, i := range insutypes {
  24905. if i == "390" {
  24906. is390 = 1
  24907. }
  24908. if i == "310" {
  24909. is310 = 1
  24910. }
  24911. }
  24912. }
  24913. if is390 == 1 {
  24914. insutype = "390"
  24915. }
  24916. if is310 == 1 {
  24917. insutype = "310"
  24918. }
  24919. if len(insutypes) == 0 {
  24920. insutype = "310"
  24921. }
  24922. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  24923. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  24924. infoStr := string(Iinfos)
  24925. idetinfoStr := string(Idetinfos)
  24926. psn := &models.HisPsn{
  24927. PsnNo: res5.Output.Baseinfo.PsnNo,
  24928. PatientId: id,
  24929. Certno: res5.Output.Baseinfo.Certno,
  24930. Gend: res5.Output.Baseinfo.Gend,
  24931. Naty: res5.Output.Baseinfo.Naty,
  24932. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  24933. PsnName: res5.Output.Baseinfo.PsnName,
  24934. Idetinfo: idetinfoStr,
  24935. Insuinfo: infoStr,
  24936. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  24937. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  24938. VerifyNumber: res2.Output.EcToken,
  24939. }
  24940. if res2.Output.MdtrtCertType == "01" {
  24941. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24942. psn.VerifyNumber = res2.Output.EcToken
  24943. } else if res2.Output.MdtrtCertType == "02" {
  24944. psn.VerifyNumber = res2.Output.CardNo
  24945. } else {
  24946. psn.VerifyNumber = res2.Output.MdtrtCertNo
  24947. }
  24948. service.CreateHisPsn(psn)
  24949. if res2.Output.MdtrtCertType == "01" {
  24950. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24951. token := res2.Output.EcToken
  24952. 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)
  24953. } else if res2.Output.MdtrtCertType == "02" {
  24954. 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)
  24955. } else {
  24956. 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)
  24957. }
  24958. var dat2 map[string]interface{}
  24959. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  24960. fmt.Println(dat2)
  24961. } else {
  24962. fmt.Println(err)
  24963. }
  24964. userJSONBytes3, _ := json.Marshal(dat2)
  24965. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24966. utils.ErrorLog("解析失败:%v", err)
  24967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24968. return
  24969. }
  24970. saveLog(result2, src_resquest, "2207", "结算")
  24971. } else {
  24972. c.ServeSuccessJSON(map[string]interface{}{
  24973. "failed_code": -10,
  24974. "msg": res2.ErrMsg,
  24975. })
  24976. return
  24977. }
  24978. } else {
  24979. if miConfig.Code == "H15049901371" {
  24980. //赤峰地区国家医保医疗类别
  24981. //职工透析:医疗类别选特殊情况门诊990502
  24982. //居民定额血透门慢: 医疗类别选门诊慢病140104
  24983. var med_type string
  24984. if his.Insutype == "390" {
  24985. if reg_type == 14 {
  24986. med_type = "9933"
  24987. } else if reg_type == 11 {
  24988. med_type = "11"
  24989. }
  24990. } else if his.Insutype == "310" {
  24991. if reg_type == 14 {
  24992. med_type = "990502"
  24993. } else if reg_type == 11 {
  24994. med_type = "11"
  24995. }
  24996. }
  24997. 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)
  24998. } else {
  24999. if his.IdCardType == 4 {
  25000. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25001. var token string
  25002. token = psn_info.VerifyNumber
  25003. 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)
  25004. } else {
  25005. if his.IdCardType == 1 {
  25006. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25007. bas := strings.Split(psn_info.CardInfo, "|")
  25008. basNumber := bas[2]
  25009. cert_no = basNumber
  25010. }
  25011. 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)
  25012. }
  25013. }
  25014. //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)
  25015. var dat map[string]interface{}
  25016. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25017. fmt.Println(dat)
  25018. } else {
  25019. fmt.Println(err)
  25020. }
  25021. saveLog(result2, src_resquest, "2207", "结算")
  25022. userJSONBytes, _ := json.Marshal(dat)
  25023. if miConfig.Code == "H15049901371" {
  25024. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  25025. utils.ErrorLog("解析失败:%v", err)
  25026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25027. return
  25028. }
  25029. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25030. res.Output = resSeven10265.Output
  25031. res.ErrMsg = resSeven10265.ErrMsg
  25032. res.Cainfo = resSeven10265.Cainfo
  25033. res.WarnMsg = resSeven10265.WarnMsg
  25034. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25035. res.Infcode = infocode
  25036. } else {
  25037. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25038. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  25039. utils.ErrorLog("解析失败:%v", err)
  25040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25041. return
  25042. }
  25043. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  25044. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  25045. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  25046. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  25047. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  25048. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  25049. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  25050. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  25051. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  25052. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25053. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25054. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25055. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25056. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  25057. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  25058. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  25059. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  25060. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  25061. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  25062. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  25063. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  25064. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  25065. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  25066. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  25067. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  25068. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  25069. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  25070. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  25071. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  25072. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  25073. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  25074. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  25075. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  25076. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  25077. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  25078. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  25079. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  25080. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  25081. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25082. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  25083. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  25084. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  25085. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  25086. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  25087. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  25088. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  25089. res.ErrMsg = gzresSeven10265Two.ErrMsg
  25090. res.Cainfo = gzresSeven10265Two.Cainfo
  25091. res.WarnMsg = gzresSeven10265Two.WarnMsg
  25092. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  25093. //res.Infcode = infocode
  25094. } else {
  25095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25096. utils.ErrorLog("解析失败:%v", err)
  25097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25098. return
  25099. }
  25100. }
  25101. }
  25102. }
  25103. if res.Infcode == -1 {
  25104. errlog := &models.HisOrderError{
  25105. UserOrgId: adminUser.CurrentOrgId,
  25106. Ctime: time.Now().Unix(),
  25107. Mtime: time.Now().Unix(),
  25108. Number: chrg_bchno,
  25109. ErrMsg: res.ErrMsg,
  25110. Status: 1,
  25111. PatientId: id,
  25112. RecordTime: recordDateTime,
  25113. Stage: 6,
  25114. }
  25115. service.CreateErrMsgLog(errlog)
  25116. c.ServeSuccessJSON(map[string]interface{}{
  25117. "failed_code": -10,
  25118. "msg": res.ErrMsg,
  25119. })
  25120. return
  25121. } else {
  25122. sickConfig, _ := service.FindSickById(his.SickType)
  25123. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  25124. order.OrderStatus = 2
  25125. order.Status = 1
  25126. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  25127. order.SetlId = res.Output.Setlinfo.SetlID
  25128. order.PsnNo = res.Output.Setlinfo.PsnNo
  25129. order.PsnName = res.Output.Setlinfo.PsnName
  25130. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  25131. order.Certno = res.Output.Setlinfo.Certno
  25132. order.Gend = res.Output.Setlinfo.Gend
  25133. order.Naty = res.Output.Setlinfo.Naty
  25134. order.Age = res.Output.Setlinfo.Age
  25135. order.Insutype = res.Output.Setlinfo.Insutype
  25136. order.PsnType = res.Output.Setlinfo.PsnType
  25137. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  25138. order.SetlTime = res.Output.Setlinfo.SetlTime
  25139. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  25140. if res.Output.Setlinfo.MedType == "140101" {
  25141. order.MedType = "14"
  25142. } else {
  25143. if res.Output.Setlinfo.MedType == "110104" {
  25144. order.MedType = "11"
  25145. } else {
  25146. order.MedType = res.Output.Setlinfo.MedType
  25147. }
  25148. }
  25149. if reg_type == 1112 {
  25150. order.MedType = "1112"
  25151. }
  25152. if reg_type == 1111 {
  25153. order.MedType = "1111"
  25154. }
  25155. order.ClrType = res.Output.Setlinfo.ClrType
  25156. if adminUser.CurrentOrgId == 10480 {
  25157. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  25158. order.ClrType = "11"
  25159. } else {
  25160. order.ClrType = "9903"
  25161. }
  25162. }
  25163. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  25164. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  25165. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  25166. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  25167. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  25168. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  25169. order.HifpPay = res.Output.Setlinfo.HifpPay
  25170. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  25171. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  25172. order.HifesPay = res.Output.Setlinfo.HifesPay
  25173. order.HifobPay = res.Output.Setlinfo.HifobPay
  25174. order.MafPay = res.Output.Setlinfo.MafPay
  25175. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  25176. order.OthPay = res.Output.Setlinfo.OthPay
  25177. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  25178. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  25179. order.AcctPay = res.Output.Setlinfo.AcctPay
  25180. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  25181. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  25182. order.Balc = res.Output.Setlinfo.Balc
  25183. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  25184. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  25185. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  25186. //order.ClrType = res.Output.Setlinfo.ClrType
  25187. order.ClrWay = res.Output.Setlinfo.ClrWay
  25188. order.Creator = order.Creator
  25189. order.Modify = roles.AdminUserId
  25190. order.RequestLog = src_resquest
  25191. order.FaPiaoNumber = fapiao_number
  25192. order.FaPiaoCode = fapiao_code
  25193. order.SickName = sickConfig.ClassName
  25194. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  25195. //detailStr := string(setlDetail)
  25196. //order.SetlDetail = detailStr
  25197. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  25198. err = service.UpDateOrder(order)
  25199. if err == nil {
  25200. //判断是否使用了押金
  25201. if dec_way == "true" {
  25202. tmpstring := strconv.FormatInt(order.ID, 10)
  25203. order.Decimal = decimal
  25204. service.UpDateOrder(order)
  25205. //扣押金
  25206. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  25207. if errmsg != nil {
  25208. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  25209. return
  25210. }
  25211. }
  25212. c.ServeSuccessJSON(map[string]interface{}{
  25213. "msg": "结算成功",
  25214. })
  25215. } else {
  25216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  25217. return
  25218. }
  25219. }
  25220. } else {
  25221. adminUser := c.GetAdminUserInfo()
  25222. errlog := &models.HisOrderError{
  25223. UserOrgId: adminUser.CurrentOrgId,
  25224. Ctime: time.Now().Unix(),
  25225. Mtime: time.Now().Unix(),
  25226. ErrMsg: res.ErrMsg,
  25227. Status: 1,
  25228. PatientId: id,
  25229. RecordTime: recordDateTime,
  25230. Stage: 4,
  25231. }
  25232. service.CreateErrMsgLog(errlog)
  25233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  25234. return
  25235. }
  25236. } else {
  25237. adminUser := c.GetAdminUserInfo()
  25238. errlog := &models.HisOrderError{
  25239. UserOrgId: adminUser.CurrentOrgId,
  25240. Ctime: time.Now().Unix(),
  25241. Mtime: time.Now().Unix(),
  25242. ErrMsg: res.ErrMsg,
  25243. Status: 1,
  25244. PatientId: id,
  25245. RecordTime: recordDateTime,
  25246. Stage: 4,
  25247. }
  25248. service.CreateErrMsgLog(errlog)
  25249. c.ServeSuccessJSON(map[string]interface{}{
  25250. "failed_code": -10,
  25251. "msg": res.ErrMsg,
  25252. })
  25253. return
  25254. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  25255. //return
  25256. }
  25257. }
  25258. }
  25259. } else if tempOrder.ID > 0 {
  25260. if tempOrder.IsPre == 1 {
  25261. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  25262. var rf []*ResultFive
  25263. json.Unmarshal([]byte(his.Iinfo), &rf)
  25264. chrg_bchno := tempOrder.Number
  25265. cert_no := his.Certno
  25266. var insutypes []string
  25267. var insutype string
  25268. var is390 int = 0
  25269. var is310 int = 0
  25270. for _, item := range rf {
  25271. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25272. insutypes = append(insutypes, item.Insutype)
  25273. }
  25274. }
  25275. if len(insutypes) == 1 {
  25276. insutype = insutypes[0]
  25277. } else {
  25278. for _, i := range insutypes {
  25279. if i == "390" {
  25280. is390 = 1
  25281. }
  25282. if i == "310" {
  25283. is310 = 1
  25284. }
  25285. }
  25286. }
  25287. if is390 == 1 {
  25288. insutype = "390"
  25289. }
  25290. if is310 == 1 {
  25291. insutype = "310"
  25292. }
  25293. if len(insutypes) == 0 {
  25294. insutype = "310"
  25295. }
  25296. if len(insutypes) == 2 {
  25297. insutype = strconv.FormatInt(his.SocialType, 10)
  25298. }
  25299. //insutype = "390"
  25300. if his.IdCardType == 1 {
  25301. // cert_no = his.MedicalInsuranceNumber
  25302. cert_no = his.Certno
  25303. } else {
  25304. cert_no = his.Certno
  25305. }
  25306. var res ResultSeven
  25307. var ahres ResultSevenAH
  25308. var resSeven10265 ResultSeven10265
  25309. var gzresSeven10265Two GZResultSeven10265Two
  25310. var src_resquest string
  25311. var result2 string
  25312. if miConfig.MdtrtareaAdmvs == "450721" {
  25313. res2 := c.GetoleInfo()
  25314. if res2.Infcode == 0 {
  25315. var result string
  25316. var request_log string
  25317. var result_log string
  25318. if res2.Output.MdtrtCertType == "02" {
  25319. 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)
  25320. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  25321. } else if res2.Output.MdtrtCertType == "01" {
  25322. 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)
  25323. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  25324. } else {
  25325. 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)
  25326. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  25327. }
  25328. var dat map[string]interface{}
  25329. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25330. fmt.Println(dat)
  25331. } else {
  25332. fmt.Println(err)
  25333. }
  25334. userJSONBytes, _ := json.Marshal(dat)
  25335. var res5 ResultTwo
  25336. //var resTwo10265 ResultTwo10265
  25337. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  25338. utils.ErrorLog("解析失败:%v", err)
  25339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25340. return
  25341. }
  25342. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  25343. if res5.Infcode == -1 {
  25344. c.ServeSuccessJSON(map[string]interface{}{
  25345. "failed_code": -10,
  25346. "msg": res5.ErrMsg,
  25347. })
  25348. return
  25349. }
  25350. var insutypes []string
  25351. var insutype string
  25352. var is390 int = 0
  25353. var is310 int = 0
  25354. for _, item := range res5.Output.Iinfo {
  25355. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25356. insutypes = append(insutypes, item.Insutype)
  25357. }
  25358. }
  25359. if len(insutypes) == 1 {
  25360. insutype = insutypes[0]
  25361. } else {
  25362. for _, i := range insutypes {
  25363. if i == "390" {
  25364. is390 = 1
  25365. }
  25366. if i == "310" {
  25367. is310 = 1
  25368. }
  25369. }
  25370. }
  25371. if is390 == 1 {
  25372. insutype = "390"
  25373. }
  25374. if is310 == 1 {
  25375. insutype = "310"
  25376. }
  25377. if len(insutypes) == 0 {
  25378. insutype = "310"
  25379. }
  25380. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  25381. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  25382. infoStr := string(Iinfos)
  25383. idetinfoStr := string(Idetinfos)
  25384. psn := &models.HisPsn{
  25385. PsnNo: res5.Output.Baseinfo.PsnNo,
  25386. PatientId: id,
  25387. Certno: res5.Output.Baseinfo.Certno,
  25388. Gend: res5.Output.Baseinfo.Gend,
  25389. Naty: res5.Output.Baseinfo.Naty,
  25390. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  25391. PsnName: res5.Output.Baseinfo.PsnName,
  25392. Idetinfo: idetinfoStr,
  25393. Insuinfo: infoStr,
  25394. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  25395. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  25396. VerifyNumber: res2.Output.EcToken,
  25397. }
  25398. service.CreateHisPsn(psn)
  25399. if res2.Output.MdtrtCertType == "01" {
  25400. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25401. token := res2.Output.EcToken
  25402. 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)
  25403. } else if res2.Output.MdtrtCertType == "02" {
  25404. 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)
  25405. } else {
  25406. 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)
  25407. }
  25408. var dat2 map[string]interface{}
  25409. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  25410. fmt.Println(dat2)
  25411. } else {
  25412. fmt.Println(err)
  25413. }
  25414. userJSONBytes3, _ := json.Marshal(dat2)
  25415. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  25416. utils.ErrorLog("解析失败:%v", err)
  25417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25418. return
  25419. }
  25420. saveLog(result2, src_resquest, "2207", "结算")
  25421. } else {
  25422. c.ServeSuccessJSON(map[string]interface{}{
  25423. "failed_code": -10,
  25424. "msg": res2.ErrMsg,
  25425. })
  25426. return
  25427. }
  25428. } else if miConfig.MdtrtareaAdmvs == "421300" {
  25429. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25430. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25431. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25432. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25433. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25434. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25435. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25436. resp, requestErr := http.Get(api)
  25437. if requestErr != nil {
  25438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25439. return
  25440. }
  25441. body, ioErr := ioutil.ReadAll(resp.Body)
  25442. if ioErr != nil {
  25443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25445. return
  25446. }
  25447. var respJSON map[string]interface{}
  25448. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25451. return
  25452. }
  25453. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25454. result, _ := json.Marshal(respJSON)
  25455. fmt.Println("log")
  25456. fmt.Println(string(result))
  25457. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25458. utils.ErrorLog("解析失败:%v", err)
  25459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25460. return
  25461. }
  25462. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25463. if reg_type == 11 && his.Insutype == "390" {
  25464. reg_type = 110104
  25465. }
  25466. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25467. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25468. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25469. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25470. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25471. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25472. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25473. resp, requestErr := http.Get(api)
  25474. if requestErr != nil {
  25475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25476. return
  25477. }
  25478. body, ioErr := ioutil.ReadAll(resp.Body)
  25479. if ioErr != nil {
  25480. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25482. return
  25483. }
  25484. var respJSON map[string]interface{}
  25485. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25488. return
  25489. }
  25490. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25491. result, _ := json.Marshal(respJSON)
  25492. fmt.Println("log")
  25493. fmt.Println(string(result))
  25494. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25495. utils.ErrorLog("解析失败:%v", err)
  25496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25497. return
  25498. }
  25499. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25500. if reg_type == 11 && his.Insutype == "390" {
  25501. reg_type = 110104
  25502. }
  25503. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25504. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25505. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25506. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25507. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25508. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25509. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25510. resp, requestErr := http.Get(api)
  25511. if requestErr != nil {
  25512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25513. return
  25514. }
  25515. body, ioErr := ioutil.ReadAll(resp.Body)
  25516. if ioErr != nil {
  25517. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25519. return
  25520. }
  25521. var respJSON map[string]interface{}
  25522. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25525. return
  25526. }
  25527. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25528. result, _ := json.Marshal(respJSON)
  25529. fmt.Println("log")
  25530. fmt.Println(string(result))
  25531. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25532. utils.ErrorLog("解析失败:%v", err)
  25533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25534. return
  25535. }
  25536. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25537. if reg_type == 11 && his.Insutype == "390" {
  25538. reg_type = 110104
  25539. }
  25540. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25541. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25542. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25543. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25544. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25545. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25546. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25547. resp, requestErr := http.Get(api)
  25548. if requestErr != nil {
  25549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25550. return
  25551. }
  25552. body, ioErr := ioutil.ReadAll(resp.Body)
  25553. if ioErr != nil {
  25554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25556. return
  25557. }
  25558. var respJSON map[string]interface{}
  25559. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25562. return
  25563. }
  25564. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25565. result, _ := json.Marshal(respJSON)
  25566. fmt.Println("log")
  25567. fmt.Println(string(result))
  25568. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25569. utils.ErrorLog("解析失败:%v", err)
  25570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25571. return
  25572. }
  25573. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25574. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  25575. if result3101.Infcode == "0" {
  25576. if len(result3101.Output.Result) > 0 {
  25577. var errMsgs []string
  25578. for _, item := range result3101.Output.Result {
  25579. errMsgs = append(errMsgs, item.VolaCont)
  25580. }
  25581. c.ServeSuccessJSON(map[string]interface{}{
  25582. "failed_code": -10,
  25583. "msg": errMsgs,
  25584. })
  25585. return
  25586. } else {
  25587. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25588. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25589. bas := strings.Split(psn_info.CardInfo, "|")
  25590. if his.IdCardType == 1 {
  25591. cert_no = bas[2]
  25592. } else if his.IdCardType == 3 {
  25593. cert_no = his.Certno
  25594. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  25595. } else if his.IdCardType == 4 {
  25596. cert_no = his.Certno
  25597. psn_info.VerifyNumber = psn_info.VerifyNumber
  25598. }
  25599. //江苏地区国家医保医疗类别
  25600. //职工透析:医疗类别选特殊情况门诊9933
  25601. //居民血透门慢: 医疗类别选门诊慢病1402
  25602. //var med_type string
  25603. //if his.Insutype == "310" {
  25604. // if reg_type == 14 {
  25605. // med_type = "9933"
  25606. // } else if reg_type == 11 {
  25607. // med_type = "11"
  25608. //
  25609. // }
  25610. //} else if his.Insutype == "390" {
  25611. // if reg_type == 14 {
  25612. // med_type = "1402"
  25613. // } else if reg_type == 11 {
  25614. // med_type = "11"
  25615. // }
  25616. //}
  25617. var api string
  25618. if miConfig.MdtrtareaAdmvs == "320921" {
  25619. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25620. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25621. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25622. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25623. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25624. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25625. "&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
  25626. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25627. } else {
  25628. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25629. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25630. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25631. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25632. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25633. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25634. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25635. "&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
  25636. }
  25637. resp, requestErr := http.Get(api)
  25638. if requestErr != nil {
  25639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25640. return
  25641. }
  25642. body, ioErr := ioutil.ReadAll(resp.Body)
  25643. if ioErr != nil {
  25644. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25646. return
  25647. }
  25648. var respJSON map[string]interface{}
  25649. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25652. return
  25653. }
  25654. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25655. result, _ := json.Marshal(respJSON)
  25656. fmt.Println("log")
  25657. fmt.Println(string(result))
  25658. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25659. utils.ErrorLog("解析失败:%v", err)
  25660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25661. return
  25662. }
  25663. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25664. res.Output = resSeven10265.Output
  25665. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25666. res.ErrMsg = resSeven10265.ErrMsg
  25667. res.Cainfo = resSeven10265.Cainfo
  25668. res.WarnMsg = resSeven10265.WarnMsg
  25669. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25670. res.Infcode = infocode
  25671. }
  25672. }
  25673. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25674. psn_info, _ := service.GetPsnByPatientId(id)
  25675. var verify_number string
  25676. if psn_info.IdCardType == 4 {
  25677. verify_number = psn_info.VerifyNumber
  25678. } else if psn_info.IdCardType == 1 {
  25679. bas := strings.Split(psn_info.CardInfo, "|")
  25680. cardNumber := bas[2]
  25681. verify_number = cardNumber
  25682. } else {
  25683. verify_number = psn_info.Certno
  25684. psn_info.IdCardType = 2
  25685. }
  25686. var api string
  25687. new_chrg_bchno := chrg_bchno
  25688. if adminUser.CurrentOrgId == 10265 {
  25689. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25690. new_chrg_bchno = "0000"
  25691. }
  25692. }
  25693. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25694. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  25695. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25696. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25697. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  25698. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25699. "&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
  25700. resp, requestErr := http.Get(api)
  25701. if requestErr != nil {
  25702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25703. return
  25704. }
  25705. body, ioErr := ioutil.ReadAll(resp.Body)
  25706. if ioErr != nil {
  25707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25709. return
  25710. }
  25711. var respJSON map[string]interface{}
  25712. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25715. return
  25716. }
  25717. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25718. result, _ := json.Marshal(respJSON)
  25719. fmt.Println("log")
  25720. fmt.Println(string(result))
  25721. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25722. utils.ErrorLog("解析失败:%v", err)
  25723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25724. return
  25725. }
  25726. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25727. res.Output = resSeven10265.Output
  25728. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25729. res.ErrMsg = resSeven10265.ErrMsg
  25730. res.Cainfo = resSeven10265.Cainfo
  25731. res.WarnMsg = resSeven10265.WarnMsg
  25732. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25733. res.Infcode = infocode
  25734. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25735. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25736. var cert_no string
  25737. if his.IdCardType == 1 {
  25738. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25739. } else {
  25740. cert_no = psn_info.VerifyNumber
  25741. }
  25742. 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)
  25743. var dat map[string]interface{}
  25744. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25745. fmt.Println(dat)
  25746. } else {
  25747. fmt.Println(err)
  25748. }
  25749. saveLog(result2, src_resquest, "2207", "结算")
  25750. userJSONBytes, _ := json.Marshal(dat)
  25751. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25752. utils.ErrorLog("解析失败:%v", err)
  25753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25754. return
  25755. }
  25756. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25757. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25758. var cert_no string
  25759. var card_sn string
  25760. if his.IdCardType == 1 {
  25761. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25762. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25763. bas := strings.Split(psn_info.CardInfo, "|")
  25764. card_sn = bas[3]
  25765. } else if his.IdCardType == 2 {
  25766. cert_no = his.IdCardNo
  25767. } else {
  25768. cert_no = psn_info.VerifyNumber
  25769. }
  25770. var rf []*ResultFive
  25771. json.Unmarshal([]byte(his.Iinfo), &rf)
  25772. var psn_type string
  25773. for _, item := range rf {
  25774. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  25775. psn_type = item.PsnType
  25776. }
  25777. }
  25778. 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)
  25779. var dat map[string]interface{}
  25780. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25781. fmt.Println(dat)
  25782. } else {
  25783. fmt.Println(err)
  25784. }
  25785. saveLog(result2, src_resquest, "2207", "结算")
  25786. userJSONBytes, _ := json.Marshal(dat)
  25787. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25788. utils.ErrorLog("解析失败:%v", err)
  25789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25790. return
  25791. }
  25792. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25793. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25794. if his.IdCardType == 1 {
  25795. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25796. bas := strings.Split(psn_info.CardInfo, "|")
  25797. cert_no = bas[2]
  25798. } else if his.IdCardType == 3 {
  25799. cert_no = his.Certno
  25800. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  25801. } else if his.IdCardType == 4 {
  25802. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25803. cert_no = his.Certno
  25804. psn_info.VerifyNumber = psn_info.VerifyNumber
  25805. } else {
  25806. cert_no = his.Certno
  25807. psn_info.VerifyNumber = his.Certno
  25808. }
  25809. var api string
  25810. var med_type string
  25811. if his.Insutype == "390" {
  25812. if reg_type == 992102 {
  25813. med_type = "992102"
  25814. }
  25815. if reg_type == 140104 {
  25816. med_type = "140104"
  25817. }
  25818. if reg_type == 14 {
  25819. med_type = "14"
  25820. }
  25821. } else if his.Insutype == "310" {
  25822. if reg_type == 992102 {
  25823. med_type = "992102"
  25824. }
  25825. if reg_type == 14 {
  25826. med_type = "14"
  25827. }
  25828. }
  25829. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25830. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25831. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25832. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25833. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25834. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25835. "&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
  25836. resp, requestErr := http.Get(api)
  25837. if requestErr != nil {
  25838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25839. return
  25840. }
  25841. body, ioErr := ioutil.ReadAll(resp.Body)
  25842. if ioErr != nil {
  25843. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25845. return
  25846. }
  25847. var respJSON map[string]interface{}
  25848. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25849. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25851. return
  25852. }
  25853. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25854. if status == "0" {
  25855. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25856. c.ServeSuccessJSON(map[string]interface{}{
  25857. "failed_code": -10,
  25858. "msg": err_msg,
  25859. })
  25860. return
  25861. }
  25862. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25863. result, _ := json.Marshal(respJSON)
  25864. fmt.Println("log")
  25865. fmt.Println(string(result))
  25866. if err := json.Unmarshal(result, &ahres); err != nil {
  25867. utils.ErrorLog("解析失败:%v", err)
  25868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25869. return
  25870. }
  25871. res.InfRefmsgid = ahres.InfRefmsgid
  25872. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  25873. // 创建对应的Time类型
  25874. t := time.UnixMilli(timestamp)
  25875. // 格式化成指定的日期字符串
  25876. str := t.Format("2006-01-02 15:04:05")
  25877. res.Output.Setlinfo.SetlTime = str
  25878. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  25879. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  25880. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  25881. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  25882. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  25883. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  25884. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  25885. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  25886. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  25887. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  25888. res.Output.Setlinfo.ClrType = "11"
  25889. } else {
  25890. res.Output.Setlinfo.ClrType = "9903"
  25891. }
  25892. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  25893. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  25894. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  25895. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  25896. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  25897. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  25898. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  25899. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  25900. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  25901. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  25902. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  25903. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  25904. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  25905. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  25906. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  25907. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  25908. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  25909. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  25910. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  25911. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  25912. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  25913. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  25914. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  25915. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  25916. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  25917. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  25918. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  25919. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  25920. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  25921. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  25922. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  25923. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  25924. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  25925. res.Output.Setldetail = ahres.Output.Setldetail
  25926. res.ErrMsg = ahres.ErrMsg
  25927. res.Cainfo = ahres.Cainfo
  25928. res.WarnMsg = ahres.WarnMsg
  25929. res.Infcode = ahres.Infcode
  25930. } else if miConfig.MdtrtareaAdmvs == "340699" {
  25931. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25932. if his.IdCardType == 1 {
  25933. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25934. bas := strings.Split(psn_info.CardInfo, "|")
  25935. cert_no = bas[2]
  25936. } else if his.IdCardType == 3 {
  25937. cert_no = his.Certno
  25938. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  25939. } else if his.IdCardType == 4 {
  25940. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25941. cert_no = his.Certno
  25942. psn_info.VerifyNumber = psn_info.VerifyNumber
  25943. } else {
  25944. cert_no = his.Certno
  25945. psn_info.VerifyNumber = his.Certno
  25946. }
  25947. var api string
  25948. var med_type string
  25949. if his.Insutype == "390" {
  25950. if reg_type == 992102 {
  25951. med_type = "992102"
  25952. }
  25953. if reg_type == 140104 {
  25954. med_type = "140104"
  25955. }
  25956. if reg_type == 14 {
  25957. med_type = "14"
  25958. }
  25959. } else if his.Insutype == "310" {
  25960. if reg_type == 992102 {
  25961. med_type = "992102"
  25962. }
  25963. if reg_type == 14 {
  25964. med_type = "14"
  25965. }
  25966. }
  25967. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25968. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25969. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25970. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25971. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25972. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25973. "&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
  25974. resp, requestErr := http.Get(api)
  25975. if requestErr != nil {
  25976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25977. return
  25978. }
  25979. body, ioErr := ioutil.ReadAll(resp.Body)
  25980. if ioErr != nil {
  25981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25983. return
  25984. }
  25985. var respJSON map[string]interface{}
  25986. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25989. return
  25990. }
  25991. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25992. if status == "0" {
  25993. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25994. c.ServeSuccessJSON(map[string]interface{}{
  25995. "failed_code": -10,
  25996. "msg": err_msg,
  25997. })
  25998. return
  25999. }
  26000. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26001. result, _ := json.Marshal(respJSON)
  26002. fmt.Println("log")
  26003. fmt.Println(string(result))
  26004. if err := json.Unmarshal(result, &ahres); err != nil {
  26005. utils.ErrorLog("解析失败:%v", err)
  26006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26007. return
  26008. }
  26009. res.InfRefmsgid = ahres.InfRefmsgid
  26010. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  26011. // 创建对应的Time类型
  26012. t := time.UnixMilli(timestamp)
  26013. // 格式化成指定的日期字符串
  26014. str := t.Format("2006-01-02 15:04:05")
  26015. res.Output.Setlinfo.SetlTime = str
  26016. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  26017. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  26018. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  26019. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  26020. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  26021. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  26022. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26023. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  26024. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  26025. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26026. res.Output.Setlinfo.ClrType = "11"
  26027. } else {
  26028. res.Output.Setlinfo.ClrType = "9903"
  26029. }
  26030. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  26031. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  26032. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  26033. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  26034. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  26035. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  26036. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  26037. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  26038. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  26039. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26040. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  26041. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  26042. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  26043. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  26044. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  26045. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  26046. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  26047. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  26048. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  26049. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  26050. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  26051. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  26052. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  26053. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  26054. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  26055. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  26056. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  26057. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  26058. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  26059. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  26060. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  26061. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  26062. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  26063. res.Output.Setldetail = ahres.Output.Setldetail
  26064. res.ErrMsg = ahres.ErrMsg
  26065. res.Cainfo = ahres.Cainfo
  26066. res.WarnMsg = ahres.WarnMsg
  26067. res.Infcode = ahres.Infcode
  26068. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26069. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26070. var cert_no string
  26071. if his.IdCardType == 1 {
  26072. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26073. } else if his.IdCardType == 2 {
  26074. cert_no = his.IdCardNo
  26075. } else {
  26076. cert_no = psn_info.VerifyNumber
  26077. }
  26078. 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, "")
  26079. var dat map[string]interface{}
  26080. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26081. fmt.Println(dat)
  26082. } else {
  26083. fmt.Println(err)
  26084. }
  26085. saveLog(result2, src_resquest, "2207", "结算")
  26086. userJSONBytes, _ := json.Marshal(dat)
  26087. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26088. utils.ErrorLog("解析失败:%v", err)
  26089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26090. return
  26091. }
  26092. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26093. psn_info, _ := service.GetPsnByPatientId(id)
  26094. var verify_number string
  26095. if psn_info.IdCardType == 4 {
  26096. verify_number = psn_info.VerifyNumber
  26097. } else if psn_info.IdCardType == 1 {
  26098. bas := strings.Split(psn_info.CardInfo, "|")
  26099. cardNumber := bas[2]
  26100. verify_number = cardNumber
  26101. } else {
  26102. verify_number = psn_info.Certno
  26103. psn_info.IdCardType = 2
  26104. }
  26105. var api string
  26106. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26107. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26108. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26109. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26110. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  26111. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26112. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  26113. resp, requestErr := http.Get(api)
  26114. if requestErr != nil {
  26115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26116. return
  26117. }
  26118. body, ioErr := ioutil.ReadAll(resp.Body)
  26119. if ioErr != nil {
  26120. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26122. return
  26123. }
  26124. var respJSON map[string]interface{}
  26125. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26128. return
  26129. }
  26130. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26131. result, _ := json.Marshal(respJSON)
  26132. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26133. utils.ErrorLog("解析失败:%v", err)
  26134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26135. return
  26136. }
  26137. } else {
  26138. var src_resquest string
  26139. if miConfig.Code == "H15049901371" {
  26140. //赤峰地区国家医保医疗类别
  26141. //职工透析:医疗类别选特殊情况门诊990502
  26142. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26143. var med_type string
  26144. if his.Insutype == "390" {
  26145. if reg_type == 14 {
  26146. med_type = "9933"
  26147. } else if reg_type == 11 {
  26148. med_type = "11"
  26149. }
  26150. } else if his.Insutype == "310" {
  26151. if reg_type == 14 {
  26152. med_type = "990502"
  26153. } else if reg_type == 11 {
  26154. med_type = "11"
  26155. }
  26156. }
  26157. 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)
  26158. } else {
  26159. if his.IdCardType == 4 {
  26160. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26161. token := psn_info.VerifyNumber
  26162. 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)
  26163. } else {
  26164. 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)
  26165. }
  26166. }
  26167. var dat map[string]interface{}
  26168. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26169. fmt.Println(dat)
  26170. } else {
  26171. fmt.Println(err)
  26172. }
  26173. saveLog(result2, src_resquest, "2207", "结算")
  26174. userJSONBytes, _ := json.Marshal(dat)
  26175. if miConfig.Code == "H15049901371" {
  26176. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26177. utils.ErrorLog("解析失败:%v", err)
  26178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26179. return
  26180. }
  26181. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26182. res.Output = resSeven10265.Output
  26183. res.ErrMsg = resSeven10265.ErrMsg
  26184. res.Cainfo = resSeven10265.Cainfo
  26185. res.WarnMsg = resSeven10265.WarnMsg
  26186. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26187. res.Infcode = infocode
  26188. } else {
  26189. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26190. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26191. utils.ErrorLog("解析失败:%v", err)
  26192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26193. return
  26194. }
  26195. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26196. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26197. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26198. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26199. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26200. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26201. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26202. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26203. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26204. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26205. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26206. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26207. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26208. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26209. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26210. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26211. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26212. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26213. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26214. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26215. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26216. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26217. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26218. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26219. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26220. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26221. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26222. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26223. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26224. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26225. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26226. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26227. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26228. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26229. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26230. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26231. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26232. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26233. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26234. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26235. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26236. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26237. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26238. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26239. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26240. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26241. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26242. res.Cainfo = gzresSeven10265Two.Cainfo
  26243. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26244. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26245. //res.Infcode = infocode
  26246. } else {
  26247. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26248. utils.ErrorLog("解析失败:%v", err)
  26249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26250. return
  26251. }
  26252. }
  26253. }
  26254. }
  26255. if res.Infcode == -1 {
  26256. errlog := &models.HisOrderError{
  26257. UserOrgId: adminUser.CurrentOrgId,
  26258. Ctime: time.Now().Unix(),
  26259. Mtime: time.Now().Unix(),
  26260. Number: chrg_bchno,
  26261. ErrMsg: res.ErrMsg,
  26262. Status: 1,
  26263. PatientId: id,
  26264. RecordTime: recordDateTime,
  26265. Stage: 6,
  26266. }
  26267. service.CreateErrMsgLog(errlog)
  26268. c.ServeSuccessJSON(map[string]interface{}{
  26269. "failed_code": -10,
  26270. "msg": res.ErrMsg,
  26271. })
  26272. return
  26273. } else {
  26274. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  26275. order.OrderStatus = 2
  26276. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  26277. order.SetlId = res.Output.Setlinfo.SetlID
  26278. order.PsnNo = res.Output.Setlinfo.PsnNo
  26279. order.PsnName = res.Output.Setlinfo.PsnName
  26280. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26281. order.Certno = res.Output.Setlinfo.Certno
  26282. order.Gend = res.Output.Setlinfo.Gend
  26283. order.Naty = res.Output.Setlinfo.Naty
  26284. order.Age = res.Output.Setlinfo.Age
  26285. order.Insutype = res.Output.Setlinfo.Insutype
  26286. order.PsnType = res.Output.Setlinfo.PsnType
  26287. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26288. order.SetlTime = res.Output.Setlinfo.SetlTime
  26289. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26290. order.PayWays = pay_ways
  26291. order.AcctUsedFlag = acct_used_flag
  26292. order.WechatPay = wechat_pay
  26293. order.AliPay = ali_pay
  26294. order.JifenPay = jifen_pay
  26295. order.BandCardPay = band_card_pay
  26296. order.CashPay = cash_pay
  26297. order.OthDesc = oth_desc
  26298. //order.MedType = res.Output.Setlinfo.MedType
  26299. if reg_type == 1112 {
  26300. order.MedType = "1112"
  26301. }
  26302. if reg_type == 1111 {
  26303. order.MedType = "1111"
  26304. }
  26305. order.ClrType = res.Output.Setlinfo.ClrType
  26306. if adminUser.CurrentOrgId == 10480 {
  26307. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26308. order.ClrType = "11"
  26309. } else {
  26310. order.ClrType = "9903"
  26311. }
  26312. }
  26313. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26314. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26315. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26316. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26317. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26318. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26319. order.HifpPay = res.Output.Setlinfo.HifpPay
  26320. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26321. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26322. order.HifesPay = res.Output.Setlinfo.HifesPay
  26323. order.HifobPay = res.Output.Setlinfo.HifobPay
  26324. order.MafPay = res.Output.Setlinfo.MafPay
  26325. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26326. order.OthPay = res.Output.Setlinfo.OthPay
  26327. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26328. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26329. order.AcctPay = res.Output.Setlinfo.AcctPay
  26330. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26331. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26332. order.Balc = res.Output.Setlinfo.Balc
  26333. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26334. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26335. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26336. order.ClrWay = res.Output.Setlinfo.ClrWay
  26337. order.Creator = order.Creator
  26338. order.Modify = roles.AdminUserId
  26339. order.RequestLog = src_resquest
  26340. order.Diagnosis = diagnosis_id
  26341. order.FaPiaoNumber = fapiao_number
  26342. order.FaPiaoCode = fapiao_code
  26343. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26344. detailStr := string(setlDetail)
  26345. order.SetlDetail = detailStr
  26346. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26347. err = service.UpDateOrder(order)
  26348. if err == nil {
  26349. //判断是否使用了押金
  26350. if dec_way == "true" {
  26351. tmpstring := strconv.FormatInt(order.ID, 10)
  26352. //扣押金
  26353. order.Decimal = decimal
  26354. service.UpDateOrder(order)
  26355. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  26356. if errmsg != nil {
  26357. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  26358. return
  26359. }
  26360. }
  26361. c.ServeSuccessJSON(map[string]interface{}{
  26362. "msg": "结算成功",
  26363. })
  26364. } else {
  26365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26366. return
  26367. }
  26368. }
  26369. }
  26370. }
  26371. }
  26372. // 上传明细-预结算-
  26373. func (c *HisApiController) GetPreUploadInfo() {
  26374. id, _ := c.GetInt64("id")
  26375. record_time := c.GetString("record_time")
  26376. his_patient_id, _ := c.GetInt64("his_patient_id")
  26377. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  26378. admin_user_id, _ := c.GetInt64("admin_user_id")
  26379. diagnosis_id := c.GetString("diagnosis")
  26380. sick_type, _ := c.GetInt64("sick_type")
  26381. reg_type, _ := c.GetInt64("p_type")
  26382. begin_time := c.GetString("begin_time")
  26383. acct_used_flag := c.GetString("acct_used_flag")
  26384. id_str := c.GetString("ids")
  26385. ids_arr := strings.Split(id_str, ",")
  26386. timeLayout := "2006-01-02"
  26387. loc, _ := time.LoadLocation("Local")
  26388. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26389. if err != nil {
  26390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26391. return
  26392. }
  26393. recordDateTime := theTime.Unix()
  26394. adminUser := c.GetAdminUserInfo()
  26395. diagnosis_ids := strings.Split(diagnosis_id, ",")
  26396. var config []*models.HisXtDiagnoseConfig
  26397. for _, item := range diagnosis_ids {
  26398. id, _ := strconv.ParseInt(item, 10, 64)
  26399. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26400. config = append(config, &diagnosisConfig)
  26401. }
  26402. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  26403. sickConfig, _ := service.FindSickById(sick_type)
  26404. var prescriptions []*models.HisPrescription
  26405. var start_time int64
  26406. var end_time int64
  26407. var isSuccess bool = true
  26408. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26409. fmt.Println(his_patient_id)
  26410. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26411. timestamp := time.Now().Unix()
  26412. tempTime := time.Unix(timestamp, 0)
  26413. timeFormat := tempTime.Format("20060102150405")
  26414. chrgBchno := rand.Intn(100000) + 10000
  26415. new_chrg_bchno := ""
  26416. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  26417. new_chrg_bchno = chrg_bchno
  26418. if adminUser.CurrentOrgId == 10265 {
  26419. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  26420. new_chrg_bchno = "0000"
  26421. }
  26422. }
  26423. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26424. var patientPrescription models.HisPrescriptionInfo
  26425. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26426. if patientPrescription.ID == 0 {
  26427. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  26428. }
  26429. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26430. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26431. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26432. strconv.FormatInt(his.PatientId, 10)
  26433. var res2406 Result2406
  26434. //安徽单病种处理
  26435. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  26436. data := make(map[string]interface{})
  26437. client := &http.Client{}
  26438. data["psn_no"] = his.PsnNo
  26439. data["mdtrt_id"] = his.Number
  26440. data["operator"] = roles.UserName
  26441. data["cert_no"] = his.IdCardNo
  26442. data["org_name"] = miConfig.OrgName
  26443. data["psn_name"] = his.Name
  26444. data["ipt_otp_no"] = his.IptOtpNo
  26445. data["ipt_psn_sp_flag_type"] = "0901"
  26446. data["ipt_psn_sp_flag"] = "1"
  26447. data["fixmedins_code"] = miConfig.Code
  26448. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26449. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26450. data["url"] = miConfig.Url
  26451. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  26452. bytesData, _ := json.Marshal(data)
  26453. var req *http.Request
  26454. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  26455. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  26456. resp, _ := client.Do(req)
  26457. defer resp.Body.Close()
  26458. body, ioErr := ioutil.ReadAll(resp.Body)
  26459. if ioErr != nil {
  26460. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26462. return
  26463. }
  26464. var respJSON map[string]interface{}
  26465. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26468. return
  26469. }
  26470. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26471. if status == "0" {
  26472. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26473. c.ServeSuccessJSON(map[string]interface{}{
  26474. "failed_code": -10,
  26475. "msg": err_msg,
  26476. })
  26477. return
  26478. }
  26479. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26480. userJSONBytes, _ := json.Marshal(respJSON)
  26481. fmt.Println("log")
  26482. fmt.Println(string(userJSONBytes))
  26483. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  26484. utils.ErrorLog("解析失败:%v", err)
  26485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26486. return
  26487. }
  26488. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  26489. data := make(map[string]interface{})
  26490. client := &http.Client{}
  26491. data["psn_no"] = his.PsnNo
  26492. data["mdtrt_id"] = his.Number
  26493. data["operator"] = roles.UserName
  26494. data["cert_no"] = his.IdCardNo
  26495. data["org_name"] = miConfig.OrgName
  26496. data["psn_name"] = his.Name
  26497. data["ipt_otp_no"] = his.IptOtpNo
  26498. data["ipt_psn_sp_flag_type"] = "0901"
  26499. data["ipt_psn_sp_flag"] = "1"
  26500. data["fixmedins_code"] = miConfig.Code
  26501. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26502. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26503. data["url"] = miConfig.Url
  26504. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  26505. bytesData, _ := json.Marshal(data)
  26506. var req *http.Request
  26507. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  26508. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  26509. resp, _ := client.Do(req)
  26510. defer resp.Body.Close()
  26511. body, ioErr := ioutil.ReadAll(resp.Body)
  26512. if ioErr != nil {
  26513. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26515. return
  26516. }
  26517. var respJSON map[string]interface{}
  26518. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26521. return
  26522. }
  26523. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26524. if status == "0" {
  26525. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26526. c.ServeSuccessJSON(map[string]interface{}{
  26527. "failed_code": -10,
  26528. "msg": err_msg,
  26529. })
  26530. return
  26531. }
  26532. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26533. userJSONBytes, _ := json.Marshal(respJSON)
  26534. fmt.Println("log")
  26535. fmt.Println(string(userJSONBytes))
  26536. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  26537. utils.ErrorLog("解析失败:%v", err)
  26538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26539. return
  26540. }
  26541. }
  26542. if res2406.Infcode != 0 {
  26543. adminUser := c.GetAdminUserInfo()
  26544. errlog := &models.HisOrderError{
  26545. UserOrgId: adminUser.CurrentOrgId,
  26546. Ctime: time.Now().Unix(),
  26547. Mtime: time.Now().Unix(),
  26548. ErrMsg: res2406.ErrMsg,
  26549. Status: 1,
  26550. PatientId: id,
  26551. RecordTime: recordDateTime,
  26552. Stage: 3,
  26553. }
  26554. service.CreateErrMsgLog(errlog)
  26555. c.ServeSuccessJSON(map[string]interface{}{
  26556. "failed_code": -10,
  26557. "msg": res2406.ErrMsg,
  26558. })
  26559. return
  26560. }
  26561. var res2 ResultSix
  26562. var res3 GZResultSix
  26563. var resSix10265 ResultSix10265
  26564. //var time_stamp string
  26565. if miConfig.MdtrtareaAdmvs == "421300" {
  26566. data := make(map[string]interface{})
  26567. client := &http.Client{}
  26568. data["psn_no"] = his.PsnNo
  26569. data["mdtrt_id"] = his.Number
  26570. data["department"] = department.Name
  26571. data["org_name"] = miConfig.OrgName
  26572. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26573. data["doctor_id"] = doctor_info.DoctorNumber
  26574. data["doctor_name"] = roles.UserName
  26575. data["fixmedins_code"] = miConfig.Code
  26576. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26577. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26578. data["secret_key"] = miConfig.SecretKey
  26579. data["sick_code"] = sickConfig.CountryCode
  26580. data["sick_name"] = sickConfig.ClassName
  26581. data["begin_time"] = begin_time
  26582. data["dept"] = strconv.FormatInt(department.ID, 10)
  26583. data["config"] = config
  26584. data["opter"] = roles.UserName
  26585. fmt.Println(data)
  26586. bytesData, _ := json.Marshal(data)
  26587. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26588. resp, _ := client.Do(req)
  26589. defer resp.Body.Close()
  26590. body, ioErr := ioutil.ReadAll(resp.Body)
  26591. if ioErr != nil {
  26592. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26594. return
  26595. }
  26596. var respJSON map[string]interface{}
  26597. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26600. return
  26601. }
  26602. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26603. userJSONBytes, _ := json.Marshal(respJSON)
  26604. fmt.Println("log")
  26605. fmt.Println(string(userJSONBytes))
  26606. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26607. utils.ErrorLog("解析失败:%v", err)
  26608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26609. return
  26610. }
  26611. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26612. data := make(map[string]interface{})
  26613. client := &http.Client{}
  26614. data["psn_no"] = his.PsnNo
  26615. data["mdtrt_id"] = his.Number
  26616. data["department"] = department.Name
  26617. data["org_name"] = miConfig.OrgName
  26618. if reg_type == 11 && his.Insutype == "390" {
  26619. data["med_type"] = "110104"
  26620. } else {
  26621. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26622. }
  26623. data["doctor_id"] = doctor_info.DoctorNumber
  26624. data["doctor_name"] = roles.UserName
  26625. data["fixmedins_code"] = miConfig.Code
  26626. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26627. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26628. data["secret_key"] = miConfig.SecretKey
  26629. data["sick_code"] = sickConfig.CountryCode
  26630. data["sick_name"] = sickConfig.ClassName
  26631. data["begin_time"] = begin_time
  26632. data["dept"] = strconv.FormatInt(department.ID, 10)
  26633. data["config"] = config
  26634. data["opter"] = roles.UserName
  26635. fmt.Println(data)
  26636. bytesData, _ := json.Marshal(data)
  26637. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26638. resp, _ := client.Do(req)
  26639. defer resp.Body.Close()
  26640. body, ioErr := ioutil.ReadAll(resp.Body)
  26641. if ioErr != nil {
  26642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26644. return
  26645. }
  26646. var respJSON map[string]interface{}
  26647. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26650. return
  26651. }
  26652. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26653. userJSONBytes, _ := json.Marshal(respJSON)
  26654. fmt.Println("log")
  26655. fmt.Println(string(userJSONBytes))
  26656. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26657. utils.ErrorLog("解析失败:%v", err)
  26658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26659. return
  26660. }
  26661. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26662. data := make(map[string]interface{})
  26663. client := &http.Client{}
  26664. data["psn_no"] = his.PsnNo
  26665. data["mdtrt_id"] = his.Number
  26666. data["department"] = department.Name
  26667. data["org_name"] = miConfig.OrgName
  26668. if reg_type == 11 && his.Insutype == "390" {
  26669. data["med_type"] = "110104"
  26670. } else {
  26671. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26672. }
  26673. data["doctor_id"] = doctor_info.DoctorNumber
  26674. data["doctor_name"] = roles.UserName
  26675. data["fixmedins_code"] = miConfig.Code
  26676. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26677. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26678. data["secret_key"] = miConfig.SecretKey
  26679. data["sick_code"] = sickConfig.CountryCode
  26680. data["sick_name"] = sickConfig.ClassName
  26681. data["begin_time"] = begin_time
  26682. data["dept"] = strconv.FormatInt(department.ID, 10)
  26683. data["config"] = config
  26684. data["opter"] = roles.UserName
  26685. fmt.Println(data)
  26686. bytesData, _ := json.Marshal(data)
  26687. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26688. resp, _ := client.Do(req)
  26689. defer resp.Body.Close()
  26690. body, ioErr := ioutil.ReadAll(resp.Body)
  26691. if ioErr != nil {
  26692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26694. return
  26695. }
  26696. var respJSON map[string]interface{}
  26697. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26700. return
  26701. }
  26702. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26703. userJSONBytes, _ := json.Marshal(respJSON)
  26704. fmt.Println("log")
  26705. fmt.Println(string(userJSONBytes))
  26706. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26707. utils.ErrorLog("解析失败:%v", err)
  26708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26709. return
  26710. }
  26711. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26712. data := make(map[string]interface{})
  26713. client := &http.Client{}
  26714. data["psn_no"] = his.PsnNo
  26715. data["mdtrt_id"] = his.Number
  26716. data["department"] = department.Name
  26717. data["org_name"] = miConfig.OrgName
  26718. if reg_type == 11 && his.Insutype == "390" {
  26719. data["med_type"] = "110104"
  26720. } else {
  26721. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26722. }
  26723. data["doctor_id"] = doctor_info.DoctorNumber
  26724. data["doctor_name"] = roles.UserName
  26725. data["fixmedins_code"] = miConfig.Code
  26726. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26727. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26728. data["secret_key"] = miConfig.SecretKey
  26729. data["sick_code"] = sickConfig.CountryCode
  26730. data["sick_name"] = sickConfig.ClassName
  26731. data["begin_time"] = begin_time
  26732. data["dept"] = strconv.FormatInt(department.ID, 10)
  26733. data["config"] = config
  26734. data["opter"] = roles.UserName
  26735. fmt.Println(data)
  26736. bytesData, _ := json.Marshal(data)
  26737. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26738. resp, _ := client.Do(req)
  26739. defer resp.Body.Close()
  26740. body, ioErr := ioutil.ReadAll(resp.Body)
  26741. if ioErr != nil {
  26742. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26744. return
  26745. }
  26746. var respJSON map[string]interface{}
  26747. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26750. return
  26751. }
  26752. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26753. userJSONBytes, _ := json.Marshal(respJSON)
  26754. fmt.Println("log")
  26755. fmt.Println(string(userJSONBytes))
  26756. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26757. utils.ErrorLog("解析失败:%v", err)
  26758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26759. return
  26760. }
  26761. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26762. data := make(map[string]interface{})
  26763. client := &http.Client{}
  26764. data["psn_no"] = his.PsnNo
  26765. data["mdtrt_id"] = his.Number
  26766. data["doctor"] = roles.UserName
  26767. data["department"] = department.Name
  26768. data["org_name"] = miConfig.OrgName
  26769. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26770. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  26771. data["fixmedins_code"] = miConfig.Code
  26772. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26773. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26774. data["secret_key"] = miConfig.SecretKey
  26775. data["sick_code"] = sickConfig.CountryCode
  26776. data["sick_name"] = sickConfig.ClassName
  26777. data["begin_time"] = begin_time
  26778. data["dept"] = strconv.FormatInt(department.ID, 10)
  26779. data["config"] = config
  26780. data["url"] = miConfig.Url
  26781. data["ak"] = miConfig.AccessKey
  26782. data["cainfo"] = miConfig.Cainfo
  26783. bytesData, _ := json.Marshal(data)
  26784. var req *http.Request
  26785. if miConfig.MdtrtareaAdmvs == "320921" {
  26786. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26787. } else {
  26788. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26789. }
  26790. resp, _ := client.Do(req)
  26791. defer resp.Body.Close()
  26792. body, ioErr := ioutil.ReadAll(resp.Body)
  26793. if ioErr != nil {
  26794. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26796. return
  26797. }
  26798. var respJSON map[string]interface{}
  26799. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26800. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26802. return
  26803. }
  26804. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  26805. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  26806. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  26807. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26808. userJSONBytes, _ := json.Marshal(respJSON)
  26809. fmt.Println("log")
  26810. fmt.Println(string(userJSONBytes))
  26811. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  26812. utils.ErrorLog("解析失败:%v", err)
  26813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26814. return
  26815. }
  26816. res2.InfRefmsgid = resSix10265.InfRefmsgid
  26817. res2.Output = resSix10265.Output
  26818. res2.ErrMsg = resSix10265.ErrMsg
  26819. res2.Cainfo = resSix10265.Cainfo
  26820. res2.WarnMsg = resSix10265.WarnMsg
  26821. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  26822. res2.Infcode = infocode
  26823. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26824. data := make(map[string]interface{})
  26825. client := &http.Client{}
  26826. data["psn_no"] = his.PsnNo
  26827. data["mdtrt_id"] = his.Number
  26828. data["doctor"] = roles.UserName
  26829. data["department"] = department.Name
  26830. data["org_name"] = miConfig.OrgName
  26831. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26832. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  26833. data["fixmedins_code"] = miConfig.Code
  26834. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26835. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26836. data["secret_key"] = miConfig.SecretKey
  26837. data["sick_code"] = sickConfig.CountryCode
  26838. data["sick_name"] = sickConfig.ClassName
  26839. data["begin_time"] = begin_time
  26840. data["dept"] = strconv.FormatInt(department.ID, 10)
  26841. data["config"] = config
  26842. //data["url"] = miConfig.Url
  26843. //data["ak"] = miConfig.AccessKey
  26844. data["cainfo"] = miConfig.Cainfo
  26845. fmt.Println(data)
  26846. bytesData, _ := json.Marshal(data)
  26847. var req *http.Request
  26848. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  26849. resp, _ := client.Do(req)
  26850. defer resp.Body.Close()
  26851. body, ioErr := ioutil.ReadAll(resp.Body)
  26852. if ioErr != nil {
  26853. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26855. return
  26856. }
  26857. var respJSON map[string]interface{}
  26858. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26861. return
  26862. }
  26863. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  26864. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  26865. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  26866. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26867. userJSONBytes, _ := json.Marshal(respJSON)
  26868. fmt.Println("log")
  26869. fmt.Println(string(userJSONBytes))
  26870. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  26871. utils.ErrorLog("解析失败:%v", err)
  26872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26873. return
  26874. }
  26875. res2.InfRefmsgid = resSix10265.InfRefmsgid
  26876. res2.Output = resSix10265.Output
  26877. res2.ErrMsg = resSix10265.ErrMsg
  26878. res2.Cainfo = resSix10265.Cainfo
  26879. res2.WarnMsg = resSix10265.WarnMsg
  26880. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  26881. res2.Infcode = infocode
  26882. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26883. 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)
  26884. saveLog(result, requestLog, "2203", "上传就诊信息")
  26885. var respJSON2 map[string]interface{}
  26886. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26887. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26889. return
  26890. }
  26891. userJSONBytes2, _ := json.Marshal(respJSON2)
  26892. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26893. utils.ErrorLog("解析失败:%v", err)
  26894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26895. return
  26896. }
  26897. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26898. var result string
  26899. var requestLog string
  26900. 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, "")
  26901. saveLog(result, requestLog, "2203", "上传就诊信息")
  26902. var respJSON2 map[string]interface{}
  26903. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26906. return
  26907. }
  26908. userJSONBytes2, _ := json.Marshal(respJSON2)
  26909. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26910. utils.ErrorLog("解析失败:%v", err)
  26911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26912. return
  26913. }
  26914. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26915. data := make(map[string]interface{})
  26916. client := &http.Client{}
  26917. data["psn_no"] = his.PsnNo
  26918. data["mdtrt_id"] = his.Number
  26919. data["operator"] = roles.UserName
  26920. data["department"] = department.Name
  26921. data["org_name"] = miConfig.OrgName
  26922. var med_type string
  26923. if his.Insutype == "390" {
  26924. if reg_type == 992102 {
  26925. med_type = "992102"
  26926. data["sick_code"] = "ZDZ940"
  26927. data["sick_name"] = "慢性肾衰竭"
  26928. }
  26929. if reg_type == 140104 {
  26930. med_type = "140104"
  26931. data["sick_code"] = sickConfig.CountryCode
  26932. data["sick_name"] = sickConfig.ClassName
  26933. }
  26934. if reg_type == 14 {
  26935. med_type = "140104"
  26936. data["sick_code"] = sickConfig.CountryCode
  26937. data["sick_name"] = sickConfig.ClassName
  26938. }
  26939. } else if his.Insutype == "310" {
  26940. if reg_type == 992102 {
  26941. med_type = "992102"
  26942. data["sick_code"] = "ZDZ940"
  26943. data["sick_name"] = "慢性肾衰竭"
  26944. }
  26945. if reg_type == 140104 {
  26946. med_type = "140104"
  26947. data["sick_code"] = sickConfig.CountryCode
  26948. data["sick_name"] = sickConfig.ClassName
  26949. }
  26950. if reg_type == 14 {
  26951. med_type = "14"
  26952. data["sick_code"] = sickConfig.CountryCode
  26953. data["sick_name"] = sickConfig.ClassName
  26954. }
  26955. }
  26956. data["med_type"] = med_type
  26957. data["doctor_number"] = doctor_info.DoctorNumber
  26958. data["doctor_name"] = doctor_info.UserName
  26959. data["fixmedins_code"] = miConfig.Code
  26960. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26961. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26962. data["secret_key"] = miConfig.SecretKey
  26963. data["begin_time"] = begin_time
  26964. data["dept"] = strconv.FormatInt(department.ID, 10)
  26965. data["config"] = config
  26966. data["url"] = miConfig.Url
  26967. data["ak"] = miConfig.AccessKey
  26968. data["cainfo"] = miConfig.Cainfo
  26969. bytesData, _ := json.Marshal(data)
  26970. var req *http.Request
  26971. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  26972. resp, _ := client.Do(req)
  26973. defer resp.Body.Close()
  26974. body, ioErr := ioutil.ReadAll(resp.Body)
  26975. if ioErr != nil {
  26976. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26978. return
  26979. }
  26980. var respJSON map[string]interface{}
  26981. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26982. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26984. return
  26985. }
  26986. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26987. if status == "0" {
  26988. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26989. c.ServeSuccessJSON(map[string]interface{}{
  26990. "failed_code": -10,
  26991. "msg": err_msg,
  26992. })
  26993. return
  26994. }
  26995. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26996. userJSONBytes, _ := json.Marshal(respJSON)
  26997. fmt.Println("log")
  26998. fmt.Println(string(userJSONBytes))
  26999. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27000. utils.ErrorLog("解析失败:%v", err)
  27001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27002. return
  27003. }
  27004. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27005. data := make(map[string]interface{})
  27006. client := &http.Client{}
  27007. data["psn_no"] = his.PsnNo
  27008. data["mdtrt_id"] = his.Number
  27009. data["operator"] = roles.UserName
  27010. data["department"] = department.Name
  27011. data["org_name"] = miConfig.OrgName
  27012. var med_type string
  27013. if his.Insutype == "390" {
  27014. if reg_type == 992102 {
  27015. med_type = "992102"
  27016. data["sick_code"] = sickConfig.CountryCode
  27017. data["sick_name"] = sickConfig.ClassName
  27018. }
  27019. if reg_type == 140104 {
  27020. med_type = "140104"
  27021. data["sick_code"] = sickConfig.CountryCode
  27022. data["sick_name"] = sickConfig.ClassName
  27023. }
  27024. if reg_type == 14 {
  27025. med_type = "140104"
  27026. data["sick_code"] = sickConfig.CountryCode
  27027. data["sick_name"] = sickConfig.ClassName
  27028. }
  27029. } else if his.Insutype == "310" {
  27030. if reg_type == 992102 {
  27031. med_type = "992102"
  27032. data["sick_code"] = sickConfig.CountryCode
  27033. data["sick_name"] = sickConfig.CountryCode
  27034. }
  27035. if reg_type == 140104 {
  27036. med_type = "140104"
  27037. data["sick_code"] = sickConfig.CountryCode
  27038. data["sick_name"] = sickConfig.CountryCode
  27039. }
  27040. if reg_type == 14 {
  27041. med_type = "14"
  27042. data["sick_code"] = sickConfig.CountryCode
  27043. data["sick_name"] = sickConfig.ClassName
  27044. }
  27045. }
  27046. data["med_type"] = med_type
  27047. data["doctor_number"] = doctor_info.DoctorNumber
  27048. data["doctor_name"] = doctor_info.UserName
  27049. data["fixmedins_code"] = miConfig.Code
  27050. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27051. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27052. data["secret_key"] = miConfig.SecretKey
  27053. data["begin_time"] = begin_time
  27054. data["dept"] = strconv.FormatInt(department.ID, 10)
  27055. data["config"] = config
  27056. data["url"] = miConfig.Url
  27057. data["ak"] = miConfig.AccessKey
  27058. data["cainfo"] = miConfig.Cainfo
  27059. bytesData, _ := json.Marshal(data)
  27060. var req *http.Request
  27061. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  27062. resp, _ := client.Do(req)
  27063. defer resp.Body.Close()
  27064. body, ioErr := ioutil.ReadAll(resp.Body)
  27065. if ioErr != nil {
  27066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27068. return
  27069. }
  27070. var respJSON map[string]interface{}
  27071. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27074. return
  27075. }
  27076. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27077. if status == "0" {
  27078. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27079. c.ServeSuccessJSON(map[string]interface{}{
  27080. "failed_code": -10,
  27081. "msg": err_msg,
  27082. })
  27083. return
  27084. }
  27085. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27086. userJSONBytes, _ := json.Marshal(respJSON)
  27087. fmt.Println("log")
  27088. fmt.Println(string(userJSONBytes))
  27089. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27090. utils.ErrorLog("解析失败:%v", err)
  27091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27092. return
  27093. }
  27094. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27095. var result string
  27096. var requestLog string
  27097. 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, "")
  27098. saveLog(result, requestLog, "2203", "上传就诊信息")
  27099. var respJSON2 map[string]interface{}
  27100. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  27101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27103. return
  27104. }
  27105. userJSONBytes2, _ := json.Marshal(respJSON2)
  27106. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27107. utils.ErrorLog("解析失败:%v", err)
  27108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27109. return
  27110. }
  27111. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27112. data := make(map[string]interface{})
  27113. client := &http.Client{}
  27114. data["psn_no"] = his.PsnNo
  27115. data["mdtrt_id"] = his.Number
  27116. data["doctor"] = roles.UserName
  27117. data["department"] = department.Name
  27118. data["org_name"] = miConfig.OrgName
  27119. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27120. data["doctor_id"] = doctor_info.DoctorNumber
  27121. data["fixmedins_code"] = miConfig.Code
  27122. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27123. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27124. data["secret_key"] = miConfig.SecretKey
  27125. data["sick_code"] = sickConfig.CountryCode
  27126. data["sick_name"] = sickConfig.ClassName
  27127. data["begin_time"] = begin_time
  27128. data["new_doctor_name"] = doctor_info.UserName
  27129. data["dept"] = strconv.FormatInt(department.ID, 10)
  27130. data["config"] = config
  27131. bytesData, _ := json.Marshal(data)
  27132. var req *http.Request
  27133. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  27134. resp, _ := client.Do(req)
  27135. defer resp.Body.Close()
  27136. body, ioErr := ioutil.ReadAll(resp.Body)
  27137. if ioErr != nil {
  27138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27140. return
  27141. }
  27142. var respJSON map[string]interface{}
  27143. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27146. return
  27147. }
  27148. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27149. userJSONBytes, _ := json.Marshal(respJSON)
  27150. fmt.Println("log")
  27151. fmt.Println(string(userJSONBytes))
  27152. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27153. utils.ErrorLog("解析失败:%v", err)
  27154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27155. return
  27156. }
  27157. } else {
  27158. var result string
  27159. var requestLog string
  27160. if miConfig.MdtrtareaAdmvs == "440781" { //
  27161. 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)
  27162. } else {
  27163. if miConfig.Code == "H15049901371" {
  27164. //赤峰地区国家医保医疗类别
  27165. //职工透析:医疗类别选特殊情况门诊990502
  27166. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27167. var med_type string
  27168. if his.Insutype == "390" {
  27169. if reg_type == 14 {
  27170. med_type = "9933"
  27171. } else if reg_type == 11 {
  27172. med_type = "11"
  27173. }
  27174. } else if his.Insutype == "310" {
  27175. if reg_type == 14 {
  27176. med_type = "990502"
  27177. } else if reg_type == 11 {
  27178. med_type = "11"
  27179. }
  27180. }
  27181. 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)
  27182. } else {
  27183. 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)
  27184. }
  27185. saveLog(result, requestLog, "2203", "上传就诊信息")
  27186. var respJSON2 map[string]interface{}
  27187. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  27188. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27190. return
  27191. }
  27192. userJSONBytes2, _ := json.Marshal(respJSON2)
  27193. if miConfig.Code == "H15049901371" {
  27194. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  27195. utils.ErrorLog("解析失败:%v", err)
  27196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27197. return
  27198. }
  27199. res2.InfRefmsgid = resSix10265.InfRefmsgid
  27200. res2.Output = resSix10265.Output
  27201. res2.ErrMsg = resSix10265.ErrMsg
  27202. res2.Cainfo = resSix10265.Cainfo
  27203. res2.WarnMsg = resSix10265.WarnMsg
  27204. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  27205. res2.Infcode = infocode
  27206. } else {
  27207. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27208. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  27209. utils.ErrorLog("解析失败:%v", err)
  27210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27211. return
  27212. }
  27213. res2.Infcode = res3.Infcode
  27214. } else {
  27215. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27216. utils.ErrorLog("解析失败:%v", err)
  27217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27218. return
  27219. }
  27220. }
  27221. }
  27222. }
  27223. }
  27224. if res2.Infcode == -1 {
  27225. adminUser := c.GetAdminUserInfo()
  27226. errlog := &models.HisOrderError{
  27227. UserOrgId: adminUser.CurrentOrgId,
  27228. Ctime: time.Now().Unix(),
  27229. Mtime: time.Now().Unix(),
  27230. ErrMsg: res2.ErrMsg,
  27231. Status: 1,
  27232. PatientId: id,
  27233. RecordTime: recordDateTime,
  27234. Stage: 3,
  27235. }
  27236. service.CreateErrMsgLog(errlog)
  27237. c.ServeSuccessJSON(map[string]interface{}{
  27238. "failed_code": -10,
  27239. "msg": res2.ErrMsg,
  27240. })
  27241. return
  27242. }
  27243. if res2.Infcode != 0 {
  27244. adminUser := c.GetAdminUserInfo()
  27245. errlog := &models.HisOrderError{
  27246. UserOrgId: adminUser.CurrentOrgId,
  27247. Ctime: time.Now().Unix(),
  27248. Mtime: time.Now().Unix(),
  27249. ErrMsg: res2.ErrMsg,
  27250. Status: 1,
  27251. PatientId: id,
  27252. RecordTime: recordDateTime,
  27253. Stage: 3,
  27254. }
  27255. service.CreateErrMsgLog(errlog)
  27256. c.ServeSuccessJSON(map[string]interface{}{
  27257. "failed_code": -10,
  27258. "msg": res2.ErrMsg,
  27259. })
  27260. return
  27261. } else {
  27262. his.Diagnosis = diagnosis_id
  27263. his.SickType = sickConfig.ID
  27264. his.PType = fmt.Sprintf("%d", reg_type)
  27265. service.UpdateHisPatientThree(&his)
  27266. data := make(map[string]interface{})
  27267. if settle_accounts_type == 1 { //日结
  27268. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  27269. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  27270. } else {
  27271. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  27272. }
  27273. data["pre"] = prescriptions
  27274. } else { //月结
  27275. start_time_str := c.GetString("start_time")
  27276. end_time_str := c.GetString("end_time")
  27277. timeLayout := "2006-01-02"
  27278. loc, _ := time.LoadLocation("Local")
  27279. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  27280. if err != nil {
  27281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27282. return
  27283. }
  27284. recordStartTime := theStartTime.Unix()
  27285. start_time = recordStartTime
  27286. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  27287. if err != nil {
  27288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27289. return
  27290. }
  27291. recordEndTime := theEndTime.Unix()
  27292. end_time = recordEndTime
  27293. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  27294. data["pre"] = prescriptions
  27295. }
  27296. client := &http.Client{}
  27297. data["psn_no"] = his.PsnNo
  27298. data["mdtrt_id"] = his.Number
  27299. data["chrg_bchno"] = new_chrg_bchno
  27300. data["org_name"] = miConfig.OrgName
  27301. data["doctor"] = doctor_info.UserName
  27302. data["doctor_id"] = doctor_info.DoctorNumber
  27303. data["dept"] = department.Name
  27304. data["fixmedins_code"] = miConfig.Code
  27305. data["opter"] = roles.UserName
  27306. data["dept_code"] = department.Number
  27307. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27308. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27309. data["secret_key"] = miConfig.SecretKey
  27310. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  27311. data["url"] = miConfig.Url
  27312. data["ak"] = miConfig.AccessKey
  27313. data["new_doctor_name"] = patientPrescription.Doctor
  27314. if his.Insutype == "390" {
  27315. if reg_type == 992102 {
  27316. data["diag_code"] = "ZDZ940"
  27317. }
  27318. if reg_type == 140104 {
  27319. data["diag_code"] = sickConfig.CountryCode
  27320. }
  27321. if reg_type == 14 {
  27322. data["diag_code"] = sickConfig.CountryCode
  27323. }
  27324. } else if his.Insutype == "310" {
  27325. if reg_type == 992102 {
  27326. data["diag_code"] = "ZDZ940"
  27327. }
  27328. if reg_type == 14 {
  27329. data["diag_code"] = sickConfig.CountryCode
  27330. }
  27331. }
  27332. data["cainfo"] = miConfig.Cainfo
  27333. data["opter"] = roles.UserName
  27334. var ids []int64
  27335. for _, item := range prescriptions {
  27336. ids = append(ids, item.ID)
  27337. }
  27338. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27339. if config.IsOpen == 1 { //对接了医保,走医保流程
  27340. var res ResultFour
  27341. var resFour10265 ResultFour10265
  27342. if miConfig.MdtrtareaAdmvs == "421300" {
  27343. bytesData, _ := json.Marshal(data)
  27344. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  27345. resp, _ := client.Do(req)
  27346. defer resp.Body.Close()
  27347. body, ioErr := ioutil.ReadAll(resp.Body)
  27348. if ioErr != nil {
  27349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27351. return
  27352. }
  27353. var respJSON map[string]interface{}
  27354. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27357. return
  27358. }
  27359. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27360. userJSONBytes, _ := json.Marshal(respJSON)
  27361. fmt.Println("log")
  27362. fmt.Println(string(userJSONBytes))
  27363. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27364. utils.ErrorLog("解析失败:%v", err)
  27365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27366. return
  27367. }
  27368. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27369. bytesData, _ := json.Marshal(data)
  27370. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  27371. resp, _ := client.Do(req)
  27372. defer resp.Body.Close()
  27373. body, ioErr := ioutil.ReadAll(resp.Body)
  27374. if ioErr != nil {
  27375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27377. return
  27378. }
  27379. var respJSON map[string]interface{}
  27380. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27383. return
  27384. }
  27385. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27386. userJSONBytes, _ := json.Marshal(respJSON)
  27387. fmt.Println("log")
  27388. fmt.Println(string(userJSONBytes))
  27389. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27390. utils.ErrorLog("解析失败:%v", err)
  27391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27392. return
  27393. }
  27394. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27395. bytesData, _ := json.Marshal(data)
  27396. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  27397. resp, _ := client.Do(req)
  27398. defer resp.Body.Close()
  27399. body, ioErr := ioutil.ReadAll(resp.Body)
  27400. if ioErr != nil {
  27401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27403. return
  27404. }
  27405. var respJSON map[string]interface{}
  27406. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27409. return
  27410. }
  27411. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27412. userJSONBytes, _ := json.Marshal(respJSON)
  27413. fmt.Println("log")
  27414. fmt.Println(string(userJSONBytes))
  27415. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27416. utils.ErrorLog("解析失败:%v", err)
  27417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27418. return
  27419. }
  27420. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27421. bytesData, _ := json.Marshal(data)
  27422. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  27423. resp, _ := client.Do(req)
  27424. defer resp.Body.Close()
  27425. body, ioErr := ioutil.ReadAll(resp.Body)
  27426. if ioErr != nil {
  27427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27429. return
  27430. }
  27431. var respJSON map[string]interface{}
  27432. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27435. return
  27436. }
  27437. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27438. userJSONBytes, _ := json.Marshal(respJSON)
  27439. fmt.Println("log")
  27440. fmt.Println(string(userJSONBytes))
  27441. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27442. utils.ErrorLog("解析失败:%v", err)
  27443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27444. return
  27445. }
  27446. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27447. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  27448. if result3101.Infcode == "0" {
  27449. if len(result3101.Output.Result) > 0 {
  27450. var errMsgs []string
  27451. for _, item := range result3101.Output.Result {
  27452. errMsgs = append(errMsgs, item.VolaCont)
  27453. }
  27454. c.ServeSuccessJSON(map[string]interface{}{
  27455. "failed_code": -10,
  27456. "msg": errMsgs,
  27457. })
  27458. return
  27459. } else {
  27460. if miConfig.MdtrtareaAdmvs == "320921" {
  27461. data["doctor_id"] = "D320923012139"
  27462. } else {
  27463. data["doctor_id"] = "D371621008686"
  27464. }
  27465. bytesData, _ := json.Marshal(data)
  27466. var req *http.Request
  27467. if miConfig.MdtrtareaAdmvs == "320921" {
  27468. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27469. } else {
  27470. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27471. }
  27472. resp, _ := client.Do(req)
  27473. defer resp.Body.Close()
  27474. body, ioErr := ioutil.ReadAll(resp.Body)
  27475. if ioErr != nil {
  27476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27478. return
  27479. }
  27480. var respJSON map[string]interface{}
  27481. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27484. return
  27485. }
  27486. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27487. userJSONBytes, _ := json.Marshal(respJSON)
  27488. fmt.Println("log")
  27489. fmt.Println(string(userJSONBytes))
  27490. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27491. utils.ErrorLog("解析失败:%v", err)
  27492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27493. return
  27494. }
  27495. res.InfRefmsgid = resFour10265.InfRefmsgid
  27496. res.Output = resFour10265.Output
  27497. res.ErrMsg = resFour10265.ErrMsg
  27498. res.Cainfo = resFour10265.Cainfo
  27499. res.WarnMsg = resFour10265.WarnMsg
  27500. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27501. res.Infcode = infocode
  27502. }
  27503. }
  27504. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27505. var pagesize int = 5
  27506. var start int = 1
  27507. var stop int
  27508. var pagecount int
  27509. var curpage int
  27510. data["doctor_id"] = doctor_info.DoctorNumber
  27511. var res2 ResultFour
  27512. //var result res.
  27513. //总页数,向上取整,注意除之前要先转换类型为float64
  27514. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  27515. for curpage = 1; curpage <= pagecount; curpage++ {
  27516. if curpage == 1 {
  27517. start = 1
  27518. } else {
  27519. start = (curpage-1)*pagesize + 1
  27520. }
  27521. stop = curpage * pagesize
  27522. if stop > len(prescriptions) {
  27523. stop = len(prescriptions)
  27524. }
  27525. //var requestLog string
  27526. data["pre"] = prescriptions[start-1 : stop]
  27527. fmt.Println(data["pre"])
  27528. bytesData, _ := json.Marshal(data)
  27529. var req *http.Request
  27530. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  27531. resp, _ := client.Do(req)
  27532. defer resp.Body.Close()
  27533. body, ioErr := ioutil.ReadAll(resp.Body)
  27534. if ioErr != nil {
  27535. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27537. return
  27538. }
  27539. var respJSON map[string]interface{}
  27540. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27543. return
  27544. }
  27545. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27546. userJSONBytes, _ := json.Marshal(respJSON)
  27547. fmt.Println("log")
  27548. fmt.Println(string(userJSONBytes))
  27549. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27550. utils.ErrorLog("解析失败:%v", err)
  27551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27552. return
  27553. }
  27554. res.InfRefmsgid = resFour10265.InfRefmsgid
  27555. res.Output = resFour10265.Output
  27556. res.ErrMsg = resFour10265.ErrMsg
  27557. res.Cainfo = resFour10265.Cainfo
  27558. res.WarnMsg = resFour10265.WarnMsg
  27559. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27560. res.Infcode = infocode
  27561. if infocode == 0 {
  27562. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  27563. } else {
  27564. isSuccess = false
  27565. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  27566. res.Infcode = -1
  27567. res.ErrMsg = resFour10265.ErrMsg
  27568. errlog := &models.HisOrderError{
  27569. UserOrgId: adminUser.CurrentOrgId,
  27570. Ctime: time.Now().Unix(),
  27571. Mtime: time.Now().Unix(),
  27572. Number: chrg_bchno,
  27573. ErrMsg: "",
  27574. Status: 1,
  27575. PatientId: id,
  27576. RecordTime: recordDateTime,
  27577. Stage: 4,
  27578. }
  27579. service.CreateErrMsgLog(errlog)
  27580. }
  27581. }
  27582. if isSuccess {
  27583. res.Infcode = 0
  27584. res.Output.Result = res2.Output.Result
  27585. } else {
  27586. order := &models.HisOrder{
  27587. UserOrgId: adminUser.CurrentOrgId,
  27588. HisPatientId: his.ID,
  27589. PatientId: his.PatientId,
  27590. SettleAccountsDate: recordDateTime,
  27591. Ctime: time.Now().Unix(),
  27592. Mtime: time.Now().Unix(),
  27593. MdtrtId: his.Number,
  27594. PsnNo: his.PsnNo,
  27595. MedType: strconv.FormatInt(reg_type, 10),
  27596. Status: 1,
  27597. Number: chrg_bchno,
  27598. Infcode: res.Infcode,
  27599. WarnMsg: res.WarnMsg,
  27600. Cainfo: res.Cainfo,
  27601. ErrMsg: res.ErrMsg,
  27602. RespondTime: res.RefmsgTime,
  27603. InfRefmsgid: res.InfRefmsgid,
  27604. OrderStatus: 1,
  27605. IsMedicineInsurance: 1,
  27606. SettleType: settle_accounts_type,
  27607. SettleStartTime: start_time,
  27608. SettleEndTime: end_time,
  27609. Creator: roles.AdminUserId,
  27610. Modify: roles.AdminUserId,
  27611. PType: 2,
  27612. Diagnosis: diagnosis_id,
  27613. }
  27614. err = service.CreateOrder(order)
  27615. if err != nil {
  27616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  27617. return
  27618. }
  27619. c.ServeSuccessJSON(map[string]interface{}{
  27620. "failed_code": -10,
  27621. "msg": res2.ErrMsg,
  27622. })
  27623. return
  27624. }
  27625. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27626. 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)
  27627. var dat map[string]interface{}
  27628. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27629. fmt.Println(dat)
  27630. } else {
  27631. fmt.Println(err)
  27632. }
  27633. saveLog(result, request_log, "2204", "上传费用明细")
  27634. userJSONBytes, _ := json.Marshal(dat)
  27635. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27636. utils.ErrorLog("解析失败:%v", err)
  27637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27638. return
  27639. }
  27640. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27641. 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, "", "")
  27642. var dat map[string]interface{}
  27643. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27644. fmt.Println(dat)
  27645. } else {
  27646. fmt.Println(err)
  27647. }
  27648. saveLog(result, request_log, "2204", "上传费用明细")
  27649. userJSONBytes, _ := json.Marshal(dat)
  27650. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27651. utils.ErrorLog("解析失败:%v", err)
  27652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27653. return
  27654. }
  27655. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27656. bytesData, _ := json.Marshal(data)
  27657. var req *http.Request
  27658. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  27659. resp, _ := client.Do(req)
  27660. defer resp.Body.Close()
  27661. body, ioErr := ioutil.ReadAll(resp.Body)
  27662. if ioErr != nil {
  27663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27665. return
  27666. }
  27667. var respJSON map[string]interface{}
  27668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27671. return
  27672. }
  27673. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27674. if status == "0" {
  27675. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27676. c.ServeSuccessJSON(map[string]interface{}{
  27677. "failed_code": -10,
  27678. "msg": err_msg,
  27679. })
  27680. return
  27681. }
  27682. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27683. userJSONBytes, _ := json.Marshal(respJSON)
  27684. fmt.Println("log")
  27685. fmt.Println(string(userJSONBytes))
  27686. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27687. utils.ErrorLog("解析失败:%v", err)
  27688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27689. return
  27690. }
  27691. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27692. bytesData, _ := json.Marshal(data)
  27693. var req *http.Request
  27694. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  27695. resp, _ := client.Do(req)
  27696. defer resp.Body.Close()
  27697. body, ioErr := ioutil.ReadAll(resp.Body)
  27698. if ioErr != nil {
  27699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27701. return
  27702. }
  27703. var respJSON map[string]interface{}
  27704. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27707. return
  27708. }
  27709. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27710. if status == "0" {
  27711. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27712. c.ServeSuccessJSON(map[string]interface{}{
  27713. "failed_code": -10,
  27714. "msg": err_msg,
  27715. })
  27716. return
  27717. }
  27718. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27719. userJSONBytes, _ := json.Marshal(respJSON)
  27720. fmt.Println("log")
  27721. fmt.Println(string(userJSONBytes))
  27722. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27723. utils.ErrorLog("解析失败:%v", err)
  27724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27725. return
  27726. }
  27727. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27728. 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, "", "")
  27729. var dat map[string]interface{}
  27730. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27731. fmt.Println(dat)
  27732. } else {
  27733. fmt.Println(err)
  27734. }
  27735. saveLog(result, request_log, "2204", "上传费用明细")
  27736. userJSONBytes, _ := json.Marshal(dat)
  27737. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27738. utils.ErrorLog("解析失败:%v", err)
  27739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27740. return
  27741. }
  27742. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27743. bytesData, _ := json.Marshal(data)
  27744. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  27745. resp, _ := client.Do(req)
  27746. defer resp.Body.Close()
  27747. body, ioErr := ioutil.ReadAll(resp.Body)
  27748. if ioErr != nil {
  27749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27751. return
  27752. }
  27753. var respJSON map[string]interface{}
  27754. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27757. return
  27758. }
  27759. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27760. userJSONBytes, _ := json.Marshal(respJSON)
  27761. fmt.Println("log")
  27762. fmt.Println(string(userJSONBytes))
  27763. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27764. utils.ErrorLog("解析失败:%v", err)
  27765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27766. return
  27767. }
  27768. } else {
  27769. if miConfig.MdtrtareaAdmvs == "441202" {
  27770. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  27771. if result3101.Infcode == 0 {
  27772. if len(result3101.Output.Result) > 0 {
  27773. var errMsgs []string
  27774. for _, item := range result3101.Output.Result {
  27775. errMsgs = append(errMsgs, item.VolaCont)
  27776. }
  27777. c.ServeSuccessJSON(map[string]interface{}{
  27778. "failed_code": -10,
  27779. "msg": errMsgs,
  27780. })
  27781. return
  27782. } else {
  27783. 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)
  27784. var dat map[string]interface{}
  27785. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27786. fmt.Println(dat)
  27787. } else {
  27788. fmt.Println(err)
  27789. }
  27790. saveLog(result, request_log, "2204", "上传费用明细")
  27791. userJSONBytes, _ := json.Marshal(dat)
  27792. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27793. utils.ErrorLog("解析失败:%v", err)
  27794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27795. return
  27796. }
  27797. }
  27798. } else {
  27799. c.ServeSuccessJSON(map[string]interface{}{
  27800. "failed_code": -10,
  27801. "msg": result3101.ErrMsg,
  27802. })
  27803. return
  27804. }
  27805. } else if miConfig.MdtrtareaAdmvs == "440205" {
  27806. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  27807. if result3101.Infcode == 0 {
  27808. if len(result3101.Output.Result) > 0 {
  27809. var errMsgs []string
  27810. for _, item := range result3101.Output.Result {
  27811. errMsgs = append(errMsgs, item.VolaCont)
  27812. }
  27813. c.ServeSuccessJSON(map[string]interface{}{
  27814. "failed_code": -10,
  27815. "msg": errMsgs,
  27816. })
  27817. return
  27818. } else {
  27819. 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)
  27820. var dat map[string]interface{}
  27821. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27822. fmt.Println(dat)
  27823. } else {
  27824. fmt.Println(err)
  27825. }
  27826. saveLog(result, request_log, "2204", "上传费用明细")
  27827. userJSONBytes, _ := json.Marshal(dat)
  27828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27829. utils.ErrorLog("解析失败:%v", err)
  27830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27831. return
  27832. }
  27833. }
  27834. } else {
  27835. c.ServeSuccessJSON(map[string]interface{}{
  27836. "failed_code": -10,
  27837. "msg": result3101.ErrMsg,
  27838. })
  27839. return
  27840. }
  27841. } else {
  27842. if miConfig.Code == "H15049901371" {
  27843. 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)
  27844. var dat map[string]interface{}
  27845. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27846. fmt.Println(dat)
  27847. } else {
  27848. fmt.Println(err)
  27849. }
  27850. saveLog(result, request_log, "2204", "上传费用明细")
  27851. userJSONBytes, _ := json.Marshal(dat)
  27852. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27853. utils.ErrorLog("解析失败:%v", err)
  27854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27855. return
  27856. }
  27857. res.InfRefmsgid = resFour10265.InfRefmsgid
  27858. res.Output = resFour10265.Output
  27859. res.ErrMsg = resFour10265.ErrMsg
  27860. res.Cainfo = resFour10265.Cainfo
  27861. res.WarnMsg = resFour10265.WarnMsg
  27862. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27863. res.Infcode = infocode
  27864. } else {
  27865. 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)
  27866. var dat map[string]interface{}
  27867. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27868. fmt.Println(dat)
  27869. } else {
  27870. fmt.Println(err)
  27871. }
  27872. saveLog(result, request_log, "2204", "上传费用明细")
  27873. userJSONBytes, _ := json.Marshal(dat)
  27874. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27875. utils.ErrorLog("解析失败:%v", err)
  27876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27877. return
  27878. }
  27879. }
  27880. }
  27881. }
  27882. var total_two float64
  27883. if res.Infcode == -1 {
  27884. errlog := &models.HisOrderError{
  27885. UserOrgId: adminUser.CurrentOrgId,
  27886. Ctime: time.Now().Unix(),
  27887. Mtime: time.Now().Unix(),
  27888. Number: chrg_bchno,
  27889. ErrMsg: res.ErrMsg,
  27890. Status: 1,
  27891. PatientId: id,
  27892. RecordTime: recordDateTime,
  27893. Stage: 4,
  27894. }
  27895. service.CreateErrMsgLog(errlog)
  27896. c.ServeSuccessJSON(map[string]interface{}{
  27897. "failed_code": -10,
  27898. "msg": res.ErrMsg,
  27899. })
  27900. return
  27901. }
  27902. if res.Infcode == 0 {
  27903. order := &models.HisOrder{
  27904. UserOrgId: adminUser.CurrentOrgId,
  27905. HisPatientId: his.ID,
  27906. PatientId: his.PatientId,
  27907. SettleAccountsDate: recordDateTime,
  27908. Ctime: time.Now().Unix(),
  27909. Mtime: time.Now().Unix(),
  27910. MdtrtId: his.Number,
  27911. PsnNo: his.PsnNo,
  27912. MedType: strconv.FormatInt(reg_type, 10),
  27913. Status: 1,
  27914. Number: chrg_bchno,
  27915. Infcode: res.Infcode,
  27916. WarnMsg: res.WarnMsg,
  27917. Cainfo: res.Cainfo,
  27918. ErrMsg: res.ErrMsg,
  27919. RespondTime: res.RefmsgTime,
  27920. InfRefmsgid: res.InfRefmsgid,
  27921. OrderStatus: 1,
  27922. IsMedicineInsurance: 1,
  27923. SettleType: settle_accounts_type,
  27924. SettleStartTime: start_time,
  27925. SettleEndTime: end_time,
  27926. Creator: roles.AdminUserId,
  27927. Modify: roles.AdminUserId,
  27928. PType: 2,
  27929. Diagnosis: diagnosis_id,
  27930. }
  27931. err = service.CreateOrder(order)
  27932. if err != nil {
  27933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  27934. return
  27935. }
  27936. for _, item := range res.Output.Result {
  27937. temp := strings.Split(item.FeedetlSn, "-")
  27938. var advice_id int64 = 0
  27939. var project_id int64 = 0
  27940. var types int64 = 0
  27941. id, _ := strconv.ParseInt(temp[2], 10, 64)
  27942. types, _ = strconv.ParseInt(temp[1], 10, 64)
  27943. if temp[1] == "1" {
  27944. advice_id = id
  27945. project_id = 0
  27946. } else if temp[1] == "2" {
  27947. advice_id = 0
  27948. project_id = id
  27949. }
  27950. total_two = total_two + item.DetItemFeeSumamt
  27951. info := &models.HisOrderInfo{
  27952. OrderNumber: order.Number,
  27953. FeedetlSn: item.FeedetlSn,
  27954. UploadDate: time.Now().Unix(),
  27955. AdviceId: advice_id,
  27956. DetItemFeeSumamt: item.DetItemFeeSumamt,
  27957. Cnt: item.Cnt,
  27958. Pric: float64(item.Pric),
  27959. PatientId: his.PatientId,
  27960. PricUplmtAmt: item.PricUplmtAmt,
  27961. SelfpayProp: item.SelfpayProp,
  27962. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  27963. OverlmtAmt: item.OverlmtAmt,
  27964. PreselfpayAmt: item.PreselfpayAmt,
  27965. BasMednFlag: item.BasMednFlag,
  27966. MedChrgitmType: item.MedChrgitmType,
  27967. HiNegoDrugFlag: item.HiNegoDrugFlag,
  27968. Status: 1,
  27969. Memo: item.Memo,
  27970. Mtime: time.Now().Unix(),
  27971. InscpScpAmt: item.InscpScpAmt,
  27972. DrtReimFlag: item.DrtReimFlag,
  27973. Ctime: time.Now().Unix(),
  27974. ListSpItemFlag: item.ListSpItemFlag,
  27975. ChldMedcFlag: item.ChldMedcFlag,
  27976. LmtUsedFlag: item.LmtUsedFlag,
  27977. ChrgitmLv: item.ChrgitmLv,
  27978. UserOrgId: adminUser.CurrentOrgId,
  27979. HisPatientId: his.ID,
  27980. OrderId: order.ID,
  27981. ProjectId: project_id,
  27982. Type: types,
  27983. }
  27984. service.CreateOrderInfo(info)
  27985. }
  27986. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  27987. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  27988. var total float64
  27989. for _, item := range prescriptions {
  27990. if item.Type == 1 { //药品
  27991. for _, subItem := range item.HisDoctorAdviceInfo {
  27992. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27993. total_one := price * subItem.PrescribingNumber
  27994. fmt.Println("subItem")
  27995. fmt.Println(subItem.Price)
  27996. fmt.Println("price")
  27997. fmt.Println(price)
  27998. fmt.Println("total_one")
  27999. fmt.Println(total_one)
  28000. total = total + total_one
  28001. fmt.Println(total)
  28002. }
  28003. }
  28004. if item.Type == 2 { //项目
  28005. for _, subItem := range item.HisPrescriptionProject {
  28006. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  28007. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  28008. total_one := price * cnt
  28009. total = total + total_one
  28010. }
  28011. }
  28012. }
  28013. allTotal := fmt.Sprintf("%.2f", total)
  28014. if res.Infcode == 0 {
  28015. var rf []*ResultFive
  28016. json.Unmarshal([]byte(his.Iinfo), &rf)
  28017. chrg_bchno := chrg_bchno
  28018. cert_no := his.Certno
  28019. var insutypes []string
  28020. var insutype string
  28021. var is390 int = 0
  28022. var is310 int = 0
  28023. for _, item := range rf {
  28024. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28025. insutypes = append(insutypes, item.Insutype)
  28026. }
  28027. }
  28028. if len(insutypes) == 1 {
  28029. insutype = insutypes[0]
  28030. } else {
  28031. for _, i := range insutypes {
  28032. if i == "390" {
  28033. is390 = 1
  28034. }
  28035. if i == "310" {
  28036. is310 = 1
  28037. }
  28038. }
  28039. }
  28040. if is390 == 1 {
  28041. insutype = "390"
  28042. }
  28043. if is310 == 1 {
  28044. insutype = "310"
  28045. }
  28046. if len(insutypes) == 0 {
  28047. insutype = "390"
  28048. }
  28049. if len(insutypes) == 2 {
  28050. insutype = strconv.FormatInt(his.SocialType, 10)
  28051. }
  28052. //insutype = "390"
  28053. if his.IdCardType == 1 {
  28054. cert_no = his.MedicalInsuranceNumber
  28055. } else {
  28056. cert_no = his.Certno
  28057. }
  28058. var res ResultSeven
  28059. var ahres ResultSevenAH
  28060. var resSeven10265 ResultSeven10265
  28061. var resSeven10265Two ResultSeven10265Two
  28062. var gzresSeven10265Two GZResultSeven10265Two
  28063. if miConfig.MdtrtareaAdmvs == "421300" {
  28064. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  28065. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28066. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28067. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28068. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28069. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28070. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28071. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  28072. resp, requestErr := http.Get(api)
  28073. if requestErr != nil {
  28074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28075. return
  28076. }
  28077. body, ioErr := ioutil.ReadAll(resp.Body)
  28078. if ioErr != nil {
  28079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28081. return
  28082. }
  28083. var respJSON map[string]interface{}
  28084. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28087. return
  28088. }
  28089. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28090. result, _ := json.Marshal(respJSON)
  28091. fmt.Println("log")
  28092. fmt.Println(string(result))
  28093. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28094. utils.ErrorLog("解析失败:%v", err)
  28095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28096. return
  28097. }
  28098. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28099. if reg_type == 11 && his.Insutype == "390" {
  28100. reg_type = 110104
  28101. }
  28102. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28103. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28104. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28105. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28106. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28107. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28108. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  28109. resp, requestErr := http.Get(api)
  28110. if requestErr != nil {
  28111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28112. return
  28113. }
  28114. body, ioErr := ioutil.ReadAll(resp.Body)
  28115. if ioErr != nil {
  28116. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28118. return
  28119. }
  28120. var respJSON map[string]interface{}
  28121. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28124. return
  28125. }
  28126. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28127. result, _ := json.Marshal(respJSON)
  28128. fmt.Println("log")
  28129. fmt.Println(string(result))
  28130. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28131. utils.ErrorLog("解析失败:%v", err)
  28132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28133. return
  28134. }
  28135. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28136. if reg_type == 11 && his.Insutype == "390" {
  28137. reg_type = 110104
  28138. }
  28139. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28140. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28141. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28142. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28143. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28144. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28145. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  28146. resp, requestErr := http.Get(api)
  28147. if requestErr != nil {
  28148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28149. return
  28150. }
  28151. body, ioErr := ioutil.ReadAll(resp.Body)
  28152. if ioErr != nil {
  28153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28155. return
  28156. }
  28157. var respJSON map[string]interface{}
  28158. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28161. return
  28162. }
  28163. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28164. result, _ := json.Marshal(respJSON)
  28165. fmt.Println("log")
  28166. fmt.Println(string(result))
  28167. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28168. utils.ErrorLog("解析失败:%v", err)
  28169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28170. return
  28171. }
  28172. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28173. if reg_type == 11 && his.Insutype == "390" {
  28174. reg_type = 110104
  28175. }
  28176. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28177. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28178. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28179. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28180. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28181. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28182. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  28183. resp, requestErr := http.Get(api)
  28184. if requestErr != nil {
  28185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28186. return
  28187. }
  28188. body, ioErr := ioutil.ReadAll(resp.Body)
  28189. if ioErr != nil {
  28190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28192. return
  28193. }
  28194. var respJSON map[string]interface{}
  28195. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28198. return
  28199. }
  28200. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28201. result, _ := json.Marshal(respJSON)
  28202. fmt.Println("log")
  28203. fmt.Println(string(result))
  28204. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28205. utils.ErrorLog("解析失败:%v", err)
  28206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28207. return
  28208. }
  28209. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28210. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  28211. if result3101.Infcode == "0" {
  28212. if len(result3101.Output.Result) > 0 {
  28213. var errMsgs []string
  28214. for _, item := range result3101.Output.Result {
  28215. errMsgs = append(errMsgs, item.VolaCont)
  28216. }
  28217. c.ServeSuccessJSON(map[string]interface{}{
  28218. "failed_code": -10,
  28219. "msg": errMsgs,
  28220. })
  28221. return
  28222. } else {
  28223. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28224. if his.IdCardType != 4 {
  28225. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28226. bas := strings.Split(psn_info.CardInfo, "|")
  28227. if his.IdCardType == 1 {
  28228. cert_no = bas[2]
  28229. } else {
  28230. cert_no = bas[1]
  28231. }
  28232. } else {
  28233. cert_no = his.Certno
  28234. }
  28235. //江苏地区国家医保医疗类别
  28236. //职工透析:医疗类别选特殊情况门诊9933
  28237. //居民血透门慢: 医疗类别选门诊慢病1402
  28238. //var med_type string
  28239. //if his.Insutype == "310" {
  28240. // if reg_type == 14 {
  28241. // med_type = "9933"
  28242. // } else if reg_type == 11 {
  28243. // med_type = "11"
  28244. //
  28245. // }
  28246. //} else if his.Insutype == "390" {
  28247. // if reg_type == 14 {
  28248. // med_type = "1402"
  28249. // } else if reg_type == 11 {
  28250. // med_type = "11"
  28251. // }
  28252. //}
  28253. var api string
  28254. if miConfig.MdtrtareaAdmvs == "320921" {
  28255. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28256. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28257. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28258. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28259. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28260. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28261. "&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
  28262. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28263. } else {
  28264. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28265. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28266. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28267. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28268. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28269. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28270. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28271. "&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
  28272. }
  28273. resp, requestErr := http.Get(api)
  28274. if requestErr != nil {
  28275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28276. return
  28277. }
  28278. body, ioErr := ioutil.ReadAll(resp.Body)
  28279. if ioErr != nil {
  28280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28282. return
  28283. }
  28284. var respJSON map[string]interface{}
  28285. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28288. return
  28289. }
  28290. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28291. result, _ := json.Marshal(respJSON)
  28292. fmt.Println("log")
  28293. fmt.Println(string(result))
  28294. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  28295. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28296. utils.ErrorLog("解析失败:%v", err)
  28297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28298. return
  28299. }
  28300. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28301. res.Output = resSeven10265.Output
  28302. res.ErrMsg = resSeven10265.ErrMsg
  28303. res.Cainfo = resSeven10265.Cainfo
  28304. res.WarnMsg = resSeven10265.WarnMsg
  28305. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28306. res.Infcode = infocode
  28307. } else {
  28308. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  28309. utils.ErrorLog("解析失败:%v", err)
  28310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28311. return
  28312. }
  28313. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  28314. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  28315. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  28316. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  28317. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  28318. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  28319. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  28320. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  28321. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  28322. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  28323. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  28324. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  28325. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  28326. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  28327. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  28328. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  28329. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  28330. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  28331. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  28332. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  28333. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  28334. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28335. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  28336. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  28337. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  28338. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  28339. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  28340. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  28341. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  28342. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  28343. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  28344. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  28345. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  28346. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  28347. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  28348. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  28349. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  28350. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  28351. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  28352. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  28353. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  28354. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  28355. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  28356. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  28357. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  28358. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  28359. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  28360. res.ErrMsg = resSeven10265Two.ErrMsg
  28361. res.Cainfo = resSeven10265Two.Cainfo
  28362. res.WarnMsg = resSeven10265Two.WarnMsg
  28363. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  28364. res.Infcode = infocode
  28365. }
  28366. }
  28367. }
  28368. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28369. psn_info, _ := service.GetPsnByPatientId(id)
  28370. var verify_number string
  28371. if psn_info.IdCardType == 4 {
  28372. verify_number = psn_info.VerifyNumber
  28373. } else if psn_info.IdCardType == 1 {
  28374. bas := strings.Split(psn_info.CardInfo, "|")
  28375. cardNumber := bas[2]
  28376. verify_number = cardNumber
  28377. } else {
  28378. psn_info.IdCardType = 2
  28379. verify_number = psn_info.Certno
  28380. }
  28381. var api string
  28382. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28383. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  28384. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28385. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28386. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  28387. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28388. "&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
  28389. resp, requestErr := http.Get(api)
  28390. if requestErr != nil {
  28391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28392. return
  28393. }
  28394. body, ioErr := ioutil.ReadAll(resp.Body)
  28395. if ioErr != nil {
  28396. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28398. return
  28399. }
  28400. var respJSON map[string]interface{}
  28401. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28404. return
  28405. }
  28406. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28407. result, _ := json.Marshal(respJSON)
  28408. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28409. utils.ErrorLog("解析失败:%v", err)
  28410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28411. return
  28412. }
  28413. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28414. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  28415. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  28416. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  28417. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  28418. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  28419. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  28420. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  28421. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  28422. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  28423. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  28424. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  28425. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  28426. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  28427. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  28428. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  28429. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  28430. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  28431. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  28432. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  28433. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28434. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  28435. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  28436. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  28437. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  28438. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  28439. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  28440. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  28441. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  28442. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  28443. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  28444. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  28445. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  28446. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  28447. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  28448. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  28449. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  28450. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  28451. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  28452. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  28453. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  28454. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  28455. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  28456. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  28457. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  28458. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  28459. res.ErrMsg = resSeven10265.ErrMsg
  28460. res.Cainfo = resSeven10265.Cainfo
  28461. res.WarnMsg = resSeven10265.WarnMsg
  28462. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28463. res.Infcode = infocode
  28464. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28465. acct_used_flag := "1"
  28466. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  28467. var result string
  28468. var request_log string
  28469. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  28470. 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)
  28471. } else {
  28472. 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)
  28473. }
  28474. var dat map[string]interface{}
  28475. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28476. fmt.Println(dat)
  28477. } else {
  28478. fmt.Println(err)
  28479. }
  28480. saveLog(result, request_log, "2206", "预结算")
  28481. userJSONBytes, _ := json.Marshal(dat)
  28482. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28483. utils.ErrorLog("解析失败:%v", err)
  28484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28485. return
  28486. }
  28487. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28488. var result string
  28489. var request_log string
  28490. if his.IdCardType == 2 {
  28491. 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, "")
  28492. } else if his.IdCardType == 1 {
  28493. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28494. bas := strings.Split(psn_info.CardInfo, "|")
  28495. basNumber := bas[2]
  28496. card_sn := bas[3]
  28497. var rf []*ResultFive
  28498. json.Unmarshal([]byte(his.Iinfo), &rf)
  28499. var psn_type string
  28500. for _, item := range rf {
  28501. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28502. psn_type = item.PsnType
  28503. }
  28504. }
  28505. 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)
  28506. } else {
  28507. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28508. //bas := strings.Split(psn_info.CardInfo, "|")
  28509. //basNumber := bas[2]
  28510. //card_sn := bas[3]
  28511. var rf []*ResultFive
  28512. json.Unmarshal([]byte(his.Iinfo), &rf)
  28513. var psn_type string
  28514. for _, item := range rf {
  28515. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28516. psn_type = item.PsnType
  28517. }
  28518. }
  28519. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28520. 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)
  28521. }
  28522. var dat map[string]interface{}
  28523. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28524. fmt.Println(dat)
  28525. } else {
  28526. fmt.Println(err)
  28527. }
  28528. saveLog(result, request_log, "2206", "预结算")
  28529. userJSONBytes, _ := json.Marshal(dat)
  28530. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28531. utils.ErrorLog("解析失败:%v", err)
  28532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28533. return
  28534. }
  28535. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28536. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28537. if his.IdCardType == 4 {
  28538. psn_info.VerifyNumber = psn_info.VerifyNumber
  28539. cert_no = psn_info.Certno
  28540. } else if his.IdCardType == 2 {
  28541. cert_no = psn_info.Certno
  28542. psn_info.VerifyNumber = psn_info.Certno
  28543. } else {
  28544. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28545. bas := strings.Split(psn_info.CardInfo, "|")
  28546. if his.IdCardType == 1 {
  28547. cert_no = bas[2]
  28548. } else {
  28549. cert_no = bas[1]
  28550. }
  28551. }
  28552. var api string
  28553. var med_type string
  28554. if his.Insutype == "390" {
  28555. if reg_type == 992102 {
  28556. med_type = "992102"
  28557. }
  28558. if reg_type == 140104 {
  28559. med_type = "140104"
  28560. }
  28561. if reg_type == 14 {
  28562. med_type = "140104"
  28563. }
  28564. } else if his.Insutype == "310" {
  28565. if reg_type == 992102 {
  28566. med_type = "992102"
  28567. }
  28568. if reg_type == 14 {
  28569. med_type = "14"
  28570. }
  28571. }
  28572. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28573. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28574. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28575. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28576. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28577. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28578. "&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
  28579. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28580. resp, requestErr := http.Get(api)
  28581. if requestErr != nil {
  28582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28583. return
  28584. }
  28585. body, ioErr := ioutil.ReadAll(resp.Body)
  28586. if ioErr != nil {
  28587. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28589. return
  28590. }
  28591. var respJSON map[string]interface{}
  28592. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28595. return
  28596. }
  28597. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28598. if status == "0" {
  28599. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28600. c.ServeSuccessJSON(map[string]interface{}{
  28601. "failed_code": -10,
  28602. "msg": err_msg,
  28603. })
  28604. return
  28605. }
  28606. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28607. result, _ := json.Marshal(respJSON)
  28608. fmt.Println("log")
  28609. fmt.Println(string(result))
  28610. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  28611. utils.ErrorLog("解析失败:%v", err)
  28612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28613. return
  28614. }
  28615. res.InfRefmsgid = ahres.InfRefmsgid
  28616. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28617. // 创建对应的Time类型
  28618. t := time.UnixMilli(timestamp)
  28619. // 格式化成指定的日期字符串
  28620. str := t.Format("2006-01-02 15:04:05")
  28621. res.Output.Setlinfo.SetlTime = str
  28622. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28623. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28624. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28625. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28626. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28627. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28628. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28629. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28630. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28631. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  28632. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28633. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28634. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28635. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28636. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28637. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28638. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28639. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28640. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28641. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28642. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28643. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28644. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28645. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28646. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28647. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28648. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28649. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28650. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28651. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28652. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28653. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28654. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28655. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  28656. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28657. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  28658. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  28659. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  28660. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  28661. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28662. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  28663. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28664. //res.Output.Setldetail = ahres.Output.Setldetail
  28665. res.ErrMsg = ahres.ErrMsg
  28666. res.Cainfo = ahres.Cainfo
  28667. res.WarnMsg = ahres.WarnMsg
  28668. res.Infcode = ahres.Infcode
  28669. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28670. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28671. if his.IdCardType == 4 {
  28672. psn_info.VerifyNumber = psn_info.VerifyNumber
  28673. cert_no = psn_info.Certno
  28674. } else if his.IdCardType == 2 {
  28675. cert_no = psn_info.Certno
  28676. psn_info.VerifyNumber = psn_info.Certno
  28677. } else {
  28678. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28679. bas := strings.Split(psn_info.CardInfo, "|")
  28680. if his.IdCardType == 1 {
  28681. cert_no = bas[2]
  28682. } else {
  28683. cert_no = bas[1]
  28684. }
  28685. }
  28686. var api string
  28687. var med_type string
  28688. if his.Insutype == "390" {
  28689. if reg_type == 992102 {
  28690. med_type = "992102"
  28691. }
  28692. if reg_type == 140104 {
  28693. med_type = "140104"
  28694. }
  28695. if reg_type == 14 {
  28696. med_type = "140104"
  28697. }
  28698. } else if his.Insutype == "310" {
  28699. if reg_type == 992102 {
  28700. med_type = "992102"
  28701. }
  28702. if reg_type == 14 {
  28703. med_type = "14"
  28704. }
  28705. }
  28706. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28707. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28708. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28709. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28710. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28711. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28712. "&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
  28713. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28714. resp, requestErr := http.Get(api)
  28715. if requestErr != nil {
  28716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28717. return
  28718. }
  28719. body, ioErr := ioutil.ReadAll(resp.Body)
  28720. if ioErr != nil {
  28721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28723. return
  28724. }
  28725. var respJSON map[string]interface{}
  28726. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28729. return
  28730. }
  28731. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28732. if status == "0" {
  28733. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28734. c.ServeSuccessJSON(map[string]interface{}{
  28735. "failed_code": -10,
  28736. "msg": err_msg,
  28737. })
  28738. return
  28739. }
  28740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28741. result, _ := json.Marshal(respJSON)
  28742. fmt.Println("log")
  28743. fmt.Println(string(result))
  28744. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  28745. utils.ErrorLog("解析失败:%v", err)
  28746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28747. return
  28748. }
  28749. res.InfRefmsgid = ahres.InfRefmsgid
  28750. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28751. // 创建对应的Time类型
  28752. t := time.UnixMilli(timestamp)
  28753. // 格式化成指定的日期字符串
  28754. str := t.Format("2006-01-02 15:04:05")
  28755. res.Output.Setlinfo.SetlTime = str
  28756. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28757. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28758. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28759. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28760. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28761. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28762. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28763. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28764. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28765. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  28766. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28767. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28768. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28769. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28770. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28771. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28772. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28773. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28774. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28775. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28776. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28777. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28778. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28779. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28780. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28781. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28782. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28783. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28784. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28785. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28786. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28787. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28788. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28789. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  28790. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28791. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  28792. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  28793. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  28794. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  28795. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28796. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  28797. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28798. //res.Output.Setldetail = ahres.Output.Setldetail
  28799. res.ErrMsg = ahres.ErrMsg
  28800. res.Cainfo = ahres.Cainfo
  28801. res.WarnMsg = ahres.WarnMsg
  28802. res.Infcode = ahres.Infcode
  28803. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28804. var result string
  28805. var request_log string
  28806. if his.IdCardType == 2 {
  28807. 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")
  28808. } else if his.IdCardType == 1 {
  28809. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28810. bas := strings.Split(psn_info.CardInfo, "|")
  28811. basNumber := bas[2]
  28812. card_sn := bas[3]
  28813. 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")
  28814. } else {
  28815. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28816. 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")
  28817. }
  28818. var dat map[string]interface{}
  28819. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28820. fmt.Println(dat)
  28821. } else {
  28822. fmt.Println(err)
  28823. }
  28824. saveLog(result, request_log, "2206", "预结算")
  28825. userJSONBytes, _ := json.Marshal(dat)
  28826. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28827. utils.ErrorLog("解析失败:%v", err)
  28828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28829. return
  28830. }
  28831. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28832. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28833. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28834. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28835. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28836. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28837. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28838. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  28839. resp, requestErr := http.Get(api)
  28840. if requestErr != nil {
  28841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28842. return
  28843. }
  28844. body, ioErr := ioutil.ReadAll(resp.Body)
  28845. if ioErr != nil {
  28846. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28848. return
  28849. }
  28850. var respJSON map[string]interface{}
  28851. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28852. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28854. return
  28855. }
  28856. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28857. result, _ := json.Marshal(respJSON)
  28858. fmt.Println("log")
  28859. fmt.Println(string(result))
  28860. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28861. utils.ErrorLog("解析失败:%v", err)
  28862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28863. return
  28864. }
  28865. } else {
  28866. if miConfig.MdtrtareaAdmvs == "441202" {
  28867. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  28868. if result3101.Infcode == 0 {
  28869. if len(result3101.Output.Result) > 0 {
  28870. var errMsgs []string
  28871. for _, item := range result3101.Output.Result {
  28872. errMsgs = append(errMsgs, item.VolaCont)
  28873. }
  28874. c.ServeSuccessJSON(map[string]interface{}{
  28875. "failed_code": -10,
  28876. "msg": errMsgs,
  28877. })
  28878. return
  28879. } else {
  28880. var result string
  28881. var request_log string
  28882. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28883. allTotal = fmt.Sprintf("%.2f", total_two)
  28884. if his.IdCardType == 4 {
  28885. 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)
  28886. } else {
  28887. 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)
  28888. }
  28889. var dat map[string]interface{}
  28890. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28891. fmt.Println(dat)
  28892. } else {
  28893. fmt.Println(err)
  28894. }
  28895. saveLog(result, request_log, "2206", "预结算")
  28896. //userJSONBytes, _ := json.Marshal(dat)
  28897. //
  28898. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28899. // utils.ErrorLog("解析失败:%v", err)
  28900. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28901. // return
  28902. //}
  28903. userJSONBytes, _ := json.Marshal(dat)
  28904. if miConfig.Code == "H15049901371" {
  28905. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  28906. utils.ErrorLog("解析失败:%v", err)
  28907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28908. return
  28909. }
  28910. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28911. res.Output = resSeven10265.Output
  28912. res.ErrMsg = resSeven10265.ErrMsg
  28913. res.Cainfo = resSeven10265.Cainfo
  28914. res.WarnMsg = resSeven10265.WarnMsg
  28915. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28916. res.Infcode = infocode
  28917. } else {
  28918. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28919. utils.ErrorLog("解析失败:%v", err)
  28920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28921. return
  28922. }
  28923. }
  28924. }
  28925. } else {
  28926. c.ServeSuccessJSON(map[string]interface{}{
  28927. "failed_code": -10,
  28928. "msg": result3101.ErrMsg,
  28929. })
  28930. return
  28931. }
  28932. } else if miConfig.MdtrtareaAdmvs == "440205" {
  28933. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  28934. if result3101.Infcode == 0 {
  28935. if len(result3101.Output.Result) > 0 {
  28936. var errMsgs []string
  28937. for _, item := range result3101.Output.Result {
  28938. errMsgs = append(errMsgs, item.VolaCont)
  28939. }
  28940. c.ServeSuccessJSON(map[string]interface{}{
  28941. "failed_code": -10,
  28942. "msg": errMsgs,
  28943. })
  28944. return
  28945. } else {
  28946. var result string
  28947. var request_log string
  28948. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28949. allTotal = fmt.Sprintf("%.2f", total_two)
  28950. if his.IdCardType == 4 {
  28951. 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)
  28952. } else {
  28953. 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)
  28954. }
  28955. var dat map[string]interface{}
  28956. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28957. fmt.Println(dat)
  28958. } else {
  28959. fmt.Println(err)
  28960. }
  28961. saveLog(result, request_log, "2206", "预结算")
  28962. //userJSONBytes, _ := json.Marshal(dat)
  28963. //
  28964. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28965. // utils.ErrorLog("解析失败:%v", err)
  28966. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28967. // return
  28968. //}
  28969. userJSONBytes, _ := json.Marshal(dat)
  28970. if miConfig.Code == "H15049901371" {
  28971. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  28972. utils.ErrorLog("解析失败:%v", err)
  28973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28974. return
  28975. }
  28976. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28977. res.Output = resSeven10265.Output
  28978. res.ErrMsg = resSeven10265.ErrMsg
  28979. res.Cainfo = resSeven10265.Cainfo
  28980. res.WarnMsg = resSeven10265.WarnMsg
  28981. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28982. res.Infcode = infocode
  28983. } else {
  28984. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28985. utils.ErrorLog("解析失败:%v", err)
  28986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28987. return
  28988. }
  28989. }
  28990. }
  28991. } else {
  28992. c.ServeSuccessJSON(map[string]interface{}{
  28993. "failed_code": -10,
  28994. "msg": result3101.ErrMsg,
  28995. })
  28996. return
  28997. }
  28998. } else {
  28999. var result string
  29000. var request_log string
  29001. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29002. allTotal = fmt.Sprintf("%.2f", total_two)
  29003. if his.IdCardType == 4 {
  29004. 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)
  29005. } else {
  29006. 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)
  29007. }
  29008. var dat map[string]interface{}
  29009. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29010. fmt.Println(dat)
  29011. } else {
  29012. fmt.Println(err)
  29013. }
  29014. saveLog(result, request_log, "2206", "预结算")
  29015. //userJSONBytes, _ := json.Marshal(dat)
  29016. //
  29017. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29018. // utils.ErrorLog("解析失败:%v", err)
  29019. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29020. // return
  29021. //}
  29022. userJSONBytes, _ := json.Marshal(dat)
  29023. if miConfig.Code == "H15049901371" {
  29024. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  29025. utils.ErrorLog("解析失败:%v", err)
  29026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29027. return
  29028. }
  29029. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29030. res.Output = resSeven10265.Output
  29031. res.ErrMsg = resSeven10265.ErrMsg
  29032. res.Cainfo = resSeven10265.Cainfo
  29033. res.WarnMsg = resSeven10265.WarnMsg
  29034. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29035. res.Infcode = infocode
  29036. } else {
  29037. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29038. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  29039. utils.ErrorLog("解析失败:%v", err)
  29040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29041. return
  29042. }
  29043. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  29044. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  29045. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  29046. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29047. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  29048. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  29049. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  29050. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29051. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  29052. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29053. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29054. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29055. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29056. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29057. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29058. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  29059. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  29060. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  29061. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  29062. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  29063. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29064. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  29065. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  29066. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  29067. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  29068. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  29069. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  29070. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  29071. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  29072. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29073. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  29074. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  29075. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  29076. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29077. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29078. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29079. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29080. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  29081. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29082. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  29083. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  29084. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  29085. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  29086. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  29087. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  29088. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  29089. res.ErrMsg = gzresSeven10265Two.ErrMsg
  29090. res.Cainfo = gzresSeven10265Two.Cainfo
  29091. res.WarnMsg = gzresSeven10265Two.WarnMsg
  29092. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29093. //res.Infcode = infocode
  29094. } else {
  29095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29096. utils.ErrorLog("解析失败:%v", err)
  29097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29098. return
  29099. }
  29100. }
  29101. }
  29102. }
  29103. }
  29104. utils.ErrorLog("解析失败:%v", res.Infcode)
  29105. if res.Infcode == -1 {
  29106. errlog := &models.HisOrderError{
  29107. UserOrgId: adminUser.CurrentOrgId,
  29108. Ctime: time.Now().Unix(),
  29109. Mtime: time.Now().Unix(),
  29110. Number: chrg_bchno,
  29111. ErrMsg: res.ErrMsg,
  29112. Status: 1,
  29113. PatientId: id,
  29114. RecordTime: recordDateTime,
  29115. Stage: 20,
  29116. }
  29117. service.CreateErrMsgLog(errlog)
  29118. c.ServeSuccessJSON(map[string]interface{}{
  29119. "failed_code": -10,
  29120. "msg": res.ErrMsg,
  29121. })
  29122. return
  29123. }
  29124. if res.Infcode != 0 {
  29125. errlog := &models.HisOrderError{
  29126. UserOrgId: adminUser.CurrentOrgId,
  29127. Ctime: time.Now().Unix(),
  29128. Mtime: time.Now().Unix(),
  29129. Number: chrg_bchno,
  29130. ErrMsg: res.ErrMsg,
  29131. Status: 1,
  29132. PatientId: id,
  29133. RecordTime: recordDateTime,
  29134. Stage: 20,
  29135. }
  29136. service.CreateErrMsgLog(errlog)
  29137. c.ServeSuccessJSON(map[string]interface{}{
  29138. "failed_code": -10,
  29139. "msg": res.ErrMsg,
  29140. })
  29141. return
  29142. } else {
  29143. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  29144. order.OrderStatus = 1
  29145. order.IsPre = 1
  29146. order.Status = 1
  29147. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  29148. order.SetlId = res.Output.Setlinfo.SetlID
  29149. order.PsnNo = res.Output.Setlinfo.PsnNo
  29150. order.PsnName = res.Output.Setlinfo.PsnName
  29151. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  29152. order.Certno = res.Output.Setlinfo.Certno
  29153. order.Gend = res.Output.Setlinfo.Gend
  29154. order.Naty = res.Output.Setlinfo.Naty
  29155. order.Age = res.Output.Setlinfo.Age
  29156. order.Insutype = res.Output.Setlinfo.Insutype
  29157. order.PsnType = res.Output.Setlinfo.PsnType
  29158. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  29159. order.SetlTime = res.Output.Setlinfo.SetlTime
  29160. order.AcctUsedFlag = acct_used_flag
  29161. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  29162. if res.Output.Setlinfo.MedType == "140101" {
  29163. order.MedType = "14"
  29164. } else {
  29165. if res.Output.Setlinfo.MedType == "110104" {
  29166. order.MedType = "11"
  29167. } else {
  29168. order.MedType = res.Output.Setlinfo.MedType
  29169. }
  29170. }
  29171. if res.Output.Setlinfo.MedType == "992102" {
  29172. order.MedType = "992102"
  29173. }
  29174. if res.Output.Setlinfo.MedType == "140104" {
  29175. order.MedType = "140104"
  29176. }
  29177. if res.Output.Setlinfo.MedType == "14" {
  29178. order.MedType = "14"
  29179. }
  29180. if reg_type == 1112 {
  29181. order.MedType = "1112"
  29182. }
  29183. if reg_type == 1111 {
  29184. order.MedType = "1111"
  29185. }
  29186. order.ClrType = res.Output.Setlinfo.ClrType
  29187. if adminUser.CurrentOrgId == 10480 {
  29188. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29189. order.ClrType = "11"
  29190. } else {
  29191. order.ClrType = "9903"
  29192. }
  29193. }
  29194. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  29195. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  29196. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  29197. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  29198. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  29199. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  29200. order.HifpPay = res.Output.Setlinfo.HifpPay
  29201. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  29202. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  29203. order.HifesPay = res.Output.Setlinfo.HifesPay
  29204. order.HifobPay = res.Output.Setlinfo.HifobPay
  29205. order.MafPay = res.Output.Setlinfo.MafPay
  29206. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  29207. order.OthPay = res.Output.Setlinfo.OthPay
  29208. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  29209. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  29210. order.AcctPay = res.Output.Setlinfo.AcctPay
  29211. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  29212. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  29213. order.Balc = res.Output.Setlinfo.Balc
  29214. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  29215. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  29216. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  29217. order.ClrWay = res.Output.Setlinfo.ClrWay
  29218. order.Creator = order.Creator
  29219. order.Modify = roles.AdminUserId
  29220. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  29221. //detailStr := string(setlDetail)
  29222. //order.SetlDetail = detailStr
  29223. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  29224. err = service.UpDateOrder(order)
  29225. if err == nil {
  29226. c.ServeSuccessJSON(map[string]interface{}{
  29227. "msg": "预结算成功",
  29228. })
  29229. } else {
  29230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  29231. return
  29232. }
  29233. }
  29234. } else {
  29235. adminUser := c.GetAdminUserInfo()
  29236. errlog := &models.HisOrderError{
  29237. UserOrgId: adminUser.CurrentOrgId,
  29238. Ctime: time.Now().Unix(),
  29239. Mtime: time.Now().Unix(),
  29240. ErrMsg: res.ErrMsg,
  29241. Status: 1,
  29242. PatientId: id,
  29243. RecordTime: recordDateTime,
  29244. Stage: 4,
  29245. }
  29246. service.CreateErrMsgLog(errlog)
  29247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  29248. return
  29249. }
  29250. } else {
  29251. if miConfig.MdtrtareaAdmvs == "150499" {
  29252. order := &models.HisOrder{
  29253. UserOrgId: adminUser.CurrentOrgId,
  29254. HisPatientId: his.ID,
  29255. PatientId: his.PatientId,
  29256. SettleAccountsDate: recordDateTime,
  29257. Ctime: time.Now().Unix(),
  29258. Mtime: time.Now().Unix(),
  29259. MdtrtId: his.Number,
  29260. PsnNo: his.PsnNo,
  29261. MedType: strconv.FormatInt(reg_type, 10),
  29262. Status: 1,
  29263. Number: chrg_bchno,
  29264. Infcode: res.Infcode,
  29265. WarnMsg: res.WarnMsg,
  29266. Cainfo: res.Cainfo,
  29267. ErrMsg: res.ErrMsg,
  29268. RespondTime: res.RefmsgTime,
  29269. InfRefmsgid: res.InfRefmsgid,
  29270. OrderStatus: 1,
  29271. IsMedicineInsurance: 1,
  29272. SettleType: settle_accounts_type,
  29273. SettleStartTime: start_time,
  29274. SettleEndTime: end_time,
  29275. Creator: roles.AdminUserId,
  29276. Modify: roles.AdminUserId,
  29277. PType: 2,
  29278. Diagnosis: diagnosis_id,
  29279. }
  29280. err = service.CreateOrder(order)
  29281. if err != nil {
  29282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29283. return
  29284. }
  29285. }
  29286. adminUser := c.GetAdminUserInfo()
  29287. errlog := &models.HisOrderError{
  29288. UserOrgId: adminUser.CurrentOrgId,
  29289. Ctime: time.Now().Unix(),
  29290. Mtime: time.Now().Unix(),
  29291. ErrMsg: res.ErrMsg,
  29292. Status: 1,
  29293. PatientId: id,
  29294. RecordTime: recordDateTime,
  29295. Stage: 4,
  29296. }
  29297. service.CreateErrMsgLog(errlog)
  29298. c.ServeSuccessJSON(map[string]interface{}{
  29299. "failed_code": -10,
  29300. "msg": res.ErrMsg,
  29301. })
  29302. return
  29303. }
  29304. }
  29305. }
  29306. }
  29307. // 退款
  29308. func (c *HisApiController) Refund() {
  29309. order_id, _ := c.GetInt64("order_id")
  29310. admin_user_id, _ := c.GetInt64("admin_user_id")
  29311. adminUser := c.GetAdminUserInfo()
  29312. var order models.HisOrder
  29313. order, _ = service.GetHisOrderByID(order_id)
  29314. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  29315. if fapiao.ID > 0 {
  29316. c.ServeSuccessJSON(map[string]interface{}{
  29317. "failed_code": -10,
  29318. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  29319. })
  29320. return
  29321. }
  29322. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29323. if order.ID == 0 {
  29324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29325. return
  29326. }
  29327. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  29328. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29329. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29330. if config.IsOpen == 1 { //对接了医保,走医保流程
  29331. var res ResultSixteen
  29332. var ahres ResultSevenAH
  29333. var resSixteen10265 ResultSixteen10265
  29334. var resSixteen10265Two ResultSixteen10265Two
  29335. var gz ResultgzSixteen10265Two
  29336. var src_resquest string
  29337. var result string
  29338. if miConfig.MdtrtareaAdmvs == "421300" {
  29339. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  29340. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29341. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29342. resp3, requestErr3 := http.Get(api3)
  29343. if requestErr3 != nil {
  29344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29345. return
  29346. }
  29347. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29348. if ioErr3 != nil {
  29349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29351. return
  29352. }
  29353. var respJSON3 map[string]interface{}
  29354. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29357. return
  29358. }
  29359. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29360. userJSONBytes3, _ := json.Marshal(respJSON3)
  29361. fmt.Println("log")
  29362. fmt.Println(string(userJSONBytes3))
  29363. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  29364. utils.ErrorLog("解析失败:%v", err)
  29365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29366. return
  29367. }
  29368. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29369. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  29370. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29371. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29372. resp3, requestErr3 := http.Get(api3)
  29373. if requestErr3 != nil {
  29374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29375. return
  29376. }
  29377. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29378. if ioErr3 != nil {
  29379. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29381. return
  29382. }
  29383. var respJSON3 map[string]interface{}
  29384. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29387. return
  29388. }
  29389. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29390. userJSONBytes3, _ := json.Marshal(respJSON3)
  29391. fmt.Println("log")
  29392. fmt.Println(string(userJSONBytes3))
  29393. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  29394. utils.ErrorLog("解析失败:%v", err)
  29395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29396. return
  29397. }
  29398. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29399. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  29400. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29401. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29402. resp3, requestErr3 := http.Get(api3)
  29403. if requestErr3 != nil {
  29404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29405. return
  29406. }
  29407. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29408. if ioErr3 != nil {
  29409. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29411. return
  29412. }
  29413. var respJSON3 map[string]interface{}
  29414. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29417. return
  29418. }
  29419. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29420. userJSONBytes3, _ := json.Marshal(respJSON3)
  29421. fmt.Println("log")
  29422. fmt.Println(string(userJSONBytes3))
  29423. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  29424. utils.ErrorLog("解析失败:%v", err)
  29425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29426. return
  29427. }
  29428. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29429. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  29430. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29431. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29432. resp3, requestErr3 := http.Get(api3)
  29433. if requestErr3 != nil {
  29434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29435. return
  29436. }
  29437. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29438. if ioErr3 != nil {
  29439. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29441. return
  29442. }
  29443. var respJSON3 map[string]interface{}
  29444. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29447. return
  29448. }
  29449. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29450. userJSONBytes3, _ := json.Marshal(respJSON3)
  29451. fmt.Println("log")
  29452. fmt.Println(string(userJSONBytes3))
  29453. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  29454. utils.ErrorLog("解析失败:%v", err)
  29455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29456. return
  29457. }
  29458. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29459. var api3 string
  29460. if miConfig.MdtrtareaAdmvs == "320921" {
  29461. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  29462. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29463. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29464. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29465. } else {
  29466. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29467. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  29468. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29469. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29470. }
  29471. resp3, requestErr3 := http.Get(api3)
  29472. if requestErr3 != nil {
  29473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29474. return
  29475. }
  29476. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29477. if ioErr3 != nil {
  29478. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29480. return
  29481. }
  29482. var respJSON3 map[string]interface{}
  29483. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29486. return
  29487. }
  29488. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29489. userJSONBytes3, _ := json.Marshal(respJSON3)
  29490. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  29491. utils.ErrorLog("解析失败:%v", err)
  29492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29493. return
  29494. }
  29495. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  29496. res.Output = resSixteen10265.Output
  29497. res.ErrMsg = resSixteen10265.ErrMsg
  29498. res.Cainfo = resSixteen10265.Cainfo
  29499. res.WarnMsg = resSixteen10265.WarnMsg
  29500. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  29501. res.Infcode = infocode
  29502. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29503. var api3 string
  29504. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  29505. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29506. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29507. resp3, requestErr3 := http.Get(api3)
  29508. if requestErr3 != nil {
  29509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29510. return
  29511. }
  29512. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29513. if ioErr3 != nil {
  29514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29516. return
  29517. }
  29518. var respJSON3 map[string]interface{}
  29519. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29522. return
  29523. }
  29524. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29525. userJSONBytes3, _ := json.Marshal(respJSON3)
  29526. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  29527. utils.ErrorLog("解析失败:%v", err)
  29528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29529. return
  29530. }
  29531. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  29532. res.Output = resSixteen10265.Output
  29533. res.ErrMsg = resSixteen10265.ErrMsg
  29534. res.Cainfo = resSixteen10265.Cainfo
  29535. res.WarnMsg = resSixteen10265.WarnMsg
  29536. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  29537. res.Infcode = infocode
  29538. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29539. 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)
  29540. var dat map[string]interface{}
  29541. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29542. fmt.Println(dat)
  29543. } else {
  29544. fmt.Println(err)
  29545. }
  29546. saveLog(result, src_resquest, "2208", "退费")
  29547. userJSONBytes, _ := json.Marshal(dat)
  29548. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29549. utils.ErrorLog("解析失败:%v", err)
  29550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29551. return
  29552. }
  29553. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29554. 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, "")
  29555. var dat map[string]interface{}
  29556. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29557. fmt.Println(dat)
  29558. } else {
  29559. fmt.Println(err)
  29560. }
  29561. saveLog(result, src_resquest, "2208", "退费")
  29562. userJSONBytes, _ := json.Marshal(dat)
  29563. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29564. utils.ErrorLog("解析失败:%v", err)
  29565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29566. return
  29567. }
  29568. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29569. var api3 string
  29570. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  29571. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29572. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29573. resp3, requestErr3 := http.Get(api3)
  29574. if requestErr3 != nil {
  29575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29576. return
  29577. }
  29578. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29579. if ioErr3 != nil {
  29580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29582. return
  29583. }
  29584. var respJSON3 map[string]interface{}
  29585. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29588. return
  29589. }
  29590. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  29591. if status == "0" {
  29592. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  29593. c.ServeSuccessJSON(map[string]interface{}{
  29594. "failed_code": -10,
  29595. "msg": err_msg,
  29596. })
  29597. return
  29598. }
  29599. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29600. userJSONBytes3, _ := json.Marshal(respJSON3)
  29601. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  29602. // utils.ErrorLog("解析失败:%v", err)
  29603. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29604. // return
  29605. //}
  29606. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  29607. utils.ErrorLog("解析失败:%v", err)
  29608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29609. return
  29610. }
  29611. res.InfRefmsgid = ahres.InfRefmsgid
  29612. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  29613. // 创建对应的Time类型
  29614. t := time.UnixMilli(timestamp)
  29615. // 格式化成指定的日期字符串
  29616. str := t.Format("2006-01-02 15:04:05")
  29617. res.Output.Setlinfo.SetlTime = str
  29618. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29619. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29620. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29621. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29622. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29623. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29624. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29625. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29626. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29627. //
  29628. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  29629. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29630. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29631. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29632. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29633. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29634. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29635. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29636. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29637. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29638. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29639. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29640. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29641. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29642. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29643. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29644. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29645. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29646. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29647. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29648. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29649. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29650. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29651. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29652. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29653. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29654. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29655. //res.Output.Setldetail = ahres.Output.Setldetail
  29656. res.ErrMsg = ahres.ErrMsg
  29657. res.Cainfo = ahres.Cainfo
  29658. res.WarnMsg = ahres.WarnMsg
  29659. res.Infcode = ahres.Infcode
  29660. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29661. var api3 string
  29662. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  29663. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29664. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29665. resp3, requestErr3 := http.Get(api3)
  29666. if requestErr3 != nil {
  29667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29668. return
  29669. }
  29670. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29671. if ioErr3 != nil {
  29672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29674. return
  29675. }
  29676. var respJSON3 map[string]interface{}
  29677. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29680. return
  29681. }
  29682. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  29683. if status == "0" {
  29684. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  29685. c.ServeSuccessJSON(map[string]interface{}{
  29686. "failed_code": -10,
  29687. "msg": err_msg,
  29688. })
  29689. return
  29690. }
  29691. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29692. userJSONBytes3, _ := json.Marshal(respJSON3)
  29693. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  29694. // utils.ErrorLog("解析失败:%v", err)
  29695. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29696. // return
  29697. //}
  29698. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  29699. utils.ErrorLog("解析失败:%v", err)
  29700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29701. return
  29702. }
  29703. res.InfRefmsgid = ahres.InfRefmsgid
  29704. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  29705. // 创建对应的Time类型
  29706. t := time.UnixMilli(timestamp)
  29707. // 格式化成指定的日期字符串
  29708. str := t.Format("2006-01-02 15:04:05")
  29709. res.Output.Setlinfo.SetlTime = str
  29710. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29711. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29712. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29713. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29714. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29715. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29716. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29717. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29718. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29719. //
  29720. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  29721. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29722. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29723. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29724. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29725. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29726. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29727. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29728. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29729. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29730. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29731. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29732. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29733. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29734. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29735. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29736. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29737. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29738. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29739. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29740. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29741. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29742. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29743. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29744. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29745. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29746. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29747. //res.Output.Setldetail = ahres.Output.Setldetail
  29748. res.ErrMsg = ahres.ErrMsg
  29749. res.Cainfo = ahres.Cainfo
  29750. res.WarnMsg = ahres.WarnMsg
  29751. res.Infcode = ahres.Infcode
  29752. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29753. 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, "")
  29754. var dat map[string]interface{}
  29755. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29756. fmt.Println(dat)
  29757. } else {
  29758. fmt.Println(err)
  29759. }
  29760. saveLog(result, src_resquest, "2208", "退费")
  29761. userJSONBytes, _ := json.Marshal(dat)
  29762. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29763. utils.ErrorLog("解析失败:%v", err)
  29764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29765. return
  29766. }
  29767. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29768. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  29769. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29770. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29771. resp3, requestErr3 := http.Get(api3)
  29772. if requestErr3 != nil {
  29773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29774. return
  29775. }
  29776. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29777. if ioErr3 != nil {
  29778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29780. return
  29781. }
  29782. var respJSON3 map[string]interface{}
  29783. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29786. return
  29787. }
  29788. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29789. userJSONBytes3, _ := json.Marshal(respJSON3)
  29790. fmt.Println("log")
  29791. fmt.Println(string(userJSONBytes3))
  29792. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  29793. utils.ErrorLog("解析失败:%v", err)
  29794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29795. return
  29796. }
  29797. } else {
  29798. if miConfig.Code == "H15049901371" {
  29799. 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)
  29800. var dat map[string]interface{}
  29801. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29802. fmt.Println(dat)
  29803. } else {
  29804. fmt.Println(err)
  29805. }
  29806. saveLog(result, src_resquest, "2208", "退费")
  29807. if strings.Contains(result, "Post") {
  29808. res.Infcode = -1
  29809. res.ErrMsg = result
  29810. }
  29811. userJSONBytes, _ := json.Marshal(dat)
  29812. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  29813. utils.ErrorLog("解析失败:%v", err)
  29814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29815. return
  29816. }
  29817. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  29818. res.Output = resSixteen10265.Output
  29819. res.ErrMsg = resSixteen10265.ErrMsg
  29820. res.Cainfo = resSixteen10265.Cainfo
  29821. res.WarnMsg = resSixteen10265.WarnMsg
  29822. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  29823. res.Infcode = infocode
  29824. } else {
  29825. 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)
  29826. var dat map[string]interface{}
  29827. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29828. fmt.Println(dat)
  29829. } else {
  29830. fmt.Println(err)
  29831. }
  29832. saveLog(result, src_resquest, "2208", "退费")
  29833. userJSONBytes, _ := json.Marshal(dat)
  29834. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29835. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  29836. utils.ErrorLog("解析失败:%v", err)
  29837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29838. return
  29839. }
  29840. res.Infcode = gz.Infcode
  29841. } else {
  29842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29843. utils.ErrorLog("解析失败:%v", err)
  29844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29845. return
  29846. }
  29847. }
  29848. if strings.Contains(result, "Post") {
  29849. res.Infcode = -1
  29850. res.ErrMsg = result
  29851. }
  29852. }
  29853. }
  29854. if res.Infcode == -1 {
  29855. c.ServeSuccessJSON(map[string]interface{}{
  29856. "failed_code": -10,
  29857. "msg": res.ErrMsg,
  29858. })
  29859. return
  29860. }
  29861. if res.Infcode != -1 {
  29862. var res2 ResultSix
  29863. var resSix10265 ResultSix10265
  29864. if miConfig.MdtrtareaAdmvs == "421300" {
  29865. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  29866. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29867. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29868. resp3, requestErr3 := http.Get(api3)
  29869. if requestErr3 != nil {
  29870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29871. return
  29872. }
  29873. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29874. if ioErr3 != nil {
  29875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29877. return
  29878. }
  29879. var respJSON3 map[string]interface{}
  29880. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29883. return
  29884. }
  29885. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29886. userJSONBytes3, _ := json.Marshal(respJSON3)
  29887. fmt.Println("log")
  29888. fmt.Println(string(userJSONBytes3))
  29889. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29890. utils.ErrorLog("解析失败:%v", err)
  29891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29892. return
  29893. }
  29894. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29895. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  29896. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29897. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29898. resp3, requestErr3 := http.Get(api3)
  29899. if requestErr3 != nil {
  29900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29901. return
  29902. }
  29903. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29904. if ioErr3 != nil {
  29905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29907. return
  29908. }
  29909. var respJSON3 map[string]interface{}
  29910. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29913. return
  29914. }
  29915. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29916. userJSONBytes3, _ := json.Marshal(respJSON3)
  29917. fmt.Println("log")
  29918. fmt.Println(string(userJSONBytes3))
  29919. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29920. utils.ErrorLog("解析失败:%v", err)
  29921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29922. return
  29923. }
  29924. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29925. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  29926. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29927. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29928. resp3, requestErr3 := http.Get(api3)
  29929. if requestErr3 != nil {
  29930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29931. return
  29932. }
  29933. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29934. if ioErr3 != nil {
  29935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29937. return
  29938. }
  29939. var respJSON3 map[string]interface{}
  29940. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29943. return
  29944. }
  29945. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29946. userJSONBytes3, _ := json.Marshal(respJSON3)
  29947. fmt.Println("log")
  29948. fmt.Println(string(userJSONBytes3))
  29949. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29950. utils.ErrorLog("解析失败:%v", err)
  29951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29952. return
  29953. }
  29954. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29955. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  29956. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29957. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29958. resp3, requestErr3 := http.Get(api3)
  29959. if requestErr3 != nil {
  29960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29961. return
  29962. }
  29963. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29964. if ioErr3 != nil {
  29965. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29967. return
  29968. }
  29969. var respJSON3 map[string]interface{}
  29970. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29973. return
  29974. }
  29975. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29976. userJSONBytes3, _ := json.Marshal(respJSON3)
  29977. fmt.Println("log")
  29978. fmt.Println(string(userJSONBytes3))
  29979. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29980. utils.ErrorLog("解析失败:%v", err)
  29981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29982. return
  29983. }
  29984. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29985. var api3 string
  29986. if miConfig.MdtrtareaAdmvs == "320921" {
  29987. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  29988. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29989. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29990. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29991. } else {
  29992. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29993. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  29994. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29995. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29996. }
  29997. resp3, requestErr3 := http.Get(api3)
  29998. if requestErr3 != nil {
  29999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30000. return
  30001. }
  30002. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30003. if ioErr3 != nil {
  30004. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30006. return
  30007. }
  30008. var respJSON3 map[string]interface{}
  30009. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30010. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30012. return
  30013. }
  30014. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30015. userJSONBytes3, _ := json.Marshal(respJSON3)
  30016. fmt.Println("log")
  30017. fmt.Println(string(userJSONBytes3))
  30018. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  30019. utils.ErrorLog("解析失败:%v", err)
  30020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30021. return
  30022. }
  30023. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30024. res2.Output = resSix10265.Output
  30025. res2.ErrMsg = resSix10265.ErrMsg
  30026. res2.Cainfo = resSix10265.Cainfo
  30027. res2.WarnMsg = resSix10265.WarnMsg
  30028. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30029. res2.Infcode = infocode
  30030. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30031. var api3 string
  30032. new_chrg_bchno := order.Number
  30033. if adminUser.CurrentOrgId == 10265 {
  30034. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  30035. new_chrg_bchno = "0000"
  30036. }
  30037. }
  30038. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  30039. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30040. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30041. resp3, requestErr3 := http.Get(api3)
  30042. if requestErr3 != nil {
  30043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30044. return
  30045. }
  30046. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30047. if ioErr3 != nil {
  30048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30050. return
  30051. }
  30052. var respJSON3 map[string]interface{}
  30053. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30056. return
  30057. }
  30058. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30059. userJSONBytes3, _ := json.Marshal(respJSON3)
  30060. fmt.Println("log")
  30061. fmt.Println(string(userJSONBytes3))
  30062. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  30063. utils.ErrorLog("解析失败:%v", err)
  30064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30065. return
  30066. }
  30067. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30068. res2.Output = resSix10265.Output
  30069. res2.ErrMsg = resSix10265.ErrMsg
  30070. res2.Cainfo = resSix10265.Cainfo
  30071. res2.WarnMsg = resSix10265.WarnMsg
  30072. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30073. res2.Infcode = infocode
  30074. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30075. 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)
  30076. var dat map[string]interface{}
  30077. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  30078. fmt.Println(dat)
  30079. } else {
  30080. fmt.Println(err)
  30081. }
  30082. saveLog(result2, src_request, "2205", "撤销明细")
  30083. userJSONBytes, _ := json.Marshal(dat)
  30084. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30085. utils.ErrorLog("解析失败:%v", err)
  30086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30087. return
  30088. }
  30089. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30090. 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, "")
  30091. var dat map[string]interface{}
  30092. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  30093. fmt.Println(dat)
  30094. } else {
  30095. fmt.Println(err)
  30096. }
  30097. saveLog(result2, src_request, "2205", "撤销明细")
  30098. userJSONBytes, _ := json.Marshal(dat)
  30099. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30100. utils.ErrorLog("解析失败:%v", err)
  30101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30102. return
  30103. }
  30104. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30105. var api3 string
  30106. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  30107. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30108. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30109. resp3, requestErr3 := http.Get(api3)
  30110. if requestErr3 != nil {
  30111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30112. return
  30113. }
  30114. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30115. if ioErr3 != nil {
  30116. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30118. return
  30119. }
  30120. var respJSON3 map[string]interface{}
  30121. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30124. return
  30125. }
  30126. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  30127. if status == "0" {
  30128. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  30129. c.ServeSuccessJSON(map[string]interface{}{
  30130. "failed_code": -10,
  30131. "msg": err_msg,
  30132. })
  30133. return
  30134. }
  30135. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30136. userJSONBytes3, _ := json.Marshal(respJSON3)
  30137. fmt.Println("log")
  30138. fmt.Println(string(userJSONBytes3))
  30139. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30140. utils.ErrorLog("解析失败:%v", err)
  30141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30142. return
  30143. }
  30144. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30145. 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, "")
  30146. var dat map[string]interface{}
  30147. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  30148. fmt.Println(dat)
  30149. } else {
  30150. fmt.Println(err)
  30151. }
  30152. saveLog(result2, src_request, "2205", "撤销明细")
  30153. userJSONBytes, _ := json.Marshal(dat)
  30154. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30155. utils.ErrorLog("解析失败:%v", err)
  30156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30157. return
  30158. }
  30159. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30160. var api3 string
  30161. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  30162. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30163. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30164. resp3, requestErr3 := http.Get(api3)
  30165. if requestErr3 != nil {
  30166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30167. return
  30168. }
  30169. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30170. if ioErr3 != nil {
  30171. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30173. return
  30174. }
  30175. var respJSON3 map[string]interface{}
  30176. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30177. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30179. return
  30180. }
  30181. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  30182. if status == "0" {
  30183. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  30184. c.ServeSuccessJSON(map[string]interface{}{
  30185. "failed_code": -10,
  30186. "msg": err_msg,
  30187. })
  30188. return
  30189. }
  30190. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30191. userJSONBytes3, _ := json.Marshal(respJSON3)
  30192. fmt.Println("log")
  30193. fmt.Println(string(userJSONBytes3))
  30194. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30195. utils.ErrorLog("解析失败:%v", err)
  30196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30197. return
  30198. }
  30199. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30200. 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, "")
  30201. var dat map[string]interface{}
  30202. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  30203. fmt.Println(dat)
  30204. } else {
  30205. fmt.Println(err)
  30206. }
  30207. saveLog(result2, src_request, "2205", "撤销明细")
  30208. userJSONBytes, _ := json.Marshal(dat)
  30209. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30210. utils.ErrorLog("解析失败:%v", err)
  30211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30212. return
  30213. }
  30214. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30215. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  30216. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30217. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30218. resp3, requestErr3 := http.Get(api3)
  30219. if requestErr3 != nil {
  30220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30221. return
  30222. }
  30223. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30224. if ioErr3 != nil {
  30225. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30227. return
  30228. }
  30229. var respJSON3 map[string]interface{}
  30230. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30231. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30233. return
  30234. }
  30235. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30236. userJSONBytes3, _ := json.Marshal(respJSON3)
  30237. fmt.Println("log")
  30238. fmt.Println(string(userJSONBytes3))
  30239. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30240. utils.ErrorLog("解析失败:%v", err)
  30241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30242. return
  30243. }
  30244. } else {
  30245. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30246. res2.Infcode = 0
  30247. } else {
  30248. 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)
  30249. var dat map[string]interface{}
  30250. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  30251. fmt.Println(dat)
  30252. } else {
  30253. fmt.Println(err)
  30254. }
  30255. saveLog(result2, src_request, "2205", "撤销明细")
  30256. userJSONBytes, _ := json.Marshal(dat)
  30257. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30258. utils.ErrorLog("解析失败:%v", err)
  30259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30260. return
  30261. }
  30262. }
  30263. }
  30264. if res2.Infcode == -1 {
  30265. c.ServeSuccessJSON(map[string]interface{}{
  30266. "failed_code": -10,
  30267. "msg": res2.ErrMsg,
  30268. })
  30269. return
  30270. }
  30271. if res2.Infcode == 0 {
  30272. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  30273. if err == nil {
  30274. //当押金不为零时产生退费记录
  30275. if order.Decimal != 0 {
  30276. tmp := strconv.FormatInt(order.ID, 10)
  30277. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  30278. if err != nil {
  30279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30280. return
  30281. }
  30282. }
  30283. c.ServeSuccessJSON(map[string]interface{}{
  30284. "msg": "退费成功",
  30285. })
  30286. } else {
  30287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30288. return
  30289. }
  30290. } else {
  30291. c.ServeSuccessJSON(map[string]interface{}{
  30292. "failed_code": -10,
  30293. "msg": res2.ErrMsg,
  30294. })
  30295. }
  30296. } else {
  30297. c.ServeSuccessJSON(map[string]interface{}{
  30298. "failed_code": -10,
  30299. "msg": res.ErrMsg,
  30300. })
  30301. }
  30302. }
  30303. }
  30304. func (c *HisApiController) RefundNumber() {
  30305. record_time := c.GetString("record_time")
  30306. //patient_id, _ := c.GetInt64("patient_id")
  30307. admin_user_id, _ := c.GetInt64("admin_user_id")
  30308. his_patient_id, _ := c.GetInt64("id")
  30309. timeLayout := "2006-01-02"
  30310. loc, _ := time.LoadLocation("Local")
  30311. adminUser := c.GetAdminUserInfo()
  30312. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  30313. fmt.Println(err)
  30314. if err != nil {
  30315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30316. return
  30317. }
  30318. recordDateTime := theTime.Unix()
  30319. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  30320. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  30321. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  30322. //order, _ := service.GetHisOrderByID(order_id)
  30323. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30324. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30325. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30326. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  30327. if count > 0 {
  30328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  30329. return
  30330. }
  30331. if config.IsOpen == 1 { //对接了医保,走医保流程
  30332. var res2 ResultSix
  30333. var res3 GZResultSix
  30334. var resSix10265 ResultSix10265
  30335. if miConfig.MdtrtareaAdmvs == "421300" {
  30336. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  30337. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30338. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30339. resp3, requestErr3 := http.Get(api3)
  30340. if requestErr3 != nil {
  30341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30342. return
  30343. }
  30344. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30345. if ioErr3 != nil {
  30346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30348. return
  30349. }
  30350. var respJSON3 map[string]interface{}
  30351. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30354. return
  30355. }
  30356. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30357. userJSONBytes3, _ := json.Marshal(respJSON3)
  30358. fmt.Println("log")
  30359. fmt.Println(string(userJSONBytes3))
  30360. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30361. utils.ErrorLog("解析失败:%v", err)
  30362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30363. return
  30364. }
  30365. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30366. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  30367. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30368. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30369. resp3, requestErr3 := http.Get(api3)
  30370. if requestErr3 != nil {
  30371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30372. return
  30373. }
  30374. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30375. if ioErr3 != nil {
  30376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30378. return
  30379. }
  30380. var respJSON3 map[string]interface{}
  30381. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30384. return
  30385. }
  30386. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30387. userJSONBytes3, _ := json.Marshal(respJSON3)
  30388. fmt.Println("log")
  30389. fmt.Println(string(userJSONBytes3))
  30390. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30391. utils.ErrorLog("解析失败:%v", err)
  30392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30393. return
  30394. }
  30395. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30396. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  30397. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30398. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30399. resp3, requestErr3 := http.Get(api3)
  30400. if requestErr3 != nil {
  30401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30402. return
  30403. }
  30404. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30405. if ioErr3 != nil {
  30406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30408. return
  30409. }
  30410. var respJSON3 map[string]interface{}
  30411. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30414. return
  30415. }
  30416. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30417. userJSONBytes3, _ := json.Marshal(respJSON3)
  30418. fmt.Println("log")
  30419. fmt.Println(string(userJSONBytes3))
  30420. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30421. utils.ErrorLog("解析失败:%v", err)
  30422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30423. return
  30424. }
  30425. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30426. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  30427. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30428. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30429. resp3, requestErr3 := http.Get(api3)
  30430. if requestErr3 != nil {
  30431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30432. return
  30433. }
  30434. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30435. if ioErr3 != nil {
  30436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30438. return
  30439. }
  30440. var respJSON3 map[string]interface{}
  30441. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30444. return
  30445. }
  30446. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30447. userJSONBytes3, _ := json.Marshal(respJSON3)
  30448. fmt.Println("log")
  30449. fmt.Println(string(userJSONBytes3))
  30450. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30451. utils.ErrorLog("解析失败:%v", err)
  30452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30453. return
  30454. }
  30455. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30456. var api3 string
  30457. if miConfig.MdtrtareaAdmvs == "320921" {
  30458. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  30459. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30460. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30461. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30462. } else {
  30463. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30464. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  30465. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30466. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30467. }
  30468. resp3, requestErr3 := http.Get(api3)
  30469. if requestErr3 != nil {
  30470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30471. return
  30472. }
  30473. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30474. if ioErr3 != nil {
  30475. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30477. return
  30478. }
  30479. var respJSON3 map[string]interface{}
  30480. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30481. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30483. return
  30484. }
  30485. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30486. userJSONBytes3, _ := json.Marshal(respJSON3)
  30487. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  30488. utils.ErrorLog("解析失败:%v", err)
  30489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30490. return
  30491. }
  30492. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30493. res2.Output = resSix10265.Output
  30494. res2.ErrMsg = resSix10265.ErrMsg
  30495. res2.Cainfo = resSix10265.Cainfo
  30496. res2.WarnMsg = resSix10265.WarnMsg
  30497. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30498. res2.Infcode = infocode
  30499. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30500. var api3 string
  30501. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  30502. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30503. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30504. resp3, requestErr3 := http.Get(api3)
  30505. if requestErr3 != nil {
  30506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30507. return
  30508. }
  30509. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30510. if ioErr3 != nil {
  30511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30513. return
  30514. }
  30515. var respJSON3 map[string]interface{}
  30516. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30519. return
  30520. }
  30521. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30522. userJSONBytes3, _ := json.Marshal(respJSON3)
  30523. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  30524. utils.ErrorLog("解析失败:%v", err)
  30525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30526. return
  30527. }
  30528. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30529. res2.Output = resSix10265.Output
  30530. res2.ErrMsg = resSix10265.ErrMsg
  30531. res2.Cainfo = resSix10265.Cainfo
  30532. res2.WarnMsg = resSix10265.WarnMsg
  30533. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30534. res2.Infcode = infocode
  30535. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30536. 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)
  30537. var dat map[string]interface{}
  30538. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30539. fmt.Println(dat)
  30540. } else {
  30541. fmt.Println(err)
  30542. }
  30543. saveLog(result, request, "2202", "退号")
  30544. userJSONBytes, _ := json.Marshal(dat)
  30545. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30546. utils.ErrorLog("解析失败:%v", err)
  30547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30548. return
  30549. }
  30550. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30551. 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, "")
  30552. var dat map[string]interface{}
  30553. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30554. fmt.Println(dat)
  30555. } else {
  30556. fmt.Println(err)
  30557. }
  30558. saveLog(result, request, "2202", "退号")
  30559. userJSONBytes, _ := json.Marshal(dat)
  30560. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30561. utils.ErrorLog("解析失败:%v", err)
  30562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30563. return
  30564. }
  30565. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30566. var api3 string
  30567. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  30568. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30569. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30570. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30571. resp3, requestErr3 := http.Get(api3)
  30572. if requestErr3 != nil {
  30573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30574. return
  30575. }
  30576. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30577. if ioErr3 != nil {
  30578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30580. return
  30581. }
  30582. var respJSON3 map[string]interface{}
  30583. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30586. return
  30587. }
  30588. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  30589. if status == "0" {
  30590. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  30591. c.ServeSuccessJSON(map[string]interface{}{
  30592. "failed_code": -10,
  30593. "msg": err_msg,
  30594. })
  30595. return
  30596. }
  30597. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30598. userJSONBytes3, _ := json.Marshal(respJSON3)
  30599. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30600. utils.ErrorLog("解析失败:%v", err)
  30601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30602. return
  30603. }
  30604. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  30605. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30606. var api3 string
  30607. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  30608. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30609. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30610. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30611. resp3, requestErr3 := http.Get(api3)
  30612. if requestErr3 != nil {
  30613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30614. return
  30615. }
  30616. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30617. if ioErr3 != nil {
  30618. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30620. return
  30621. }
  30622. var respJSON3 map[string]interface{}
  30623. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30624. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30626. return
  30627. }
  30628. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  30629. if status == "0" {
  30630. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  30631. c.ServeSuccessJSON(map[string]interface{}{
  30632. "failed_code": -10,
  30633. "msg": err_msg,
  30634. })
  30635. return
  30636. }
  30637. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30638. userJSONBytes3, _ := json.Marshal(respJSON3)
  30639. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30640. utils.ErrorLog("解析失败:%v", err)
  30641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30642. return
  30643. }
  30644. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  30645. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30646. 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, "")
  30647. var dat map[string]interface{}
  30648. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30649. fmt.Println(dat)
  30650. } else {
  30651. fmt.Println(err)
  30652. }
  30653. saveLog(result, request, "2202", "退号")
  30654. userJSONBytes, _ := json.Marshal(dat)
  30655. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30656. utils.ErrorLog("解析失败:%v", err)
  30657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30658. return
  30659. }
  30660. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30661. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  30662. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30663. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  30664. resp3, requestErr3 := http.Get(api3)
  30665. if requestErr3 != nil {
  30666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30667. return
  30668. }
  30669. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30670. if ioErr3 != nil {
  30671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30673. return
  30674. }
  30675. var respJSON3 map[string]interface{}
  30676. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30679. return
  30680. }
  30681. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30682. userJSONBytes3, _ := json.Marshal(respJSON3)
  30683. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30684. utils.ErrorLog("解析失败:%v", err)
  30685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30686. return
  30687. }
  30688. } else {
  30689. var api3 string
  30690. if miConfig.Code == "H15049901371" {
  30691. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  30692. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30693. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30694. } else {
  30695. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  30696. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30697. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  30698. }
  30699. resp3, requestErr3 := http.Get(api3)
  30700. if requestErr3 != nil {
  30701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30702. return
  30703. }
  30704. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30705. if ioErr3 != nil {
  30706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30708. return
  30709. }
  30710. var respJSON3 map[string]interface{}
  30711. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30714. return
  30715. }
  30716. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30717. userJSONBytes3, _ := json.Marshal(respJSON3)
  30718. if miConfig.Code == "H15049901371" {
  30719. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  30720. utils.ErrorLog("解析失败:%v", err)
  30721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30722. return
  30723. }
  30724. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30725. res2.Output = resSix10265.Output
  30726. res2.ErrMsg = resSix10265.ErrMsg
  30727. res2.Cainfo = resSix10265.Cainfo
  30728. res2.WarnMsg = resSix10265.WarnMsg
  30729. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30730. res2.Infcode = infocode
  30731. } else {
  30732. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30733. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  30734. utils.ErrorLog("解析失败:%v", err)
  30735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30736. return
  30737. }
  30738. res2.Infcode = res3.Infcode
  30739. } else {
  30740. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30741. utils.ErrorLog("解析失败:%v", err)
  30742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30743. return
  30744. }
  30745. }
  30746. }
  30747. }
  30748. if res2.Infcode == -1 {
  30749. c.ServeSuccessJSON(map[string]interface{}{
  30750. "failed_code": -10,
  30751. "msg": res2.ErrMsg,
  30752. })
  30753. return
  30754. }
  30755. if res2.Infcode == 0 {
  30756. if err == nil {
  30757. c.ServeSuccessJSON(map[string]interface{}{
  30758. "msg": "退号成功",
  30759. })
  30760. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  30761. } else {
  30762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30763. return
  30764. }
  30765. }
  30766. } else {
  30767. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  30768. //if err == nil {
  30769. // c.ServeSuccessJSON(map[string]interface{}{
  30770. // "msg": "退费成功",
  30771. // })
  30772. //} else {
  30773. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30774. // return
  30775. //}
  30776. }
  30777. }
  30778. func (c *HisApiController) RefundDetail() {
  30779. order_id, _ := c.GetInt64("order_id")
  30780. admin_user_id, _ := c.GetInt64("admin_user_id")
  30781. //his_patient_id, _ := c.GetInt64("his_patient_id")
  30782. number := c.GetString("number")
  30783. record_time := c.GetString("record_time")
  30784. patient_id, _ := c.GetInt64("patient_id")
  30785. //med_type, _ := c.GetInt64("med_type")
  30786. timeLayout := "2006-01-02"
  30787. loc, _ := time.LoadLocation("Local")
  30788. adminUser := c.GetAdminUserInfo()
  30789. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30790. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  30791. fmt.Println(err)
  30792. if err != nil {
  30793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30794. return
  30795. }
  30796. recordDateTime := theTime.Unix()
  30797. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  30798. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  30799. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30800. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30801. var order models.HisOrder
  30802. order, _ = service.GetHisOrderByID(order_id)
  30803. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  30804. if config.IsOpen == 1 { //对接了医保,走医保流程
  30805. var res2 ResultSix
  30806. if miConfig.MdtrtareaAdmvs == "421300" {
  30807. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  30808. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30809. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30810. resp3, requestErr3 := http.Get(api3)
  30811. if requestErr3 != nil {
  30812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30813. return
  30814. }
  30815. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30816. if ioErr3 != nil {
  30817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30819. return
  30820. }
  30821. var respJSON3 map[string]interface{}
  30822. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30823. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30825. return
  30826. }
  30827. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30828. userJSONBytes3, _ := json.Marshal(respJSON3)
  30829. fmt.Println("log")
  30830. fmt.Println(string(userJSONBytes3))
  30831. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30832. utils.ErrorLog("解析失败:%v", err)
  30833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30834. return
  30835. }
  30836. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  30837. if err == nil {
  30838. c.ServeSuccessJSON(map[string]interface{}{
  30839. "msg": "撤销明细成功",
  30840. })
  30841. return
  30842. } else {
  30843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30844. return
  30845. }
  30846. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30847. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  30848. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30849. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30850. resp3, requestErr3 := http.Get(api3)
  30851. if requestErr3 != nil {
  30852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30853. return
  30854. }
  30855. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30856. if ioErr3 != nil {
  30857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30859. return
  30860. }
  30861. var respJSON3 map[string]interface{}
  30862. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30865. return
  30866. }
  30867. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30868. userJSONBytes3, _ := json.Marshal(respJSON3)
  30869. fmt.Println("log")
  30870. fmt.Println(string(userJSONBytes3))
  30871. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30872. utils.ErrorLog("解析失败:%v", err)
  30873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30874. return
  30875. }
  30876. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  30877. if err == nil {
  30878. c.ServeSuccessJSON(map[string]interface{}{
  30879. "msg": "撤销明细成功",
  30880. })
  30881. return
  30882. } else {
  30883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30884. return
  30885. }
  30886. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30887. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  30888. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30889. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30890. resp3, requestErr3 := http.Get(api3)
  30891. if requestErr3 != nil {
  30892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30893. return
  30894. }
  30895. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30896. if ioErr3 != nil {
  30897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30899. return
  30900. }
  30901. var respJSON3 map[string]interface{}
  30902. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30905. return
  30906. }
  30907. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30908. userJSONBytes3, _ := json.Marshal(respJSON3)
  30909. fmt.Println("log")
  30910. fmt.Println(string(userJSONBytes3))
  30911. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30912. utils.ErrorLog("解析失败:%v", err)
  30913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30914. return
  30915. }
  30916. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  30917. if err == nil {
  30918. c.ServeSuccessJSON(map[string]interface{}{
  30919. "msg": "撤销明细成功",
  30920. })
  30921. return
  30922. } else {
  30923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30924. return
  30925. }
  30926. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30927. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  30928. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30929. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30930. resp3, requestErr3 := http.Get(api3)
  30931. if requestErr3 != nil {
  30932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30933. return
  30934. }
  30935. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30936. if ioErr3 != nil {
  30937. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30939. return
  30940. }
  30941. var respJSON3 map[string]interface{}
  30942. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30945. return
  30946. }
  30947. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30948. userJSONBytes3, _ := json.Marshal(respJSON3)
  30949. fmt.Println("log")
  30950. fmt.Println(string(userJSONBytes3))
  30951. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30952. utils.ErrorLog("解析失败:%v", err)
  30953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30954. return
  30955. }
  30956. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  30957. if err == nil {
  30958. c.ServeSuccessJSON(map[string]interface{}{
  30959. "msg": "撤销明细成功",
  30960. })
  30961. return
  30962. } else {
  30963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30964. return
  30965. }
  30966. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30967. var resSix10265 ResultSix10265
  30968. var api3 string
  30969. if miConfig.MdtrtareaAdmvs == "320921" {
  30970. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  30971. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30972. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30973. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30974. } else {
  30975. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30976. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  30977. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30978. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30979. }
  30980. resp3, requestErr3 := http.Get(api3)
  30981. utils.ErrorLog("接口: %v", requestErr3)
  30982. if requestErr3 != nil {
  30983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30984. return
  30985. }
  30986. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30987. if ioErr3 != nil {
  30988. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30990. return
  30991. }
  30992. var respJSON3 map[string]interface{}
  30993. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30994. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30996. return
  30997. }
  30998. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30999. userJSONBytes3, _ := json.Marshal(respJSON3)
  31000. fmt.Println("log")
  31001. fmt.Println(string(userJSONBytes3))
  31002. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31003. utils.ErrorLog("解析失败:%v", err)
  31004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31005. return
  31006. }
  31007. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31008. res2.Output = resSix10265.Output
  31009. res2.ErrMsg = resSix10265.ErrMsg
  31010. res2.Cainfo = resSix10265.Cainfo
  31011. res2.WarnMsg = resSix10265.WarnMsg
  31012. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31013. res2.Infcode = infocode
  31014. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31015. if err == nil {
  31016. c.ServeSuccessJSON(map[string]interface{}{
  31017. "msg": "撤销明细成功",
  31018. })
  31019. return
  31020. } else {
  31021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31022. return
  31023. }
  31024. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31025. var api3 string
  31026. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31027. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31028. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31029. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31030. resp3, requestErr3 := http.Get(api3)
  31031. utils.ErrorLog("接口: %v", requestErr3)
  31032. if requestErr3 != nil {
  31033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31034. return
  31035. }
  31036. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31037. if ioErr3 != nil {
  31038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31040. return
  31041. }
  31042. var respJSON3 map[string]interface{}
  31043. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31046. return
  31047. }
  31048. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31049. if status == "0" {
  31050. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31051. c.ServeSuccessJSON(map[string]interface{}{
  31052. "failed_code": -10,
  31053. "msg": err_msg,
  31054. })
  31055. return
  31056. }
  31057. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31058. userJSONBytes3, _ := json.Marshal(respJSON3)
  31059. fmt.Println("log")
  31060. fmt.Println(string(userJSONBytes3))
  31061. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31062. utils.ErrorLog("解析失败:%v", err)
  31063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31064. return
  31065. }
  31066. fmt.Println(res2.Infcode)
  31067. if res2.Infcode == -1 {
  31068. c.ServeSuccessJSON(map[string]interface{}{
  31069. "failed_code": -10,
  31070. "msg": res2.ErrMsg,
  31071. })
  31072. return
  31073. }
  31074. if res2.Infcode == 0 {
  31075. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31076. if err == nil {
  31077. c.ServeSuccessJSON(map[string]interface{}{
  31078. "msg": "撤销明细成功",
  31079. })
  31080. return
  31081. } else {
  31082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31083. return
  31084. }
  31085. } else {
  31086. c.ServeSuccessJSON(map[string]interface{}{
  31087. "failed_code": -10,
  31088. "msg": res2.ErrMsg,
  31089. })
  31090. }
  31091. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31092. if err == nil {
  31093. c.ServeSuccessJSON(map[string]interface{}{
  31094. "msg": "撤销明细成功",
  31095. })
  31096. return
  31097. } else {
  31098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31099. return
  31100. }
  31101. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31102. var api3 string
  31103. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31104. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31105. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31106. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31107. resp3, requestErr3 := http.Get(api3)
  31108. utils.ErrorLog("接口: %v", requestErr3)
  31109. if requestErr3 != nil {
  31110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31111. return
  31112. }
  31113. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31114. if ioErr3 != nil {
  31115. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31117. return
  31118. }
  31119. var respJSON3 map[string]interface{}
  31120. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31121. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31123. return
  31124. }
  31125. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31126. if status == "0" {
  31127. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31128. c.ServeSuccessJSON(map[string]interface{}{
  31129. "failed_code": -10,
  31130. "msg": err_msg,
  31131. })
  31132. return
  31133. }
  31134. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31135. userJSONBytes3, _ := json.Marshal(respJSON3)
  31136. fmt.Println("log")
  31137. fmt.Println(string(userJSONBytes3))
  31138. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31139. utils.ErrorLog("解析失败:%v", err)
  31140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31141. return
  31142. }
  31143. fmt.Println(res2.Infcode)
  31144. if res2.Infcode == -1 {
  31145. c.ServeSuccessJSON(map[string]interface{}{
  31146. "failed_code": -10,
  31147. "msg": res2.ErrMsg,
  31148. })
  31149. return
  31150. }
  31151. if res2.Infcode == 0 {
  31152. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31153. if err == nil {
  31154. c.ServeSuccessJSON(map[string]interface{}{
  31155. "msg": "撤销明细成功",
  31156. })
  31157. return
  31158. } else {
  31159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31160. return
  31161. }
  31162. } else {
  31163. c.ServeSuccessJSON(map[string]interface{}{
  31164. "failed_code": -10,
  31165. "msg": res2.ErrMsg,
  31166. })
  31167. }
  31168. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31169. if err == nil {
  31170. c.ServeSuccessJSON(map[string]interface{}{
  31171. "msg": "撤销明细成功",
  31172. })
  31173. return
  31174. } else {
  31175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31176. return
  31177. }
  31178. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31179. var resSix10265 ResultSix10265
  31180. new_chrg_bchno := order.Number
  31181. if adminUser.CurrentOrgId == 10265 {
  31182. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  31183. new_chrg_bchno = "0000"
  31184. }
  31185. }
  31186. var api3 string
  31187. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  31188. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31189. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31190. resp3, requestErr3 := http.Get(api3)
  31191. if requestErr3 != nil {
  31192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31193. return
  31194. }
  31195. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31196. if ioErr3 != nil {
  31197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31199. return
  31200. }
  31201. var respJSON3 map[string]interface{}
  31202. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31205. return
  31206. }
  31207. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31208. userJSONBytes3, _ := json.Marshal(respJSON3)
  31209. fmt.Println("log")
  31210. fmt.Println(string(userJSONBytes3))
  31211. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31212. utils.ErrorLog("解析失败:%v", err)
  31213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31214. return
  31215. }
  31216. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31217. res2.Output = resSix10265.Output
  31218. res2.ErrMsg = resSix10265.ErrMsg
  31219. res2.Cainfo = resSix10265.Cainfo
  31220. res2.WarnMsg = resSix10265.WarnMsg
  31221. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31222. res2.Infcode = infocode
  31223. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31224. if err == nil {
  31225. c.ServeSuccessJSON(map[string]interface{}{
  31226. "msg": "撤销明细成功",
  31227. })
  31228. return
  31229. } else {
  31230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31231. return
  31232. }
  31233. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31234. 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)
  31235. var dat map[string]interface{}
  31236. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31237. fmt.Println(dat)
  31238. } else {
  31239. fmt.Println(err)
  31240. }
  31241. saveLog(result2, src_request, "2205", "撤销明细")
  31242. userJSONBytes, _ := json.Marshal(dat)
  31243. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31244. utils.ErrorLog("解析失败:%v", err)
  31245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31246. return
  31247. }
  31248. if res2.Infcode == 0 {
  31249. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31250. if err == nil {
  31251. c.ServeSuccessJSON(map[string]interface{}{
  31252. "msg": "撤销明细成功",
  31253. })
  31254. return
  31255. } else {
  31256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31257. return
  31258. }
  31259. } else {
  31260. c.ServeSuccessJSON(map[string]interface{}{
  31261. "failed_code": -10,
  31262. "msg": res2.ErrMsg,
  31263. })
  31264. }
  31265. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31266. 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, "")
  31267. var dat map[string]interface{}
  31268. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31269. fmt.Println(dat)
  31270. } else {
  31271. fmt.Println(err)
  31272. }
  31273. saveLog(result2, src_request, "2205", "撤销明细")
  31274. userJSONBytes, _ := json.Marshal(dat)
  31275. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31276. utils.ErrorLog("解析失败:%v", err)
  31277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31278. return
  31279. }
  31280. if res2.Infcode == 0 {
  31281. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31282. if err == nil {
  31283. c.ServeSuccessJSON(map[string]interface{}{
  31284. "msg": "撤销明细成功",
  31285. })
  31286. return
  31287. } else {
  31288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31289. return
  31290. }
  31291. } else {
  31292. c.ServeSuccessJSON(map[string]interface{}{
  31293. "failed_code": -10,
  31294. "msg": res2.ErrMsg,
  31295. })
  31296. }
  31297. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31298. 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, "")
  31299. var dat map[string]interface{}
  31300. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31301. fmt.Println(dat)
  31302. } else {
  31303. fmt.Println(err)
  31304. }
  31305. saveLog(result2, src_request, "2205", "撤销明细")
  31306. userJSONBytes, _ := json.Marshal(dat)
  31307. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31308. utils.ErrorLog("解析失败:%v", err)
  31309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31310. return
  31311. }
  31312. if res2.Infcode == 0 {
  31313. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31314. if err == nil {
  31315. c.ServeSuccessJSON(map[string]interface{}{
  31316. "msg": "撤销明细成功",
  31317. })
  31318. return
  31319. } else {
  31320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31321. return
  31322. }
  31323. } else {
  31324. c.ServeSuccessJSON(map[string]interface{}{
  31325. "failed_code": -10,
  31326. "msg": res2.ErrMsg,
  31327. })
  31328. }
  31329. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31330. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  31331. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31332. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31333. resp2, requestErr2 := http.Get(api2)
  31334. if requestErr2 != nil {
  31335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31336. return
  31337. }
  31338. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  31339. if ioErr2 != nil {
  31340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  31341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31342. return
  31343. }
  31344. var respJSON2 map[string]interface{}
  31345. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  31346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31348. return
  31349. }
  31350. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31351. userJSONBytes3, _ := json.Marshal(respJSON2)
  31352. fmt.Println("log")
  31353. fmt.Println(string(userJSONBytes3))
  31354. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31355. utils.ErrorLog("解析失败:%v", err)
  31356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31357. return
  31358. }
  31359. if res2.Infcode == 0 {
  31360. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31361. if err == nil {
  31362. c.ServeSuccessJSON(map[string]interface{}{
  31363. "msg": "撤销明细成功",
  31364. })
  31365. return
  31366. } else {
  31367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31368. return
  31369. }
  31370. } else {
  31371. c.ServeSuccessJSON(map[string]interface{}{
  31372. "failed_code": -10,
  31373. "msg": res2.ErrMsg,
  31374. })
  31375. }
  31376. } else {
  31377. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  31378. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31379. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  31380. resp2, requestErr2 := http.Get(api2)
  31381. if requestErr2 != nil {
  31382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31383. return
  31384. }
  31385. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  31386. if ioErr2 != nil {
  31387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  31388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31389. return
  31390. }
  31391. var respJSON2 map[string]interface{}
  31392. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  31393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31395. return
  31396. }
  31397. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31398. userJSONBytes3, _ := json.Marshal(respJSON2)
  31399. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31400. utils.ErrorLog("解析失败:%v", err)
  31401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31402. return
  31403. }
  31404. if res2.Infcode == -1 {
  31405. c.ServeSuccessJSON(map[string]interface{}{
  31406. "failed_code": -10,
  31407. "msg": res2.ErrMsg,
  31408. })
  31409. return
  31410. } else {
  31411. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31412. if err == nil {
  31413. c.ServeSuccessJSON(map[string]interface{}{
  31414. "msg": "撤销明细成功",
  31415. })
  31416. return
  31417. } else {
  31418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31419. return
  31420. }
  31421. }
  31422. }
  31423. } else {
  31424. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31425. if err == nil {
  31426. c.ServeSuccessJSON(map[string]interface{}{
  31427. "msg": "退费成功",
  31428. })
  31429. } else {
  31430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31431. return
  31432. }
  31433. }
  31434. }
  31435. // 对账
  31436. func (c *HisApiController) GetCheckAccount() {
  31437. start_time := c.GetString("start_time")
  31438. end_time := c.GetString("end_time")
  31439. insutype := c.GetString("insutype")
  31440. clr_type := c.GetString("clr_type")
  31441. clr_org := c.GetString("clr_optins")
  31442. admin_user_id, _ := c.GetInt64("admin_user_id")
  31443. adminUser := c.GetAdminUserInfo()
  31444. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31445. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31446. if len(clr_org) == 0 {
  31447. clr_org = miConfig.InsuplcAdmdvs
  31448. }
  31449. timeLayout := "2006-01-02"
  31450. loc, _ := time.LoadLocation("Local")
  31451. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  31452. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  31453. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  31454. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  31455. fixmedins_setl_cnt := int64(len(orders))
  31456. var medfee_sumamt float64
  31457. var acct_pay float64
  31458. var fund_pay_sumamt float64
  31459. for _, item := range orders {
  31460. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  31461. acct_pay = acct_pay + item.AcctPay
  31462. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  31463. }
  31464. var user_name string
  31465. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31466. if role.ID == 0 {
  31467. user_name = "xxx"
  31468. } else {
  31469. user_name = role.UserName
  31470. }
  31471. var res ResultEight
  31472. var res10188 ResultEightFor10188
  31473. if config.IsOpen == 1 {
  31474. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31475. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  31476. "insutype=" + insutype +
  31477. "&clr_type=" + clr_type +
  31478. "&setl_optins=" + clr_org +
  31479. "&stmt_begndate=" + start_time +
  31480. "&stm_enddate=" + end_time +
  31481. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  31482. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  31483. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  31484. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  31485. "&fixmedins_code=" + miConfig.Code +
  31486. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  31487. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31488. "&secret_key=" + miConfig.SecretKey +
  31489. "&org_name=" + miConfig.OrgName +
  31490. "&doctor=" + user_name +
  31491. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31492. fmt.Println(api)
  31493. resp, requestErr := http.Get(api)
  31494. if requestErr != nil {
  31495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31496. return
  31497. }
  31498. body, ioErr := ioutil.ReadAll(resp.Body)
  31499. fmt.Println(body)
  31500. if ioErr != nil {
  31501. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31503. return
  31504. }
  31505. var respJSON map[string]interface{}
  31506. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31509. return
  31510. }
  31511. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31512. userJSONBytes, _ := json.Marshal(respJSON)
  31513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31514. utils.ErrorLog("解析失败:%v", err)
  31515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31516. return
  31517. }
  31518. res.InfRefmsgid = res10188.InfRefmsgid
  31519. res.Output = res10188.Output
  31520. res.ErrMsg = res10188.ErrMsg
  31521. res.Cainfo = res10188.Cainfo
  31522. res.WarnMsg = res10188.WarnMsg
  31523. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  31524. res.Infcode = infocode
  31525. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31526. if clr_type != "9903" {
  31527. clr_type = "99" // 就诊 ID(来自2201接口返回)
  31528. }
  31529. if clr_type == "9903" {
  31530. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  31531. }
  31532. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  31533. "insutype=" + insutype +
  31534. "&clr_type=" + clr_type +
  31535. "&setl_optins=" + clr_org +
  31536. "&stmt_begndate=" + start_time +
  31537. "&stm_enddate=" + end_time +
  31538. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  31539. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  31540. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  31541. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  31542. "&fixmedins_code=" + miConfig.Code +
  31543. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  31544. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31545. "&secret_key=" + miConfig.SecretKey +
  31546. "&org_name=" + miConfig.OrgName +
  31547. "&doctor=" + user_name
  31548. resp, requestErr := http.Get(api)
  31549. if requestErr != nil {
  31550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31551. return
  31552. }
  31553. body, ioErr := ioutil.ReadAll(resp.Body)
  31554. if ioErr != nil {
  31555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31557. return
  31558. }
  31559. var respJSON map[string]interface{}
  31560. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31563. return
  31564. }
  31565. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31566. result, _ := json.Marshal(respJSON)
  31567. fmt.Println("log")
  31568. fmt.Println(string(result))
  31569. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  31570. utils.ErrorLog("解析失败:%v", err)
  31571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31572. return
  31573. }
  31574. res.InfRefmsgid = res10188.InfRefmsgid
  31575. res.Output = res10188.Output
  31576. res.ErrMsg = res10188.ErrMsg
  31577. res.Cainfo = res10188.Cainfo
  31578. res.WarnMsg = res10188.WarnMsg
  31579. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  31580. res.Infcode = infocode
  31581. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31582. var baseParams models.BaseParams
  31583. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  31584. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  31585. baseParams.SecretKey = miConfig.SecretKey
  31586. baseParams.OrgName = miConfig.OrgName
  31587. baseParams.FixmedinsCode = miConfig.Code
  31588. baseParams.EncKey = miConfig.EncKey
  31589. baseParams.AppSecret = miConfig.AppSecret
  31590. baseParams.SignKey = miConfig.SignKey
  31591. baseParams.AppID = miConfig.Code
  31592. baseParams.Doctor = role.UserName
  31593. baseParams.RequestUrl = miConfig.Url
  31594. businessParams := models.BusinessParams{
  31595. Insutype: insutype,
  31596. ClrType: clr_type,
  31597. SetlOptins: clr_org,
  31598. StmtBegndate: start_time,
  31599. StmtEnddate: end_time,
  31600. MedfeeSumamt: medfee_sumamt,
  31601. FundPaySumamt: fund_pay_sumamt,
  31602. AcctPay: acct_pay,
  31603. FixmedinsSetlCnt: fixmedins_setl_cnt,
  31604. }
  31605. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  31606. fmt.Println(requestLog)
  31607. fmt.Println(result)
  31608. fmt.Println(err_msg)
  31609. var dat map[string]interface{}
  31610. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31611. fmt.Println(dat)
  31612. } else {
  31613. fmt.Println(err)
  31614. }
  31615. userJSONBytes, _ := json.Marshal(dat)
  31616. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31617. utils.ErrorLog("解析失败:%v", err)
  31618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31619. return
  31620. }
  31621. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31622. var baseParams models.BaseParams
  31623. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  31624. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  31625. baseParams.SecretKey = miConfig.SecretKey
  31626. baseParams.OrgName = miConfig.OrgName
  31627. baseParams.FixmedinsCode = miConfig.Code
  31628. baseParams.EncKey = miConfig.EncKey
  31629. baseParams.AppSecret = miConfig.AppSecret
  31630. baseParams.SignKey = miConfig.SignKey
  31631. baseParams.AppID = miConfig.Code
  31632. baseParams.Doctor = role.UserName
  31633. baseParams.RequestUrl = miConfig.Url
  31634. baseParams.AccessKey = miConfig.AccessKey
  31635. businessParams := models.BusinessParams{
  31636. Insutype: insutype,
  31637. ClrType: clr_type,
  31638. SetlOptins: "430822",
  31639. StmtBegndate: start_time,
  31640. StmtEnddate: end_time,
  31641. MedfeeSumamt: medfee_sumamt,
  31642. FundPaySumamt: fund_pay_sumamt,
  31643. AcctPay: acct_pay,
  31644. FixmedinsSetlCnt: fixmedins_setl_cnt,
  31645. }
  31646. 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)
  31647. fmt.Println(requestLog)
  31648. fmt.Println(result)
  31649. var dat map[string]interface{}
  31650. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31651. fmt.Println(dat)
  31652. } else {
  31653. fmt.Println(err)
  31654. }
  31655. userJSONBytes, _ := json.Marshal(dat)
  31656. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31657. utils.ErrorLog("解析失败:%v", err)
  31658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31659. return
  31660. }
  31661. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31662. var baseParams models.BaseParams
  31663. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  31664. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  31665. baseParams.SecretKey = miConfig.SecretKey
  31666. baseParams.OrgName = miConfig.OrgName
  31667. baseParams.FixmedinsCode = miConfig.Code
  31668. baseParams.EncKey = miConfig.EncKey
  31669. baseParams.AppSecret = miConfig.AppSecret
  31670. baseParams.SignKey = miConfig.SignKey
  31671. baseParams.AppID = miConfig.Code
  31672. baseParams.Doctor = role.UserName
  31673. baseParams.RequestUrl = miConfig.Url
  31674. businessParams := models.BusinessParams{
  31675. Insutype: insutype,
  31676. ClrType: clr_type,
  31677. SetlOptins: clr_org,
  31678. StmtBegndate: start_time,
  31679. StmtEnddate: end_time,
  31680. MedfeeSumamt: medfee_sumamt,
  31681. FundPaySumamt: fund_pay_sumamt,
  31682. AcctPay: acct_pay,
  31683. FixmedinsSetlCnt: fixmedins_setl_cnt,
  31684. }
  31685. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  31686. fmt.Println(requestLog)
  31687. fmt.Println(result)
  31688. fmt.Println(err_msg)
  31689. var dat map[string]interface{}
  31690. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31691. fmt.Println(dat)
  31692. } else {
  31693. fmt.Println(err)
  31694. }
  31695. userJSONBytes, _ := json.Marshal(dat)
  31696. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31697. utils.ErrorLog("解析失败:%v", err)
  31698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31699. return
  31700. }
  31701. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31702. if len(clr_type) == 0 {
  31703. clr_type = "11"
  31704. }
  31705. api := miConfig.Url + "gdyb/ten?" +
  31706. "insutype=" + insutype +
  31707. "&clr_type=" + clr_type +
  31708. "&setl_optins=" + clr_org +
  31709. "&stmt_begndate=" + start_time +
  31710. "&stm_enddate=" + end_time +
  31711. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  31712. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  31713. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  31714. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  31715. "&fixmedins_code=" + miConfig.Code +
  31716. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  31717. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31718. "&secret_key=" + miConfig.SecretKey +
  31719. "&org_name=" + miConfig.OrgName +
  31720. "&doctor=" + user_name
  31721. fmt.Println(api)
  31722. resp, requestErr := http.Get(api)
  31723. if requestErr != nil {
  31724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31725. return
  31726. }
  31727. body, ioErr := ioutil.ReadAll(resp.Body)
  31728. fmt.Println(body)
  31729. if ioErr != nil {
  31730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31732. return
  31733. }
  31734. var respJSON map[string]interface{}
  31735. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31738. return
  31739. }
  31740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31741. userJSONBytes, _ := json.Marshal(respJSON)
  31742. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31743. utils.ErrorLog("解析失败:%v", err)
  31744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31745. return
  31746. }
  31747. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31748. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  31749. fixmedins_setl_cnt := int64(len(orders_two))
  31750. var medfee_sumamt float64
  31751. var acct_pay float64
  31752. var fund_pay_sumamt float64
  31753. for _, item := range orders_two {
  31754. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  31755. acct_pay = acct_pay + item.AcctPay
  31756. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  31757. }
  31758. var baseParams models.BaseParams
  31759. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  31760. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  31761. baseParams.SecretKey = miConfig.SecretKey
  31762. baseParams.OrgName = miConfig.OrgName
  31763. baseParams.FixmedinsCode = miConfig.Code
  31764. baseParams.EncKey = miConfig.EncKey
  31765. baseParams.AppSecret = miConfig.AppSecret
  31766. baseParams.SignKey = miConfig.SignKey
  31767. baseParams.AppID = miConfig.Code
  31768. baseParams.Doctor = role.UserName
  31769. baseParams.RequestUrl = miConfig.Url
  31770. if clr_type == "9903" {
  31771. clr_type = "9994"
  31772. }
  31773. businessParams := models.BusinessParams{
  31774. Insutype: insutype,
  31775. ClrType: clr_type,
  31776. SetlOptins: "360302",
  31777. StmtBegndate: start_time,
  31778. StmtEnddate: end_time,
  31779. MedfeeSumamt: 0,
  31780. FundPaySumamt: 0,
  31781. AcctPay: 0,
  31782. FixmedinsSetlCnt: fixmedins_setl_cnt,
  31783. }
  31784. 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))
  31785. fmt.Println(requestLog)
  31786. fmt.Println(result)
  31787. var dat map[string]interface{}
  31788. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31789. fmt.Println(dat)
  31790. } else {
  31791. fmt.Println(err)
  31792. }
  31793. userJSONBytes, _ := json.Marshal(dat)
  31794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31795. utils.ErrorLog("解析失败:%v", err)
  31796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31797. return
  31798. }
  31799. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31800. var api string
  31801. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  31802. "&clr_type=" + clr_type +
  31803. "&setl_optins=" + clr_org +
  31804. "&stmt_begndate=" + start_time +
  31805. "&stm_enddate=" + end_time +
  31806. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  31807. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  31808. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  31809. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  31810. "&fixmedins_code=" + miConfig.Code +
  31811. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  31812. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31813. "&secret_key=" + miConfig.SecretKey +
  31814. "&org_name=" + miConfig.OrgName +
  31815. "&doctor=" + user_name + "&url=" + miConfig.Url
  31816. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31817. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31818. resp, requestErr := http.Get(api)
  31819. if requestErr != nil {
  31820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31821. return
  31822. }
  31823. body, ioErr := ioutil.ReadAll(resp.Body)
  31824. if ioErr != nil {
  31825. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31827. return
  31828. }
  31829. var respJSON map[string]interface{}
  31830. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31831. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31833. return
  31834. }
  31835. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31836. if status == "0" {
  31837. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31838. c.ServeSuccessJSON(map[string]interface{}{
  31839. "failed_code": -10,
  31840. "msg": err_msg,
  31841. })
  31842. return
  31843. }
  31844. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31845. userJSONBytes, _ := json.Marshal(respJSON)
  31846. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31847. utils.ErrorLog("解析失败:%v", err)
  31848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31849. return
  31850. }
  31851. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31852. var api string
  31853. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  31854. "&clr_type=" + clr_type +
  31855. "&setl_optins=" + clr_org +
  31856. "&stmt_begndate=" + start_time +
  31857. "&stm_enddate=" + end_time +
  31858. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  31859. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  31860. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  31861. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  31862. "&fixmedins_code=" + miConfig.Code +
  31863. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  31864. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31865. "&secret_key=" + miConfig.SecretKey +
  31866. "&org_name=" + miConfig.OrgName +
  31867. "&doctor=" + user_name + "&url=" + miConfig.Url
  31868. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31869. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31870. resp, requestErr := http.Get(api)
  31871. if requestErr != nil {
  31872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31873. return
  31874. }
  31875. body, ioErr := ioutil.ReadAll(resp.Body)
  31876. if ioErr != nil {
  31877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31879. return
  31880. }
  31881. var respJSON map[string]interface{}
  31882. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31885. return
  31886. }
  31887. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31888. if status == "0" {
  31889. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31890. c.ServeSuccessJSON(map[string]interface{}{
  31891. "failed_code": -10,
  31892. "msg": err_msg,
  31893. })
  31894. return
  31895. }
  31896. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31897. userJSONBytes, _ := json.Marshal(respJSON)
  31898. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31899. utils.ErrorLog("解析失败:%v", err)
  31900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31901. return
  31902. }
  31903. } else {
  31904. if len(clr_type) == 0 {
  31905. clr_type = "11"
  31906. }
  31907. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  31908. "insutype=" + insutype +
  31909. "&clr_type=" + clr_type +
  31910. "&setl_optins=" + clr_org +
  31911. "&stmt_begndate=" + start_time +
  31912. "&stm_enddate=" + end_time +
  31913. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  31914. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  31915. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  31916. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  31917. "&fixmedins_code=" + miConfig.Code +
  31918. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  31919. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31920. "&secret_key=" + miConfig.SecretKey +
  31921. "&org_name=" + miConfig.OrgName +
  31922. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  31923. fmt.Println(api)
  31924. resp, requestErr := http.Get(api)
  31925. if requestErr != nil {
  31926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31927. return
  31928. }
  31929. body, ioErr := ioutil.ReadAll(resp.Body)
  31930. fmt.Println(body)
  31931. if ioErr != nil {
  31932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31934. return
  31935. }
  31936. var respJSON map[string]interface{}
  31937. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31940. return
  31941. }
  31942. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31943. userJSONBytes, _ := json.Marshal(respJSON)
  31944. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31945. utils.ErrorLog("解析失败:%v", err)
  31946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31947. return
  31948. }
  31949. }
  31950. if res.Infcode == 0 {
  31951. if res.Output.Stmtinfo.StmtRslt == "0" {
  31952. micc := &models.MedicalInsuranceCostCompare{
  31953. StartTime: startime.Unix(),
  31954. EndTime: endtime.Unix(),
  31955. Insutype: insutype,
  31956. CheckType: 1,
  31957. Num: fixmedins_setl_cnt,
  31958. Mtime: time.Now().Unix(),
  31959. Status: 1,
  31960. UserOrgId: adminUser.CurrentOrgId,
  31961. CostTotal: medfee_sumamt,
  31962. FuncTotal: fund_pay_sumamt,
  31963. PsnPay: acct_pay,
  31964. Creator: admin_user_id,
  31965. Ctime: time.Now().Unix(),
  31966. ClrType: clr_type,
  31967. }
  31968. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  31969. if err == nil {
  31970. c.ServeSuccessJSON(map[string]interface{}{
  31971. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  31972. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  31973. })
  31974. } else {
  31975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31976. }
  31977. } else {
  31978. c.ServeSuccessJSON(map[string]interface{}{
  31979. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  31980. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  31981. })
  31982. }
  31983. } else {
  31984. c.ServeSuccessJSON(map[string]interface{}{
  31985. "failed_code": -10,
  31986. "msg": res.ErrMsg,
  31987. })
  31988. }
  31989. }
  31990. }
  31991. func (c *HisApiController) Check310() {
  31992. adminUser := c.GetAdminUserInfo()
  31993. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31994. var user_name string
  31995. user_name = "高慧裕"
  31996. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  31997. "insutype=" + "310" +
  31998. "&clr_type=" + "" +
  31999. "&setl_optins=" + "441202" +
  32000. "&stmt_begndate=" + "2022-03-01" +
  32001. "&stm_enddate=" + "2022-03-31" +
  32002. "&medfee_sumamt=" + "194930.12" +
  32003. "&fund_pay_sumamt=" + "188741.46" +
  32004. "&acct_pay=" + "0" +
  32005. "&fixmedins_setl_cnt=" + "452" +
  32006. "&fixmedins_code=" + miConfig.Code +
  32007. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  32008. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32009. "&secret_key=" + miConfig.SecretKey +
  32010. "&org_name=" + miConfig.OrgName +
  32011. "&doctor=" + user_name
  32012. fmt.Println(api)
  32013. resp, requestErr := http.Get(api)
  32014. if requestErr != nil {
  32015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32016. return
  32017. }
  32018. body, ioErr := ioutil.ReadAll(resp.Body)
  32019. fmt.Println(body)
  32020. if ioErr != nil {
  32021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32023. return
  32024. }
  32025. var respJSON map[string]interface{}
  32026. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32029. return
  32030. }
  32031. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32032. userJSONBytes, _ := json.Marshal(respJSON)
  32033. var res ResultEight
  32034. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32035. utils.ErrorLog("解析失败:%v", err)
  32036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32037. return
  32038. }
  32039. }
  32040. func (c *HisApiController) Check390() {
  32041. adminUser := c.GetAdminUserInfo()
  32042. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32043. var user_name string
  32044. user_name = "高慧裕"
  32045. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  32046. "insutype=" + "390" +
  32047. "&clr_type=" + "" +
  32048. "&setl_optins=" + "441202" +
  32049. "&stmt_begndate=" + "2022-03-01" +
  32050. "&stm_enddate=" + "2022-03-31" +
  32051. "&medfee_sumamt=" + "1068448.89" +
  32052. "&fund_pay_sumamt=" + "1014677.62" +
  32053. "&acct_pay=" + "0" +
  32054. "&fixmedins_setl_cnt=" + "1950" +
  32055. "&fixmedins_code=" + miConfig.Code +
  32056. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  32057. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32058. "&secret_key=" + miConfig.SecretKey +
  32059. "&org_name=" + miConfig.OrgName +
  32060. "&doctor=" + user_name
  32061. fmt.Println(api)
  32062. resp, requestErr := http.Get(api)
  32063. if requestErr != nil {
  32064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32065. return
  32066. }
  32067. body, ioErr := ioutil.ReadAll(resp.Body)
  32068. fmt.Println(body)
  32069. if ioErr != nil {
  32070. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32072. return
  32073. }
  32074. var respJSON map[string]interface{}
  32075. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32078. return
  32079. }
  32080. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32081. userJSONBytes, _ := json.Marshal(respJSON)
  32082. var res ResultEight
  32083. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32084. utils.ErrorLog("解析失败:%v", err)
  32085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32086. return
  32087. }
  32088. }
  32089. // 对账明细
  32090. func (c *HisApiController) GetCheckDetailAccount() {
  32091. start_time := c.GetString("start_time")
  32092. end_time := c.GetString("end_time")
  32093. admin_user_id, _ := c.GetInt64("admin_user_id")
  32094. adminUser := c.GetAdminUserInfo()
  32095. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32096. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32097. timeLayout := "2006-01-02"
  32098. loc, _ := time.LoadLocation("Local")
  32099. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  32100. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  32101. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  32102. rand.Seed(time.Now().UnixNano())
  32103. num := rand.Intn(30000)
  32104. Mkdir(miConfig.OrgName)
  32105. file := strconv.FormatInt(int64(num), 10)
  32106. file_name := file + ".txt"
  32107. zip_name := file + ".zip"
  32108. zip_path := miConfig.OrgName + "/" + zip_name
  32109. file_path := miConfig.OrgName + "/" + file_name
  32110. decimal.DivisionPrecision = 2
  32111. var medfee_sumamt float64
  32112. var psn_cash_pay float64
  32113. var fund_pay_sumamt float64
  32114. fixmedins_setl_cnt := int64(len(orders))
  32115. for _, item := range orders {
  32116. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  32117. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  32118. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  32119. }
  32120. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  32121. defer f.Close()
  32122. if err != nil {
  32123. fmt.Println(err.Error())
  32124. } else {
  32125. for _, item := range orders {
  32126. var refd_setl_flag string
  32127. if item.OrderStatus == 2 {
  32128. refd_setl_flag = "0"
  32129. var str string
  32130. str = item.SetlId + " " +
  32131. item.MdtrtId + " " +
  32132. item.PsnNo + " " +
  32133. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  32134. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  32135. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  32136. _, err = f.Write([]byte(str))
  32137. }
  32138. if item.OrderStatus == 3 {
  32139. var str string
  32140. str = item.SetlId + " " +
  32141. item.MdtrtId + " " +
  32142. item.PsnNo + " " +
  32143. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  32144. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  32145. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  32146. _, err = f.Write([]byte(str))
  32147. var str2 string
  32148. str2 = item.SetlId + " " +
  32149. item.MdtrtId + " " +
  32150. item.PsnNo + " " +
  32151. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  32152. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  32153. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  32154. _, err = f.Write([]byte(str2))
  32155. }
  32156. }
  32157. }
  32158. Zip(file_path, zip_path)
  32159. fmt.Println(ReadFile(zip_path))
  32160. fmt.Println(string(ReadFile(zip_path)))
  32161. if config.IsOpen == 1 {
  32162. var user_name string
  32163. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32164. if role.ID == 0 {
  32165. user_name = "管理员"
  32166. } else {
  32167. user_name = role.UserName
  32168. }
  32169. baseParams := models.BaseParams{
  32170. SecretKey: miConfig.SecretKey,
  32171. FixmedinsCode: miConfig.Code,
  32172. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  32173. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  32174. OrgName: miConfig.OrgName,
  32175. Doctor: user_name,
  32176. }
  32177. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  32178. var dat map[string]interface{}
  32179. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32180. fmt.Println(dat)
  32181. } else {
  32182. fmt.Println(err)
  32183. }
  32184. userJSONBytes, _ := json.Marshal(dat)
  32185. var res ResultNine
  32186. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32187. utils.ErrorLog("解析失败:%v", err)
  32188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32189. return
  32190. }
  32191. if res.Infcode == 0 {
  32192. fileNo := res.Output.FileQuryNo
  32193. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  32194. "file_qury_no=" + fileNo +
  32195. "&setl_optins=" + "定点医保中心" +
  32196. "&stmt_begndate=" + start_time +
  32197. "&stm_enddate=" + end_time +
  32198. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  32199. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  32200. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  32201. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  32202. "&fixmedins_code=" + miConfig.Code +
  32203. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  32204. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32205. "&secret_key=" + miConfig.SecretKey +
  32206. "&org_name=" + miConfig.OrgName +
  32207. "&doctor=" + user_name
  32208. resp, requestErr := http.Get(api)
  32209. if requestErr != nil {
  32210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32211. return
  32212. }
  32213. body, ioErr := ioutil.ReadAll(resp.Body)
  32214. if ioErr != nil {
  32215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32217. return
  32218. }
  32219. var respJSON map[string]interface{}
  32220. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32223. return
  32224. }
  32225. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32226. userJSONBytes, _ := json.Marshal(respJSON)
  32227. var res ResultTen
  32228. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32229. utils.ErrorLog("解析失败:%v", err)
  32230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32231. return
  32232. }
  32233. if res.Infcode == 0 {
  32234. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  32235. micc := &models.MedicalInsuranceCostCompare{
  32236. StartTime: startime.Unix(),
  32237. EndTime: endtime.Unix(),
  32238. Insutype: "0",
  32239. CheckType: 2,
  32240. Num: fixmedins_setl_cnt,
  32241. Mtime: time.Now().Unix(),
  32242. Status: 1,
  32243. UserOrgId: adminUser.CurrentOrgId,
  32244. CostTotal: medfee_sumamt,
  32245. FuncTotal: fund_pay_sumamt,
  32246. PsnPay: psn_cash_pay,
  32247. Creator: admin_user_id,
  32248. Ctime: time.Now().Unix(),
  32249. }
  32250. service.CreateMedicalInsuranceCostCompareRecord(micc)
  32251. c.ServeSuccessJSON(map[string]interface{}{
  32252. "msg": "明细对账成功",
  32253. })
  32254. }
  32255. } else {
  32256. }
  32257. }
  32258. }
  32259. type CustomOrderInfo struct {
  32260. Name string
  32261. Spec string
  32262. Unit string
  32263. Count float64
  32264. Price float64
  32265. Total float64
  32266. }
  32267. func (c *HisApiController) GetBatchSettleAccounts() {
  32268. admin_user_id, _ := c.GetInt64("admin_user_id")
  32269. order_ids := c.GetString("order_ids")
  32270. order_ids_arr := strings.Split(order_ids, ",")
  32271. data3 := []map[string]interface{}{}
  32272. for _, item := range order_ids_arr {
  32273. id, _ := strconv.ParseInt(item, 10, 64)
  32274. order_id := id
  32275. adminUser := c.GetAdminUserInfo()
  32276. order, _ := service.GetHisOrderByID(order_id)
  32277. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32278. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  32279. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  32280. orderInfos = append(orderInfos, orderInfos_two...)
  32281. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  32282. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  32283. var diagnosis_ids []string
  32284. if his.ID > 0 {
  32285. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  32286. } else {
  32287. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  32288. }
  32289. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  32290. var dia_config []*models.HisXtDiagnoseConfig
  32291. var name string
  32292. for _, item := range diagnosis_ids {
  32293. id, _ := strconv.ParseInt(item, 10, 64)
  32294. diagnosisConfig, _ := service.FindDiagnoseById(id)
  32295. dia_config = append(dia_config, &diagnosisConfig)
  32296. if len(name) == 0 {
  32297. name = diagnosisConfig.ClassName
  32298. }
  32299. //} else {
  32300. // name = name + "," + diagnosisConfig.ClassName
  32301. //}
  32302. }
  32303. var bedCostTotal float64 = 0 //床位总费
  32304. var bedCostSelfTotal float64 = 0 //床位自费
  32305. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  32306. var bedSelfTotal float64 = 0 //床位部分项目自费
  32307. var bedInscpTotal float64 = 0 //床位部分项目自费
  32308. var operationCostTotal float64 = 0 //手术费
  32309. var operationCostSelfTotal float64 = 0 //手术费
  32310. var operationCostPartSelfTotal float64 = 0 //手术费
  32311. var operationSelfTotal float64 = 0 //床位部分项目自费
  32312. var operationInscpTotal float64 = 0 //床位部分项目自费
  32313. var otherCostTotal float64 = 0 //其他费用
  32314. var otherCostSelfTotal float64 = 0 //其他费用
  32315. var otherCostPartSelfTotal float64 = 0 //其他费用
  32316. var otherSelfTotal float64 = 0 //床位部分项目自费
  32317. var otherInscpTotal float64 = 0 //床位部分项目自费
  32318. var materialCostTotal float64 = 0 //材料费
  32319. var materialCostSelfTotal float64 = 0 //材料费
  32320. var materialCostPartSelfTotal float64 = 0 //材料费
  32321. var materialSelfTotal float64 = 0 //床位部分项目自费
  32322. var materialInscpTotal float64 = 0 //床位部分项目自费
  32323. var westernMedicineCostTotal float64 = 0 //西药费
  32324. var westernMedicineCostSelfTotal float64 = 0 //西药费
  32325. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  32326. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  32327. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  32328. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  32329. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  32330. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  32331. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  32332. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  32333. var checkCostTotal float64 = 0 //检查费
  32334. var checkCostSelfTotal float64 = 0 //检查费
  32335. var checkCostPartSelfTotal float64 = 0 //检查费
  32336. var checkSelfTotal float64 = 0 //床位部分项目自费
  32337. var checkInscpTotal float64 = 0 //床位部分项目自费
  32338. var laboratoryCostTotal float64 = 0 //化验费
  32339. var laboratoryCostSelfTotal float64 = 0 //化验费
  32340. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  32341. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  32342. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  32343. var treatCostTotal float64 = 0 //治疗费用
  32344. var treatCostSelfTotal float64 = 0 //治疗费用
  32345. var treatCostPartSelfTotal float64 = 0 //治疗费用
  32346. var treatSelfTotal float64 = 0 //床位部分项目自费
  32347. var treatInscpTotal float64 = 0 //床位部分项目自费
  32348. decimal.DivisionPrecision = 2
  32349. for _, item := range orderInfos {
  32350. if item.MedChrgitmType == "01" { //床位费
  32351. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32352. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32353. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32354. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32355. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32356. }
  32357. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  32358. if item.MedChrgitmType == "03" { //检查费
  32359. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32360. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32361. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32362. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32363. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32364. }
  32365. } else {
  32366. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  32367. fmt.Println("------------")
  32368. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32369. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32370. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32371. }
  32372. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  32373. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32374. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32375. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32376. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32377. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32378. }
  32379. }
  32380. if item.MedChrgitmType == "04" { //化验费
  32381. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32382. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32383. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32384. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32385. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32386. }
  32387. if item.MedChrgitmType == "05" { //治疗费
  32388. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32389. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32390. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32391. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32392. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32393. }
  32394. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  32395. fmt.Println("------------")
  32396. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32397. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32398. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32399. }
  32400. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  32401. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32402. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32403. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32404. }
  32405. //if item.MedChrgitmType == "06" { //手术费
  32406. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32407. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32408. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32409. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32410. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32411. //
  32412. //}
  32413. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  32414. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32415. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32416. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32417. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32418. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32419. }
  32420. if item.MedChrgitmType == "09" { //西药费
  32421. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32422. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32423. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32424. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32425. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32426. }
  32427. if item.MedChrgitmType == "11" { //中成费
  32428. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32429. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32430. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32431. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32432. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32433. }
  32434. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  32435. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32436. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32437. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32438. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32439. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32440. }
  32441. }
  32442. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32443. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32444. var user_name string
  32445. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32446. if role.ID == 0 {
  32447. user_name = "管理员"
  32448. } else {
  32449. user_name = role.UserName
  32450. }
  32451. baseParams := models.BaseParams{
  32452. SecretKey: miConfig.SecretKey,
  32453. FixmedinsCode: miConfig.Code,
  32454. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  32455. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  32456. OrgName: miConfig.OrgName,
  32457. Doctor: user_name,
  32458. RequestUrl: miConfig.Url,
  32459. AccessKey: miConfig.AccessKey,
  32460. }
  32461. businessParams := models.BusinessParams{
  32462. PsnNo: order.PsnNo,
  32463. MdtrtId: order.MdtrtId,
  32464. SetlId: order.SetlId,
  32465. }
  32466. var res ResultEleven
  32467. var resEleven10265 ResultEleven10265
  32468. if config.IsOpen == 1 {
  32469. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  32470. result := service.Gdyb5203(baseParams, businessParams)
  32471. service.Gdyb5204(baseParams, businessParams)
  32472. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  32473. var dat map[string]interface{}
  32474. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32475. fmt.Println(dat)
  32476. } else {
  32477. fmt.Println(err)
  32478. }
  32479. userJSONBytes, _ := json.Marshal(dat)
  32480. if miConfig.Code == "H15049901371" {
  32481. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  32482. utils.ErrorLog("解析失败:%v", err)
  32483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32484. return
  32485. }
  32486. res.InfRefmsgid = resEleven10265.InfRefmsgid
  32487. res.Output = resEleven10265.Output
  32488. res.ErrMsg = resEleven10265.ErrMsg
  32489. res.Cainfo = resEleven10265.Cainfo
  32490. res.WarnMsg = resEleven10265.WarnMsg
  32491. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  32492. res.Infcode = infocode
  32493. } else {
  32494. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32495. utils.ErrorLog("解析失败:%v", err)
  32496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32497. return
  32498. }
  32499. }
  32500. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32501. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  32502. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  32503. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  32504. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  32505. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32506. var doctor_name string
  32507. if roles.ID == 0 {
  32508. doctor_name = "管理员"
  32509. } else {
  32510. doctor_name = roles.UserName
  32511. }
  32512. yiliao_leibie := ""
  32513. switch order.MedType {
  32514. case "11":
  32515. yiliao_leibie = "普通门诊"
  32516. break
  32517. case "12":
  32518. yiliao_leibie = "门诊挂号"
  32519. break
  32520. case "13":
  32521. yiliao_leibie = "急诊"
  32522. break
  32523. case "14":
  32524. yiliao_leibie = "门诊特殊病"
  32525. break
  32526. case "15":
  32527. yiliao_leibie = "门诊统筹"
  32528. break
  32529. case "16":
  32530. yiliao_leibie = "门诊慢性病"
  32531. break
  32532. case "21":
  32533. yiliao_leibie = "普通住院"
  32534. break
  32535. }
  32536. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  32537. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  32538. if res.Infcode == 0 {
  32539. data2 := map[string]interface{}{
  32540. "diagnosis": name,
  32541. "order_infos": orderInfos,
  32542. "number": order.MdtrtId,
  32543. "date": order.SettleAccountsDate,
  32544. "charge_admin": charge_admin,
  32545. "printor_admin": printor_admin,
  32546. "info": res.Output.Setlinfo,
  32547. "order": order,
  32548. "bedCostTotal": bedCostTotal,
  32549. "bedCostSelfTotal": bedCostSelfTotal,
  32550. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  32551. "bedSelfTotal": bedSelfTotal,
  32552. "bedInscpTotal": bedInscpTotal,
  32553. "operationCostTotal": operationCostTotal,
  32554. "operationCostSelfTotal": operationCostSelfTotal,
  32555. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  32556. "operationSelfTotal": operationSelfTotal,
  32557. "operationInscpTotal": operationInscpTotal,
  32558. "otherCostTotal": otherCostTotal,
  32559. "otherCostSelfTotal": otherCostSelfTotal,
  32560. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  32561. "otherSelfTotal": otherSelfTotal,
  32562. "otherInscpTotal": otherInscpTotal,
  32563. "materialCostTotal": materialCostTotal,
  32564. "materialCostSelfTotal": materialCostSelfTotal,
  32565. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  32566. "materialSelfTotal": materialSelfTotal,
  32567. "materialInscpTotal": materialInscpTotal,
  32568. "westernMedicineCostTotal": westernMedicineCostTotal,
  32569. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  32570. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  32571. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  32572. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  32573. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  32574. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  32575. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  32576. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  32577. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  32578. "checkCostTotal": checkCostTotal,
  32579. "checkCostSelfTotal": checkCostSelfTotal,
  32580. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  32581. "checkSelfTotal": checkSelfTotal,
  32582. "checkInscpTotal": checkInscpTotal,
  32583. "laboratoryCostTotal": laboratoryCostTotal,
  32584. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  32585. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  32586. "laboratorySelfTotal": laboratorySelfTotal,
  32587. "laboratoryInscpTotal": laboratoryInscpTotal,
  32588. "treatCostTotal": treatCostTotal,
  32589. "treatCostSelfTotal": treatCostSelfTotal,
  32590. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  32591. "treatSelfTotal": treatSelfTotal,
  32592. "treatInscpTotal": treatInscpTotal,
  32593. "doctor_info": doctor_info,
  32594. "doctor_code": adminRole_two.DoctorCode,
  32595. "doctor_name": doctor_name,
  32596. "health_card_no": order.PsnNo,
  32597. "department": departments.Name,
  32598. "yiliao_leibie": yiliao_leibie,
  32599. "after_money": order.AccountPrice,
  32600. "patient": patient,
  32601. "org_name": miConfig.OrgName,
  32602. "org_code": miConfig.Code,
  32603. "order_number": order.Number,
  32604. "his_hospital": his_hospital,
  32605. "his": his,
  32606. "dia_config": dia_config,
  32607. "psn_cash_pay": order.PsnCashPay,
  32608. //"check_order_info": cus_slice,
  32609. }
  32610. data3 = append(data3, data2)
  32611. }
  32612. }
  32613. }
  32614. c.ServeSuccessJSON(map[string]interface{}{
  32615. "infos": data3,
  32616. })
  32617. }
  32618. func (c *HisApiController) GetSettleAccounts() {
  32619. //id, _ := c.GetInt64("id")
  32620. //record_time := c.GetString("record_time")
  32621. order_id, _ := c.GetInt64("order_id")
  32622. admin_user_id, _ := c.GetInt64("admin_user_id")
  32623. //timeLayout := "2006-01-02"
  32624. //loc, _ := time.LoadLocation("Local")
  32625. //
  32626. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32627. //if err != nil {
  32628. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32629. // return
  32630. //}Hbyb5203
  32631. //recordDateTime := theTime.Unix()
  32632. adminUser := c.GetAdminUserInfo()
  32633. order, _ := service.GetHisOrderByID(order_id)
  32634. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32635. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  32636. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  32637. orderInfos = append(orderInfos, orderInfos_two...)
  32638. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  32639. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  32640. var diagnosis_ids []string
  32641. if his.ID > 0 {
  32642. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  32643. } else {
  32644. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  32645. }
  32646. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  32647. var dia_config []*models.HisXtDiagnoseConfig
  32648. var name string
  32649. for _, item := range diagnosis_ids {
  32650. id, _ := strconv.ParseInt(item, 10, 64)
  32651. diagnosisConfig, _ := service.FindDiagnoseById(id)
  32652. dia_config = append(dia_config, &diagnosisConfig)
  32653. if len(name) == 0 {
  32654. name = diagnosisConfig.ClassName
  32655. } else {
  32656. name = name + "," + diagnosisConfig.ClassName
  32657. }
  32658. }
  32659. if patient.UserOrgId == 10215 {
  32660. name = "慢性肾功能不全(血透治疗)"
  32661. }
  32662. var bedCostTotal float64 = 0 //床位总费
  32663. var bedCostSelfTotal float64 = 0 //床位自费
  32664. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  32665. var bedSelfTotal float64 = 0 //床位部分项目自费
  32666. var bedInscpTotal float64 = 0 //床位部分项目自费
  32667. var operationCostTotal float64 = 0 //手术费
  32668. var operationCostSelfTotal float64 = 0 //手术费
  32669. var operationCostPartSelfTotal float64 = 0 //手术费
  32670. var operationSelfTotal float64 = 0 //床位部分项目自费
  32671. var operationInscpTotal float64 = 0 //床位部分项目自费
  32672. var otherCostTotal float64 = 0 //其他费用
  32673. var otherCostSelfTotal float64 = 0 //其他费用
  32674. var otherCostPartSelfTotal float64 = 0 //其他费用
  32675. var otherSelfTotal float64 = 0 //床位部分项目自费
  32676. var otherInscpTotal float64 = 0 //床位部分项目自费
  32677. var materialCostTotal float64 = 0 //材料费
  32678. var materialCostSelfTotal float64 = 0 //材料费
  32679. var materialCostPartSelfTotal float64 = 0 //材料费
  32680. var materialSelfTotal float64 = 0 //床位部分项目自费
  32681. var materialInscpTotal float64 = 0 //床位部分项目自费
  32682. var westernMedicineCostTotal float64 = 0 //西药费
  32683. var westernMedicineCostSelfTotal float64 = 0 //西药费
  32684. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  32685. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  32686. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  32687. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  32688. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  32689. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  32690. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  32691. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  32692. var checkCostTotal float64 = 0 //检查费
  32693. var checkCostSelfTotal float64 = 0 //检查费
  32694. var checkCostPartSelfTotal float64 = 0 //检查费
  32695. var checkSelfTotal float64 = 0 //床位部分项目自费
  32696. var checkInscpTotal float64 = 0 //床位部分项目自费
  32697. var laboratoryCostTotal float64 = 0 //化验费
  32698. var laboratoryCostSelfTotal float64 = 0 //化验费
  32699. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  32700. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  32701. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  32702. var treatCostTotal float64 = 0 //治疗费用
  32703. var treatCostSelfTotal float64 = 0 //治疗费用
  32704. var treatCostPartSelfTotal float64 = 0 //治疗费用
  32705. var treatSelfTotal float64 = 0 //床位部分项目自费
  32706. var treatInscpTotal float64 = 0 //床位部分项目自费
  32707. var zcCostTotal float64 = 0 //治疗费用
  32708. var zcCostSelfTotal float64 = 0 //治疗费用
  32709. var zcCostPartSelfTotal float64 = 0 //治疗费用
  32710. var zcSelfTotal float64 = 0 //床位部分项目自费
  32711. var zcInscpTotal float64 = 0 //床位部分项目自费
  32712. var huliCostTotal float64 = 0 //治疗费用
  32713. var huliCostSelfTotal float64 = 0 //治疗费用
  32714. var huliCostPartSelfTotal float64 = 0 //治疗费用
  32715. var huliSelfTotal float64 = 0 //床位部分项目自费
  32716. var huliInscpTotal float64 = 0 //床位部分项目自费
  32717. decimal.DivisionPrecision = 2
  32718. for _, item := range orderInfos {
  32719. if item.MedChrgitmType == "01" { //床位费
  32720. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32721. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32722. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32723. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32724. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32725. }
  32726. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  32727. if item.MedChrgitmType == "03" { //检查费
  32728. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32729. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32730. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32731. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32732. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32733. }
  32734. } else {
  32735. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  32736. fmt.Println("------------")
  32737. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32738. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32739. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32740. }
  32741. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  32742. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32743. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32744. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32745. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32746. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32747. }
  32748. }
  32749. if item.MedChrgitmType == "04" { //化验费
  32750. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32751. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32752. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32753. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32754. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32755. }
  32756. if item.MedChrgitmType == "05" { //治疗费
  32757. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32758. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32759. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32760. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32761. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32762. }
  32763. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  32764. fmt.Println("------------")
  32765. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32766. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32767. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32768. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32769. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32770. }
  32771. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  32772. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32773. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32774. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32775. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32776. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32777. }
  32778. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  32779. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32780. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32781. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32782. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32783. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32784. }
  32785. if item.MedChrgitmType == "09" { //西药费
  32786. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32787. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32788. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32789. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32790. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32791. }
  32792. if item.MedChrgitmType == "11" { //中成费
  32793. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32794. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32795. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32796. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32797. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32798. }
  32799. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  32800. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32801. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32802. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32803. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32804. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32805. }
  32806. if item.MedChrgitmType == "02" { //其他费
  32807. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32808. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32809. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32810. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32811. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32812. }
  32813. if item.MedChrgitmType == "07" { //其他费
  32814. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  32815. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  32816. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  32817. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  32818. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  32819. }
  32820. }
  32821. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32822. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32823. var user_name string
  32824. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32825. if role.ID == 0 {
  32826. user_name = "管理员"
  32827. } else {
  32828. user_name = role.UserName
  32829. }
  32830. baseParams := models.BaseParams{
  32831. SecretKey: miConfig.SecretKey,
  32832. FixmedinsCode: miConfig.Code,
  32833. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  32834. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  32835. OrgName: miConfig.OrgName,
  32836. Doctor: user_name,
  32837. RequestUrl: miConfig.Url,
  32838. AccessKey: miConfig.AccessKey,
  32839. }
  32840. businessParams := models.BusinessParams{
  32841. PsnNo: order.PsnNo,
  32842. MdtrtId: order.MdtrtId,
  32843. SetlId: order.SetlId,
  32844. }
  32845. var res ResultEleven
  32846. var resah ResultElevenah
  32847. var resEleven10265 ResultEleven10265
  32848. if config.IsOpen == 1 {
  32849. if miConfig.MdtrtareaAdmvs == "421300" {
  32850. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  32851. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  32852. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32853. resp, requestErr := http.Get(api)
  32854. if requestErr != nil {
  32855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32856. return
  32857. }
  32858. body, ioErr := ioutil.ReadAll(resp.Body)
  32859. if ioErr != nil {
  32860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32862. return
  32863. }
  32864. var respJSON map[string]interface{}
  32865. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32868. return
  32869. }
  32870. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32871. result, _ := json.Marshal(respJSON)
  32872. fmt.Println("log")
  32873. fmt.Println(string(result))
  32874. if err := json.Unmarshal([]byte(result), &res); err != nil {
  32875. utils.ErrorLog("解析失败:%v", err)
  32876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32877. return
  32878. }
  32879. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32880. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  32881. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  32882. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32883. resp, requestErr := http.Get(api)
  32884. if requestErr != nil {
  32885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32886. return
  32887. }
  32888. body, ioErr := ioutil.ReadAll(resp.Body)
  32889. if ioErr != nil {
  32890. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32892. return
  32893. }
  32894. var respJSON map[string]interface{}
  32895. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32898. return
  32899. }
  32900. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32901. result, _ := json.Marshal(respJSON)
  32902. fmt.Println("log")
  32903. fmt.Println(string(result))
  32904. if err := json.Unmarshal([]byte(result), &res); err != nil {
  32905. utils.ErrorLog("解析失败:%v", err)
  32906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32907. return
  32908. }
  32909. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32910. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  32911. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  32912. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32913. resp, requestErr := http.Get(api)
  32914. if requestErr != nil {
  32915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32916. return
  32917. }
  32918. body, ioErr := ioutil.ReadAll(resp.Body)
  32919. if ioErr != nil {
  32920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32922. return
  32923. }
  32924. var respJSON map[string]interface{}
  32925. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32928. return
  32929. }
  32930. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32931. result, _ := json.Marshal(respJSON)
  32932. fmt.Println("log")
  32933. fmt.Println(string(result))
  32934. if err := json.Unmarshal([]byte(result), &res); err != nil {
  32935. utils.ErrorLog("解析失败:%v", err)
  32936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32937. return
  32938. }
  32939. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32940. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  32941. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  32942. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  32943. resp, requestErr := http.Get(api)
  32944. if requestErr != nil {
  32945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32946. return
  32947. }
  32948. body, ioErr := ioutil.ReadAll(resp.Body)
  32949. if ioErr != nil {
  32950. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32952. return
  32953. }
  32954. var respJSON map[string]interface{}
  32955. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32958. return
  32959. }
  32960. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32961. result, _ := json.Marshal(respJSON)
  32962. fmt.Println("log")
  32963. fmt.Println(string(result))
  32964. if err := json.Unmarshal([]byte(result), &res); err != nil {
  32965. utils.ErrorLog("解析失败:%v", err)
  32966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32967. return
  32968. }
  32969. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32970. var api string
  32971. if miConfig.MdtrtareaAdmvs == "320921" {
  32972. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  32973. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  32974. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32975. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32976. } else {
  32977. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32978. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  32979. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  32980. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32981. }
  32982. resp, requestErr := http.Get(api)
  32983. if requestErr != nil {
  32984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32985. return
  32986. }
  32987. body, ioErr := ioutil.ReadAll(resp.Body)
  32988. if ioErr != nil {
  32989. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32991. return
  32992. }
  32993. var respJSON map[string]interface{}
  32994. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32997. return
  32998. }
  32999. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33000. result, _ := json.Marshal(respJSON)
  33001. fmt.Println("log")
  33002. fmt.Println(string(result))
  33003. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  33004. utils.ErrorLog("解析失败:%v", err)
  33005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33006. return
  33007. }
  33008. res.InfRefmsgid = resEleven10265.InfRefmsgid
  33009. res.Output = resEleven10265.Output
  33010. res.ErrMsg = resEleven10265.ErrMsg
  33011. res.Cainfo = resEleven10265.Cainfo
  33012. res.WarnMsg = resEleven10265.WarnMsg
  33013. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  33014. res.Infcode = infocode
  33015. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33016. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  33017. saveLog(result, requestLog, "5203", "结算单")
  33018. var dat map[string]interface{}
  33019. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33020. fmt.Println(dat)
  33021. } else {
  33022. fmt.Println(err)
  33023. }
  33024. userJSONBytes, _ := json.Marshal(dat)
  33025. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33026. utils.ErrorLog("解析失败:%v", err)
  33027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33028. return
  33029. }
  33030. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33031. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  33032. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  33033. fmt.Println(result3)
  33034. fmt.Println(requestLog3)
  33035. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  33036. fmt.Println(result2)
  33037. fmt.Println(requestLog2)
  33038. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  33039. saveLog(result, requestLog, "5203", "结算单")
  33040. var dat map[string]interface{}
  33041. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33042. fmt.Println(dat)
  33043. } else {
  33044. fmt.Println(err)
  33045. }
  33046. userJSONBytes, _ := json.Marshal(dat)
  33047. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33048. utils.ErrorLog("解析失败:%v", err)
  33049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33050. return
  33051. }
  33052. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33053. var api string
  33054. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  33055. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  33056. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33057. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33058. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33059. resp, requestErr := http.Get(api)
  33060. if requestErr != nil {
  33061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33062. return
  33063. }
  33064. body, ioErr := ioutil.ReadAll(resp.Body)
  33065. if ioErr != nil {
  33066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33068. return
  33069. }
  33070. var respJSON map[string]interface{}
  33071. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33074. return
  33075. }
  33076. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33077. if status == "0" {
  33078. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33079. c.ServeSuccessJSON(map[string]interface{}{
  33080. "failed_code": -10,
  33081. "msg": err_msg,
  33082. })
  33083. return
  33084. }
  33085. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33086. result, _ := json.Marshal(respJSON)
  33087. fmt.Println("log")
  33088. fmt.Println(string(result))
  33089. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  33090. utils.ErrorLog("解析失败:%v", err)
  33091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33092. return
  33093. }
  33094. res.InfRefmsgid = resah.InfRefmsgid
  33095. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33096. // 创建对应的Time类型
  33097. t := time.UnixMilli(timestamp)
  33098. // 格式化成指定的日期字符串
  33099. str := t.Format("2006-01-02 15:04:05")
  33100. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33101. // 创建对应的Time类型
  33102. t3 := time.UnixMilli(timestamp2)
  33103. // 格式化成指定的日期字符串
  33104. str2 := t3.Format("2006-01-02 15:04:05")
  33105. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  33106. // 创建对应的Time类型
  33107. t4 := time.UnixMilli(timestamp3)
  33108. // 格式化成指定的日期字符串
  33109. str3 := t4.Format("2006-01-02 15:04:05")
  33110. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  33111. // 创建对应的Time类型
  33112. t5 := time.UnixMilli(timestamp4)
  33113. // 格式化成指定的日期字符串
  33114. str5 := t5.Format("2006-01-02 15:04:05")
  33115. res.Output.Setlinfo.Brdy = str2
  33116. res.Output.Setlinfo.SetlTime = str
  33117. res.Output.Setlinfo.Begndate = str3
  33118. res.Output.Setlinfo.Enddate = str5
  33119. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  33120. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  33121. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  33122. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  33123. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  33124. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  33125. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  33126. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  33127. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  33128. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  33129. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  33130. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  33131. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33132. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  33133. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  33134. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  33135. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  33136. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  33137. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  33138. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  33139. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  33140. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  33141. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  33142. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  33143. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  33144. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33145. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  33146. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  33147. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  33148. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  33149. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33150. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  33151. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  33152. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  33153. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  33154. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  33155. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  33156. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  33157. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  33158. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  33159. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  33160. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  33161. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  33162. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  33163. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  33164. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33165. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  33166. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  33167. //res.Output.Setldetail = resah.Output.Setldetail
  33168. res.ErrMsg = resah.ErrMsg
  33169. res.Cainfo = resah.Cainfo
  33170. res.WarnMsg = resah.WarnMsg
  33171. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33172. var api string
  33173. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  33174. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  33175. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33176. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33177. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33178. resp, requestErr := http.Get(api)
  33179. if requestErr != nil {
  33180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33181. return
  33182. }
  33183. body, ioErr := ioutil.ReadAll(resp.Body)
  33184. if ioErr != nil {
  33185. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33187. return
  33188. }
  33189. var respJSON map[string]interface{}
  33190. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33193. return
  33194. }
  33195. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33196. if status == "0" {
  33197. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33198. c.ServeSuccessJSON(map[string]interface{}{
  33199. "failed_code": -10,
  33200. "msg": err_msg,
  33201. })
  33202. return
  33203. }
  33204. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33205. result, _ := json.Marshal(respJSON)
  33206. fmt.Println("log")
  33207. fmt.Println(string(result))
  33208. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  33209. utils.ErrorLog("解析失败:%v", err)
  33210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33211. return
  33212. }
  33213. res.InfRefmsgid = resah.InfRefmsgid
  33214. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33215. // 创建对应的Time类型
  33216. t := time.UnixMilli(timestamp)
  33217. // 格式化成指定的日期字符串
  33218. str := t.Format("2006-01-02 15:04:05")
  33219. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33220. // 创建对应的Time类型
  33221. t3 := time.UnixMilli(timestamp2)
  33222. // 格式化成指定的日期字符串
  33223. str2 := t3.Format("2006-01-02 15:04:05")
  33224. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  33225. // 创建对应的Time类型
  33226. t4 := time.UnixMilli(timestamp3)
  33227. // 格式化成指定的日期字符串
  33228. str3 := t4.Format("2006-01-02 15:04:05")
  33229. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  33230. // 创建对应的Time类型
  33231. t5 := time.UnixMilli(timestamp4)
  33232. // 格式化成指定的日期字符串
  33233. str5 := t5.Format("2006-01-02 15:04:05")
  33234. res.Output.Setlinfo.Brdy = str2
  33235. res.Output.Setlinfo.SetlTime = str
  33236. res.Output.Setlinfo.Begndate = str3
  33237. res.Output.Setlinfo.Enddate = str5
  33238. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  33239. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  33240. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  33241. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  33242. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  33243. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  33244. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  33245. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  33246. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  33247. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  33248. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  33249. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  33250. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33251. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  33252. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  33253. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  33254. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  33255. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  33256. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  33257. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  33258. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  33259. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  33260. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  33261. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  33262. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  33263. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33264. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  33265. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  33266. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  33267. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  33268. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33269. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  33270. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  33271. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  33272. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  33273. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  33274. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  33275. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  33276. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  33277. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  33278. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  33279. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  33280. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  33281. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  33282. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  33283. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33284. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  33285. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  33286. //res.Output.Setldetail = resah.Output.Setldetail
  33287. res.ErrMsg = resah.ErrMsg
  33288. res.Cainfo = resah.Cainfo
  33289. res.WarnMsg = resah.WarnMsg
  33290. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33291. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  33292. saveLog(result, requestLog, "5203", "结算单")
  33293. var dat map[string]interface{}
  33294. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33295. fmt.Println(dat)
  33296. } else {
  33297. fmt.Println(err)
  33298. }
  33299. userJSONBytes, _ := json.Marshal(dat)
  33300. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33301. utils.ErrorLog("解析失败:%v", err)
  33302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33303. return
  33304. }
  33305. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33306. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  33307. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  33308. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33309. resp, requestErr := http.Get(api)
  33310. if requestErr != nil {
  33311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33312. return
  33313. }
  33314. body, ioErr := ioutil.ReadAll(resp.Body)
  33315. if ioErr != nil {
  33316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33318. return
  33319. }
  33320. var respJSON map[string]interface{}
  33321. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33324. return
  33325. }
  33326. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33327. result, _ := json.Marshal(respJSON)
  33328. fmt.Println("log")
  33329. fmt.Println(string(result))
  33330. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  33331. utils.ErrorLog("解析失败:%v", err)
  33332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33333. return
  33334. }
  33335. res.InfRefmsgid = resEleven10265.InfRefmsgid
  33336. res.Output = resEleven10265.Output
  33337. res.ErrMsg = resEleven10265.ErrMsg
  33338. res.Cainfo = resEleven10265.Cainfo
  33339. res.WarnMsg = resEleven10265.WarnMsg
  33340. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  33341. res.Infcode = infocode
  33342. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33343. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  33344. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  33345. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33346. resp, requestErr := http.Get(api)
  33347. if requestErr != nil {
  33348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33349. return
  33350. }
  33351. body, ioErr := ioutil.ReadAll(resp.Body)
  33352. if ioErr != nil {
  33353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33355. return
  33356. }
  33357. var respJSON map[string]interface{}
  33358. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33361. return
  33362. }
  33363. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33364. result, _ := json.Marshal(respJSON)
  33365. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33366. utils.ErrorLog("解析失败:%v", err)
  33367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33368. return
  33369. }
  33370. } else if miConfig.MdtrtareaAdmvs == "450721" {
  33371. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  33372. //return
  33373. } else {
  33374. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  33375. if len(his.InsuplcAdmdvs) == 0 {
  33376. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33377. } else {
  33378. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  33379. }
  33380. result := service.Gdyb5203(baseParams, businessParams)
  33381. //service.Gdyb5204(baseParams, businessParams)
  33382. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  33383. var dat map[string]interface{}
  33384. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33385. fmt.Println(dat)
  33386. } else {
  33387. fmt.Println(err)
  33388. }
  33389. userJSONBytes, _ := json.Marshal(dat)
  33390. if miConfig.Code == "H15049901371" {
  33391. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  33392. utils.ErrorLog("解析失败:%v", err)
  33393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33394. return
  33395. }
  33396. res.InfRefmsgid = resEleven10265.InfRefmsgid
  33397. res.Output = resEleven10265.Output
  33398. res.ErrMsg = resEleven10265.ErrMsg
  33399. res.Cainfo = resEleven10265.Cainfo
  33400. res.WarnMsg = resEleven10265.WarnMsg
  33401. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  33402. res.Infcode = infocode
  33403. } else {
  33404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33405. utils.ErrorLog("解析失败:%v", err)
  33406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33407. return
  33408. }
  33409. }
  33410. }
  33411. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33412. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  33413. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  33414. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  33415. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  33416. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33417. var doctor_name string
  33418. if roles.ID == 0 {
  33419. doctor_name = "管理员"
  33420. } else {
  33421. doctor_name = roles.UserName
  33422. }
  33423. yiliao_leibie := ""
  33424. switch order.MedType {
  33425. case "11":
  33426. yiliao_leibie = "普通门诊"
  33427. break
  33428. case "12":
  33429. yiliao_leibie = "门诊挂号"
  33430. break
  33431. case "13":
  33432. yiliao_leibie = "急诊"
  33433. break
  33434. case "14":
  33435. yiliao_leibie = "门诊特殊病"
  33436. break
  33437. case "15":
  33438. yiliao_leibie = "门诊统筹"
  33439. break
  33440. case "16":
  33441. yiliao_leibie = "门诊慢性病"
  33442. break
  33443. case "21":
  33444. yiliao_leibie = "普通住院"
  33445. break
  33446. }
  33447. //var rf []CustomFundPay
  33448. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  33449. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  33450. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  33451. if res.Infcode == 0 {
  33452. 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 {
  33453. c.ServeSuccessJSON(map[string]interface{}{
  33454. "diagnosis": name,
  33455. "order_infos": orderInfos,
  33456. "number": order.MdtrtId,
  33457. "date": order.SettleAccountsDate,
  33458. "charge_admin": charge_admin,
  33459. "printor_admin": printor_admin,
  33460. "info": res.Output.Setlinfo,
  33461. "order": order,
  33462. "bedCostTotal": bedCostTotal,
  33463. "bedCostSelfTotal": bedCostSelfTotal,
  33464. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  33465. "bedSelfTotal": bedSelfTotal,
  33466. "bedInscpTotal": bedInscpTotal,
  33467. "operationCostTotal": operationCostTotal,
  33468. "operationCostSelfTotal": operationCostSelfTotal,
  33469. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  33470. "operationSelfTotal": operationSelfTotal,
  33471. "operationInscpTotal": operationInscpTotal,
  33472. "otherCostTotal": otherCostTotal,
  33473. "otherCostSelfTotal": otherCostSelfTotal,
  33474. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  33475. "otherSelfTotal": otherSelfTotal,
  33476. "otherInscpTotal": otherInscpTotal,
  33477. "materialCostTotal": materialCostTotal,
  33478. "materialCostSelfTotal": materialCostSelfTotal,
  33479. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  33480. "materialSelfTotal": materialSelfTotal,
  33481. "materialInscpTotal": materialInscpTotal,
  33482. "westernMedicineCostTotal": westernMedicineCostTotal,
  33483. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  33484. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  33485. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  33486. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  33487. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  33488. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  33489. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  33490. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  33491. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  33492. "checkCostTotal": checkCostTotal,
  33493. "checkCostSelfTotal": checkCostSelfTotal,
  33494. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  33495. "checkSelfTotal": checkSelfTotal,
  33496. "checkInscpTotal": checkInscpTotal,
  33497. "laboratoryCostTotal": laboratoryCostTotal,
  33498. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  33499. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  33500. "laboratorySelfTotal": laboratorySelfTotal,
  33501. "laboratoryInscpTotal": laboratoryInscpTotal,
  33502. "treatCostTotal": treatCostTotal,
  33503. "treatCostSelfTotal": treatCostSelfTotal,
  33504. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  33505. "treatSelfTotal": treatSelfTotal,
  33506. "treatInscpTotal": treatInscpTotal,
  33507. "doctor_info": doctor_info,
  33508. "doctor_code": adminRole_two.DoctorCode,
  33509. "doctor_name": doctor_name,
  33510. "health_card_no": order.PsnNo,
  33511. "department": departments.Name,
  33512. "yiliao_leibie": yiliao_leibie,
  33513. "after_money": order.AccountPrice,
  33514. "patient": patient,
  33515. "org_name": miConfig.OrgName,
  33516. "org_code": miConfig.Code,
  33517. "order_number": order.Number,
  33518. "his_hospital": his_hospital,
  33519. "his": his,
  33520. "dia_config": dia_config,
  33521. "psn_cash_pay": order.PsnCashPay,
  33522. "zcCostTotal": zcCostTotal,
  33523. "zcCostSelfTotal": zcCostSelfTotal,
  33524. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  33525. "zcSelfTotal": zcSelfTotal,
  33526. "zcInscpTotal": zcInscpTotal,
  33527. "huliCostTotal": huliCostTotal,
  33528. "huliCostSelfTotal": huliCostSelfTotal,
  33529. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  33530. "huliSelfTotal": huliSelfTotal,
  33531. "huliInscpTotal": huliInscpTotal,
  33532. //"funds": rf,
  33533. //"check_order_info": cus_slice,
  33534. })
  33535. } else {
  33536. c.ServeSuccessJSON(map[string]interface{}{
  33537. "diagnosis": name,
  33538. "order_infos": orderInfos,
  33539. "number": order.MdtrtId,
  33540. "date": order.SettleAccountsDate,
  33541. "charge_admin": charge_admin,
  33542. "printor_admin": printor_admin,
  33543. "info": order,
  33544. "order": order,
  33545. "bedCostTotal": bedCostTotal,
  33546. "bedCostSelfTotal": bedCostSelfTotal,
  33547. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  33548. "bedSelfTotal": bedSelfTotal,
  33549. "bedInscpTotal": bedInscpTotal,
  33550. "operationCostTotal": operationCostTotal,
  33551. "operationCostSelfTotal": operationCostSelfTotal,
  33552. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  33553. "operationSelfTotal": operationSelfTotal,
  33554. "operationInscpTotal": operationInscpTotal,
  33555. "otherCostTotal": otherCostTotal,
  33556. "otherCostSelfTotal": otherCostSelfTotal,
  33557. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  33558. "otherSelfTotal": otherSelfTotal,
  33559. "otherInscpTotal": otherInscpTotal,
  33560. "materialCostTotal": materialCostTotal,
  33561. "materialCostSelfTotal": materialCostSelfTotal,
  33562. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  33563. "materialSelfTotal": materialSelfTotal,
  33564. "materialInscpTotal": materialInscpTotal,
  33565. "westernMedicineCostTotal": westernMedicineCostTotal,
  33566. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  33567. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  33568. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  33569. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  33570. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  33571. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  33572. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  33573. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  33574. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  33575. "checkCostTotal": checkCostTotal,
  33576. "checkCostSelfTotal": checkCostSelfTotal,
  33577. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  33578. "checkSelfTotal": checkSelfTotal,
  33579. "checkInscpTotal": checkInscpTotal,
  33580. "laboratoryCostTotal": laboratoryCostTotal,
  33581. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  33582. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  33583. "laboratorySelfTotal": laboratorySelfTotal,
  33584. "laboratoryInscpTotal": laboratoryInscpTotal,
  33585. "treatCostTotal": treatCostTotal,
  33586. "treatCostSelfTotal": treatCostSelfTotal,
  33587. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  33588. "treatSelfTotal": treatSelfTotal,
  33589. "treatInscpTotal": treatInscpTotal,
  33590. "doctor_info": doctor_info,
  33591. "doctor_code": adminRole_two.DoctorCode,
  33592. "doctor_name": doctor_name,
  33593. "health_card_no": order.PsnNo,
  33594. "department": departments.Name,
  33595. "yiliao_leibie": yiliao_leibie,
  33596. "after_money": order.AccountPrice,
  33597. "patient": patient,
  33598. "org_name": miConfig.OrgName,
  33599. "org_code": miConfig.Code,
  33600. "order_number": order.Number,
  33601. "his_hospital": his_hospital,
  33602. "his": his,
  33603. "dia_config": dia_config,
  33604. "psn_cash_pay": order.PsnCashPay,
  33605. "zcCostTotal": zcCostTotal,
  33606. "zcCostSelfTotal": zcCostSelfTotal,
  33607. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  33608. "zcSelfTotal": zcSelfTotal,
  33609. "zcInscpTotal": zcInscpTotal,
  33610. "huliCostTotal": huliCostTotal,
  33611. "huliCostSelfTotal": huliCostSelfTotal,
  33612. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  33613. "huliSelfTotal": huliSelfTotal,
  33614. "huliInscpTotal": huliInscpTotal,
  33615. //"funds": rf,
  33616. //"check_order_info": cus_slice,
  33617. })
  33618. }
  33619. }
  33620. }
  33621. }
  33622. //func (c *HisApiController) CheckTreatment() {
  33623. // patient_id, _ := c.GetInt64("patient_id")
  33624. // id_card_no := c.GetString("id_card_no")
  33625. // insutype := c.GetString("insutype")
  33626. // med_type := c.GetString("med_type")
  33627. // admin_user_id, _ := c.GetInt64("admin_user_id")
  33628. //
  33629. // adminUser := c.GetAdminUserInfo()
  33630. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  33631. //
  33632. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33633. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33634. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33635. //
  33636. // if miConfig.MdtrtareaAdmvs == "421300" {
  33637. // var res ResultTwo
  33638. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  33639. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  33640. // "&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)
  33641. // resp, requestErr := http.Get(api)
  33642. // if requestErr != nil {
  33643. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33644. // return
  33645. // }
  33646. //
  33647. // body, ioErr := ioutil.ReadAll(resp.Body)
  33648. // if ioErr != nil {
  33649. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33651. // return
  33652. // }
  33653. // var respJSON map[string]interface{}
  33654. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33655. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33656. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33657. // return
  33658. // }
  33659. //
  33660. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33661. // result, _ := json.Marshal(respJSON)
  33662. //
  33663. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  33664. // utils.ErrorLog("解析失败:%v", err)
  33665. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33666. // return
  33667. // }
  33668. //
  33669. // if res.Infcode == 0 {
  33670. //
  33671. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  33672. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  33673. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  33674. // resp, requestErr := http.Get(api)
  33675. // if requestErr != nil {
  33676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33677. // return
  33678. // }
  33679. //
  33680. // body, ioErr := ioutil.ReadAll(resp.Body)
  33681. // if ioErr != nil {
  33682. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33683. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33684. // return
  33685. // }
  33686. // var respJSON map[string]interface{}
  33687. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33688. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33689. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33690. // return
  33691. // }
  33692. // var res Result2001
  33693. //
  33694. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33695. // result2, _ := json.Marshal(respJSON)
  33696. //
  33697. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  33698. // utils.ErrorLog("解析失败:%v", err)
  33699. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33700. // return
  33701. // }
  33702. //
  33703. // if res.Infcode == 0 {
  33704. // c.ServeSuccessJSON(map[string]interface{}{
  33705. // "msg": res.Output.Trtinfo,
  33706. // })
  33707. // }
  33708. //
  33709. // } else {
  33710. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  33711. // return
  33712. // }
  33713. //
  33714. // } else {
  33715. //
  33716. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  33717. // var dat map[string]interface{}
  33718. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33719. // fmt.Println(dat)
  33720. // } else {
  33721. // fmt.Println(err)
  33722. // }
  33723. // userJSONBytes, _ := json.Marshal(dat)
  33724. // var res ResultTwo
  33725. // var res10265 ResultTwo10265
  33726. // if miConfig.Code == "H15049901371" {
  33727. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  33728. // utils.ErrorLog("解析失败:%v", err)
  33729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33730. // return
  33731. // }
  33732. // res.ErrMsg = res10265.ErrMsg
  33733. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  33734. // res.Infcode = infocode
  33735. // res.Output = res10265.Output
  33736. // res.InfRefmsgid = res10265.InfRefmsgid
  33737. // } else {
  33738. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33739. // utils.ErrorLog("解析失败:%v", err)
  33740. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33741. // return
  33742. // }
  33743. // }
  33744. //
  33745. // var user_name string
  33746. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  33747. // if role.ID == 0 {
  33748. // user_name = "xxx"
  33749. // } else {
  33750. // user_name = role.UserName
  33751. // }
  33752. //
  33753. // baseParams := models.BaseParams{
  33754. // SecretKey: miConfig.SecretKey,
  33755. // FixmedinsCode: miConfig.Code,
  33756. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  33757. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  33758. // OrgName: miConfig.OrgName,
  33759. // Doctor: user_name,
  33760. // }
  33761. //
  33762. // if config.IsOpen == 1 {
  33763. // if miConfig.Code == "H15049901371" {
  33764. // if med_type == "14" {
  33765. // if insutype == "390" {
  33766. // med_type = "9933"
  33767. // } else if insutype == "310" {
  33768. // med_type = "990502"
  33769. // }
  33770. // } else if med_type == "11" {
  33771. // med_type = "11"
  33772. // }
  33773. // }
  33774. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  33775. // var dat map[string]interface{}
  33776. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33777. // fmt.Println(dat)
  33778. // } else {
  33779. // fmt.Println(err)
  33780. // }
  33781. // var res Result2001
  33782. // var res10265 Result2001Org10265
  33783. // if miConfig.Code == "H15049901371" {
  33784. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  33785. // utils.ErrorLog("解析失败:%v", err)
  33786. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33787. // return
  33788. // }
  33789. // res.ErrMsg = res10265.ErrMsg
  33790. // res.Output = res10265.Output
  33791. // res.InfRefmsgid = res10265.InfRefmsgid
  33792. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  33793. // res.Infcode = infocode
  33794. // } else {
  33795. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  33796. // utils.ErrorLog("解析失败:%v", err)
  33797. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33798. // return
  33799. // }
  33800. // }
  33801. // if res.Infcode == 0 {
  33802. // c.ServeSuccessJSON(map[string]interface{}{
  33803. // "msg": res.Output.Trtinfo,
  33804. // })
  33805. // }
  33806. // }
  33807. // }
  33808. //}
  33809. //func (c *HisApiController) PutRecord() {
  33810. // id, _ := c.GetInt64("id")
  33811. // record_time := c.GetString("record_time")
  33812. // timeLayout := "2006-01-02"
  33813. // loc, _ := time.LoadLocation("Local")
  33814. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  33815. // if err != nil {
  33816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33817. // return
  33818. // }
  33819. // recordDateTime := theTime.Unix()
  33820. //
  33821. // adminInfo := c.GetAdminUserInfo()
  33822. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  33823. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  33824. //
  33825. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  33826. //
  33827. // fmt.Println(miConfig.SecretKey)
  33828. //
  33829. // if patient == nil {
  33830. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  33831. // return
  33832. // }
  33833. // if len(patient.IdCardNo) == 0 {
  33834. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  33835. // return
  33836. // }
  33837. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  33838. // if config.IsOpen == 1 {
  33839. // 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
  33840. // resp, requestErr := http.Get(api)
  33841. // if requestErr != nil {
  33842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33843. // return
  33844. // }
  33845. // defer resp.Body.Close()
  33846. // body, ioErr := ioutil.ReadAll(resp.Body)
  33847. // if ioErr != nil {
  33848. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33850. // return
  33851. // }
  33852. // var respJSON map[string]interface{}
  33853. //
  33854. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33855. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33856. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33857. // return
  33858. // }
  33859. //
  33860. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33861. // userJSONBytes, _ := json.Marshal(userJSON)
  33862. // var res ResultTwo
  33863. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33864. // utils.ErrorLog("解析失败:%v", err)
  33865. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33866. // return
  33867. // }
  33868. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  33869. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  33870. // infoStr := string(Iinfos)
  33871. // idetinfoStr := string(Idetinfos)
  33872. //
  33873. // if res.Infcode == 0 {
  33874. // his := models.VMHisPatient{
  33875. // Status: 1,
  33876. // Ctime: time.Now().Unix(),
  33877. // Mtime: time.Now().Unix(),
  33878. // PsnNo: res.Output.Baseinfo.PsnNo,
  33879. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  33880. // Certno: res.Output.Baseinfo.Certno,
  33881. // PsnName: res.Output.Baseinfo.PsnName,
  33882. // Gend: res.Output.Baseinfo.Gend,
  33883. // Naty: res.Output.Baseinfo.Naty,
  33884. // Brdy: res.Output.Baseinfo.Brdy,
  33885. // Age: res.Output.Baseinfo.Age,
  33886. // Iinfo: infoStr,
  33887. // Idetinfo: idetinfoStr,
  33888. // PatientId: patient.ID,
  33889. // RecordDate: theTime.Unix(),
  33890. // UserOrgId: adminInfo.CurrentOrgId,
  33891. // AdminUserId: adminInfo.AdminUser.Id,
  33892. // IsReturn: 1,
  33893. // }
  33894. //
  33895. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  33896. // //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")
  33897. // //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")
  33898. //
  33899. // //var dat map[string]interface{}
  33900. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33901. // // fmt.Println(dat)
  33902. // //} else {
  33903. // // fmt.Println(err)
  33904. // //}
  33905. //
  33906. // var dat2 map[string]interface{}
  33907. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  33908. // fmt.Println(dat2)
  33909. // } else {
  33910. // fmt.Println(err)
  33911. // }
  33912. //
  33913. // } else {
  33914. // adminUser := c.GetAdminUserInfo()
  33915. // errlog := &models.HisOrderError{
  33916. // UserOrgId: adminUser.CurrentOrgId,
  33917. // Ctime: time.Now().Unix(),
  33918. // Mtime: time.Now().Unix(),
  33919. // ErrMsg: res.ErrMsg,
  33920. // Status: 1,
  33921. // PatientId: id,
  33922. // RecordTime: recordDateTime,
  33923. // Stage: 1,
  33924. // }
  33925. // service.CreateErrMsgLog(errlog)
  33926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  33927. // return
  33928. // }
  33929. // }
  33930. //
  33931. //}
  33932. //func (c *HisApiController) GetUploadDiag() {
  33933. // id, _ := c.GetInt64("id")
  33934. // record_time := c.GetString("record_time")
  33935. //
  33936. // diagnosis_id, _ := c.GetInt64("diagnosis")
  33937. // sick_type, _ := c.GetInt64("sick_type")
  33938. // reg_type, _ := c.GetInt64("reg_type")
  33939. //
  33940. // timeLayout := "2006-01-02"
  33941. // loc, _ := time.LoadLocation("Local")
  33942. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  33943. // if err != nil {
  33944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33945. // return
  33946. // }
  33947. //
  33948. // var patientPrescription models.HisPrescriptionInfo
  33949. // recordDateTime := theTime.Unix()
  33950. // adminInfo := c.GetAdminUserInfo()
  33951. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  33952. //
  33953. // if patientPrescription.ID == 0 {
  33954. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  33955. // }
  33956. //
  33957. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  33958. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  33959. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  33960. // sickConfig, _ := service.FindSickById(sick_type)
  33961. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  33962. //
  33963. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  33964. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  33965. // "&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 +
  33966. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  33967. // resp2, requestErr2 := http.Get(api2)
  33968. // if requestErr2 != nil {
  33969. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33970. // return
  33971. // }
  33972. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33973. // if ioErr2 != nil {
  33974. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33975. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33976. // return
  33977. // }
  33978. // var respJSON2 map[string]interface{}
  33979. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33980. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33981. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33982. // return
  33983. // }
  33984. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33985. // userJSONBytes2, _ := json.Marshal(respJSON2)
  33986. //
  33987. // var res2 ResultSix
  33988. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  33989. // utils.ErrorLog("解析失败:%v", err)
  33990. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33991. // return
  33992. // }
  33993. // if res2.Infcode != 0 {
  33994. // adminUser := c.GetAdminUserInfo()
  33995. // errlog := &models.HisOrderError{
  33996. // UserOrgId: adminUser.CurrentOrgId,
  33997. // Ctime: time.Now().Unix(),
  33998. // Mtime: time.Now().Unix(),
  33999. // ErrMsg: res2.ErrMsg,
  34000. // Status: 1,
  34001. // PatientId: id,
  34002. // RecordTime: recordDateTime,
  34003. // Stage: 3,
  34004. // }
  34005. // service.CreateErrMsgLog(errlog)
  34006. //
  34007. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  34008. // return
  34009. // }
  34010. //
  34011. // c.ServeSuccessJSON(map[string]interface{}{
  34012. // "msg": "上传成功",
  34013. // })
  34014. //
  34015. //}
  34016. type QueryResult struct {
  34017. ID int64
  34018. Name string
  34019. Code string
  34020. List_type_code string
  34021. }
  34022. func (c *HisApiController) GetCheckCode() {
  34023. ids_str := c.GetString("ids")
  34024. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  34025. ids_arr := strings.Split(ids_str, ",")
  34026. var queryResult []QueryResult
  34027. ids := make([]int64, 0)
  34028. for _, item := range ids_arr {
  34029. id, _ := strconv.ParseInt(item, 10, 64)
  34030. ids = append(ids, id)
  34031. }
  34032. if record_type == 1 {
  34033. drugs, _ := service.GetBatchDrugList(ids)
  34034. for _, item := range drugs {
  34035. result := QueryResult{
  34036. ID: item.ID,
  34037. Name: item.DrugName,
  34038. Code: item.MedicalInsuranceNumber,
  34039. List_type_code: "101",
  34040. }
  34041. queryResult = append(queryResult, result)
  34042. }
  34043. } else if record_type == 2 {
  34044. goods, _ := service.GetBatchGoodInformationList(ids)
  34045. fmt.Println(goods)
  34046. for _, item := range goods {
  34047. result := QueryResult{
  34048. ID: item.ID,
  34049. Name: item.GoodName,
  34050. Code: item.SocialSecurityDirectoryCode,
  34051. List_type_code: "301",
  34052. }
  34053. queryResult = append(queryResult, result)
  34054. }
  34055. } else if record_type == 3 {
  34056. projects, _ := service.GetBathchMyPorjecgList(ids)
  34057. for _, item := range projects {
  34058. result := QueryResult{
  34059. ID: item.ID,
  34060. Name: item.ProjectName,
  34061. Code: item.MedicalCode,
  34062. List_type_code: "201",
  34063. }
  34064. queryResult = append(queryResult, result)
  34065. }
  34066. }
  34067. admin_user_id, _ := c.GetInt64("admin_user_id")
  34068. adminUser := c.GetAdminUserInfo()
  34069. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34070. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34071. var user_name string
  34072. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34073. if role.ID == 0 {
  34074. user_name = "管理员"
  34075. } else {
  34076. user_name = role.UserName
  34077. }
  34078. baseParams := models.BaseParams{
  34079. SecretKey: miConfig.SecretKey,
  34080. FixmedinsCode: miConfig.Code,
  34081. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34082. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34083. OrgName: miConfig.OrgName,
  34084. Doctor: user_name,
  34085. }
  34086. var result string
  34087. if miConfig.MdtrtareaAdmvs == "430800" {
  34088. for _, item := range queryResult {
  34089. if record_type == 1 {
  34090. 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)
  34091. } else if record_type == 2 {
  34092. fmt.Println(item.Code)
  34093. 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)
  34094. } else if record_type == 3 {
  34095. 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)
  34096. }
  34097. var dat map[string]interface{}
  34098. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34099. fmt.Println(dat)
  34100. } else {
  34101. fmt.Println(err)
  34102. }
  34103. userJSONBytes, _ := json.Marshal(dat)
  34104. var res ResultSix
  34105. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34106. utils.ErrorLog("解析失败:%v", err)
  34107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34108. return
  34109. }
  34110. if res.Infcode == 0 {
  34111. if record_type == 1 {
  34112. service.UpdateBaseDrugById(item.ID)
  34113. } else if record_type == 2 {
  34114. service.UpdateGoodInformaitonByDetail(item.ID)
  34115. } else if record_type == 3 {
  34116. service.UpdateProjectById(item.ID)
  34117. }
  34118. c.ServeSuccessJSON(map[string]interface{}{
  34119. "failed_code": 0,
  34120. "msg": "目录对照成功",
  34121. })
  34122. } else {
  34123. c.ServeSuccessJSON(map[string]interface{}{
  34124. "failed_code": -10,
  34125. "msg": res.ErrMsg,
  34126. })
  34127. }
  34128. }
  34129. } else {
  34130. for _, item := range queryResult {
  34131. var result string
  34132. if record_type == 1 {
  34133. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  34134. } else if record_type == 2 {
  34135. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  34136. } else if record_type == 3 {
  34137. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  34138. }
  34139. var dat map[string]interface{}
  34140. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34141. fmt.Println(dat)
  34142. } else {
  34143. fmt.Println(err)
  34144. }
  34145. userJSONBytes, _ := json.Marshal(dat)
  34146. var res ResultSix
  34147. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34148. utils.ErrorLog("解析失败:%v", err)
  34149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34150. return
  34151. }
  34152. if res.Infcode == 0 {
  34153. if record_type == 1 {
  34154. service.UpdateBaseDrugById(item.ID)
  34155. } else if record_type == 2 {
  34156. service.UpdateGoodInformaitonByDetail(item.ID)
  34157. } else if record_type == 3 {
  34158. service.UpdateProjectById(item.ID)
  34159. }
  34160. c.ServeSuccessJSON(map[string]interface{}{
  34161. "failed_code": 0,
  34162. "msg": "目录对照成功",
  34163. })
  34164. } else {
  34165. c.ServeSuccessJSON(map[string]interface{}{
  34166. "failed_code": -10,
  34167. "msg": res.ErrMsg,
  34168. })
  34169. }
  34170. }
  34171. }
  34172. }
  34173. func (c *HisApiController) UnCheckCode() {
  34174. ids_str := c.GetString("ids")
  34175. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  34176. admin_user_id, _ := c.GetInt64("admin_user_id")
  34177. ids_arr := strings.Split(ids_str, ",")
  34178. var queryResult []QueryResult
  34179. ids := make([]int64, 0)
  34180. for _, item := range ids_arr {
  34181. id, _ := strconv.ParseInt(item, 10, 64)
  34182. ids = append(ids, id)
  34183. }
  34184. if record_type == 1 {
  34185. drugs, _ := service.GetBatchDrugList(ids)
  34186. for _, item := range drugs {
  34187. result := QueryResult{
  34188. ID: item.ID,
  34189. Name: item.DrugName,
  34190. Code: item.MedicalInsuranceNumber,
  34191. List_type_code: "101",
  34192. }
  34193. queryResult = append(queryResult, result)
  34194. }
  34195. } else if record_type == 2 {
  34196. goods, _ := service.GetBatchGoodInformationList(ids)
  34197. for _, item := range goods {
  34198. result := QueryResult{
  34199. ID: item.ID,
  34200. Name: item.GoodName,
  34201. Code: item.SocialSecurityDirectoryCode,
  34202. List_type_code: "301",
  34203. }
  34204. queryResult = append(queryResult, result)
  34205. }
  34206. } else if record_type == 3 {
  34207. projects, _ := service.GetBathchMyPorjecgList(ids)
  34208. for _, item := range projects {
  34209. result := QueryResult{
  34210. ID: item.ID,
  34211. Name: item.ProjectName,
  34212. Code: item.MedicalCode,
  34213. List_type_code: "201",
  34214. }
  34215. queryResult = append(queryResult, result)
  34216. }
  34217. }
  34218. adminUser := c.GetAdminUserInfo()
  34219. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34220. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34221. var user_name string
  34222. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34223. if role.ID == 0 {
  34224. user_name = "xxx"
  34225. } else {
  34226. user_name = role.UserName
  34227. }
  34228. baseParams := &models.BaseParams{
  34229. SecretKey: miConfig.SecretKey,
  34230. FixmedinsCode: miConfig.Code,
  34231. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34232. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34233. OrgName: miConfig.OrgName,
  34234. Doctor: user_name,
  34235. }
  34236. if config.IsOpen == 1 {
  34237. if miConfig.MdtrtareaAdmvs == "430800" {
  34238. for _, item := range queryResult {
  34239. var result string
  34240. if record_type == 1 {
  34241. 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)
  34242. } else if record_type == 2 {
  34243. fmt.Println(item.Code)
  34244. 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)
  34245. } else if record_type == 3 {
  34246. 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)
  34247. }
  34248. var dat map[string]interface{}
  34249. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34250. fmt.Println(dat)
  34251. } else {
  34252. fmt.Println(err)
  34253. }
  34254. userJSONBytes, _ := json.Marshal(dat)
  34255. var res ResultSix
  34256. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34257. utils.ErrorLog("解析失败:%v", err)
  34258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34259. return
  34260. }
  34261. if res.Infcode == 0 {
  34262. if record_type == 1 {
  34263. service.UpdateBaseDrugById(item.ID)
  34264. } else if record_type == 2 {
  34265. service.UpdateGoodInformaitonByDetail(item.ID)
  34266. } else if record_type == 3 {
  34267. service.UpdateProjectById(item.ID)
  34268. }
  34269. c.ServeSuccessJSON(map[string]interface{}{
  34270. "failed_code": 0,
  34271. "msg": "目录对照成功",
  34272. })
  34273. } else {
  34274. c.ServeSuccessJSON(map[string]interface{}{
  34275. "failed_code": -10,
  34276. "msg": res.ErrMsg,
  34277. })
  34278. }
  34279. }
  34280. } else {
  34281. for _, item := range queryResult {
  34282. var result string
  34283. if record_type == 1 {
  34284. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  34285. } else if record_type == 2 {
  34286. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  34287. } else if record_type == 3 {
  34288. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  34289. }
  34290. var dat2 map[string]interface{}
  34291. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  34292. fmt.Println(dat2)
  34293. } else {
  34294. fmt.Println(err)
  34295. }
  34296. userJSONBytes, _ := json.Marshal(dat2)
  34297. var res ResultSix
  34298. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34299. utils.ErrorLog("解析失败:%v", err)
  34300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34301. return
  34302. }
  34303. if res.Infcode == 0 {
  34304. if record_type == 1 {
  34305. service.UpdateDrugByIdDetail(item.ID)
  34306. } else if record_type == 2 {
  34307. service.UpdateGoodInfoById(item.ID)
  34308. } else if record_type == 3 {
  34309. service.UpdateMyProjectById(item.ID)
  34310. }
  34311. c.ServeSuccessJSON(map[string]interface{}{
  34312. "failed_code": 0,
  34313. "msg": "撤销目录对照成功",
  34314. })
  34315. } else {
  34316. c.ServeSuccessJSON(map[string]interface{}{
  34317. "failed_code": -10,
  34318. "msg": res.ErrMsg,
  34319. })
  34320. }
  34321. }
  34322. }
  34323. }
  34324. }
  34325. func (c *HisApiController) GetPatientInfo() {
  34326. id_card_no := c.GetString("id_card_no")
  34327. admin_user_id, _ := c.GetInt64("admin_user_id")
  34328. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  34329. if patient.ID == 0 {
  34330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  34331. return
  34332. }
  34333. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  34334. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  34335. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  34336. var res ResultTwo
  34337. var res10265 ResultTwo10265
  34338. if config.IsOpen == 1 {
  34339. if miConfig.MdtrtareaAdmvs == "150499" {
  34340. //请求内网数据
  34341. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  34342. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  34343. "&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
  34344. resp, requestErr := http.Get(api)
  34345. if requestErr != nil {
  34346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34347. return
  34348. }
  34349. body, ioErr := ioutil.ReadAll(resp.Body)
  34350. if ioErr != nil {
  34351. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34353. return
  34354. }
  34355. var respJSON map[string]interface{}
  34356. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34359. return
  34360. }
  34361. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34362. result_byte, _ := json.Marshal(respJSON)
  34363. result := string(result_byte)
  34364. var dat map[string]interface{}
  34365. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34366. fmt.Println(dat)
  34367. } else {
  34368. fmt.Println(err)
  34369. }
  34370. userJSONBytes, _ := json.Marshal(dat)
  34371. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  34372. utils.ErrorLog("解析失败:%v", err)
  34373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34374. return
  34375. }
  34376. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  34377. res.Infcode = Infcode
  34378. res.ErrMsg = res10265.ErrMsg
  34379. res.Output = res10265.Output
  34380. res.InfRefmsgid = res10265.InfRefmsgid
  34381. res.RespondTime = res10265.RespondTime
  34382. res.WarnInfo = res10265.WarnInfo
  34383. } else {
  34384. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  34385. var dat map[string]interface{}
  34386. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34387. fmt.Println(dat)
  34388. } else {
  34389. fmt.Println(err)
  34390. }
  34391. userJSONBytes, _ := json.Marshal(dat)
  34392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34393. utils.ErrorLog("解析失败:%v", err)
  34394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34395. return
  34396. }
  34397. }
  34398. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34399. // utils.ErrorLog("解析失败:%v", err)
  34400. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34401. // return
  34402. //}
  34403. for index, item := range res.Output.Iinfo {
  34404. if item.PsnInsuStas == "2" {
  34405. fmt.Println("--------")
  34406. res.Output.Iinfo[index].Insutype = "300"
  34407. res.Output.Iinfo[index].PsnInsuStas = "1"
  34408. }
  34409. }
  34410. fmt.Println(res.Output.Iinfo)
  34411. if res.Infcode != 0 {
  34412. c.ServeSuccessJSON(map[string]interface{}{
  34413. "failed_code": -10,
  34414. "msg": res.ErrMsg,
  34415. })
  34416. } else {
  34417. c.ServeSuccessJSON(map[string]interface{}{
  34418. "failed_code": 0,
  34419. "info": res,
  34420. })
  34421. }
  34422. }
  34423. }
  34424. func (c *HisApiController) PsnPutOnRecord() {
  34425. record_type, _ := c.GetInt64("type")
  34426. patient_id, _ := c.GetInt64("patient_id")
  34427. admin_user_id, _ := c.GetInt64("admin_user_id")
  34428. start_time := c.GetString("start_time")
  34429. end_time := c.GetString("end_time")
  34430. adminUser := c.GetAdminUserInfo()
  34431. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34432. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34433. var patients []*models.Patients
  34434. if record_type == 1 { //全部备案
  34435. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  34436. patients = append(patients, patient...)
  34437. } else { //单个备案
  34438. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  34439. patients = append(patients, patient)
  34440. }
  34441. var user_name string
  34442. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34443. if role.ID == 0 {
  34444. user_name = "xxx"
  34445. } else {
  34446. user_name = role.UserName
  34447. }
  34448. if config.IsOpen == 1 {
  34449. for _, item := range patients {
  34450. 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
  34451. resp, requestErr := http.Get(api)
  34452. if requestErr != nil {
  34453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34454. return
  34455. }
  34456. defer resp.Body.Close()
  34457. body, ioErr := ioutil.ReadAll(resp.Body)
  34458. if ioErr != nil {
  34459. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34461. return
  34462. }
  34463. var respJSON map[string]interface{}
  34464. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34465. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34467. return
  34468. }
  34469. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34470. userJSONBytes, _ := json.Marshal(userJSON)
  34471. var res ResultTwo
  34472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34473. utils.ErrorLog("解析失败:%v", err)
  34474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34475. return
  34476. }
  34477. if res.Infcode == 0 {
  34478. 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)
  34479. var dat map[string]interface{}
  34480. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34481. fmt.Println(dat)
  34482. } else {
  34483. fmt.Println(err)
  34484. }
  34485. userJSONBytes, _ := json.Marshal(dat)
  34486. var res2 ResultThirteen
  34487. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34488. utils.ErrorLog("解析失败:%v", err)
  34489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34490. return
  34491. }
  34492. if res2.Infcode == 0 {
  34493. psnResult := &models.GdybPsnRecord{
  34494. UserOrgId: adminUser.CurrentOrgId,
  34495. PatientId: item.ID,
  34496. PsnNo: res.Output.Baseinfo.PsnNo,
  34497. Ctime: time.Now().Unix(),
  34498. Mtime: time.Now().Unix(),
  34499. Status: 1,
  34500. IsCancel: 1,
  34501. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  34502. }
  34503. service.CreatePsnRecord(psnResult)
  34504. } else {
  34505. c.ServeSuccessJSON(map[string]interface{}{
  34506. "failed_code": -10,
  34507. "msg": res2.ErrMsg,
  34508. })
  34509. return
  34510. }
  34511. }
  34512. }
  34513. }
  34514. }
  34515. func (c *HisApiController) PsnUnPutOnRecord() {
  34516. id, _ := c.GetInt64("id")
  34517. //record_type, _ := c.GetInt64("type")
  34518. admin_user_id, _ := c.GetInt64("admin_user_id")
  34519. adminUser := c.GetAdminUserInfo()
  34520. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34521. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34522. var user_name string
  34523. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34524. if role.ID == 0 {
  34525. user_name = "xxx"
  34526. } else {
  34527. user_name = role.UserName
  34528. }
  34529. psn_record, _ := service.GetPsnRecordById(id)
  34530. if psn_record.ID == 0 {
  34531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  34532. return
  34533. }
  34534. if config.IsOpen == 1 {
  34535. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  34536. var dat map[string]interface{}
  34537. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34538. fmt.Println(dat)
  34539. } else {
  34540. fmt.Println(err)
  34541. }
  34542. userJSONBytes, _ := json.Marshal(dat)
  34543. var res ResultFourteen
  34544. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34545. utils.ErrorLog("解析失败:%v", err)
  34546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34547. return
  34548. }
  34549. if res.Infcode == 0 {
  34550. psn_record.IsCancel = 2
  34551. service.CreatePsnRecord(&psn_record)
  34552. } else {
  34553. c.ServeSuccessJSON(map[string]interface{}{
  34554. "failed_code": -10,
  34555. "msg": res.ErrMsg,
  34556. })
  34557. return
  34558. }
  34559. }
  34560. }
  34561. func (c *HisApiController) PsnPutNCDSOnRecord() {
  34562. patient_id, _ := c.GetInt64("patient_id")
  34563. insutype_two := c.GetString("insutype")
  34564. psn_no := c.GetString("psn_no")
  34565. doctor_id, _ := c.GetInt64("doctor_id")
  34566. sick_id, _ := c.GetInt64("sick_id")
  34567. department_id, _ := c.GetInt64("department_id")
  34568. start_time := c.GetString("start_time")
  34569. end_time := c.GetString("end_time")
  34570. check_time := c.GetString("check_time")
  34571. hospital_code := c.GetString("hospital_code")
  34572. hospital_name := c.GetString("hospital_name")
  34573. adminUser := c.GetAdminUserInfo()
  34574. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  34575. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34576. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34577. sick, _ := service.FindSickById(sick_id)
  34578. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  34579. if len(hospital_code) == 0 {
  34580. hospital_code = miConfig.Code
  34581. }
  34582. if len(hospital_name) == 0 {
  34583. hospital_name = miConfig.OrgName
  34584. }
  34585. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  34586. var res ResultTwo
  34587. var res10265 ResultTwo10265
  34588. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34589. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  34590. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  34591. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  34592. "&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
  34593. resp, requestErr := http.Get(api)
  34594. if requestErr != nil {
  34595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34596. return
  34597. }
  34598. body, ioErr := ioutil.ReadAll(resp.Body)
  34599. if ioErr != nil {
  34600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34602. return
  34603. }
  34604. var respJSON map[string]interface{}
  34605. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34608. return
  34609. }
  34610. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34611. result, _ := json.Marshal(respJSON)
  34612. fmt.Println("log")
  34613. fmt.Println(string(result))
  34614. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  34615. utils.ErrorLog("解析失败:%v", err)
  34616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34617. return
  34618. }
  34619. res.ErrMsg = res10265.ErrMsg
  34620. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  34621. res.Infcode = infocode
  34622. res.Output = res10265.Output
  34623. res.InfRefmsgid = res10265.InfRefmsgid
  34624. } else {
  34625. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  34626. if miConfig.Code == "H15049901371" {
  34627. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  34628. utils.ErrorLog("解析失败:%v", err)
  34629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34630. return
  34631. }
  34632. res.ErrMsg = res10265.ErrMsg
  34633. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  34634. res.Infcode = infocode
  34635. res.Output = res10265.Output
  34636. res.InfRefmsgid = res10265.InfRefmsgid
  34637. } else {
  34638. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34639. utils.ErrorLog("解析失败:%v", err)
  34640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34641. return
  34642. }
  34643. }
  34644. }
  34645. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  34646. infoStr := string(Iinfos)
  34647. var rf []*ResultFive
  34648. json.Unmarshal([]byte(infoStr), &rf)
  34649. var insuplc_admdvs string
  34650. var insutype string
  34651. var is390 int = 0
  34652. var is310 int = 0
  34653. var insutypes []*ResultFive
  34654. for _, item := range rf {
  34655. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  34656. insutypes = append(insutypes, item)
  34657. }
  34658. }
  34659. if len(insutypes) == 1 {
  34660. insutype = insutypes[0].Insutype
  34661. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  34662. } else {
  34663. for _, i := range insutypes {
  34664. if i.Insutype == "390" {
  34665. is390 = 1
  34666. }
  34667. if i.Insutype == "310" {
  34668. is310 = 1
  34669. }
  34670. }
  34671. }
  34672. if is390 == 1 {
  34673. insutype = "390"
  34674. }
  34675. if is310 == 1 {
  34676. insutype = "310"
  34677. }
  34678. if len(insutypes) == 2 {
  34679. insutype = insutype_two
  34680. }
  34681. if len(insutypes) == 0 {
  34682. insutype = "310"
  34683. }
  34684. insutype = insutype_two
  34685. fmt.Println(insutype)
  34686. for _, item := range rf {
  34687. fmt.Println(item.Insutype)
  34688. fmt.Println(insutype)
  34689. if item.Insutype == insutype {
  34690. fmt.Println(item.Insutype)
  34691. fmt.Println(insutype)
  34692. insuplc_admdvs = item.InsuplcAdmdvs
  34693. }
  34694. }
  34695. fmt.Println(insuplc_admdvs)
  34696. var res2 ResultThirteen
  34697. var res10265_2 ResultThirteen10265
  34698. if config.IsOpen == 1 {
  34699. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34700. } else {
  34701. if miConfig.MdtrtareaAdmvs == "150499" {
  34702. //
  34703. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  34704. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  34705. // "&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
  34706. //resp, requestErr := http.Get(api)
  34707. //if requestErr != nil {
  34708. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34709. // return
  34710. //}
  34711. //
  34712. //body, ioErr := ioutil.ReadAll(resp.Body)
  34713. //if ioErr != nil {
  34714. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34715. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34716. // return
  34717. //}
  34718. //var respJSON map[string]interface{}
  34719. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34720. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34721. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34722. // return
  34723. //}
  34724. //
  34725. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34726. //result, _ := json.Marshal(respJSON)
  34727. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  34728. // utils.ErrorLog("解析失败:%v", err)
  34729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34730. // return
  34731. //}
  34732. //infocode = resThree.Infcode
  34733. //result, _ := json.Marshal(respJSON)
  34734. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  34735. // utils.ErrorLog("解析失败:%v", err)
  34736. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34737. // return
  34738. //}
  34739. //
  34740. //resThree.ErrMsg = resThree10265.ErrMsg
  34741. //
  34742. //resThree.Output = resThree10265.Output
  34743. //
  34744. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  34745. //
  34746. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  34747. //
  34748. } else {
  34749. 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)
  34750. var dat map[string]interface{}
  34751. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34752. fmt.Println(dat)
  34753. } else {
  34754. fmt.Println(err)
  34755. }
  34756. userJSONBytes, _ := json.Marshal(dat)
  34757. if miConfig.Code == "H15049901371" {
  34758. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  34759. utils.ErrorLog("解析失败:%v", err)
  34760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34761. return
  34762. }
  34763. res2.ErrMsg = res10265_2.ErrMsg
  34764. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  34765. res2.Infcode = infocode
  34766. res2.Output = res10265_2.Output
  34767. res2.InfRefmsgid = res10265_2.InfRefmsgid
  34768. } else {
  34769. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34770. utils.ErrorLog("解析失败:%v", err)
  34771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34772. return
  34773. }
  34774. }
  34775. }
  34776. }
  34777. if res2.Infcode == 0 {
  34778. psnResult := &models.GdybPsnNcdsRecord{
  34779. UserOrgId: adminUser.CurrentOrgId,
  34780. PatientId: patient.ID,
  34781. PsnNo: psn_no,
  34782. DoctorId: doctor.AdminUserId,
  34783. DepartmentId: department_id,
  34784. SickType: sick_id,
  34785. Insutype: insutype,
  34786. Ctime: time.Now().Unix(),
  34787. Mtime: time.Now().Unix(),
  34788. Status: 1,
  34789. IsCancel: 1,
  34790. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  34791. }
  34792. service.CreatePsnNCDSRecord(psnResult)
  34793. c.ServeSuccessJSON(map[string]interface{}{
  34794. "failed_code": 0,
  34795. "msg": "备案成功",
  34796. "result": psnResult,
  34797. })
  34798. } else {
  34799. c.ServeSuccessJSON(map[string]interface{}{
  34800. "failed_code": -10,
  34801. "msg": res2.ErrMsg,
  34802. })
  34803. return
  34804. }
  34805. }
  34806. }
  34807. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  34808. id, _ := c.GetInt64("id")
  34809. admin_user_id, _ := c.GetInt64("admin_user_id")
  34810. adminUser := c.GetAdminUserInfo()
  34811. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34812. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34813. //config, _ := service.Ge(adminUser.CurrentOrgId)
  34814. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  34815. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34816. //var user_name string
  34817. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34818. //if role.ID == 0 {
  34819. // user_name = "xxx"
  34820. //} else {
  34821. // user_name = role.UserName
  34822. //}
  34823. psn_record, _ := service.GetPsnNCDSRecordById(id)
  34824. if psn_record.ID == 0 {
  34825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  34826. return
  34827. }
  34828. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  34829. var res ResultTwo
  34830. var res10265 ResultTwo10265
  34831. if miConfig.Code == "H15049901371" {
  34832. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  34833. utils.ErrorLog("解析失败:%v", err)
  34834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34835. return
  34836. }
  34837. res.ErrMsg = res10265.ErrMsg
  34838. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  34839. res.Infcode = infocode
  34840. res.Output = res10265.Output
  34841. res.InfRefmsgid = res10265.InfRefmsgid
  34842. } else {
  34843. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34844. utils.ErrorLog("解析失败:%v", err)
  34845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34846. return
  34847. }
  34848. }
  34849. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  34850. infoStr := string(Iinfos)
  34851. var rf []*ResultFive
  34852. json.Unmarshal([]byte(infoStr), &rf)
  34853. var insuplc_admdvs string
  34854. var insutype string
  34855. var is390 int = 0
  34856. var is310 int = 0
  34857. var insutypes []*ResultFive
  34858. for _, item := range rf {
  34859. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  34860. insutypes = append(insutypes, item)
  34861. }
  34862. }
  34863. if len(insutypes) == 1 {
  34864. insutype = insutypes[0].Insutype
  34865. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  34866. } else {
  34867. for _, i := range insutypes {
  34868. if i.Insutype == "390" {
  34869. is390 = 1
  34870. }
  34871. if i.Insutype == "310" {
  34872. is310 = 1
  34873. }
  34874. }
  34875. }
  34876. if is390 == 1 {
  34877. insutype = "390"
  34878. }
  34879. if is310 == 1 {
  34880. insutype = "310"
  34881. }
  34882. if len(insutypes) == 0 {
  34883. insutype = "310"
  34884. }
  34885. insutype = psn_record.Insutype
  34886. for _, item := range rf {
  34887. if item.Insutype == insutype {
  34888. insuplc_admdvs = item.InsuplcAdmdvs
  34889. }
  34890. }
  34891. if config.IsOpen == 1 {
  34892. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  34893. var dat map[string]interface{}
  34894. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34895. fmt.Println(dat)
  34896. } else {
  34897. fmt.Println(err)
  34898. }
  34899. userJSONBytes, _ := json.Marshal(dat)
  34900. var res ResultFourteen
  34901. var res10265 ResultFourteen10265
  34902. if miConfig.Code == "H15049901371" {
  34903. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  34904. utils.ErrorLog("解析失败:%v", err)
  34905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34906. return
  34907. }
  34908. res.ErrMsg = res10265.ErrMsg
  34909. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  34910. res.Infcode = infocode
  34911. res.Output = res10265.Output
  34912. res.InfRefmsgid = res10265.InfRefmsgid
  34913. } else {
  34914. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34915. utils.ErrorLog("解析失败:%v", err)
  34916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34917. return
  34918. }
  34919. }
  34920. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34921. // utils.ErrorLog("解析失败:%v", err)
  34922. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34923. // return
  34924. //}
  34925. if res.Infcode == 0 {
  34926. psn_record.IsCancel = 2
  34927. service.CreatePsnNCDSRecord(&psn_record)
  34928. c.ServeSuccessJSON(map[string]interface{}{
  34929. "failed_code": 0,
  34930. "msg": "撤销备案成功",
  34931. })
  34932. } else {
  34933. c.ServeSuccessJSON(map[string]interface{}{
  34934. "failed_code": -10,
  34935. "msg": res.ErrMsg,
  34936. })
  34937. return
  34938. }
  34939. }
  34940. }
  34941. func (c *HisApiController) TestTest() {
  34942. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  34943. fmt.Println(patient.Iinfo)
  34944. }
  34945. type CustomData struct {
  34946. MsgId string
  34947. PsnNo string
  34948. Info string
  34949. }
  34950. func (c *HisApiController) ReversalData() {
  34951. var customData []*CustomData
  34952. custom := &CustomData{
  34953. MsgId: "H44022900158202103301714472004",
  34954. PsnNo: "44020000001101329945",
  34955. Info: "2207",
  34956. }
  34957. customData = append(customData, custom)
  34958. custom1 := &CustomData{
  34959. MsgId: "H4402290015820210330172057803",
  34960. PsnNo: "44020000001101161813",
  34961. Info: "2207",
  34962. }
  34963. customData = append(customData, custom1)
  34964. custom2 := &CustomData{
  34965. MsgId: "H44022900158202103301705198813",
  34966. PsnNo: "44190000133097375417",
  34967. Info: "2207",
  34968. }
  34969. customData = append(customData, custom2)
  34970. custom3 := &CustomData{
  34971. MsgId: "H44022900158202103301715524756",
  34972. PsnNo: "44020000001100187221",
  34973. Info: "2207",
  34974. }
  34975. customData = append(customData, custom3)
  34976. custom4 := &CustomData{
  34977. MsgId: "H44022900158202103301730376224",
  34978. PsnNo: "44020000001101959155",
  34979. Info: "2207",
  34980. }
  34981. customData = append(customData, custom4)
  34982. custom5 := &CustomData{
  34983. MsgId: "H44022900158202103301748008725",
  34984. PsnNo: "44020000001104246641",
  34985. Info: "2207",
  34986. }
  34987. customData = append(customData, custom5)
  34988. custom6 := &CustomData{
  34989. MsgId: "H44022900158202103301718096755",
  34990. PsnNo: "44020000001102211860",
  34991. Info: "2207",
  34992. }
  34993. customData = append(customData, custom6)
  34994. custom7 := &CustomData{
  34995. MsgId: "H44022900158202103301736551640",
  34996. PsnNo: "44020000001102687718",
  34997. Info: "2207",
  34998. }
  34999. customData = append(customData, custom7)
  35000. custom8 := &CustomData{
  35001. MsgId: "H44022900158202103301743097676",
  35002. PsnNo: "44020000001102127785",
  35003. Info: "2207",
  35004. }
  35005. customData = append(customData, custom8)
  35006. custom9 := &CustomData{
  35007. MsgId: "H44022900158202103301712304203",
  35008. PsnNo: "44020000001101518097",
  35009. Info: "2207",
  35010. }
  35011. customData = append(customData, custom9)
  35012. custom10 := &CustomData{
  35013. MsgId: "H44022900158202103301738448785",
  35014. PsnNo: "44020000001100500813",
  35015. Info: "2207",
  35016. }
  35017. customData = append(customData, custom10)
  35018. custom11 := &CustomData{
  35019. MsgId: "H44022900158202103301732455843",
  35020. PsnNo: "44020000001102690557",
  35021. Info: "2207",
  35022. }
  35023. customData = append(customData, custom11)
  35024. custom12 := &CustomData{
  35025. MsgId: "H44022900158202103301745421708",
  35026. PsnNo: "44020000001102211928",
  35027. Info: "2207",
  35028. }
  35029. customData = append(customData, custom12)
  35030. custom1212 := &CustomData{
  35031. MsgId: "H440229001582021033017351627",
  35032. PsnNo: "44020000001102481733",
  35033. Info: "2207",
  35034. }
  35035. customData = append(customData, custom1212)
  35036. custom13 := &CustomData{
  35037. MsgId: "H44022900158202103301740327951",
  35038. PsnNo: "44020000001103174866",
  35039. Info: "2207",
  35040. }
  35041. customData = append(customData, custom13)
  35042. custom14 := &CustomData{
  35043. MsgId: "H4402290015820210330174922668",
  35044. PsnNo: "44020000001102927272",
  35045. Info: "2207",
  35046. }
  35047. customData = append(customData, custom14)
  35048. custom15 := &CustomData{
  35049. MsgId: "H44022900158202103301752362273",
  35050. PsnNo: "44020000001102942890",
  35051. Info: "2207",
  35052. }
  35053. customData = append(customData, custom15)
  35054. custom16 := &CustomData{
  35055. MsgId: "H44022900158202103301751082917",
  35056. PsnNo: "44020000001101662162",
  35057. Info: "2207",
  35058. }
  35059. customData = append(customData, custom16)
  35060. custom17 := &CustomData{
  35061. MsgId: "H44022900158202103301754147728",
  35062. PsnNo: "44020000000229014511",
  35063. Info: "2207",
  35064. }
  35065. customData = append(customData, custom17)
  35066. adminUser := c.GetAdminUserInfo()
  35067. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35068. for _, item := range customData {
  35069. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  35070. fmt.Println(result)
  35071. }
  35072. }
  35073. func (c *HisApiController) GetAllopatry() {
  35074. year := c.GetString("year")
  35075. month := c.GetString("month")
  35076. admin_user_id, _ := c.GetInt64("admin_user_id")
  35077. adminUser := c.GetAdminUserInfo()
  35078. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35079. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35080. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  35081. var dat map[string]interface{}
  35082. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35083. fmt.Println(dat)
  35084. } else {
  35085. fmt.Println(err)
  35086. }
  35087. userJSONBytes, _ := json.Marshal(dat)
  35088. var res models.Result9001
  35089. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35090. utils.ErrorLog("解析失败:%v", err)
  35091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35092. return
  35093. }
  35094. fmt.Println(res.Output.Signinoutb)
  35095. fmt.Println(res.Output.Signinoutb.SignNo)
  35096. fmt.Println(string(userJSONBytes))
  35097. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  35098. var dat3 map[string]interface{}
  35099. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  35100. fmt.Println(dat3)
  35101. } else {
  35102. fmt.Println(err)
  35103. }
  35104. userJSONBytes3, _ := json.Marshal(dat3)
  35105. var res3 models.Result3260
  35106. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  35107. utils.ErrorLog("解析失败:%v", err)
  35108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35109. return
  35110. }
  35111. var curpage int
  35112. var pagesize int = 100
  35113. var start int = 1
  35114. //var stop int
  35115. //pagecount := 10
  35116. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  35117. var res22 []models.Result3260
  35118. for curpage = 1; curpage <= pagecount; curpage++ {
  35119. if curpage == 1 {
  35120. start = 0
  35121. } else {
  35122. start = (curpage-1)*pagesize + 1
  35123. }
  35124. fmt.Println(start)
  35125. //stop = curpage * pagesize
  35126. //if stop > int(res3.Output.Totalrow) {
  35127. // stop =int(res3.Output.Totalrow)
  35128. //}
  35129. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  35130. var dat2 map[string]interface{}
  35131. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35132. fmt.Println(dat)
  35133. } else {
  35134. fmt.Println(err)
  35135. }
  35136. userJSONBytes2, _ := json.Marshal(dat2)
  35137. var res2 models.Result3260
  35138. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35139. utils.ErrorLog("解析失败:%v", err)
  35140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35141. return
  35142. }
  35143. if res2.Infcode == 0 {
  35144. res22 = append(res22, res2)
  35145. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  35146. //var dat2 map[string]interface{}
  35147. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  35148. // fmt.Println(dat)
  35149. //} else {
  35150. // fmt.Println(err)
  35151. //}
  35152. //c.ServeSuccessJSON(map[string]interface{}{
  35153. // "list": res2.Output.Data,
  35154. //})
  35155. //continue
  35156. }
  35157. }
  35158. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  35159. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  35160. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  35161. //var dat2 map[string]interface{}
  35162. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35163. // fmt.Println(dat)
  35164. //} else {
  35165. // fmt.Println(err)
  35166. //}
  35167. //userJSONBytes2, _ := json.Marshal(dat2)
  35168. //var res2 models.Result3260
  35169. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35170. // utils.ErrorLog("解析失败:%v", err)
  35171. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35172. // return
  35173. //}
  35174. //if res2.Infcode == 0 {
  35175. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  35176. // var dat2 map[string]interface{}
  35177. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  35178. // fmt.Println(dat)
  35179. // } else {
  35180. // fmt.Println(err)
  35181. // }
  35182. // c.ServeSuccessJSON(map[string]interface{}{
  35183. // "list": res2.Output.Data,
  35184. // })
  35185. //}
  35186. }
  35187. func (c *HisApiController) ComfirmAllopatry() {
  35188. year := c.GetString("year")
  35189. month := c.GetString("month")
  35190. admin_user_id, _ := c.GetInt64("admin_user_id")
  35191. adminUser := c.GetAdminUserInfo()
  35192. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35193. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35194. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  35195. var dat map[string]interface{}
  35196. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35197. fmt.Println(dat)
  35198. } else {
  35199. fmt.Println(err)
  35200. }
  35201. userJSONBytes, _ := json.Marshal(dat)
  35202. var res models.Result9001
  35203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35204. utils.ErrorLog("解析失败:%v", err)
  35205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35206. return
  35207. }
  35208. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  35209. var dat2 map[string]interface{}
  35210. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35211. fmt.Println(dat)
  35212. } else {
  35213. fmt.Println(err)
  35214. }
  35215. userJSONBytes2, _ := json.Marshal(dat2)
  35216. var res2 models.Result3260
  35217. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35218. utils.ErrorLog("解析失败:%v", err)
  35219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35220. return
  35221. }
  35222. //if res2.Infcode == 0 {
  35223. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  35224. // var dat map[string]interface{}
  35225. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35226. // fmt.Println(dat)
  35227. // } else {
  35228. // fmt.Println(err)
  35229. // }
  35230. // userJSONBytes, _ := json.Marshal(dat)
  35231. // var res3 models.Result3261
  35232. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  35233. // utils.ErrorLog("解析失败:%v", err)
  35234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35235. // return
  35236. // }
  35237. //
  35238. // if res3.Infcode == 0 {
  35239. // record := &models.HisYidiClearRecord{
  35240. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  35241. // Ctime: time.Now().Unix(),
  35242. // Mtime: time.Now().Unix(),
  35243. // Status: 1,
  35244. // MsgId: msgId,
  35245. // }
  35246. // service.SaveClearRecord(record)
  35247. // c.ServeSuccessJSON(map[string]interface{}{
  35248. // "msg": "提取成功",
  35249. // })
  35250. // }
  35251. //}
  35252. }
  35253. func (c *HisApiController) RefundAllopatry() {
  35254. year := c.GetString("year")
  35255. month := c.GetString("month")
  35256. //id, _ := c.GetInt64("id")
  35257. admin_user_id, _ := c.GetInt64("admin_user_id")
  35258. adminUser := c.GetAdminUserInfo()
  35259. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35260. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35261. //record, _ := service.GetClearRecordById(id)
  35262. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  35263. var dat map[string]interface{}
  35264. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35265. fmt.Println(dat)
  35266. } else {
  35267. fmt.Println(err)
  35268. }
  35269. userJSONBytes, _ := json.Marshal(dat)
  35270. var res models.Result9001
  35271. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35272. utils.ErrorLog("解析失败:%v", err)
  35273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35274. return
  35275. }
  35276. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  35277. var dat2 map[string]interface{}
  35278. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  35279. fmt.Println(dat)
  35280. } else {
  35281. fmt.Println(err)
  35282. }
  35283. userJSONBytes2, _ := json.Marshal(dat2)
  35284. var empty ResultFourteen
  35285. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  35286. utils.ErrorLog("解析失败:%v", err)
  35287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35288. return
  35289. }
  35290. if empty.Infcode == 0 {
  35291. c.ServeSuccessJSON(map[string]interface{}{
  35292. "msg": "撤销成功",
  35293. })
  35294. return
  35295. }
  35296. }
  35297. func (c *HisApiController) ReversalOtherData() {
  35298. var customData []*CustomData
  35299. custom := &CustomData{
  35300. MsgId: "H44022900158202103301714472004",
  35301. PsnNo: "44020000001101329945",
  35302. Info: "2208",
  35303. }
  35304. customData = append(customData, custom)
  35305. custom1 := &CustomData{
  35306. MsgId: "H4402290015820210330172057803",
  35307. PsnNo: "44020000001101161813",
  35308. Info: "2208",
  35309. }
  35310. customData = append(customData, custom1)
  35311. custom2 := &CustomData{
  35312. MsgId: "H44022900158202103301705198813",
  35313. PsnNo: "44190000133097375417",
  35314. Info: "2208",
  35315. }
  35316. customData = append(customData, custom2)
  35317. custom3 := &CustomData{
  35318. MsgId: "H44022900158202103301715524756",
  35319. PsnNo: "44020000001100187221",
  35320. Info: "2208",
  35321. }
  35322. customData = append(customData, custom3)
  35323. custom4 := &CustomData{
  35324. MsgId: "H44022900158202103301730376224",
  35325. PsnNo: "44020000001101959155",
  35326. Info: "2208",
  35327. }
  35328. customData = append(customData, custom4)
  35329. custom5 := &CustomData{
  35330. MsgId: "H44022900158202103301748008725",
  35331. PsnNo: "44020000001104246641",
  35332. Info: "2208",
  35333. }
  35334. customData = append(customData, custom5)
  35335. custom6 := &CustomData{
  35336. MsgId: "H44022900158202103301718096755",
  35337. PsnNo: "44020000001102211860",
  35338. Info: "2208",
  35339. }
  35340. customData = append(customData, custom6)
  35341. custom7 := &CustomData{
  35342. MsgId: "H44022900158202103301736551640",
  35343. PsnNo: "44020000001102687718",
  35344. Info: "2208",
  35345. }
  35346. customData = append(customData, custom7)
  35347. custom8 := &CustomData{
  35348. MsgId: "H44022900158202103301743097676",
  35349. PsnNo: "44020000001102127785",
  35350. Info: "2208",
  35351. }
  35352. customData = append(customData, custom8)
  35353. custom9 := &CustomData{
  35354. MsgId: "H44022900158202103301712304203",
  35355. PsnNo: "44020000001101518097",
  35356. Info: "2208",
  35357. }
  35358. customData = append(customData, custom9)
  35359. custom10 := &CustomData{
  35360. MsgId: "H44022900158202103301738448785",
  35361. PsnNo: "44020000001100500813",
  35362. Info: "2208",
  35363. }
  35364. customData = append(customData, custom10)
  35365. custom11 := &CustomData{
  35366. MsgId: "H44022900158202103301732455843",
  35367. PsnNo: "44020000001102690557",
  35368. Info: "2208",
  35369. }
  35370. customData = append(customData, custom11)
  35371. custom12 := &CustomData{
  35372. MsgId: "H44022900158202103301745421708",
  35373. PsnNo: "44020000001102211928",
  35374. Info: "2208",
  35375. }
  35376. customData = append(customData, custom12)
  35377. custom1212 := &CustomData{
  35378. MsgId: "H440229001582021033017351627",
  35379. PsnNo: "44020000001102481733",
  35380. Info: "2208",
  35381. }
  35382. customData = append(customData, custom1212)
  35383. custom13 := &CustomData{
  35384. MsgId: "H44022900158202103301740327951",
  35385. PsnNo: "44020000001103174866",
  35386. Info: "2208",
  35387. }
  35388. customData = append(customData, custom13)
  35389. custom14 := &CustomData{
  35390. MsgId: "H4402290015820210330174922668",
  35391. PsnNo: "44020000001102927272",
  35392. Info: "2208",
  35393. }
  35394. customData = append(customData, custom14)
  35395. custom15 := &CustomData{
  35396. MsgId: "H44022900158202103301752362273",
  35397. PsnNo: "44020000001102942890",
  35398. Info: "2208",
  35399. }
  35400. customData = append(customData, custom15)
  35401. custom16 := &CustomData{
  35402. MsgId: "H44022900158202103301751082917",
  35403. PsnNo: "44020000001101662162",
  35404. Info: "2208",
  35405. }
  35406. customData = append(customData, custom16)
  35407. custom17 := &CustomData{
  35408. MsgId: "H44022900158202103301754147728",
  35409. PsnNo: "44020000000229014511",
  35410. Info: "2208",
  35411. }
  35412. customData = append(customData, custom17)
  35413. adminUser := c.GetAdminUserInfo()
  35414. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35415. for _, item := range customData {
  35416. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  35417. fmt.Println(result)
  35418. }
  35419. }
  35420. func PathExists(path string) (bool, error) {
  35421. _, err := os.Stat(path)
  35422. if err == nil {
  35423. return true, nil
  35424. }
  35425. if os.IsNotExist(err) {
  35426. return false, nil
  35427. }
  35428. return false, err
  35429. }
  35430. // 创建文件夹
  35431. func Mkdir(dir string) {
  35432. // 创建文件夹
  35433. exist, err := PathExists(dir)
  35434. if err != nil {
  35435. fmt.Println(err.Error())
  35436. } else {
  35437. if exist {
  35438. fmt.Println(dir + "文件夹已存在!")
  35439. } else {
  35440. // 文件夹名称,权限
  35441. err := os.Mkdir(dir, os.ModePerm)
  35442. if err != nil {
  35443. fmt.Println(dir+"文件夹创建失败:", err.Error())
  35444. } else {
  35445. fmt.Println(dir + "文件夹创建成功!")
  35446. }
  35447. }
  35448. }
  35449. }
  35450. // 压缩文件
  35451. func Zip(srcFile string, destZip string) error {
  35452. zipfile, err := os.Create(destZip)
  35453. if err != nil {
  35454. return err
  35455. }
  35456. defer zipfile.Close()
  35457. archive := zip.NewWriter(zipfile)
  35458. defer archive.Close()
  35459. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  35460. if err != nil {
  35461. return err
  35462. }
  35463. header, err := zip.FileInfoHeader(info)
  35464. if err != nil {
  35465. return err
  35466. }
  35467. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  35468. // header.Name = path
  35469. if info.IsDir() {
  35470. header.Name += "/"
  35471. } else {
  35472. header.Method = zip.Deflate
  35473. }
  35474. writer, err := archive.CreateHeader(header)
  35475. if err != nil {
  35476. return err
  35477. }
  35478. if !info.IsDir() {
  35479. file, err := os.Open(path)
  35480. if err != nil {
  35481. return err
  35482. }
  35483. defer file.Close()
  35484. _, err = io.Copy(writer, file)
  35485. }
  35486. return err
  35487. })
  35488. return err
  35489. }
  35490. func ReadFile(filePath string) []byte {
  35491. f, err := os.Open(filePath)
  35492. if err != nil {
  35493. fmt.Println("read file fail", err)
  35494. return nil
  35495. }
  35496. defer f.Close()
  35497. fd, err := ioutil.ReadAll(f)
  35498. if err != nil {
  35499. fmt.Println("read to fd fail", err)
  35500. return nil
  35501. }
  35502. return fd
  35503. }
  35504. func saveLogq(result string, request string, infno string, desc string) {
  35505. dir := "日志"
  35506. utils.Mkdir(dir)
  35507. month := time.Unix(1557042972, 0).Format("1")
  35508. year := time.Now().Format("2006")
  35509. month = time.Now().Format("01")
  35510. day := time.Now().Format("02")
  35511. hour := time.Now().Format("15")
  35512. min := time.Now().Format("04")
  35513. sec := time.Now().Format("05")
  35514. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  35515. file := year + month + day + "_log"
  35516. file_name := file + ".txt"
  35517. file_path := "日志" + "/" + file_name
  35518. exist, _ := utils.PathExists(file_path)
  35519. if exist { //存在
  35520. fmt.Println("存在")
  35521. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  35522. if err != nil {
  35523. fmt.Println("read fail")
  35524. }
  35525. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  35526. n, _ := f.Seek(0, 2)
  35527. _, err = f.WriteAt([]byte(content), n)
  35528. } else { //不存在
  35529. fmt.Println("文件不存在,创建文件")
  35530. f, err := os.Create("日志" + "/" + file_name)
  35531. defer f.Close()
  35532. if err != nil {
  35533. } else {
  35534. _, err = f.Write([]byte("记录日志"))
  35535. }
  35536. }
  35537. }
  35538. func saveLog(result string, request string, infno string, desc string) {
  35539. org_id, _ := beego.AppConfig.Int64("org_id")
  35540. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  35541. dir := miConfig.OrgName + "日志"
  35542. utils.Mkdir(dir)
  35543. month := time.Unix(1557042972, 0).Format("1")
  35544. year := time.Now().Format("2006")
  35545. month = time.Now().Format("01")
  35546. day := time.Now().Format("02")
  35547. hour := time.Now().Format("15")
  35548. min := time.Now().Format("04")
  35549. sec := time.Now().Format("05")
  35550. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  35551. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  35552. file_name := file + ".txt"
  35553. file_path := miConfig.OrgName + "日志" + "/" + file_name
  35554. exist, _ := utils.PathExists(file_path)
  35555. if exist { //存在
  35556. fmt.Println("存在")
  35557. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  35558. if err != nil {
  35559. fmt.Println("read fail")
  35560. }
  35561. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  35562. n, _ := f.Seek(0, 2)
  35563. _, err = f.WriteAt([]byte(content), n)
  35564. } else { //不存在
  35565. fmt.Println("文件不存在,创建文件")
  35566. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  35567. defer f.Close()
  35568. if err != nil {
  35569. } else {
  35570. _, err = f.Write([]byte("记录日志"))
  35571. }
  35572. }
  35573. }
  35574. type Charset string
  35575. const (
  35576. UTF8 = Charset("UTF-8")
  35577. GB18030 = Charset("GB18030")
  35578. )
  35579. func ConvertToString(src string, srcCode string, tagCode string) string {
  35580. srcCoder := mahonia.NewDecoder(srcCode)
  35581. srcResult := srcCoder.ConvertString(src)
  35582. tagCoder := mahonia.NewDecoder(tagCode)
  35583. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  35584. result := string(cdata)
  35585. return result
  35586. }
  35587. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  35588. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  35589. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  35590. var token string
  35591. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  35592. var api string
  35593. if miConfig.MdtrtareaAdmvs == "320921" {
  35594. 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 +
  35595. "&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
  35596. fmt.Println(api)
  35597. } else {
  35598. 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 +
  35599. "&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
  35600. }
  35601. resp, requestErr := http.Get(api)
  35602. if requestErr != nil {
  35603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35604. return ""
  35605. }
  35606. body, ioErr := ioutil.ReadAll(resp.Body)
  35607. if ioErr != nil {
  35608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35610. return ""
  35611. }
  35612. var respJSON map[string]interface{}
  35613. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35616. return ""
  35617. }
  35618. var status string
  35619. status = respJSON["data"].(map[string]interface{})["status"].(string)
  35620. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  35621. var res ResultTwo //1101结果
  35622. var res10265 ResultTwo10265 //1101结果
  35623. if status == "0" { //读卡成功
  35624. var card_info string //卡信息
  35625. var busi_card_info string
  35626. token = respJSON["data"].(map[string]interface{})["token"].(string)
  35627. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  35628. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  35629. fmt.Println(card_info)
  35630. fmt.Println(busi_card_info)
  35631. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  35632. result, _ := json.Marshal(respJSON)
  35633. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35634. utils.ErrorLog("解析失败:%v", err)
  35635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35636. return ""
  35637. }
  35638. res.ErrMsg = res10265.ErrMsg
  35639. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35640. res.Infcode = infocode
  35641. res.Output = res10265.Output
  35642. res.InfRefmsgid = res10265.InfRefmsgid
  35643. if res.Infcode == 0 {
  35644. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  35645. if err == gorm.ErrRecordNotFound {
  35646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  35647. return ""
  35648. } else if err != nil {
  35649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  35650. return ""
  35651. } else {
  35652. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35653. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35654. infoStr := string(Iinfos)
  35655. idetinfoStr := string(Idetinfos)
  35656. psn := &models.HisPsn{
  35657. PsnNo: res.Output.Baseinfo.PsnNo,
  35658. PatientId: patient.ID,
  35659. Certno: res.Output.Baseinfo.Certno,
  35660. Gend: res.Output.Baseinfo.Gend,
  35661. Naty: res.Output.Baseinfo.Naty,
  35662. PsnCertType: res.Output.Baseinfo.PsnCertType,
  35663. PsnName: res.Output.Baseinfo.PsnName,
  35664. Idetinfo: idetinfoStr,
  35665. Insuinfo: infoStr,
  35666. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  35667. CardInfo: card_info,
  35668. VerifyNumber: token,
  35669. }
  35670. service.CreateHisPsn(psn)
  35671. return token
  35672. }
  35673. }
  35674. } else {
  35675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35676. return ""
  35677. }
  35678. } else { //读卡失败
  35679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35680. return ""
  35681. }
  35682. return token
  35683. }
  35684. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  35685. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  35686. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  35687. var token string
  35688. var api string
  35689. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  35690. "&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
  35691. fmt.Println(api)
  35692. resp, requestErr := http.Get(api)
  35693. if requestErr != nil {
  35694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35695. return ""
  35696. }
  35697. body, ioErr := ioutil.ReadAll(resp.Body)
  35698. if ioErr != nil {
  35699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35701. return ""
  35702. }
  35703. var respJSON map[string]interface{}
  35704. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35707. return ""
  35708. }
  35709. var status string
  35710. status = respJSON["data"].(map[string]interface{})["status"].(string)
  35711. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  35712. var res ResultTwo //1101结果
  35713. if status == "1" { //读卡成功
  35714. var card_info string //卡信息
  35715. var busi_card_info string
  35716. token = respJSON["data"].(map[string]interface{})["token"].(string)
  35717. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  35718. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  35719. fmt.Println(card_info)
  35720. fmt.Println(busi_card_info)
  35721. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  35722. result, _ := json.Marshal(respJSON)
  35723. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35724. utils.ErrorLog("解析失败:%v", err)
  35725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35726. return ""
  35727. }
  35728. if res.Infcode == 0 {
  35729. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  35730. if err == gorm.ErrRecordNotFound {
  35731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  35732. return ""
  35733. } else if err != nil {
  35734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  35735. return ""
  35736. } else {
  35737. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35738. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35739. infoStr := string(Iinfos)
  35740. idetinfoStr := string(Idetinfos)
  35741. psn := &models.HisPsn{
  35742. PsnNo: res.Output.Baseinfo.PsnNo,
  35743. PatientId: patient.ID,
  35744. Certno: res.Output.Baseinfo.Certno,
  35745. Gend: res.Output.Baseinfo.Gend,
  35746. Naty: res.Output.Baseinfo.Naty,
  35747. PsnCertType: res.Output.Baseinfo.PsnCertType,
  35748. PsnName: res.Output.Baseinfo.PsnName,
  35749. Idetinfo: idetinfoStr,
  35750. Insuinfo: infoStr,
  35751. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  35752. CardInfo: card_info,
  35753. VerifyNumber: token,
  35754. }
  35755. service.CreateHisPsn(psn)
  35756. return token
  35757. }
  35758. }
  35759. } else {
  35760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35761. return ""
  35762. }
  35763. return token
  35764. }
  35765. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  35766. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  35767. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  35768. var token string
  35769. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  35770. var api string
  35771. if miConfig.MdtrtareaAdmvs == "320921" {
  35772. 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 +
  35773. "&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
  35774. fmt.Println(api)
  35775. } else {
  35776. 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 +
  35777. "&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
  35778. }
  35779. resp, requestErr := http.Get(api)
  35780. if requestErr != nil {
  35781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35782. return ""
  35783. }
  35784. body, ioErr := ioutil.ReadAll(resp.Body)
  35785. if ioErr != nil {
  35786. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35788. return ""
  35789. }
  35790. var respJSON map[string]interface{}
  35791. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35794. return ""
  35795. }
  35796. var status string
  35797. status = respJSON["data"].(map[string]interface{})["status"].(string)
  35798. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  35799. var res ResultTwo //1101结果
  35800. var res10265 ResultTwo10265 //1101结果
  35801. if status == "0" { //读卡成功
  35802. var card_info string //卡信息
  35803. var busi_card_info string
  35804. token = respJSON["data"].(map[string]interface{})["token"].(string)
  35805. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  35806. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  35807. fmt.Println(card_info)
  35808. fmt.Println(busi_card_info)
  35809. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  35810. result, _ := json.Marshal(respJSON)
  35811. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35812. utils.ErrorLog("解析失败:%v", err)
  35813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35814. return ""
  35815. }
  35816. res.ErrMsg = res10265.ErrMsg
  35817. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35818. res.Infcode = infocode
  35819. res.Output = res10265.Output
  35820. res.InfRefmsgid = res10265.InfRefmsgid
  35821. if res.Infcode == 0 {
  35822. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  35823. if err == gorm.ErrRecordNotFound {
  35824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  35825. return ""
  35826. } else if err != nil {
  35827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  35828. return ""
  35829. } else {
  35830. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35831. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35832. infoStr := string(Iinfos)
  35833. idetinfoStr := string(Idetinfos)
  35834. psn := &models.HisPsn{
  35835. PsnNo: res.Output.Baseinfo.PsnNo,
  35836. PatientId: patient.ID,
  35837. Certno: res.Output.Baseinfo.Certno,
  35838. Gend: res.Output.Baseinfo.Gend,
  35839. Naty: res.Output.Baseinfo.Naty,
  35840. PsnCertType: res.Output.Baseinfo.PsnCertType,
  35841. PsnName: res.Output.Baseinfo.PsnName,
  35842. Idetinfo: idetinfoStr,
  35843. Insuinfo: infoStr,
  35844. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  35845. CardInfo: card_info,
  35846. VerifyNumber: token,
  35847. }
  35848. service.CreateHisPsn(psn)
  35849. return token
  35850. }
  35851. }
  35852. } else {
  35853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35854. return ""
  35855. }
  35856. } else { //读卡失败
  35857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35858. return ""
  35859. }
  35860. return token
  35861. }
  35862. func DeleteExtraSpaceTwo(s string) string {
  35863. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  35864. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  35865. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  35866. reg, _ := regexp.Compile(regstr) //编译正则表达式
  35867. s2 := make([]byte, len(s1)) //定义字符数组切片
  35868. copy(s2, s1) //将字符串复制到切片
  35869. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  35870. for len(spc_index) > 0 { //找到适配项
  35871. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  35872. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  35873. }
  35874. return string(s2)
  35875. }
  35876. func Remove0000(s string) string {
  35877. str := make([]rune, 0, len(s))
  35878. for _, v := range []rune(s) {
  35879. if v == 0 {
  35880. continue
  35881. }
  35882. str = append(str, v)
  35883. }
  35884. return string(str)
  35885. }
  35886. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  35887. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  35888. readCard := DllDef.MustFindProc("EcQuery")
  35889. pCardInfo := make([]byte, 8192)
  35890. pBusiCardInfo := make([]byte, 8192)
  35891. data := make(map[string]interface{})
  35892. //pData := make(map[string]interface{})
  35893. inputData := make(map[string]interface{})
  35894. inputData["orgId"] = code
  35895. inputData["businessType"] = "01101"
  35896. inputData["operatorId"] = operator_id
  35897. inputData["operatorName"] = operator_name
  35898. inputData["officeId"] = "001"
  35899. inputData["officeName"] = "血透室"
  35900. //
  35901. data["data"] = inputData
  35902. data["transType"] = "ec.query"
  35903. data["orgId"] = code
  35904. bytesData, _ := json.Marshal(data)
  35905. pCardInfo = bytesData
  35906. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  35907. fmt.Println(ret2)
  35908. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  35909. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  35910. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  35911. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  35912. if ret2 != 0 {
  35913. return "", ""
  35914. }
  35915. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  35916. }
  35917. func DeleteExtraSpace(s string) string {
  35918. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  35919. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  35920. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  35921. reg, _ := regexp.Compile(regstr) //编译正则表达式
  35922. s2 := make([]byte, len(s1)) //定义字符数组切片
  35923. copy(s2, s1) //将字符串复制到切片
  35924. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  35925. for len(spc_index) > 0 { //找到适配项
  35926. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  35927. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  35928. }
  35929. return string(s2)
  35930. }
  35931. // 对账
  35932. func (c *HisApiController) Post3202() {
  35933. start_time := c.GetString("start_time")
  35934. end_time := c.GetString("end_time")
  35935. //insutype := c.GetString("insutype")
  35936. clr_type := c.GetString("clr_type")
  35937. clr_org := c.GetString("clr_optins")
  35938. admin_user_id, _ := c.GetInt64("admin_user_id")
  35939. adminUser := c.GetAdminUserInfo()
  35940. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35941. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35942. if len(clr_org) == 0 {
  35943. clr_org = miConfig.MdtrtareaAdmvs
  35944. }
  35945. timeLayout := "2006-01-02"
  35946. loc, _ := time.LoadLocation("Local")
  35947. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35948. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35949. var orders []*models.HisOrder
  35950. if clr_org == "421300" {
  35951. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  35952. } else if clr_org == "420902" {
  35953. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  35954. } else {
  35955. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  35956. }
  35957. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  35958. //fixmedins_setl_cnt := int64(len(orders))
  35959. var medfee_sumamt float64
  35960. var acct_pay float64
  35961. var fund_pay_sumamt float64
  35962. for _, item := range orders {
  35963. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35964. acct_pay = acct_pay + item.AcctPay
  35965. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35966. }
  35967. //var medfee_sumamt_two float64
  35968. //var acct_pay_two float64
  35969. //var fund_pay_sumamt_two float64
  35970. //for _, item := range orders_two {
  35971. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  35972. // acct_pay_two = acct_pay_two + item.AcctPay
  35973. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  35974. //}
  35975. //var user_name string
  35976. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35977. //if role.ID == 0 {
  35978. // user_name = "xxx"
  35979. //} else {
  35980. // user_name = role.UserName
  35981. //}
  35982. var res ResultSix
  35983. if config.IsOpen == 1 {
  35984. var bps []*models.BusinessParamsTwo
  35985. var bp models.BusinessParamsTwo
  35986. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  35987. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  35988. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  35989. bp.MedfeeSumamt = medfee_sumamt_str
  35990. bp.AcctPay = acct_pay_str
  35991. bp.FundPaySumamt = fund_pay_sumamt_str
  35992. bp.Insutype = ""
  35993. bp.StmtBegndate = start_time
  35994. bp.ClrType = clr_type
  35995. bp.SetlOptins = clr_org
  35996. bp.StmtEnddate = end_time
  35997. bps = append(bps, &bp)
  35998. data := make(map[string]interface{})
  35999. data["bps"] = bps
  36000. data["org_name"] = miConfig.OrgName
  36001. data["doctor"] = role.UserName
  36002. data["fixmedins_code"] = miConfig.Code
  36003. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  36004. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  36005. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  36006. if miConfig.MdtrtareaAdmvs == "421300" {
  36007. client := &http.Client{}
  36008. bytesData, _ := json.Marshal(data)
  36009. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  36010. resp, _ := client.Do(req)
  36011. defer resp.Body.Close()
  36012. body, ioErr := ioutil.ReadAll(resp.Body)
  36013. if ioErr != nil {
  36014. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36016. return
  36017. }
  36018. var respJSON map[string]interface{}
  36019. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36022. return
  36023. }
  36024. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36025. userJSONBytes, _ := json.Marshal(respJSON)
  36026. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36027. utils.ErrorLog("解析失败:%v", err)
  36028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36029. return
  36030. }
  36031. }
  36032. if miConfig.MdtrtareaAdmvs == "420200" {
  36033. client := &http.Client{}
  36034. bytesData, _ := json.Marshal(data)
  36035. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  36036. resp, _ := client.Do(req)
  36037. defer resp.Body.Close()
  36038. body, ioErr := ioutil.ReadAll(resp.Body)
  36039. if ioErr != nil {
  36040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36042. return
  36043. }
  36044. var respJSON map[string]interface{}
  36045. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36048. return
  36049. }
  36050. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36051. userJSONBytes, _ := json.Marshal(respJSON)
  36052. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36053. utils.ErrorLog("解析失败:%v", err)
  36054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36055. return
  36056. }
  36057. }
  36058. if miConfig.MdtrtareaAdmvs == "421182" {
  36059. client := &http.Client{}
  36060. bytesData, _ := json.Marshal(data)
  36061. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  36062. resp, _ := client.Do(req)
  36063. defer resp.Body.Close()
  36064. body, ioErr := ioutil.ReadAll(resp.Body)
  36065. if ioErr != nil {
  36066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36068. return
  36069. }
  36070. var respJSON map[string]interface{}
  36071. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36074. return
  36075. }
  36076. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36077. userJSONBytes, _ := json.Marshal(respJSON)
  36078. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36079. utils.ErrorLog("解析失败:%v", err)
  36080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36081. return
  36082. }
  36083. }
  36084. if miConfig.MdtrtareaAdmvs == "420902" {
  36085. client := &http.Client{}
  36086. bytesData, _ := json.Marshal(data)
  36087. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  36088. resp, _ := client.Do(req)
  36089. defer resp.Body.Close()
  36090. body, ioErr := ioutil.ReadAll(resp.Body)
  36091. if ioErr != nil {
  36092. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36094. return
  36095. }
  36096. var respJSON map[string]interface{}
  36097. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36100. return
  36101. }
  36102. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36103. userJSONBytes, _ := json.Marshal(respJSON)
  36104. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36105. utils.ErrorLog("解析失败:%v", err)
  36106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36107. return
  36108. }
  36109. }
  36110. if res.Infcode == 0 {
  36111. c.ServeSuccessJSON(map[string]interface{}{
  36112. "msg": "发起成功",
  36113. })
  36114. } else {
  36115. c.ServeSuccessJSON(map[string]interface{}{
  36116. "failed_code": -10,
  36117. "msg": res.ErrMsg,
  36118. })
  36119. }
  36120. }
  36121. }
  36122. func (c *HisApiController) Post3204a() {
  36123. start_time := c.GetString("start_time")
  36124. end_time := c.GetString("end_time")
  36125. //insutype := c.GetString("insutype")
  36126. clr_type := c.GetString("clr_type")
  36127. clr_org := c.GetString("clr_optins")
  36128. admin_user_id, _ := c.GetInt64("admin_user_id")
  36129. adminUser := c.GetAdminUserInfo()
  36130. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36131. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36132. if len(clr_org) == 0 {
  36133. clr_org = miConfig.MdtrtareaAdmvs
  36134. }
  36135. timeLayout := "2006-01-02"
  36136. loc, _ := time.LoadLocation("Local")
  36137. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  36138. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  36139. var orders []*models.HisOrder
  36140. if clr_org == "421300" {
  36141. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  36142. } else if clr_org == "420902" {
  36143. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  36144. } else {
  36145. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  36146. }
  36147. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  36148. //fixmedins_setl_cnt := int64(len(orders))
  36149. var medfee_sumamt float64
  36150. var acct_pay float64
  36151. var fund_pay_sumamt float64
  36152. for _, item := range orders {
  36153. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  36154. acct_pay = acct_pay + item.AcctPay
  36155. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  36156. }
  36157. //var medfee_sumamt_two float64
  36158. //var acct_pay_two float64
  36159. //var fund_pay_sumamt_two float64
  36160. //for _, item := range orders_two {
  36161. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  36162. // acct_pay_two = acct_pay_two + item.AcctPay
  36163. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  36164. //}
  36165. //var user_name string
  36166. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36167. //if role.ID == 0 {
  36168. // user_name = "xxx"
  36169. //} else {
  36170. // user_name = role.UserName
  36171. //}
  36172. var res ResultSix
  36173. if config.IsOpen == 1 {
  36174. var bps []*models.BusinessParamsTwo
  36175. var bp models.BusinessParamsTwo
  36176. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  36177. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  36178. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  36179. bp.MedfeeSumamt = medfee_sumamt_str
  36180. bp.AcctPay = acct_pay_str
  36181. bp.FundPaySumamt = fund_pay_sumamt_str
  36182. bp.Insutype = ""
  36183. bp.StmtBegndate = start_time
  36184. bp.ClrType = clr_type
  36185. bp.SetlOptins = clr_org
  36186. bp.StmtEnddate = end_time
  36187. bps = append(bps, &bp)
  36188. data := make(map[string]interface{})
  36189. data["bps"] = bps
  36190. data["org_name"] = miConfig.OrgName
  36191. data["doctor"] = role.UserName
  36192. data["fixmedins_code"] = miConfig.Code
  36193. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  36194. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  36195. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  36196. if miConfig.MdtrtareaAdmvs == "421300" {
  36197. client := &http.Client{}
  36198. bytesData, _ := json.Marshal(data)
  36199. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  36200. resp, _ := client.Do(req)
  36201. defer resp.Body.Close()
  36202. body, ioErr := ioutil.ReadAll(resp.Body)
  36203. if ioErr != nil {
  36204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36206. return
  36207. }
  36208. var respJSON map[string]interface{}
  36209. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36212. return
  36213. }
  36214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36215. userJSONBytes, _ := json.Marshal(respJSON)
  36216. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36217. utils.ErrorLog("解析失败:%v", err)
  36218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36219. return
  36220. }
  36221. }
  36222. if miConfig.MdtrtareaAdmvs == "420200" {
  36223. client := &http.Client{}
  36224. bytesData, _ := json.Marshal(data)
  36225. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  36226. resp, _ := client.Do(req)
  36227. defer resp.Body.Close()
  36228. body, ioErr := ioutil.ReadAll(resp.Body)
  36229. if ioErr != nil {
  36230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36232. return
  36233. }
  36234. var respJSON map[string]interface{}
  36235. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36238. return
  36239. }
  36240. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36241. userJSONBytes, _ := json.Marshal(respJSON)
  36242. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36243. utils.ErrorLog("解析失败:%v", err)
  36244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36245. return
  36246. }
  36247. }
  36248. if miConfig.MdtrtareaAdmvs == "421182" {
  36249. client := &http.Client{}
  36250. bytesData, _ := json.Marshal(data)
  36251. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  36252. resp, _ := client.Do(req)
  36253. defer resp.Body.Close()
  36254. body, ioErr := ioutil.ReadAll(resp.Body)
  36255. if ioErr != nil {
  36256. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36258. return
  36259. }
  36260. var respJSON map[string]interface{}
  36261. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36262. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36264. return
  36265. }
  36266. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36267. userJSONBytes, _ := json.Marshal(respJSON)
  36268. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36269. utils.ErrorLog("解析失败:%v", err)
  36270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36271. return
  36272. }
  36273. }
  36274. if miConfig.MdtrtareaAdmvs == "420902" {
  36275. client := &http.Client{}
  36276. bytesData, _ := json.Marshal(data)
  36277. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  36278. resp, _ := client.Do(req)
  36279. defer resp.Body.Close()
  36280. body, ioErr := ioutil.ReadAll(resp.Body)
  36281. if ioErr != nil {
  36282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36284. return
  36285. }
  36286. var respJSON map[string]interface{}
  36287. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36290. return
  36291. }
  36292. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36293. userJSONBytes, _ := json.Marshal(respJSON)
  36294. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36295. utils.ErrorLog("解析失败:%v", err)
  36296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36297. return
  36298. }
  36299. }
  36300. if res.Infcode == 0 {
  36301. c.ServeSuccessJSON(map[string]interface{}{
  36302. "msg": "撤销成功",
  36303. })
  36304. } else {
  36305. c.ServeSuccessJSON(map[string]interface{}{
  36306. "failed_code": -10,
  36307. "msg": res.ErrMsg,
  36308. })
  36309. }
  36310. }
  36311. }
  36312. func (c *HisApiController) Post3204() {
  36313. admin_user_id, _ := c.GetInt64("admin_user_id")
  36314. id := c.GetString("id")
  36315. adminUser := c.GetAdminUserInfo()
  36316. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36317. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36318. //clr_org := miConfig.MdtrtareaAdmvs
  36319. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36320. var res ResultSix
  36321. if config.IsOpen == 1 {
  36322. data := make(map[string]interface{})
  36323. data["id"] = id
  36324. data["org_name"] = miConfig.OrgName
  36325. data["doctor"] = role.UserName
  36326. data["fixmedins_code"] = miConfig.Code
  36327. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  36328. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  36329. client := &http.Client{}
  36330. bytesData, _ := json.Marshal(data)
  36331. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  36332. resp, _ := client.Do(req)
  36333. defer resp.Body.Close()
  36334. body, ioErr := ioutil.ReadAll(resp.Body)
  36335. if ioErr != nil {
  36336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36338. return
  36339. }
  36340. var respJSON map[string]interface{}
  36341. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36344. return
  36345. }
  36346. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36347. userJSONBytes, _ := json.Marshal(respJSON)
  36348. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36349. utils.ErrorLog("解析失败:%v", err)
  36350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36351. return
  36352. }
  36353. if res.Infcode == 0 {
  36354. c.ServeSuccessJSON(map[string]interface{}{
  36355. "msg": "发起成功",
  36356. })
  36357. } else {
  36358. c.ServeSuccessJSON(map[string]interface{}{
  36359. "failed_code": -10,
  36360. "msg": res.ErrMsg,
  36361. })
  36362. }
  36363. }
  36364. }
  36365. func (c *HisApiController) Post8404() {
  36366. admin_user_id, _ := c.GetInt64("admin_user_id")
  36367. month := c.GetString("month")
  36368. adminUser := c.GetAdminUserInfo()
  36369. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36370. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36371. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36372. var res ResultSix
  36373. if config.IsOpen == 1 {
  36374. data := make(map[string]interface{})
  36375. data["month"] = month
  36376. data["org_name"] = miConfig.OrgName
  36377. data["doctor"] = role.UserName
  36378. data["fixmedins_code"] = miConfig.Code
  36379. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  36380. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  36381. client := &http.Client{}
  36382. bytesData, _ := json.Marshal(data)
  36383. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  36384. resp, _ := client.Do(req)
  36385. defer resp.Body.Close()
  36386. body, ioErr := ioutil.ReadAll(resp.Body)
  36387. if ioErr != nil {
  36388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36390. return
  36391. }
  36392. var respJSON map[string]interface{}
  36393. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36396. return
  36397. }
  36398. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36399. userJSONBytes, _ := json.Marshal(respJSON)
  36400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36401. utils.ErrorLog("解析失败:%v", err)
  36402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36403. return
  36404. }
  36405. if res.Infcode == 0 {
  36406. c.ServeSuccessJSON(map[string]interface{}{
  36407. "msg": "查询成功",
  36408. })
  36409. } else {
  36410. c.ServeSuccessJSON(map[string]interface{}{
  36411. "failed_code": -10,
  36412. "msg": res.ErrMsg,
  36413. })
  36414. }
  36415. }
  36416. }
  36417. func (c *HisApiController) Post3202b() {
  36418. start_time := c.GetString("start_time")
  36419. end_time := c.GetString("end_time")
  36420. //insutype := c.GetString("insutype")
  36421. clr_type := c.GetString("clr_type")
  36422. clr_org := c.GetString("clr_optins")
  36423. admin_user_id, _ := c.GetInt64("admin_user_id")
  36424. adminUser := c.GetAdminUserInfo()
  36425. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36426. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36427. if len(clr_org) == 0 {
  36428. clr_org = miConfig.MdtrtareaAdmvs
  36429. }
  36430. timeLayout := "2006-01-02"
  36431. loc, _ := time.LoadLocation("Local")
  36432. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  36433. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  36434. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  36435. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  36436. //fixmedins_setl_cnt := int64(len(orders))
  36437. var medfee_sumamt float64
  36438. var acct_pay float64
  36439. var fund_pay_sumamt float64
  36440. for _, item := range orders {
  36441. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  36442. acct_pay = acct_pay + item.AcctPay
  36443. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  36444. }
  36445. //var medfee_sumamt_two float64
  36446. //var acct_pay_two float64
  36447. //var fund_pay_sumamt_two float64
  36448. //for _, item := range orders_two {
  36449. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  36450. // acct_pay_two = acct_pay_two + item.AcctPay
  36451. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  36452. //}
  36453. //var user_name string
  36454. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36455. //if role.ID == 0 {
  36456. // user_name = "xxx"
  36457. //} else {
  36458. // user_name = role.UserName
  36459. //}
  36460. var res ResultSix
  36461. if config.IsOpen == 1 {
  36462. var bps []*models.BusinessParamsTwo
  36463. var bp models.BusinessParamsTwo
  36464. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  36465. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  36466. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  36467. bp.MedfeeSumamt = medfee_sumamt_str
  36468. bp.AcctPay = acct_pay_str
  36469. bp.FundPaySumamt = fund_pay_sumamt_str
  36470. bp.Insutype = "390"
  36471. bp.StmtBegndate = start_time
  36472. bp.ClrType = clr_type
  36473. bp.SetlOptins = clr_org
  36474. bp.StmtEnddate = end_time
  36475. bps = append(bps, &bp)
  36476. data := make(map[string]interface{})
  36477. data["bps"] = bps
  36478. data["org_name"] = miConfig.OrgName
  36479. data["doctor"] = role.UserName
  36480. data["fixmedins_code"] = miConfig.Code
  36481. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  36482. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  36483. if miConfig.MdtrtareaAdmvs == "421300" {
  36484. client := &http.Client{}
  36485. bytesData, _ := json.Marshal(data)
  36486. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  36487. resp, _ := client.Do(req)
  36488. defer resp.Body.Close()
  36489. body, ioErr := ioutil.ReadAll(resp.Body)
  36490. if ioErr != nil {
  36491. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36493. return
  36494. }
  36495. var respJSON map[string]interface{}
  36496. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36497. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36499. return
  36500. }
  36501. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36502. userJSONBytes, _ := json.Marshal(respJSON)
  36503. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36504. utils.ErrorLog("解析失败:%v", err)
  36505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36506. return
  36507. }
  36508. }
  36509. if miConfig.MdtrtareaAdmvs == "420200" {
  36510. client := &http.Client{}
  36511. bytesData, _ := json.Marshal(data)
  36512. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  36513. resp, _ := client.Do(req)
  36514. defer resp.Body.Close()
  36515. body, ioErr := ioutil.ReadAll(resp.Body)
  36516. if ioErr != nil {
  36517. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36519. return
  36520. }
  36521. var respJSON map[string]interface{}
  36522. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36525. return
  36526. }
  36527. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36528. userJSONBytes, _ := json.Marshal(respJSON)
  36529. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36530. utils.ErrorLog("解析失败:%v", err)
  36531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36532. return
  36533. }
  36534. }
  36535. if miConfig.MdtrtareaAdmvs == "421182" {
  36536. client := &http.Client{}
  36537. bytesData, _ := json.Marshal(data)
  36538. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  36539. resp, _ := client.Do(req)
  36540. defer resp.Body.Close()
  36541. body, ioErr := ioutil.ReadAll(resp.Body)
  36542. if ioErr != nil {
  36543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36545. return
  36546. }
  36547. var respJSON map[string]interface{}
  36548. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36551. return
  36552. }
  36553. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36554. userJSONBytes, _ := json.Marshal(respJSON)
  36555. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36556. utils.ErrorLog("解析失败:%v", err)
  36557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36558. return
  36559. }
  36560. }
  36561. if res.Infcode == 0 {
  36562. c.ServeSuccessJSON(map[string]interface{}{
  36563. "msg": "发起成功",
  36564. })
  36565. } else {
  36566. c.ServeSuccessJSON(map[string]interface{}{
  36567. "failed_code": -10,
  36568. "msg": res.ErrMsg,
  36569. })
  36570. }
  36571. }
  36572. }
  36573. func (c *HisApiController) Post1608() {
  36574. start_time := c.GetString("start_time")
  36575. end_time := c.GetString("end_time")
  36576. admin_user_id, _ := c.GetInt64("admin_user_id")
  36577. adminUser := c.GetAdminUserInfo()
  36578. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36579. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36580. timeLayout := "2006-01-02"
  36581. loc, _ := time.LoadLocation("Local")
  36582. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  36583. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  36584. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  36585. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  36586. fixmedins_setl_cnt := int64(len(orders))
  36587. var medfee_sumamt float64
  36588. var func_smamt float64
  36589. for _, item := range orders {
  36590. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  36591. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  36592. }
  36593. times := strings.Split(start_time, "-")
  36594. time_tows := strings.Split(end_time, "-")
  36595. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36596. var res ResultSix
  36597. if config.IsOpen == 1 {
  36598. //var bps []*models.BusinessParamsTwo
  36599. //var bp models.BusinessParamsTwo
  36600. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  36601. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  36602. data := make(map[string]interface{})
  36603. data["org_name"] = miConfig.OrgName
  36604. data["doctor"] = role.UserName
  36605. data["func_smamt"] = func_smamt_str
  36606. data["fixmedins_code"] = miConfig.Code
  36607. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  36608. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  36609. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  36610. data["medfee_sumamt"] = medfee_sumamt_str
  36611. data["start_time"] = times[0] + times[1] + times[2]
  36612. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  36613. if miConfig.MdtrtareaAdmvs == "421300" {
  36614. client := &http.Client{}
  36615. bytesData, _ := json.Marshal(data)
  36616. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  36617. resp, _ := client.Do(req)
  36618. defer resp.Body.Close()
  36619. body, ioErr := ioutil.ReadAll(resp.Body)
  36620. if ioErr != nil {
  36621. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36623. return
  36624. }
  36625. var respJSON map[string]interface{}
  36626. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36627. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36629. return
  36630. }
  36631. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36632. userJSONBytes, _ := json.Marshal(respJSON)
  36633. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36634. utils.ErrorLog("解析失败:%v", err)
  36635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36636. return
  36637. }
  36638. }
  36639. if miConfig.MdtrtareaAdmvs == "420200" {
  36640. client := &http.Client{}
  36641. bytesData, _ := json.Marshal(data)
  36642. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  36643. resp, _ := client.Do(req)
  36644. defer resp.Body.Close()
  36645. body, ioErr := ioutil.ReadAll(resp.Body)
  36646. if ioErr != nil {
  36647. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36649. return
  36650. }
  36651. var respJSON map[string]interface{}
  36652. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36655. return
  36656. }
  36657. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36658. userJSONBytes, _ := json.Marshal(respJSON)
  36659. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36660. utils.ErrorLog("解析失败:%v", err)
  36661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36662. return
  36663. }
  36664. }
  36665. if miConfig.MdtrtareaAdmvs == "421182" {
  36666. client := &http.Client{}
  36667. bytesData, _ := json.Marshal(data)
  36668. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  36669. resp, _ := client.Do(req)
  36670. defer resp.Body.Close()
  36671. body, ioErr := ioutil.ReadAll(resp.Body)
  36672. if ioErr != nil {
  36673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36675. return
  36676. }
  36677. var respJSON map[string]interface{}
  36678. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36681. return
  36682. }
  36683. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36684. userJSONBytes, _ := json.Marshal(respJSON)
  36685. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36686. utils.ErrorLog("解析失败:%v", err)
  36687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36688. return
  36689. }
  36690. }
  36691. if res.Infcode == 0 {
  36692. c.ServeSuccessJSON(map[string]interface{}{
  36693. "msg": "发起成功",
  36694. })
  36695. } else {
  36696. c.ServeSuccessJSON(map[string]interface{}{
  36697. "failed_code": -10,
  36698. "msg": res.ErrMsg,
  36699. })
  36700. }
  36701. }
  36702. }
  36703. // 5.11.1.1【5262】结算信息按时间段查询
  36704. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  36705. admin_user_id, _ := c.GetInt64("admin_user_id")
  36706. adminUser := c.GetAdminUserInfo()
  36707. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36708. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36709. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36710. var res Result5262
  36711. if config.IsOpen == 1 {
  36712. if miConfig.MdtrtareaAdmvs == "421300" {
  36713. data := make(map[string]interface{})
  36714. data["bps"] = bp
  36715. data["org_name"] = miConfig.OrgName
  36716. data["doctor"] = role.UserName
  36717. data["fixmedins_code"] = miConfig.Code
  36718. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  36719. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  36720. data["page"] = strconv.FormatInt(page, 10)
  36721. data["limit"] = strconv.FormatInt(limit, 10)
  36722. fmt.Println(data)
  36723. client := &http.Client{}
  36724. bytesData, _ := json.Marshal(data)
  36725. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  36726. resp, _ := client.Do(req)
  36727. defer resp.Body.Close()
  36728. body, ioErr := ioutil.ReadAll(resp.Body)
  36729. if ioErr != nil {
  36730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36732. return
  36733. }
  36734. var respJSON map[string]interface{}
  36735. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36738. return
  36739. }
  36740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36741. userJSONBytes, _ := json.Marshal(respJSON)
  36742. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36743. utils.ErrorLog("解析失败:%v", err)
  36744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36745. return
  36746. }
  36747. }
  36748. if miConfig.MdtrtareaAdmvs == "420200" {
  36749. data := make(map[string]interface{})
  36750. data["bps"] = bp
  36751. data["org_name"] = miConfig.OrgName
  36752. data["doctor"] = role.UserName
  36753. data["fixmedins_code"] = miConfig.Code
  36754. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  36755. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  36756. data["page"] = strconv.FormatInt(page, 10)
  36757. data["limit"] = strconv.FormatInt(limit, 10)
  36758. fmt.Println(data)
  36759. client := &http.Client{}
  36760. bytesData, _ := json.Marshal(data)
  36761. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  36762. resp, _ := client.Do(req)
  36763. defer resp.Body.Close()
  36764. body, ioErr := ioutil.ReadAll(resp.Body)
  36765. if ioErr != nil {
  36766. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36768. return
  36769. }
  36770. var respJSON map[string]interface{}
  36771. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36774. return
  36775. }
  36776. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36777. userJSONBytes, _ := json.Marshal(respJSON)
  36778. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36779. utils.ErrorLog("解析失败:%v", err)
  36780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36781. return
  36782. }
  36783. }
  36784. if miConfig.MdtrtareaAdmvs == "421182" {
  36785. data := make(map[string]interface{})
  36786. data["bps"] = bp
  36787. data["org_name"] = miConfig.OrgName
  36788. data["doctor"] = role.UserName
  36789. data["fixmedins_code"] = miConfig.Code
  36790. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  36791. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  36792. data["page"] = strconv.FormatInt(page, 10)
  36793. data["limit"] = strconv.FormatInt(limit, 10)
  36794. fmt.Println(data)
  36795. client := &http.Client{}
  36796. bytesData, _ := json.Marshal(data)
  36797. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  36798. resp, _ := client.Do(req)
  36799. defer resp.Body.Close()
  36800. body, ioErr := ioutil.ReadAll(resp.Body)
  36801. if ioErr != nil {
  36802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36804. return
  36805. }
  36806. var respJSON map[string]interface{}
  36807. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36810. return
  36811. }
  36812. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36813. userJSONBytes, _ := json.Marshal(respJSON)
  36814. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36815. utils.ErrorLog("解析失败:%v", err)
  36816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36817. return
  36818. }
  36819. }
  36820. if miConfig.MdtrtareaAdmvs == "420902" {
  36821. data := make(map[string]interface{})
  36822. data["bps"] = bp
  36823. data["org_name"] = miConfig.OrgName
  36824. data["doctor"] = role.UserName
  36825. data["fixmedins_code"] = miConfig.Code
  36826. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  36827. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  36828. data["page"] = strconv.FormatInt(page, 10)
  36829. data["limit"] = strconv.FormatInt(limit, 10)
  36830. fmt.Println(data)
  36831. client := &http.Client{}
  36832. bytesData, _ := json.Marshal(data)
  36833. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  36834. resp, _ := client.Do(req)
  36835. defer resp.Body.Close()
  36836. body, ioErr := ioutil.ReadAll(resp.Body)
  36837. if ioErr != nil {
  36838. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36840. return
  36841. }
  36842. var respJSON map[string]interface{}
  36843. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36844. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36846. return
  36847. }
  36848. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36849. userJSONBytes, _ := json.Marshal(respJSON)
  36850. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36851. utils.ErrorLog("解析失败:%v", err)
  36852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36853. return
  36854. }
  36855. }
  36856. if res.Infcode == 0 {
  36857. c.ServeSuccessJSON(map[string]interface{}{
  36858. "order": res.Output.Result,
  36859. "total": res.Output.PageInfo.RecordCounts,
  36860. })
  36861. } else {
  36862. c.ServeSuccessJSON(map[string]interface{}{
  36863. "failed_code": -10,
  36864. "msg": res.ErrMsg,
  36865. })
  36866. }
  36867. }
  36868. }
  36869. // 5.11.1.2【5267】异地结算信息时间段查询
  36870. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  36871. admin_user_id, _ := c.GetInt64("admin_user_id")
  36872. adminUser := c.GetAdminUserInfo()
  36873. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36874. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36875. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36876. var res Result5267
  36877. if config.IsOpen == 1 {
  36878. if miConfig.MdtrtareaAdmvs == "421300" {
  36879. data := make(map[string]interface{})
  36880. data["bps"] = bp
  36881. data["org_name"] = miConfig.OrgName
  36882. data["doctor"] = role.UserName
  36883. data["fixmedins_code"] = miConfig.Code
  36884. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  36885. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  36886. data["page"] = page
  36887. data["limit"] = limit
  36888. fmt.Println(data)
  36889. client := &http.Client{}
  36890. bytesData, _ := json.Marshal(data)
  36891. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  36892. resp, _ := client.Do(req)
  36893. defer resp.Body.Close()
  36894. body, ioErr := ioutil.ReadAll(resp.Body)
  36895. if ioErr != nil {
  36896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36898. return
  36899. }
  36900. var respJSON map[string]interface{}
  36901. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36904. return
  36905. }
  36906. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36907. userJSONBytes, _ := json.Marshal(respJSON)
  36908. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36909. utils.ErrorLog("解析失败:%v", err)
  36910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36911. return
  36912. }
  36913. }
  36914. if miConfig.MdtrtareaAdmvs == "420200" {
  36915. data := make(map[string]interface{})
  36916. data["bps"] = bp
  36917. data["org_name"] = miConfig.OrgName
  36918. data["doctor"] = role.UserName
  36919. data["fixmedins_code"] = miConfig.Code
  36920. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  36921. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  36922. data["page"] = page
  36923. data["limit"] = limit
  36924. fmt.Println(data)
  36925. client := &http.Client{}
  36926. bytesData, _ := json.Marshal(data)
  36927. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  36928. resp, _ := client.Do(req)
  36929. defer resp.Body.Close()
  36930. body, ioErr := ioutil.ReadAll(resp.Body)
  36931. if ioErr != nil {
  36932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36934. return
  36935. }
  36936. var respJSON map[string]interface{}
  36937. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36940. return
  36941. }
  36942. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36943. userJSONBytes, _ := json.Marshal(respJSON)
  36944. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36945. utils.ErrorLog("解析失败:%v", err)
  36946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36947. return
  36948. }
  36949. }
  36950. if miConfig.MdtrtareaAdmvs == "421182" {
  36951. data := make(map[string]interface{})
  36952. data["bps"] = bp
  36953. data["org_name"] = miConfig.OrgName
  36954. data["doctor"] = role.UserName
  36955. data["fixmedins_code"] = miConfig.Code
  36956. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  36957. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  36958. data["page"] = page
  36959. data["limit"] = limit
  36960. fmt.Println(data)
  36961. client := &http.Client{}
  36962. bytesData, _ := json.Marshal(data)
  36963. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  36964. resp, _ := client.Do(req)
  36965. defer resp.Body.Close()
  36966. body, ioErr := ioutil.ReadAll(resp.Body)
  36967. if ioErr != nil {
  36968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36970. return
  36971. }
  36972. var respJSON map[string]interface{}
  36973. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36976. return
  36977. }
  36978. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36979. userJSONBytes, _ := json.Marshal(respJSON)
  36980. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36981. utils.ErrorLog("解析失败:%v", err)
  36982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36983. return
  36984. }
  36985. }
  36986. if res.Infcode == 0 {
  36987. c.ServeSuccessJSON(map[string]interface{}{
  36988. "order": res.Output.Result,
  36989. "total": res.Output.PageInfo.RecordCounts,
  36990. })
  36991. } else {
  36992. c.ServeSuccessJSON(map[string]interface{}{
  36993. "failed_code": -10,
  36994. "msg": res.ErrMsg,
  36995. })
  36996. }
  36997. }
  36998. }
  36999. func (c *HisApiController) Post3501() {
  37000. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  37001. data := make(map[string]interface{})
  37002. var struct3501s []models.Struct3501
  37003. var struct3501 models.Struct3501
  37004. struct3501.OrgName = miConfig.OrgName
  37005. struct3501.AccessKey = miConfig.AccessKey
  37006. struct3501.RequestUrl = miConfig.Url
  37007. struct3501.SecretKey = miConfig.SecretKey
  37008. struct3501.ManuDate = "2022-08-17"
  37009. struct3501.FixmedinsBchno = ""
  37010. struct3501.ManuLotnum = ""
  37011. struct3501.RxFlag = "0"
  37012. struct3501.ExpyEnd = "2022-08-17"
  37013. struct3501.Invdate = "2022-08-17"
  37014. struct3501.InvCnt = "20.25"
  37015. struct3501.Memo = ""
  37016. struct3501.MedListCodg = "XB01ABD056B002020200517"
  37017. struct3501.FixmedinsHilistId = miConfig.Code
  37018. struct3501.FixmedinsHilistName = miConfig.OrgName
  37019. struct3501s = append(struct3501s, struct3501)
  37020. data["struct_3501s"] = struct3501s
  37021. client := &http.Client{}
  37022. bytesData, _ := json.Marshal(data)
  37023. var req *http.Request
  37024. if miConfig.MdtrtareaAdmvs == "320921" {
  37025. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  37026. } else {
  37027. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  37028. }
  37029. resp, _ := client.Do(req)
  37030. defer resp.Body.Close()
  37031. body, ioErr := ioutil.ReadAll(resp.Body)
  37032. if ioErr != nil {
  37033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37035. return
  37036. }
  37037. var respJSON map[string]interface{}
  37038. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37041. return
  37042. }
  37043. var res ResultSix
  37044. var resSix10265 ResultSix10265 //1101结果
  37045. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  37046. result, _ := json.Marshal(respJSON)
  37047. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  37048. utils.ErrorLog("解析失败:%v", err)
  37049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37050. return
  37051. }
  37052. res.InfRefmsgid = resSix10265.InfRefmsgid
  37053. res.Output = resSix10265.Output
  37054. res.ErrMsg = resSix10265.ErrMsg
  37055. res.Cainfo = resSix10265.Cainfo
  37056. res.WarnMsg = resSix10265.WarnMsg
  37057. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  37058. res.Infcode = infocode
  37059. if infocode == 0 {
  37060. c.ServeSuccessJSON(map[string]interface{}{
  37061. "msg": "上传成功",
  37062. })
  37063. return
  37064. } else {
  37065. c.ServeSuccessJSON(map[string]interface{}{
  37066. "failed_code": -10,
  37067. "msg": res.ErrMsg,
  37068. })
  37069. return
  37070. }
  37071. }
  37072. func (c *HisApiController) Post3502() {
  37073. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  37074. data := make(map[string]interface{})
  37075. var struct3502s []models.Struct3502
  37076. var struct3502 models.Struct3502
  37077. struct3502.OrgName = miConfig.OrgName
  37078. struct3502.AccessKey = miConfig.AccessKey
  37079. struct3502.RequestUrl = miConfig.Url
  37080. struct3502.SecretKey = miConfig.SecretKey
  37081. struct3502.ManuDate = "2022-08-15"
  37082. struct3502.FixmedinsBchno = ""
  37083. struct3502.ManuLotnum = ""
  37084. struct3502.RxFlag = "0"
  37085. struct3502.ExpyEnd = "2022-08-15"
  37086. struct3502.Invdate = "2022-08-15"
  37087. struct3502.InvCnt = "20.25"
  37088. struct3502.Memo = ""
  37089. struct3502.MedListCodg = "XB01ABD056B002020200517"
  37090. struct3502.FixmedinsHilistId = miConfig.Code
  37091. struct3502.FixmedinsHilistName = miConfig.OrgName
  37092. struct3502s = append(struct3502s, struct3502)
  37093. data["struct_3502s"] = struct3502s
  37094. client := &http.Client{}
  37095. bytesData, _ := json.Marshal(data)
  37096. var req *http.Request
  37097. if miConfig.MdtrtareaAdmvs == "320921" {
  37098. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  37099. } else {
  37100. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  37101. }
  37102. resp, _ := client.Do(req)
  37103. defer resp.Body.Close()
  37104. body, ioErr := ioutil.ReadAll(resp.Body)
  37105. if ioErr != nil {
  37106. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37108. return
  37109. }
  37110. var respJSON map[string]interface{}
  37111. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37114. return
  37115. }
  37116. var res ResultSix
  37117. var resSix10265 ResultSix10265 //1101结果
  37118. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  37119. result, _ := json.Marshal(respJSON)
  37120. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  37121. utils.ErrorLog("解析失败:%v", err)
  37122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37123. return
  37124. }
  37125. res.InfRefmsgid = resSix10265.InfRefmsgid
  37126. res.Output = resSix10265.Output
  37127. res.ErrMsg = resSix10265.ErrMsg
  37128. res.Cainfo = resSix10265.Cainfo
  37129. res.WarnMsg = resSix10265.WarnMsg
  37130. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  37131. res.Infcode = infocode
  37132. if infocode == 0 {
  37133. c.ServeSuccessJSON(map[string]interface{}{
  37134. "msg": "上传成功",
  37135. })
  37136. return
  37137. } else {
  37138. c.ServeSuccessJSON(map[string]interface{}{
  37139. "failed_code": -10,
  37140. "msg": res.ErrMsg,
  37141. })
  37142. return
  37143. }
  37144. }
  37145. func (c *HisApiController) Post3503() {
  37146. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  37147. data := make(map[string]interface{})
  37148. var struct3501s []models.Struct3501
  37149. var struct3501 models.Struct3501
  37150. struct3501.OrgName = miConfig.OrgName
  37151. struct3501.AccessKey = miConfig.AccessKey
  37152. struct3501.RequestUrl = miConfig.Url
  37153. struct3501.SecretKey = miConfig.SecretKey
  37154. struct3501.ManuDate = "2022-08-15"
  37155. struct3501.FixmedinsBchno = ""
  37156. struct3501.ManuLotnum = ""
  37157. struct3501.RxFlag = "0"
  37158. struct3501.ExpyEnd = "2022-08-15"
  37159. struct3501.Invdate = "2022-08-15"
  37160. struct3501.InvCnt = "20.25"
  37161. struct3501.Memo = ""
  37162. struct3501.MedListCodg = "XB01ABD056B002020200517"
  37163. struct3501.FixmedinsHilistId = miConfig.Code
  37164. struct3501.FixmedinsHilistName = miConfig.OrgName
  37165. struct3501s = append(struct3501s, struct3501)
  37166. data["struct_3501s"] = struct3501s
  37167. client := &http.Client{}
  37168. bytesData, _ := json.Marshal(data)
  37169. var req *http.Request
  37170. if miConfig.MdtrtareaAdmvs == "320921" {
  37171. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  37172. } else {
  37173. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  37174. }
  37175. resp, _ := client.Do(req)
  37176. defer resp.Body.Close()
  37177. body, ioErr := ioutil.ReadAll(resp.Body)
  37178. if ioErr != nil {
  37179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37181. return
  37182. }
  37183. var respJSON map[string]interface{}
  37184. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37187. return
  37188. }
  37189. var res ResultSix
  37190. var resSix10265 ResultSix10265 //1101结果
  37191. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  37192. result, _ := json.Marshal(respJSON)
  37193. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  37194. utils.ErrorLog("解析失败:%v", err)
  37195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37196. return
  37197. }
  37198. res.InfRefmsgid = resSix10265.InfRefmsgid
  37199. res.Output = resSix10265.Output
  37200. res.ErrMsg = resSix10265.ErrMsg
  37201. res.Cainfo = resSix10265.Cainfo
  37202. res.WarnMsg = resSix10265.WarnMsg
  37203. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  37204. res.Infcode = infocode
  37205. if infocode == 0 {
  37206. c.ServeSuccessJSON(map[string]interface{}{
  37207. "msg": "上传成功",
  37208. })
  37209. return
  37210. } else {
  37211. c.ServeSuccessJSON(map[string]interface{}{
  37212. "failed_code": -10,
  37213. "msg": res.ErrMsg,
  37214. })
  37215. return
  37216. }
  37217. }
  37218. func (c *HisApiController) Post3504() {
  37219. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  37220. data := make(map[string]interface{})
  37221. var struct3501s []models.Struct3501
  37222. var struct3501 models.Struct3501
  37223. struct3501.OrgName = miConfig.OrgName
  37224. struct3501.AccessKey = miConfig.AccessKey
  37225. struct3501.RequestUrl = miConfig.Url
  37226. struct3501.SecretKey = miConfig.SecretKey
  37227. struct3501.ManuDate = "2022-08-15"
  37228. struct3501.FixmedinsBchno = ""
  37229. struct3501.ManuLotnum = ""
  37230. struct3501.RxFlag = "0"
  37231. struct3501.ExpyEnd = "2022-08-15"
  37232. struct3501.Invdate = "2022-08-15"
  37233. struct3501.InvCnt = "20.25"
  37234. struct3501.Memo = ""
  37235. struct3501.MedListCodg = "XB01ABD056B002020200517"
  37236. struct3501.FixmedinsHilistId = miConfig.Code
  37237. struct3501.FixmedinsHilistName = miConfig.OrgName
  37238. struct3501s = append(struct3501s, struct3501)
  37239. data["struct_3501s"] = struct3501s
  37240. client := &http.Client{}
  37241. bytesData, _ := json.Marshal(data)
  37242. var req *http.Request
  37243. if miConfig.MdtrtareaAdmvs == "320921" {
  37244. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  37245. } else {
  37246. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  37247. }
  37248. resp, _ := client.Do(req)
  37249. defer resp.Body.Close()
  37250. body, ioErr := ioutil.ReadAll(resp.Body)
  37251. if ioErr != nil {
  37252. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37254. return
  37255. }
  37256. var respJSON map[string]interface{}
  37257. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37260. return
  37261. }
  37262. var res ResultSix
  37263. var resSix10265 ResultSix10265 //1101结果
  37264. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  37265. result, _ := json.Marshal(respJSON)
  37266. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  37267. utils.ErrorLog("解析失败:%v", err)
  37268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37269. return
  37270. }
  37271. res.InfRefmsgid = resSix10265.InfRefmsgid
  37272. res.Output = resSix10265.Output
  37273. res.ErrMsg = resSix10265.ErrMsg
  37274. res.Cainfo = resSix10265.Cainfo
  37275. res.WarnMsg = resSix10265.WarnMsg
  37276. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  37277. res.Infcode = infocode
  37278. if infocode == 0 {
  37279. c.ServeSuccessJSON(map[string]interface{}{
  37280. "msg": "上传成功",
  37281. })
  37282. return
  37283. } else {
  37284. c.ServeSuccessJSON(map[string]interface{}{
  37285. "failed_code": -10,
  37286. "msg": res.ErrMsg,
  37287. })
  37288. return
  37289. }
  37290. }
  37291. func (c *HisApiController) Post3505() {
  37292. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  37293. data := make(map[string]interface{})
  37294. var struct3501s []models.Struct3501
  37295. var struct3501 models.Struct3501
  37296. struct3501.OrgName = miConfig.OrgName
  37297. struct3501.AccessKey = miConfig.AccessKey
  37298. struct3501.RequestUrl = miConfig.Url
  37299. struct3501.SecretKey = miConfig.SecretKey
  37300. struct3501.ManuDate = "2022-08-15"
  37301. struct3501.FixmedinsBchno = ""
  37302. struct3501.ManuLotnum = ""
  37303. struct3501.RxFlag = "0"
  37304. struct3501.ExpyEnd = "2022-08-15"
  37305. struct3501.Invdate = "2022-08-15"
  37306. struct3501.InvCnt = "20.25"
  37307. struct3501.Memo = ""
  37308. struct3501.MedListCodg = "XB01ABD056B002020200517"
  37309. struct3501.FixmedinsHilistId = miConfig.Code
  37310. struct3501.FixmedinsHilistName = miConfig.OrgName
  37311. struct3501s = append(struct3501s, struct3501)
  37312. data["struct_3501s"] = struct3501s
  37313. client := &http.Client{}
  37314. bytesData, _ := json.Marshal(data)
  37315. var req *http.Request
  37316. if miConfig.MdtrtareaAdmvs == "320921" {
  37317. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  37318. } else {
  37319. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  37320. }
  37321. resp, _ := client.Do(req)
  37322. defer resp.Body.Close()
  37323. body, ioErr := ioutil.ReadAll(resp.Body)
  37324. if ioErr != nil {
  37325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37327. return
  37328. }
  37329. var respJSON map[string]interface{}
  37330. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37333. return
  37334. }
  37335. var res ResultSix
  37336. var resSix10265 ResultSix10265 //1101结果
  37337. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  37338. result, _ := json.Marshal(respJSON)
  37339. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  37340. utils.ErrorLog("解析失败:%v", err)
  37341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37342. return
  37343. }
  37344. res.InfRefmsgid = resSix10265.InfRefmsgid
  37345. res.Output = resSix10265.Output
  37346. res.ErrMsg = resSix10265.ErrMsg
  37347. res.Cainfo = resSix10265.Cainfo
  37348. res.WarnMsg = resSix10265.WarnMsg
  37349. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  37350. res.Infcode = infocode
  37351. if infocode == 0 {
  37352. c.ServeSuccessJSON(map[string]interface{}{
  37353. "msg": "上传成功",
  37354. })
  37355. return
  37356. } else {
  37357. c.ServeSuccessJSON(map[string]interface{}{
  37358. "failed_code": -10,
  37359. "msg": res.ErrMsg,
  37360. })
  37361. return
  37362. }
  37363. }
  37364. func (c *HisApiController) Post3506() {
  37365. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  37366. data := make(map[string]interface{})
  37367. var struct3501s []models.Struct3501
  37368. var struct3501 models.Struct3501
  37369. struct3501.OrgName = miConfig.OrgName
  37370. struct3501.AccessKey = miConfig.AccessKey
  37371. struct3501.RequestUrl = miConfig.Url
  37372. struct3501.SecretKey = miConfig.SecretKey
  37373. struct3501.ManuDate = "2022-08-15"
  37374. struct3501.FixmedinsBchno = ""
  37375. struct3501.ManuLotnum = ""
  37376. struct3501.RxFlag = "0"
  37377. struct3501.ExpyEnd = "2022-08-15"
  37378. struct3501.Invdate = "2022-08-15"
  37379. struct3501.InvCnt = "20.25"
  37380. struct3501.Memo = ""
  37381. struct3501.MedListCodg = "XB01ABD056B002020200517"
  37382. struct3501.FixmedinsHilistId = miConfig.Code
  37383. struct3501.FixmedinsHilistName = miConfig.OrgName
  37384. struct3501s = append(struct3501s, struct3501)
  37385. data["struct_3501s"] = struct3501s
  37386. client := &http.Client{}
  37387. bytesData, _ := json.Marshal(data)
  37388. var req *http.Request
  37389. if miConfig.MdtrtareaAdmvs == "320921" {
  37390. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  37391. } else {
  37392. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  37393. }
  37394. resp, _ := client.Do(req)
  37395. defer resp.Body.Close()
  37396. body, ioErr := ioutil.ReadAll(resp.Body)
  37397. if ioErr != nil {
  37398. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37400. return
  37401. }
  37402. var respJSON map[string]interface{}
  37403. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37406. return
  37407. }
  37408. var res ResultSix
  37409. var resSix10265 ResultSix10265 //1101结果
  37410. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  37411. result, _ := json.Marshal(respJSON)
  37412. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  37413. utils.ErrorLog("解析失败:%v", err)
  37414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37415. return
  37416. }
  37417. res.InfRefmsgid = resSix10265.InfRefmsgid
  37418. res.Output = resSix10265.Output
  37419. res.ErrMsg = resSix10265.ErrMsg
  37420. res.Cainfo = resSix10265.Cainfo
  37421. res.WarnMsg = resSix10265.WarnMsg
  37422. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  37423. res.Infcode = infocode
  37424. if infocode == 0 {
  37425. c.ServeSuccessJSON(map[string]interface{}{
  37426. "msg": "上传成功",
  37427. })
  37428. return
  37429. } else {
  37430. c.ServeSuccessJSON(map[string]interface{}{
  37431. "failed_code": -10,
  37432. "msg": res.ErrMsg,
  37433. })
  37434. return
  37435. }
  37436. }
  37437. func (c *HisApiController) Post3507() {
  37438. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  37439. data := make(map[string]interface{})
  37440. var struct3501s []models.Struct3501
  37441. var struct3501 models.Struct3501
  37442. struct3501.OrgName = miConfig.OrgName
  37443. struct3501.AccessKey = miConfig.AccessKey
  37444. struct3501.RequestUrl = miConfig.Url
  37445. struct3501.SecretKey = miConfig.SecretKey
  37446. struct3501.ManuDate = "2022-08-15"
  37447. struct3501.FixmedinsBchno = ""
  37448. struct3501.ManuLotnum = ""
  37449. struct3501.RxFlag = "0"
  37450. struct3501.ExpyEnd = "2022-08-15"
  37451. struct3501.Invdate = "2022-08-15"
  37452. struct3501.InvCnt = "20.25"
  37453. struct3501.Memo = ""
  37454. struct3501.MedListCodg = "XB01ABD056B002020200517"
  37455. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  37456. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  37457. struct3501s = append(struct3501s, struct3501)
  37458. data["struct_3501s"] = struct3501s
  37459. client := &http.Client{}
  37460. bytesData, _ := json.Marshal(data)
  37461. var req *http.Request
  37462. if miConfig.MdtrtareaAdmvs == "320921" {
  37463. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  37464. } else {
  37465. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  37466. }
  37467. resp, _ := client.Do(req)
  37468. defer resp.Body.Close()
  37469. body, ioErr := ioutil.ReadAll(resp.Body)
  37470. if ioErr != nil {
  37471. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37473. return
  37474. }
  37475. var respJSON map[string]interface{}
  37476. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37477. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37479. return
  37480. }
  37481. var res ResultSix
  37482. var resSix10265 ResultSix10265 //1101结果
  37483. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  37484. result, _ := json.Marshal(respJSON)
  37485. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  37486. utils.ErrorLog("解析失败:%v", err)
  37487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37488. return
  37489. }
  37490. res.InfRefmsgid = resSix10265.InfRefmsgid
  37491. res.Output = resSix10265.Output
  37492. res.ErrMsg = resSix10265.ErrMsg
  37493. res.Cainfo = resSix10265.Cainfo
  37494. res.WarnMsg = resSix10265.WarnMsg
  37495. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  37496. res.Infcode = infocode
  37497. if infocode == 0 {
  37498. c.ServeSuccessJSON(map[string]interface{}{
  37499. "msg": "上传成功",
  37500. })
  37501. return
  37502. } else {
  37503. c.ServeSuccessJSON(map[string]interface{}{
  37504. "failed_code": -10,
  37505. "msg": res.ErrMsg,
  37506. })
  37507. return
  37508. }
  37509. }
  37510. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  37511. // WebSocket服务器地址
  37512. serverURL := "ws://127.0.0.1:8899"
  37513. // 解析WebSocket服务器地址
  37514. u, err := url.Parse(serverURL)
  37515. if err != nil {
  37516. }
  37517. // 建立WebSocket连接
  37518. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  37519. if err != nil {
  37520. }
  37521. defer conn.Close()
  37522. input2 := make(map[string]interface{})
  37523. input := make(map[string]interface{})
  37524. inputData := make(map[string]interface{})
  37525. inputData["orgId"] = code
  37526. inputData["businessType"] = "01101"
  37527. inputData["operatorId"] = operator_id
  37528. inputData["operatorName"] = operator_name
  37529. inputData["officeId"] = "001"
  37530. inputData["officeName"] = "血透室"
  37531. inputData["deviceType"] = ""
  37532. input["data"] = inputData
  37533. input["orgId"] = code
  37534. input["transType"] = "ec.query"
  37535. //if md == ""
  37536. if md[:4] == "4403" {
  37537. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  37538. } else if md[:4] == "4401" {
  37539. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  37540. } else {
  37541. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  37542. }
  37543. input2["indata"] = input
  37544. fmt.Println(input2)
  37545. bytesData, _ := json.Marshal(input2)
  37546. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  37547. if err != nil {
  37548. fmt.Println(err)
  37549. }
  37550. // 接收消息
  37551. _, receivedMessage, err := conn.ReadMessage()
  37552. if err != nil {
  37553. fmt.Println(err)
  37554. }
  37555. return "", string(receivedMessage)
  37556. }
  37557. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  37558. // WebSocket服务器地址
  37559. serverURL := "ws://127.0.0.1:8899"
  37560. // 解析WebSocket服务器地址
  37561. u, err := url.Parse(serverURL)
  37562. if err != nil {
  37563. }
  37564. // 建立WebSocket连接
  37565. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  37566. if err != nil {
  37567. }
  37568. defer conn.Close()
  37569. input2 := make(map[string]interface{})
  37570. input := make(map[string]interface{})
  37571. inputData := make(map[string]interface{})
  37572. inputData["orgId"] = code
  37573. inputData["businessType"] = "01101"
  37574. inputData["operatorId"] = operator_id
  37575. inputData["operatorName"] = operator_name
  37576. inputData["officeId"] = "001"
  37577. inputData["officeName"] = "血透室"
  37578. inputData["deviceType"] = ""
  37579. input["data"] = inputData
  37580. input["orgId"] = code
  37581. input["transType"] = "ec.query"
  37582. //if md == ""
  37583. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  37584. input2["indata"] = input
  37585. fmt.Println(input2)
  37586. bytesData, _ := json.Marshal(input2)
  37587. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  37588. if err != nil {
  37589. fmt.Println(err)
  37590. }
  37591. // 接收消息
  37592. _, receivedMessage, err := conn.ReadMessage()
  37593. if err != nil {
  37594. fmt.Println(err)
  37595. }
  37596. return "", string(receivedMessage)
  37597. }
  37598. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  37599. // WebSocket服务器地址
  37600. serverURL := "ws://127.0.0.1:8899"
  37601. // 解析WebSocket服务器地址
  37602. u, err := url.Parse(serverURL)
  37603. if err != nil {
  37604. }
  37605. // 建立WebSocket连接
  37606. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  37607. if err != nil {
  37608. }
  37609. defer conn.Close()
  37610. input2 := make(map[string]interface{})
  37611. input := make(map[string]interface{})
  37612. inputData := make(map[string]interface{})
  37613. inputData["orgId"] = code
  37614. inputData["businessType"] = "01301"
  37615. inputData["operatorId"] = operator_id
  37616. inputData["operatorName"] = operator_name
  37617. inputData["officeId"] = "001"
  37618. inputData["officeName"] = "血透室"
  37619. inputData["deviceType"] = ""
  37620. input["data"] = inputData
  37621. input["orgId"] = code
  37622. input["transType"] = "ec.query"
  37623. //if md == ""
  37624. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  37625. input2["indata"] = input
  37626. fmt.Println(input2)
  37627. bytesData, _ := json.Marshal(input2)
  37628. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  37629. if err != nil {
  37630. fmt.Println(err)
  37631. }
  37632. // 接收消息
  37633. _, receivedMessage, err := conn.ReadMessage()
  37634. if err != nil {
  37635. fmt.Println(err)
  37636. }
  37637. return "", string(receivedMessage)
  37638. }
  37639. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  37640. // WebSocket服务器地址
  37641. serverURL := "ws://127.0.0.1:8899"
  37642. // 解析WebSocket服务器地址
  37643. u, err := url.Parse(serverURL)
  37644. if err != nil {
  37645. }
  37646. // 建立WebSocket连接
  37647. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  37648. if err != nil {
  37649. }
  37650. defer conn.Close()
  37651. input2 := make(map[string]interface{})
  37652. input := make(map[string]interface{})
  37653. inputData := make(map[string]interface{})
  37654. inputData["orgId"] = code
  37655. inputData["businessType"] = "01103"
  37656. inputData["operatorId"] = operator_id
  37657. inputData["operatorName"] = operator_name
  37658. inputData["officeId"] = "001"
  37659. inputData["officeName"] = "血透室"
  37660. inputData["deviceType"] = ""
  37661. input["data"] = inputData
  37662. input["orgId"] = code
  37663. input["transType"] = "ec.query"
  37664. //if md ==
  37665. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  37666. input2["indata"] = input
  37667. fmt.Println(input2)
  37668. bytesData, _ := json.Marshal(input2)
  37669. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  37670. if err != nil {
  37671. fmt.Println(err)
  37672. }
  37673. // 接收消息
  37674. _, receivedMessage, err := conn.ReadMessage()
  37675. if err != nil {
  37676. fmt.Println(err)
  37677. }
  37678. return "", string(receivedMessage)
  37679. }
  37680. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  37681. // WebSocket服务器地址
  37682. serverURL := "ws://127.0.0.1:8899"
  37683. // 解析WebSocket服务器地址
  37684. u, err := url.Parse(serverURL)
  37685. if err != nil {
  37686. }
  37687. // 建立WebSocket连接
  37688. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  37689. if err != nil {
  37690. }
  37691. defer conn.Close()
  37692. input2 := make(map[string]interface{})
  37693. input := make(map[string]interface{})
  37694. inputData := make(map[string]interface{})
  37695. inputData["orgId"] = code
  37696. inputData["businessType"] = "01101"
  37697. inputData["operatorId"] = operator_id
  37698. inputData["operatorName"] = operator_name
  37699. inputData["officeId"] = "001"
  37700. inputData["officeName"] = "血透室"
  37701. inputData["deviceType"] = ""
  37702. input["data"] = inputData
  37703. input["orgId"] = code
  37704. input["transType"] = "ec.query"
  37705. //if md == ""
  37706. if md[:4] == "4403" {
  37707. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  37708. } else if md[:4] == "4401" {
  37709. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  37710. } else {
  37711. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  37712. }
  37713. input2["indata"] = input
  37714. fmt.Println(input2)
  37715. bytesData, _ := json.Marshal(input2)
  37716. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  37717. if err != nil {
  37718. fmt.Println(err)
  37719. }
  37720. // 接收消息
  37721. _, receivedMessage, err := conn.ReadMessage()
  37722. if err != nil {
  37723. fmt.Println(err)
  37724. }
  37725. return "", string(receivedMessage)
  37726. }
  37727. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  37728. // WebSocket服务器地址
  37729. serverURL := "ws://127.0.0.1:8899"
  37730. // 解析WebSocket服务器地址
  37731. u, err := url.Parse(serverURL)
  37732. if err != nil {
  37733. }
  37734. // 建立WebSocket连接
  37735. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  37736. if err != nil {
  37737. }
  37738. defer conn.Close()
  37739. input2 := make(map[string]interface{})
  37740. input := make(map[string]interface{})
  37741. inputData := make(map[string]interface{})
  37742. inputData["orgId"] = code
  37743. inputData["businessType"] = "01301"
  37744. inputData["operatorId"] = operator_id
  37745. inputData["operatorName"] = operator_name
  37746. inputData["officeId"] = "001"
  37747. inputData["officeName"] = "血透室"
  37748. inputData["deviceType"] = ""
  37749. input["data"] = inputData
  37750. input["orgId"] = code
  37751. input["transType"] = "ec.query"
  37752. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  37753. input2["indata"] = input
  37754. bytesData, _ := json.Marshal(input2)
  37755. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  37756. if err != nil {
  37757. fmt.Println(err)
  37758. }
  37759. // 接收消息
  37760. _, receivedMessage, err := conn.ReadMessage()
  37761. if err != nil {
  37762. fmt.Println(err)
  37763. }
  37764. return "", string(receivedMessage)
  37765. }
  37766. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  37767. newArr = make([]string, 0)
  37768. for i := 0; i < len(arr); i++ {
  37769. repeat := false
  37770. for j := i + 1; j < len(arr); j++ {
  37771. if arr[i] == arr[j] {
  37772. repeat = true
  37773. break
  37774. }
  37775. }
  37776. if !repeat {
  37777. newArr = append(newArr, arr[i])
  37778. }
  37779. }
  37780. return
  37781. }
  37782. func getBirthdateAndAge(idNumber string) (string, int, error) {
  37783. if len(idNumber) != 18 {
  37784. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  37785. }
  37786. // 提取出生日期
  37787. year, err := strconv.Atoi(idNumber[6:10])
  37788. if err != nil {
  37789. return "", 0, err
  37790. }
  37791. month, err := strconv.Atoi(idNumber[10:12])
  37792. if err != nil {
  37793. return "", 0, err
  37794. }
  37795. day, err := strconv.Atoi(idNumber[12:14])
  37796. if err != nil {
  37797. return "", 0, err
  37798. }
  37799. // 格式化生日字符串
  37800. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  37801. birthdateFormatted := birthdate.Format("2006-01-02")
  37802. // 计算年龄
  37803. today := time.Now()
  37804. age := today.Year() - birthdate.Year()
  37805. if today.YearDay() < birthdate.YearDay() {
  37806. age--
  37807. }
  37808. return birthdateFormatted, age, nil
  37809. }
  37810. // 从身份证号码中提取出生年月日
  37811. func getBirthDateFromIDCard(idCard string) (string, error) {
  37812. // 身份证号码长度应为18位
  37813. if len(idCard) != 18 {
  37814. return "", fmt.Errorf("身份证号码长度应为18位")
  37815. }
  37816. // 提取出生日期部分 (YYYYMMDD)
  37817. birthDateStr := idCard[6:14]
  37818. // 解析出生日期
  37819. birthDate, err := time.Parse("20060102", birthDateStr)
  37820. if err != nil {
  37821. return "", fmt.Errorf("解析出生日期失败: %v", err)
  37822. }
  37823. // 格式化出生日期为 YYYY-MM-DD
  37824. formattedDate := birthDate.Format("2006-01-02")
  37825. return formattedDate, nil
  37826. }