his_api_controller.go 1.5MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286
  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"
  26. "math/rand"
  27. "net/http"
  28. "net/url"
  29. "os"
  30. "path/filepath"
  31. "regexp"
  32. "strconv"
  33. "strings"
  34. "syscall"
  35. "time"
  36. "unsafe"
  37. "github.com/go-ole/go-ole"
  38. )
  39. type HisApiController struct {
  40. controllers.BaseAuthAPIController
  41. }
  42. func HisManagerApiRegistRouters() {
  43. //挂号
  44. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  45. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  46. //上传就诊信息-上传明细-结算
  47. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  48. //查询
  49. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  50. //对总账
  51. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  52. //对明细
  53. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  54. //退费,退明细
  55. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  56. //退号
  57. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  58. //退明细
  59. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  60. //上传就诊信息-上传明细-预结算
  61. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  62. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  63. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  64. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  65. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  66. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  67. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  68. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  69. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  70. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  71. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  72. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  73. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  74. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  75. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  76. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  77. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  78. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  79. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  80. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  81. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  82. beego.Router("/api/check", &HisApiController{}, "get:Check")
  83. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  84. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  85. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  86. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  87. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  88. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  89. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  90. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  91. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  92. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  93. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  94. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  95. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  96. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  97. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  98. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  99. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  100. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  101. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  102. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  103. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  104. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  105. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  106. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  107. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  108. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  109. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  110. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  111. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  112. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  113. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  114. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  115. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  116. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  117. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  118. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  119. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  120. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  121. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  122. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  123. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  124. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  125. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  126. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  127. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  128. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  129. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  130. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  131. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  132. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  133. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  134. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  135. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  136. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  137. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  138. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  139. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  140. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  141. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  142. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  143. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  144. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  145. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  146. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  147. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  148. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  149. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  150. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  151. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  152. //库盘和变更
  153. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  154. //删除库盘和变更
  155. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  156. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  157. //药品变更
  158. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  159. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  160. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  161. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  162. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  163. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  164. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  165. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  166. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  167. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  168. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  169. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  170. //beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  171. //beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  172. }
  173. func (c *HisApiController) TestNet() {
  174. c.ServeSuccessJSON(map[string]interface{}{
  175. "msg": "成功",
  176. })
  177. }
  178. func (c *HisApiController) Get3508() {
  179. admin_user_id, _ := c.GetInt64("admin_user_id")
  180. drug_id, _ := c.GetInt64("id")
  181. start_time := c.GetString("start_time")
  182. end_time := c.GetString("end_time")
  183. adminUser := c.GetAdminUserInfo()
  184. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  185. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  186. drug, _ := service.GetDrugByID(drug_id)
  187. var struct3508 models.Struct3508
  188. struct3508.OrgName = miConfig.OrgName
  189. struct3508.FixmedinsCode = miConfig.Code
  190. struct3508.AccessKey = miConfig.AccessKey
  191. struct3508.Opter = curRoles.UserName
  192. struct3508.RequestUrl = miConfig.Url
  193. struct3508.Url = miConfig.Url
  194. struct3508.AppId = miConfig.Cainfo
  195. struct3508.AppSecret = miConfig.AppSecret
  196. struct3508.Enckey = miConfig.EncKey
  197. struct3508.SignKey = miConfig.SignKey
  198. struct3508.SecretKey = miConfig.SecretKey
  199. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  200. struct3508.Begndate = start_time
  201. struct3508.Enddate = end_time
  202. result1, result2, _ := service.FJyb3508(struct3508)
  203. saveLog(result1, result2, "3508", "3508")
  204. var res models.Result3508
  205. var respJSON2 map[string]interface{}
  206. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  209. return
  210. }
  211. userJSONBytes2, _ := json.Marshal(respJSON2)
  212. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  213. utils.ErrorLog("解析失败:%v", err)
  214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  215. return
  216. }
  217. if res.Infcode == -1 {
  218. c.ServeSuccessJSON(map[string]interface{}{
  219. "failed_code": -10,
  220. "msg": res.ErrMsg,
  221. })
  222. } else {
  223. c.ServeSuccessJSON(map[string]interface{}{
  224. "info": res.Output,
  225. })
  226. }
  227. }
  228. func (c *HisApiController) Get3509() {
  229. admin_user_id, _ := c.GetInt64("admin_user_id")
  230. drug_id, _ := c.GetInt64("id")
  231. start_time := c.GetString("start_time")
  232. end_time := c.GetString("end_time")
  233. adminUser := c.GetAdminUserInfo()
  234. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  235. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  236. drug, _ := service.GetDrugByID(drug_id)
  237. var struct3508 models.Struct3509
  238. struct3508.OrgName = miConfig.OrgName
  239. struct3508.FixmedinsCode = miConfig.Code
  240. struct3508.AccessKey = miConfig.AccessKey
  241. struct3508.Opter = curRoles.UserName
  242. struct3508.RequestUrl = miConfig.Url
  243. struct3508.Url = miConfig.Url
  244. struct3508.AppId = miConfig.Cainfo
  245. struct3508.AppSecret = miConfig.AppSecret
  246. struct3508.Enckey = miConfig.EncKey
  247. struct3508.SignKey = miConfig.SignKey
  248. struct3508.SecretKey = miConfig.SecretKey
  249. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  250. struct3508.Begndate = start_time
  251. struct3508.Enddate = end_time
  252. result1, result2, _ := service.FJyb3509(struct3508)
  253. saveLog(result1, result2, "3509", "3509")
  254. var res models.Result3509
  255. var respJSON2 map[string]interface{}
  256. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  259. return
  260. }
  261. userJSONBytes2, _ := json.Marshal(respJSON2)
  262. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  263. utils.ErrorLog("解析失败:%v", err)
  264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  265. return
  266. }
  267. if res.Infcode == -1 {
  268. c.ServeSuccessJSON(map[string]interface{}{
  269. "failed_code": -10,
  270. "msg": res.ErrMsg,
  271. })
  272. } else {
  273. c.ServeSuccessJSON(map[string]interface{}{
  274. "info": res.Output,
  275. })
  276. }
  277. }
  278. func (c *HisApiController) Get3510() {
  279. admin_user_id, _ := c.GetInt64("admin_user_id")
  280. drug_id, _ := c.GetInt64("id")
  281. start_time := c.GetString("start_time")
  282. end_time := c.GetString("end_time")
  283. adminUser := c.GetAdminUserInfo()
  284. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  285. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  286. drug, _ := service.GetDrugByID(drug_id)
  287. var struct3508 models.Struct3510
  288. struct3508.FixmedinsCode = miConfig.Code
  289. struct3508.OrgName = miConfig.OrgName
  290. struct3508.AccessKey = miConfig.AccessKey
  291. struct3508.Opter = curRoles.UserName
  292. struct3508.RequestUrl = miConfig.Url
  293. struct3508.Url = miConfig.Url
  294. struct3508.AppId = miConfig.Cainfo
  295. struct3508.AppSecret = miConfig.AppSecret
  296. struct3508.Enckey = miConfig.EncKey
  297. struct3508.SignKey = miConfig.SignKey
  298. struct3508.SecretKey = miConfig.SecretKey
  299. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  300. struct3508.Begndate = start_time
  301. struct3508.Enddate = end_time
  302. result1, result2, _ := service.FJyb3510(struct3508)
  303. saveLog(result1, result2, "3510", "3510")
  304. var res models.Result3510
  305. var respJSON2 map[string]interface{}
  306. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  309. return
  310. }
  311. userJSONBytes2, _ := json.Marshal(respJSON2)
  312. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  313. utils.ErrorLog("解析失败:%v", err)
  314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  315. return
  316. }
  317. if res.Infcode == -1 {
  318. c.ServeSuccessJSON(map[string]interface{}{
  319. "failed_code": -10,
  320. "msg": res.ErrMsg,
  321. })
  322. } else {
  323. c.ServeSuccessJSON(map[string]interface{}{
  324. "info": res.Output,
  325. })
  326. }
  327. }
  328. func (c *HisApiController) Get3511() {
  329. admin_user_id, _ := c.GetInt64("admin_user_id")
  330. drug_id, _ := c.GetInt64("id")
  331. start_time := c.GetString("start_time")
  332. end_time := c.GetString("end_time")
  333. adminUser := c.GetAdminUserInfo()
  334. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  335. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  336. drug, _ := service.GetDrugByID(drug_id)
  337. var struct3508 models.Struct3511
  338. struct3508.FixmedinsCode = miConfig.Code
  339. struct3508.OrgName = miConfig.OrgName
  340. struct3508.AccessKey = miConfig.AccessKey
  341. struct3508.Opter = curRoles.UserName
  342. struct3508.RequestUrl = miConfig.Url
  343. struct3508.Url = miConfig.Url
  344. struct3508.AppId = miConfig.Cainfo
  345. struct3508.AppSecret = miConfig.AppSecret
  346. struct3508.Enckey = miConfig.EncKey
  347. struct3508.SignKey = miConfig.SignKey
  348. struct3508.SecretKey = miConfig.SecretKey
  349. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  350. struct3508.Begndate = start_time
  351. struct3508.Enddate = end_time
  352. result1, result2, _ := service.FJyb3511(struct3508)
  353. saveLog(result1, result2, "3511", "3511")
  354. var res models.Result3511
  355. var respJSON2 map[string]interface{}
  356. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  359. return
  360. }
  361. userJSONBytes2, _ := json.Marshal(respJSON2)
  362. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  363. utils.ErrorLog("解析失败:%v", err)
  364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  365. return
  366. }
  367. if res.Infcode == -1 {
  368. c.ServeSuccessJSON(map[string]interface{}{
  369. "failed_code": -10,
  370. "msg": res.ErrMsg,
  371. })
  372. } else {
  373. c.ServeSuccessJSON(map[string]interface{}{
  374. "info": res.Output,
  375. })
  376. }
  377. }
  378. func (c *HisApiController) Get3512() {
  379. admin_user_id, _ := c.GetInt64("admin_user_id")
  380. drug_id, _ := c.GetInt64("id")
  381. start_time := c.GetString("start_time")
  382. end_time := c.GetString("end_time")
  383. adminUser := c.GetAdminUserInfo()
  384. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  385. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  386. drug, _ := service.GetDrugByID(drug_id)
  387. var struct3508 models.Struct3512
  388. struct3508.FixmedinsCode = miConfig.Code
  389. struct3508.OrgName = miConfig.OrgName
  390. struct3508.AccessKey = miConfig.AccessKey
  391. struct3508.Opter = curRoles.UserName
  392. struct3508.RequestUrl = miConfig.Url
  393. struct3508.Url = miConfig.Url
  394. struct3508.AppId = miConfig.Cainfo
  395. struct3508.AppSecret = miConfig.AppSecret
  396. struct3508.Enckey = miConfig.EncKey
  397. struct3508.SignKey = miConfig.SignKey
  398. struct3508.SecretKey = miConfig.SecretKey
  399. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  400. struct3508.Begndate = start_time
  401. struct3508.Enddate = end_time
  402. result1, result2, _ := service.FJyb3512(struct3508)
  403. saveLog(result1, result2, "3512", "3512")
  404. var res models.Result3512
  405. var respJSON2 map[string]interface{}
  406. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  409. return
  410. }
  411. userJSONBytes2, _ := json.Marshal(respJSON2)
  412. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  413. utils.ErrorLog("解析失败:%v", err)
  414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  415. return
  416. }
  417. if res.Infcode == -1 {
  418. c.ServeSuccessJSON(map[string]interface{}{
  419. "failed_code": -10,
  420. "msg": res.ErrMsg,
  421. })
  422. } else {
  423. c.ServeSuccessJSON(map[string]interface{}{
  424. "info": res.Output,
  425. })
  426. }
  427. }
  428. func (c *HisApiController) Get3513() {
  429. admin_user_id, _ := c.GetInt64("admin_user_id")
  430. drug_id, _ := c.GetInt64("id")
  431. start_time := c.GetString("start_time")
  432. end_time := c.GetString("end_time")
  433. adminUser := c.GetAdminUserInfo()
  434. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  435. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  436. drug, _ := service.GetDrugByID(drug_id)
  437. var struct3508 models.Struct3513
  438. struct3508.FixmedinsCode = miConfig.Code
  439. struct3508.OrgName = miConfig.OrgName
  440. struct3508.AccessKey = miConfig.AccessKey
  441. struct3508.Opter = curRoles.UserName
  442. struct3508.RequestUrl = miConfig.Url
  443. struct3508.Url = miConfig.Url
  444. struct3508.AppId = miConfig.Cainfo
  445. struct3508.AppSecret = miConfig.AppSecret
  446. struct3508.Enckey = miConfig.EncKey
  447. struct3508.SignKey = miConfig.SignKey
  448. struct3508.SecretKey = miConfig.SecretKey
  449. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  450. struct3508.Begndate = start_time
  451. struct3508.Enddate = end_time
  452. result1, result2, _ := service.FJyb3513(struct3508)
  453. saveLog(result1, result2, "3513", "3513")
  454. var res models.Result3513
  455. var respJSON2 map[string]interface{}
  456. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  459. return
  460. }
  461. userJSONBytes2, _ := json.Marshal(respJSON2)
  462. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  463. utils.ErrorLog("解析失败:%v", err)
  464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  465. return
  466. }
  467. if res.Infcode == -1 {
  468. c.ServeSuccessJSON(map[string]interface{}{
  469. "failed_code": -10,
  470. "msg": res.ErrMsg,
  471. })
  472. } else {
  473. c.ServeSuccessJSON(map[string]interface{}{
  474. "info": res.Output,
  475. })
  476. }
  477. }
  478. func (c *HisApiController) Get35081() {
  479. admin_user_id, _ := c.GetInt64("admin_user_id")
  480. drug_id, _ := c.GetInt64("id")
  481. //start_time := c.GetString("start_time")
  482. //end_time := c.GetString("end_time")
  483. page, _ := c.GetInt("page")
  484. adminUser := c.GetAdminUserInfo()
  485. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  486. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  487. drug, _ := service.GetDrugByID(drug_id)
  488. var struct3508 models.Struct35081
  489. struct3508.FixmedinsCode = miConfig.Code
  490. struct3508.OrgName = miConfig.OrgName
  491. struct3508.AccessKey = miConfig.AccessKey
  492. struct3508.Opter = curRoles.UserName
  493. struct3508.RequestUrl = miConfig.Url
  494. struct3508.Url = miConfig.Url
  495. struct3508.AppId = miConfig.Cainfo
  496. struct3508.AppSecret = miConfig.AppSecret
  497. struct3508.Enckey = miConfig.EncKey
  498. struct3508.SignKey = miConfig.SignKey
  499. struct3508.SecretKey = miConfig.SecretKey
  500. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  501. struct3508.PageNum = page
  502. struct3508.PageSize = 10
  503. result1, result2, _ := service.FJyb35081(struct3508)
  504. saveLog(result1, result2, "35081", "35081")
  505. var res models.Result35081
  506. var respJSON2 map[string]interface{}
  507. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  510. return
  511. }
  512. userJSONBytes2, _ := json.Marshal(respJSON2)
  513. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  514. utils.ErrorLog("解析失败:%v", err)
  515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  516. return
  517. }
  518. if res.Infcode == -1 {
  519. c.ServeSuccessJSON(map[string]interface{}{
  520. "failed_code": -10,
  521. "msg": res.ErrMsg,
  522. })
  523. } else {
  524. c.ServeSuccessJSON(map[string]interface{}{
  525. "info": res.Output,
  526. })
  527. }
  528. }
  529. func (c *HisApiController) Get35082() {
  530. admin_user_id, _ := c.GetInt64("admin_user_id")
  531. drug_id, _ := c.GetInt64("id")
  532. //start_time := c.GetString("start_time")
  533. //end_time := c.GetString("end_time")
  534. page, _ := c.GetInt("page")
  535. adminUser := c.GetAdminUserInfo()
  536. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  537. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  538. drug, _ := service.GetDrugByID(drug_id)
  539. var struct3508 models.Struct35082
  540. struct3508.FixmedinsCode = miConfig.Code
  541. struct3508.OrgName = miConfig.OrgName
  542. struct3508.AccessKey = miConfig.AccessKey
  543. struct3508.Opter = curRoles.UserName
  544. struct3508.RequestUrl = miConfig.Url
  545. struct3508.Url = miConfig.Url
  546. struct3508.AppId = miConfig.Cainfo
  547. struct3508.AppSecret = miConfig.AppSecret
  548. struct3508.Enckey = miConfig.EncKey
  549. struct3508.SignKey = miConfig.SignKey
  550. struct3508.SecretKey = miConfig.SecretKey
  551. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  552. struct3508.PageNum = page
  553. struct3508.PageSize = 10
  554. result1, result2, _ := service.FJyb35082(struct3508)
  555. saveLog(result1, result2, "35082", "35082")
  556. var res models.Result35082
  557. var respJSON2 map[string]interface{}
  558. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  561. return
  562. }
  563. userJSONBytes2, _ := json.Marshal(respJSON2)
  564. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  565. utils.ErrorLog("解析失败:%v", err)
  566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  567. return
  568. }
  569. if res.Infcode == -1 {
  570. c.ServeSuccessJSON(map[string]interface{}{
  571. "failed_code": -10,
  572. "msg": res.ErrMsg,
  573. })
  574. } else {
  575. c.ServeSuccessJSON(map[string]interface{}{
  576. "info": res.Output,
  577. })
  578. }
  579. }
  580. func (c *HisApiController) FJ3501AND3502() {
  581. ids := c.GetString("ids")
  582. admin_user_id, _ := c.GetInt64("admin_user_id")
  583. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  584. id_arr := strings.Split(ids, ",")
  585. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  586. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  587. //库盘
  588. var errs []string
  589. for _, drug := range drugs {
  590. if drug.IsPc == 0 && drug.IsBg == 0 {
  591. var res2 ResultSix
  592. var res3 ResultSix
  593. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  594. var struct3501 models.Struct3501
  595. struct3501.Code = miConfig.Code
  596. struct3501.OrgName = miConfig.OrgName
  597. struct3501.AccessKey = miConfig.AccessKey
  598. struct3501.Opter = roles.UserName
  599. struct3501.RequestUrl = miConfig.Url
  600. struct3501.Url = miConfig.Url
  601. struct3501.AppId = miConfig.Cainfo
  602. struct3501.AppSecret = miConfig.AppSecret
  603. struct3501.Enckey = miConfig.EncKey
  604. struct3501.SignKey = miConfig.SignKey
  605. struct3501.SecretKey = miConfig.SecretKey
  606. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  607. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  608. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  609. struct3501.RxFlag = "0"
  610. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  611. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  612. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  613. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  614. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  615. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  616. struct3501.FixmedinsBchno = number
  617. struct3501.DrugTracCodg = drug.DrugCode
  618. memo := make(map[string]interface{})
  619. memo["pric"] = drug.Price
  620. bytesData, _ := json.Marshal(memo)
  621. struct3501.Memo = string(bytesData)
  622. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  623. result1, result2, _ := service.FJyb3501(struct3501)
  624. saveLog(result1, result2, "3501", "3501")
  625. //saveLog(result, requestLog, "2201", "挂号")
  626. var respJSON2 map[string]interface{}
  627. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  630. return
  631. }
  632. userJSONBytes2, _ := json.Marshal(respJSON2)
  633. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  634. utils.ErrorLog("解析失败:%v", err)
  635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  636. return
  637. }
  638. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  639. data := make(map[string]interface{})
  640. data["struct_3501s"] = struct3501
  641. client := &http.Client{}
  642. bytesData, _ := json.Marshal(data)
  643. var req *http.Request
  644. if miConfig.MdtrtareaAdmvs == "320921" {
  645. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  646. } else {
  647. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  648. }
  649. resp, _ := client.Do(req)
  650. defer resp.Body.Close()
  651. body, ioErr := ioutil.ReadAll(resp.Body)
  652. if ioErr != nil {
  653. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  654. }
  655. var respJSON map[string]interface{}
  656. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  659. return
  660. }
  661. var resSix10265 ResultSix10265 //1101结果
  662. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  663. result, _ := json.Marshal(respJSON)
  664. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  665. utils.ErrorLog("解析失败:%v", err)
  666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  667. return
  668. }
  669. res2.InfRefmsgid = resSix10265.InfRefmsgid
  670. res2.Output = resSix10265.Output
  671. res2.ErrMsg = resSix10265.ErrMsg
  672. res2.Cainfo = resSix10265.Cainfo
  673. res2.WarnMsg = resSix10265.WarnMsg
  674. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  675. res2.Infcode = infocode
  676. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  677. data := make(map[string]interface{})
  678. data["struct_3501s"] = struct3501
  679. client := &http.Client{}
  680. bytesData, _ := json.Marshal(data)
  681. var req *http.Request
  682. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  683. resp, _ := client.Do(req)
  684. defer resp.Body.Close()
  685. body, ioErr := ioutil.ReadAll(resp.Body)
  686. if ioErr != nil {
  687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  688. }
  689. var respJSON map[string]interface{}
  690. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  693. return
  694. }
  695. var resSix10265 ResultSix10265 //1101结果
  696. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  697. result, _ := json.Marshal(respJSON)
  698. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  699. utils.ErrorLog("解析失败:%v", err)
  700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  701. return
  702. }
  703. res2.InfRefmsgid = resSix10265.InfRefmsgid
  704. res2.Output = resSix10265.Output
  705. res2.ErrMsg = resSix10265.ErrMsg
  706. res2.Cainfo = resSix10265.Cainfo
  707. res2.WarnMsg = resSix10265.WarnMsg
  708. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  709. res2.Infcode = infocode
  710. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  711. data := make(map[string]interface{})
  712. data["struct_3501s"] = struct3501
  713. client := &http.Client{}
  714. bytesData, _ := json.Marshal(data)
  715. var req *http.Request
  716. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  717. resp, _ := client.Do(req)
  718. defer resp.Body.Close()
  719. body, ioErr := ioutil.ReadAll(resp.Body)
  720. if ioErr != nil {
  721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  722. }
  723. var respJSON map[string]interface{}
  724. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  727. return
  728. }
  729. var resSix10265 ResultSix10265 //1101结果
  730. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  731. result, _ := json.Marshal(respJSON)
  732. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  733. utils.ErrorLog("解析失败:%v", err)
  734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  735. return
  736. }
  737. res2.InfRefmsgid = resSix10265.InfRefmsgid
  738. res2.Output = resSix10265.Output
  739. res2.ErrMsg = resSix10265.ErrMsg
  740. res2.Cainfo = resSix10265.Cainfo
  741. res2.WarnMsg = resSix10265.WarnMsg
  742. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  743. res2.Infcode = infocode
  744. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") { //广东
  745. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  746. saveLog(result1, result2, "3501", "3501")
  747. //saveLog(result, requestLog, "2201", "挂号")
  748. var respJSON2 map[string]interface{}
  749. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  752. return
  753. }
  754. userJSONBytes2, _ := json.Marshal(respJSON2)
  755. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  756. utils.ErrorLog("解析失败:%v", err)
  757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  758. return
  759. }
  760. }
  761. if res2.Infcode != -1 {
  762. drug.IsPc = 1
  763. drug.Bchno = number
  764. drug.PcDate = time.Now().Unix()
  765. err := service.SaveW(drug)
  766. if err == nil {
  767. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  768. var struct3502 models.Struct3502
  769. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  770. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  771. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  772. struct3502.FixmedinsCode = miConfig.Code
  773. struct3502.Code = miConfig.Code
  774. struct3502.RxFlag = "0"
  775. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  776. struct3502.OrgName = miConfig.OrgName
  777. struct3502.Opter = roles.UserName
  778. struct3502.AccessKey = miConfig.AccessKey
  779. struct3502.RequestUrl = miConfig.Url
  780. struct3502.SecretKey = miConfig.SecretKey
  781. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  782. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  783. struct3502.Url = miConfig.Url
  784. struct3502.AppId = miConfig.Cainfo
  785. struct3502.AppSecret = miConfig.AppSecret
  786. struct3502.Enckey = miConfig.EncKey
  787. struct3502.SignKey = miConfig.SignKey
  788. struct3502.SecretKey = miConfig.SecretKey
  789. struct3502.DrugTracCodg = drug.DrugCode
  790. struct3502.Memo = ""
  791. struct3502.InvChgType = "108"
  792. struct3502.FixmedinsBchno = bg_number
  793. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  794. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  795. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  796. result11, result22, _ := service.FJyb3502(struct3502)
  797. saveLog(result11, result22, "3502", "3502")
  798. var respJSON3 map[string]interface{}
  799. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  800. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  802. return
  803. }
  804. userJSONBytes3, _ := json.Marshal(respJSON3)
  805. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  806. utils.ErrorLog("解析失败:%v", err)
  807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  808. return
  809. }
  810. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  811. data := make(map[string]interface{})
  812. data["struct_3502s"] = struct3502
  813. client := &http.Client{}
  814. bytesData, _ := json.Marshal(data)
  815. var req *http.Request
  816. if miConfig.MdtrtareaAdmvs == "320921" {
  817. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  818. } else {
  819. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  820. }
  821. resp, _ := client.Do(req)
  822. defer resp.Body.Close()
  823. body, ioErr := ioutil.ReadAll(resp.Body)
  824. if ioErr != nil {
  825. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  826. }
  827. var respJSON map[string]interface{}
  828. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  831. return
  832. }
  833. var resSix10265 ResultSix10265 //1101结果
  834. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  835. result, _ := json.Marshal(respJSON)
  836. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  837. utils.ErrorLog("解析失败:%v", err)
  838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  839. return
  840. }
  841. res3.InfRefmsgid = resSix10265.InfRefmsgid
  842. res3.Output = resSix10265.Output
  843. res3.ErrMsg = resSix10265.ErrMsg
  844. res3.Cainfo = resSix10265.Cainfo
  845. res3.WarnMsg = resSix10265.WarnMsg
  846. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  847. res3.Infcode = infocode
  848. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  849. data := make(map[string]interface{})
  850. data["struct_3502s"] = struct3502
  851. client := &http.Client{}
  852. bytesData, _ := json.Marshal(data)
  853. var req *http.Request
  854. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  855. resp, _ := client.Do(req)
  856. defer resp.Body.Close()
  857. body, ioErr := ioutil.ReadAll(resp.Body)
  858. if ioErr != nil {
  859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  860. }
  861. var respJSON map[string]interface{}
  862. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  865. return
  866. }
  867. var resSix10265 ResultSix10265 //1101结果
  868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  869. result, _ := json.Marshal(respJSON)
  870. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  871. utils.ErrorLog("解析失败:%v", err)
  872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  873. return
  874. }
  875. res3.InfRefmsgid = resSix10265.InfRefmsgid
  876. res3.Output = resSix10265.Output
  877. res3.ErrMsg = resSix10265.ErrMsg
  878. res3.Cainfo = resSix10265.Cainfo
  879. res3.WarnMsg = resSix10265.WarnMsg
  880. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  881. res3.Infcode = infocode
  882. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  883. data := make(map[string]interface{})
  884. data["struct_3501s"] = struct3501
  885. client := &http.Client{}
  886. bytesData, _ := json.Marshal(data)
  887. var req *http.Request
  888. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  889. resp, _ := client.Do(req)
  890. defer resp.Body.Close()
  891. body, ioErr := ioutil.ReadAll(resp.Body)
  892. if ioErr != nil {
  893. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  894. }
  895. var respJSON map[string]interface{}
  896. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  899. return
  900. }
  901. var resSix10265 ResultSix10265 //1101结果
  902. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  903. result, _ := json.Marshal(respJSON)
  904. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  905. utils.ErrorLog("解析失败:%v", err)
  906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  907. return
  908. }
  909. res2.InfRefmsgid = resSix10265.InfRefmsgid
  910. res2.Output = resSix10265.Output
  911. res2.ErrMsg = resSix10265.ErrMsg
  912. res2.Cainfo = resSix10265.Cainfo
  913. res2.WarnMsg = resSix10265.WarnMsg
  914. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  915. res2.Infcode = infocode
  916. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  917. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  918. saveLog(result11, result22, "3502", "3502")
  919. var respJSON3 map[string]interface{}
  920. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  923. return
  924. }
  925. userJSONBytes3, _ := json.Marshal(respJSON3)
  926. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  927. utils.ErrorLog("解析失败:%v", err)
  928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  929. return
  930. }
  931. }
  932. if res3.Infcode == -1 {
  933. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  934. c.ServeSuccessJSON(map[string]interface{}{
  935. "failed_code": -10,
  936. "msg": res3.ErrMsg,
  937. })
  938. } else {
  939. drug.IsBg = 1
  940. drug.BgBchno = bg_number
  941. service.SaveW(drug)
  942. }
  943. }
  944. } else {
  945. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  946. }
  947. }
  948. //变更
  949. if drug.IsPc == 1 && drug.IsBg == 0 {
  950. var res3 ResultSix
  951. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  952. var struct3502 models.Struct3502
  953. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  954. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  955. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  956. struct3502.FixmedinsCode = miConfig.Code
  957. struct3502.Code = miConfig.Code
  958. struct3502.Opter = roles.UserName
  959. struct3502.RxFlag = "0"
  960. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  961. struct3502.OrgName = miConfig.OrgName
  962. struct3502.AccessKey = miConfig.AccessKey
  963. struct3502.RequestUrl = miConfig.Url
  964. struct3502.SecretKey = miConfig.SecretKey
  965. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  966. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  967. struct3502.InvChgType = "108"
  968. struct3502.DrugTracCodg = drug.DrugCode
  969. struct3502.Url = miConfig.Url
  970. struct3502.AppId = miConfig.Cainfo
  971. struct3502.AppSecret = miConfig.AppSecret
  972. struct3502.Enckey = miConfig.EncKey
  973. struct3502.SignKey = miConfig.SignKey
  974. struct3502.SecretKey = miConfig.SecretKey
  975. struct3502.FixmedinsBchno = bg_number
  976. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  977. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  978. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  979. result1, result2, _ := service.FJyb3502(struct3502)
  980. saveLog(result1, result2, "3502", "3502")
  981. var respJSON3 map[string]interface{}
  982. if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  985. return
  986. }
  987. userJSONBytes3, _ := json.Marshal(respJSON3)
  988. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  989. utils.ErrorLog("解析失败:%v", err)
  990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  991. return
  992. }
  993. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  994. data := make(map[string]interface{})
  995. data["struct_3502s"] = struct3502
  996. client := &http.Client{}
  997. bytesData, _ := json.Marshal(data)
  998. var req *http.Request
  999. if miConfig.MdtrtareaAdmvs == "320921" {
  1000. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1001. } else {
  1002. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1003. }
  1004. resp, _ := client.Do(req)
  1005. defer resp.Body.Close()
  1006. body, ioErr := ioutil.ReadAll(resp.Body)
  1007. if ioErr != nil {
  1008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1009. }
  1010. var respJSON map[string]interface{}
  1011. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1014. return
  1015. }
  1016. var resSix10265 ResultSix10265 //1101结果
  1017. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1018. result, _ := json.Marshal(respJSON)
  1019. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1020. utils.ErrorLog("解析失败:%v", err)
  1021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1022. return
  1023. }
  1024. res3.InfRefmsgid = resSix10265.InfRefmsgid
  1025. res3.Output = resSix10265.Output
  1026. res3.ErrMsg = resSix10265.ErrMsg
  1027. res3.Cainfo = resSix10265.Cainfo
  1028. res3.WarnMsg = resSix10265.WarnMsg
  1029. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1030. res3.Infcode = infocode
  1031. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1032. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1033. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  1034. }
  1035. if res3.Infcode == -1 {
  1036. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1037. } else {
  1038. drug.IsBg = 1
  1039. drug.BgBchno = bg_number
  1040. service.SaveW(drug)
  1041. }
  1042. }
  1043. }
  1044. if len(errs) == 0 {
  1045. c.ServeSuccessJSON(map[string]interface{}{
  1046. "msg": "盘存变更成功",
  1047. })
  1048. } else {
  1049. c.ServeSuccessJSON(map[string]interface{}{
  1050. "failed_code": -10,
  1051. "msg": errs,
  1052. })
  1053. }
  1054. }
  1055. func (c *HisApiController) DeletePCandBG() {
  1056. ids := c.GetString("ids")
  1057. id_arr := strings.Split(ids, ",")
  1058. admin_user_id, _ := c.GetInt64("admin_user_id")
  1059. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1060. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1061. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1062. var err []string
  1063. for _, item := range drugs {
  1064. if item.IsPc == 1 && item.IsBg == 1 {
  1065. var res FJ3507Result
  1066. var res2 FJ3507Result
  1067. var struct3507 models.Struct3507
  1068. struct3507.FixmedinsBchno = item.Bchno
  1069. struct3507.InvDataType = "1"
  1070. struct3507.Opter = roles.UserName
  1071. struct3507.OrgName = miConfig.OrgName
  1072. struct3507.AccessKey = miConfig.AccessKey
  1073. struct3507.RequestUrl = miConfig.Url
  1074. struct3507.FixmedinsCode = miConfig.Code
  1075. struct3507.Code = miConfig.Code
  1076. struct3507.SecretKey = miConfig.SecretKey
  1077. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1078. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1079. struct3507.Url = miConfig.Url
  1080. struct3507.AppId = miConfig.Cainfo
  1081. struct3507.AppSecret = miConfig.AppSecret
  1082. struct3507.Enckey = miConfig.EncKey
  1083. struct3507.SignKey = miConfig.SignKey
  1084. struct3507.SecretKey = miConfig.SecretKey
  1085. if miConfig.MdtrtareaAdmvs == "350500" {
  1086. result, result1, _ := service.FJyb3507(struct3507)
  1087. saveLog(result, result1, "3507", "3507")
  1088. var respJSON2 map[string]interface{}
  1089. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1092. return
  1093. }
  1094. userJSONBytes2, _ := json.Marshal(respJSON2)
  1095. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1096. utils.ErrorLog("解析失败:%v", err)
  1097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1098. return
  1099. }
  1100. } else {
  1101. data := make(map[string]interface{})
  1102. data["struct_3507s"] = struct3507
  1103. client := &http.Client{}
  1104. bytesData, _ := json.Marshal(data)
  1105. var req *http.Request
  1106. if miConfig.MdtrtareaAdmvs == "320921" {
  1107. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1108. } else {
  1109. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1110. }
  1111. resp, _ := client.Do(req)
  1112. defer resp.Body.Close()
  1113. body, ioErr := ioutil.ReadAll(resp.Body)
  1114. if ioErr != nil {
  1115. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1116. }
  1117. var respJSON map[string]interface{}
  1118. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1121. return
  1122. }
  1123. var resSix10265 ResultSix10265 //1101结果
  1124. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1125. result, _ := json.Marshal(respJSON)
  1126. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1127. utils.ErrorLog("解析失败:%v", err)
  1128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1129. return
  1130. }
  1131. res.InfRefmsgid = resSix10265.InfRefmsgid
  1132. //res.Output = resSix10265.Output
  1133. res.ErrMsg = resSix10265.ErrMsg
  1134. res.Cainfo = resSix10265.Cainfo
  1135. res.WarnMsg = resSix10265.WarnMsg
  1136. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1137. res.Infcode = infocode
  1138. }
  1139. if res.Infcode == 0 {
  1140. item.IsPc = 0
  1141. err2 := service.SaveW(item)
  1142. if err2 == nil {
  1143. var struct3507_2 models.Struct3507
  1144. struct3507_2.OrgName = miConfig.OrgName
  1145. struct3507_2.AccessKey = miConfig.AccessKey
  1146. struct3507_2.RequestUrl = miConfig.Url
  1147. struct3507_2.Opter = roles.UserName
  1148. struct3507_2.FixmedinsCode = miConfig.Code
  1149. struct3507_2.Code = miConfig.Code
  1150. struct3507_2.SecretKey = miConfig.SecretKey
  1151. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1152. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1153. struct3507_2.Url = miConfig.Url
  1154. struct3507_2.AppId = miConfig.Cainfo
  1155. struct3507_2.AppSecret = miConfig.AppSecret
  1156. struct3507_2.Enckey = miConfig.EncKey
  1157. struct3507_2.SignKey = miConfig.SignKey
  1158. struct3507_2.SecretKey = miConfig.SecretKey
  1159. struct3507_2.FixmedinsBchno = item.BgBchno
  1160. struct3507_2.InvDataType = "2"
  1161. if miConfig.MdtrtareaAdmvs == "350500" {
  1162. result11, result22, _ := service.FJyb3507(struct3507_2)
  1163. saveLog(result11, result22, "3507", "3507")
  1164. var respJSON3 map[string]interface{}
  1165. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1168. return
  1169. }
  1170. userJSONBytes3, _ := json.Marshal(respJSON3)
  1171. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1172. utils.ErrorLog("解析失败:%v", err)
  1173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1174. return
  1175. }
  1176. } else {
  1177. data := make(map[string]interface{})
  1178. data["struct_3507s"] = struct3507_2
  1179. client := &http.Client{}
  1180. bytesData, _ := json.Marshal(data)
  1181. var req *http.Request
  1182. if miConfig.MdtrtareaAdmvs == "320921" {
  1183. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1184. } else {
  1185. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1186. }
  1187. resp, _ := client.Do(req)
  1188. defer resp.Body.Close()
  1189. body, ioErr := ioutil.ReadAll(resp.Body)
  1190. if ioErr != nil {
  1191. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1192. }
  1193. var respJSON map[string]interface{}
  1194. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1197. return
  1198. }
  1199. var resSix10265 ResultSix10265 //1101结果
  1200. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1201. result, _ := json.Marshal(respJSON)
  1202. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1203. utils.ErrorLog("解析失败:%v", err)
  1204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1205. return
  1206. }
  1207. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1208. //res2.Output = resSix10265.Output
  1209. res2.ErrMsg = resSix10265.ErrMsg
  1210. res2.Cainfo = resSix10265.Cainfo
  1211. res2.WarnMsg = resSix10265.WarnMsg
  1212. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1213. res2.Infcode = infocode
  1214. }
  1215. if res2.Infcode != -1 {
  1216. item.IsBg = 0
  1217. item.Bchno = ""
  1218. item.BgBchno = ""
  1219. item.PcDate = 0
  1220. service.SaveW(item)
  1221. } else {
  1222. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1223. }
  1224. }
  1225. } else {
  1226. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1227. }
  1228. }
  1229. if item.IsPc == 1 && item.IsBg == 0 {
  1230. var res FJ3507Result
  1231. var struct3507 models.Struct3507
  1232. struct3507.FixmedinsBchno = item.Bchno
  1233. struct3507.InvDataType = "1"
  1234. struct3507.Opter = roles.UserName
  1235. struct3507.FixmedinsCode = miConfig.Code
  1236. struct3507.Code = miConfig.Code
  1237. struct3507.OrgName = miConfig.OrgName
  1238. struct3507.AccessKey = miConfig.AccessKey
  1239. struct3507.RequestUrl = miConfig.Url
  1240. struct3507.SecretKey = miConfig.SecretKey
  1241. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1242. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1243. struct3507.Url = miConfig.Url
  1244. struct3507.AppId = miConfig.Cainfo
  1245. struct3507.AppSecret = miConfig.AppSecret
  1246. struct3507.Enckey = miConfig.EncKey
  1247. struct3507.SignKey = miConfig.SignKey
  1248. struct3507.SecretKey = miConfig.SecretKey
  1249. //result, result1, _ := service.FJyb3507(struct3507)
  1250. //saveLog(result, result1, "3507", "3507")
  1251. if miConfig.MdtrtareaAdmvs == "350500" {
  1252. result, result1, _ := service.FJyb3507(struct3507)
  1253. saveLog(result, result1, "3507", "3507")
  1254. var respJSON2 map[string]interface{}
  1255. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1258. return
  1259. }
  1260. userJSONBytes2, _ := json.Marshal(respJSON2)
  1261. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1262. utils.ErrorLog("解析失败:%v", err)
  1263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1264. return
  1265. }
  1266. } else {
  1267. data := make(map[string]interface{})
  1268. data["struct_3507s"] = struct3507
  1269. client := &http.Client{}
  1270. bytesData, _ := json.Marshal(data)
  1271. var req *http.Request
  1272. if miConfig.MdtrtareaAdmvs == "320921" {
  1273. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1274. } else {
  1275. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1276. }
  1277. resp, _ := client.Do(req)
  1278. defer resp.Body.Close()
  1279. body, ioErr := ioutil.ReadAll(resp.Body)
  1280. if ioErr != nil {
  1281. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1282. }
  1283. var respJSON map[string]interface{}
  1284. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1287. return
  1288. }
  1289. var resSix10265 ResultSix10265 //1101结果
  1290. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1291. result, _ := json.Marshal(respJSON)
  1292. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1293. utils.ErrorLog("解析失败:%v", err)
  1294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1295. return
  1296. }
  1297. res.InfRefmsgid = resSix10265.InfRefmsgid
  1298. //res.Output = resSix10265.Output
  1299. res.ErrMsg = resSix10265.ErrMsg
  1300. res.Cainfo = resSix10265.Cainfo
  1301. res.WarnMsg = resSix10265.WarnMsg
  1302. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1303. res.Infcode = infocode
  1304. }
  1305. if res.Infcode == 0 {
  1306. item.IsPc = 0
  1307. item.Bchno = ""
  1308. item.BgBchno = ""
  1309. item.PcDate = 0
  1310. service.SaveW(item)
  1311. } else {
  1312. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1313. }
  1314. }
  1315. if item.IsPc == 0 && item.IsBg == 1 {
  1316. var res FJ3507Result
  1317. var struct3507 models.Struct3507
  1318. struct3507.FixmedinsBchno = item.BgBchno
  1319. struct3507.InvDataType = "2"
  1320. struct3507.Opter = roles.UserName
  1321. struct3507.FixmedinsCode = miConfig.Code
  1322. struct3507.OrgName = miConfig.OrgName
  1323. struct3507.AccessKey = miConfig.AccessKey
  1324. struct3507.RequestUrl = miConfig.Url
  1325. struct3507.SecretKey = miConfig.SecretKey
  1326. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1327. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1328. struct3507.Url = miConfig.Url
  1329. struct3507.AppId = miConfig.Cainfo
  1330. struct3507.AppSecret = miConfig.AppSecret
  1331. struct3507.Enckey = miConfig.EncKey
  1332. struct3507.SignKey = miConfig.SignKey
  1333. struct3507.SecretKey = miConfig.SecretKey
  1334. //result, result1, _ := service.FJyb3507(struct3507)
  1335. //saveLog(result, result1, "3507", "3507")
  1336. if miConfig.MdtrtareaAdmvs == "350500" {
  1337. result, result1, _ := service.FJyb3507(struct3507)
  1338. saveLog(result, result1, "3507", "3507")
  1339. var respJSON2 map[string]interface{}
  1340. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1343. return
  1344. }
  1345. userJSONBytes2, _ := json.Marshal(respJSON2)
  1346. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1347. utils.ErrorLog("解析失败:%v", err)
  1348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1349. return
  1350. }
  1351. } else {
  1352. data := make(map[string]interface{})
  1353. data["struct_3507s"] = struct3507
  1354. client := &http.Client{}
  1355. bytesData, _ := json.Marshal(data)
  1356. var req *http.Request
  1357. if miConfig.MdtrtareaAdmvs == "320921" {
  1358. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1359. } else {
  1360. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1361. }
  1362. resp, _ := client.Do(req)
  1363. defer resp.Body.Close()
  1364. body, ioErr := ioutil.ReadAll(resp.Body)
  1365. if ioErr != nil {
  1366. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1367. }
  1368. var respJSON map[string]interface{}
  1369. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1372. return
  1373. }
  1374. var resSix10265 ResultSix10265 //1101结果
  1375. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1376. result, _ := json.Marshal(respJSON)
  1377. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1378. utils.ErrorLog("解析失败:%v", err)
  1379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1380. return
  1381. }
  1382. res.InfRefmsgid = resSix10265.InfRefmsgid
  1383. //res.Output = resSix10265.Output
  1384. res.ErrMsg = resSix10265.ErrMsg
  1385. res.Cainfo = resSix10265.Cainfo
  1386. res.WarnMsg = resSix10265.WarnMsg
  1387. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1388. res.Infcode = infocode
  1389. }
  1390. if res.Infcode == 0 {
  1391. item.IsBg = 0
  1392. item.Bchno = ""
  1393. item.BgBchno = ""
  1394. item.PcDate = 0
  1395. service.SaveW(item)
  1396. } else {
  1397. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1398. }
  1399. }
  1400. }
  1401. if len(err) == 0 {
  1402. c.ServeSuccessJSON(map[string]interface{}{
  1403. "msg": "删除盘存变更成功",
  1404. })
  1405. } else {
  1406. c.ServeSuccessJSON(map[string]interface{}{
  1407. "failed_code": -10,
  1408. "msg": err,
  1409. })
  1410. }
  1411. }
  1412. func (c *HisApiController) DeleteXSandBG() {
  1413. ids := c.GetString("ids")
  1414. id_arr := strings.Split(ids, ",")
  1415. admin_user_id, _ := c.GetInt64("admin_user_id")
  1416. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1417. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1418. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1419. var err []string
  1420. for _, item := range flows {
  1421. if item.IsSale == 1 && item.IsChange == 1 {
  1422. var res FJ3507Result
  1423. var res2 FJ3507Result
  1424. var struct3507 models.Struct3507
  1425. struct3507.FixmedinsBchno = item.Bchno
  1426. struct3507.InvDataType = "4"
  1427. struct3507.Opter = roles.UserName
  1428. struct3507.OrgName = miConfig.OrgName
  1429. struct3507.AccessKey = miConfig.AccessKey
  1430. struct3507.RequestUrl = miConfig.Url
  1431. struct3507.FixmedinsCode = miConfig.Code
  1432. struct3507.SecretKey = miConfig.SecretKey
  1433. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1434. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1435. struct3507.Url = miConfig.Url
  1436. struct3507.AppId = miConfig.Cainfo
  1437. struct3507.AppSecret = miConfig.AppSecret
  1438. struct3507.Enckey = miConfig.EncKey
  1439. struct3507.SignKey = miConfig.SignKey
  1440. struct3507.SecretKey = miConfig.SecretKey
  1441. //result, result1, _ := service.FJyb3507(struct3507)
  1442. //saveLog(result, result1, "3507", "3507")
  1443. if miConfig.MdtrtareaAdmvs == "350500" {
  1444. result, result1, _ := service.FJyb3507(struct3507)
  1445. saveLog(result, result1, "3507", "3507")
  1446. var respJSON2 map[string]interface{}
  1447. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1450. return
  1451. }
  1452. userJSONBytes2, _ := json.Marshal(respJSON2)
  1453. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1454. utils.ErrorLog("解析失败:%v", err)
  1455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1456. return
  1457. }
  1458. } else {
  1459. data := make(map[string]interface{})
  1460. data["struct_3507s"] = struct3507
  1461. client := &http.Client{}
  1462. bytesData, _ := json.Marshal(data)
  1463. var req *http.Request
  1464. if miConfig.MdtrtareaAdmvs == "320921" {
  1465. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1466. } else {
  1467. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1468. }
  1469. resp, _ := client.Do(req)
  1470. defer resp.Body.Close()
  1471. body, ioErr := ioutil.ReadAll(resp.Body)
  1472. if ioErr != nil {
  1473. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1474. }
  1475. var respJSON map[string]interface{}
  1476. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1477. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1479. return
  1480. }
  1481. var resSix10265 ResultSix10265 //1101结果
  1482. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1483. result, _ := json.Marshal(respJSON)
  1484. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1485. utils.ErrorLog("解析失败:%v", err)
  1486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1487. return
  1488. }
  1489. res.InfRefmsgid = resSix10265.InfRefmsgid
  1490. //res.Output = resSix10265.Output
  1491. res.ErrMsg = resSix10265.ErrMsg
  1492. res.Cainfo = resSix10265.Cainfo
  1493. res.WarnMsg = resSix10265.WarnMsg
  1494. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1495. res.Infcode = infocode
  1496. }
  1497. if res.Infcode == 0 {
  1498. item.IsSale = 0
  1499. item.SaleDate = ""
  1500. item.Bchno = ""
  1501. err2 := service.SaveDF(item)
  1502. if err2 == nil {
  1503. var struct3507_2 models.Struct3507
  1504. struct3507_2.OrgName = miConfig.OrgName
  1505. struct3507_2.AccessKey = miConfig.AccessKey
  1506. struct3507_2.RequestUrl = miConfig.Url
  1507. struct3507_2.Opter = roles.UserName
  1508. struct3507_2.FixmedinsCode = miConfig.Code
  1509. struct3507_2.Code = miConfig.Code
  1510. struct3507_2.SecretKey = miConfig.SecretKey
  1511. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1512. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1513. struct3507_2.Url = miConfig.Url
  1514. struct3507_2.AppId = miConfig.Cainfo
  1515. struct3507_2.AppSecret = miConfig.AppSecret
  1516. struct3507_2.Enckey = miConfig.EncKey
  1517. struct3507_2.SignKey = miConfig.SignKey
  1518. struct3507_2.SecretKey = miConfig.SecretKey
  1519. struct3507_2.FixmedinsBchno = item.BgBchno
  1520. struct3507_2.InvDataType = "2"
  1521. if miConfig.MdtrtareaAdmvs == "350500" {
  1522. result11, result22, _ := service.FJyb3507(struct3507_2)
  1523. saveLog(result11, result22, "3507", "3507")
  1524. var respJSON3 map[string]interface{}
  1525. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1528. return
  1529. }
  1530. userJSONBytes3, _ := json.Marshal(respJSON3)
  1531. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1532. utils.ErrorLog("解析失败:%v", err)
  1533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1534. return
  1535. }
  1536. } else {
  1537. data := make(map[string]interface{})
  1538. data["struct_3507s"] = struct3507_2
  1539. client := &http.Client{}
  1540. bytesData, _ := json.Marshal(data)
  1541. var req *http.Request
  1542. if miConfig.MdtrtareaAdmvs == "320921" {
  1543. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1544. } else {
  1545. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1546. }
  1547. resp, _ := client.Do(req)
  1548. defer resp.Body.Close()
  1549. body, ioErr := ioutil.ReadAll(resp.Body)
  1550. if ioErr != nil {
  1551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1552. }
  1553. var respJSON map[string]interface{}
  1554. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1557. return
  1558. }
  1559. var resSix10265 ResultSix10265 //1101结果
  1560. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1561. result, _ := json.Marshal(respJSON)
  1562. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1563. utils.ErrorLog("解析失败:%v", err)
  1564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1565. return
  1566. }
  1567. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1568. //res.Output = resSix10265.Output
  1569. res2.ErrMsg = resSix10265.ErrMsg
  1570. res2.Cainfo = resSix10265.Cainfo
  1571. res2.WarnMsg = resSix10265.WarnMsg
  1572. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1573. res2.Infcode = infocode
  1574. }
  1575. if res2.Infcode == 0 {
  1576. item.IsChange = 0
  1577. item.BgBchno = ""
  1578. service.SaveDF2(item)
  1579. } else {
  1580. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1581. }
  1582. }
  1583. } else {
  1584. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1585. }
  1586. }
  1587. if item.IsSale == 2 && item.IsChange == 1 {
  1588. var res FJ3507Result
  1589. var res2 FJ3507Result
  1590. var struct3507 models.Struct3507
  1591. struct3507.FixmedinsBchno = item.Bchno
  1592. struct3507.InvDataType = "4"
  1593. struct3507.Opter = roles.UserName
  1594. struct3507.OrgName = miConfig.OrgName
  1595. struct3507.AccessKey = miConfig.AccessKey
  1596. struct3507.RequestUrl = miConfig.Url
  1597. struct3507.FixmedinsCode = miConfig.Code
  1598. struct3507.Code = miConfig.Code
  1599. struct3507.SecretKey = miConfig.SecretKey
  1600. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1601. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1602. struct3507.Url = miConfig.Url
  1603. struct3507.AppId = miConfig.Cainfo
  1604. struct3507.AppSecret = miConfig.AppSecret
  1605. struct3507.Enckey = miConfig.EncKey
  1606. struct3507.SignKey = miConfig.SignKey
  1607. struct3507.SecretKey = miConfig.SecretKey
  1608. //result, result1, _ := service.FJyb3507(struct3507)
  1609. //saveLog(result, result1, "3507", "3507")
  1610. //
  1611. //var respJSON2 map[string]interface{}
  1612. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1613. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1614. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1615. // return
  1616. //}
  1617. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1618. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1619. // utils.ErrorLog("解析失败:%v", err)
  1620. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1621. // return
  1622. //}
  1623. if miConfig.MdtrtareaAdmvs == "350500" {
  1624. result, result1, _ := service.FJyb3507(struct3507)
  1625. saveLog(result, result1, "3507", "3507")
  1626. var respJSON2 map[string]interface{}
  1627. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1630. return
  1631. }
  1632. userJSONBytes2, _ := json.Marshal(respJSON2)
  1633. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1634. utils.ErrorLog("解析失败:%v", err)
  1635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1636. return
  1637. }
  1638. } else {
  1639. data := make(map[string]interface{})
  1640. data["struct_3507s"] = struct3507
  1641. client := &http.Client{}
  1642. bytesData, _ := json.Marshal(data)
  1643. var req *http.Request
  1644. if miConfig.MdtrtareaAdmvs == "320921" {
  1645. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1646. } else {
  1647. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1648. }
  1649. resp, _ := client.Do(req)
  1650. defer resp.Body.Close()
  1651. body, ioErr := ioutil.ReadAll(resp.Body)
  1652. if ioErr != nil {
  1653. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1654. }
  1655. var respJSON map[string]interface{}
  1656. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1659. return
  1660. }
  1661. var resSix10265 ResultSix10265 //1101结果
  1662. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1663. result, _ := json.Marshal(respJSON)
  1664. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1665. utils.ErrorLog("解析失败:%v", err)
  1666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1667. return
  1668. }
  1669. res.InfRefmsgid = resSix10265.InfRefmsgid
  1670. //res.Output = resSix10265.Output
  1671. res.ErrMsg = resSix10265.ErrMsg
  1672. res.Cainfo = resSix10265.Cainfo
  1673. res.WarnMsg = resSix10265.WarnMsg
  1674. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1675. res.Infcode = infocode
  1676. }
  1677. if res.Infcode == 0 {
  1678. item.IsSale = 0
  1679. item.SaleDate = ""
  1680. item.Bchno = ""
  1681. err2 := service.SaveDF(item)
  1682. if err2 == nil {
  1683. var struct3507_2 models.Struct3507
  1684. struct3507_2.OrgName = miConfig.OrgName
  1685. struct3507_2.AccessKey = miConfig.AccessKey
  1686. struct3507_2.RequestUrl = miConfig.Url
  1687. struct3507_2.Opter = roles.UserName
  1688. struct3507_2.FixmedinsCode = miConfig.Code
  1689. struct3507_2.Code = miConfig.Code
  1690. struct3507_2.SecretKey = miConfig.SecretKey
  1691. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1692. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1693. struct3507_2.Url = miConfig.Url
  1694. struct3507_2.AppId = miConfig.Cainfo
  1695. struct3507_2.AppSecret = miConfig.AppSecret
  1696. struct3507_2.Enckey = miConfig.EncKey
  1697. struct3507_2.SignKey = miConfig.SignKey
  1698. struct3507_2.SecretKey = miConfig.SecretKey
  1699. struct3507_2.FixmedinsBchno = item.BgBchno
  1700. struct3507_2.InvDataType = "2"
  1701. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1702. //saveLog(result11, result22, "3507", "3507")
  1703. //var respJSON3 map[string]interface{}
  1704. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1705. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1706. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1707. // return
  1708. //}
  1709. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1710. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1711. // utils.ErrorLog("解析失败:%v", err)
  1712. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1713. // return
  1714. //}
  1715. if miConfig.MdtrtareaAdmvs == "350500" {
  1716. result11, result22, _ := service.FJyb3507(struct3507_2)
  1717. saveLog(result11, result22, "3507", "3507")
  1718. var respJSON3 map[string]interface{}
  1719. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1722. return
  1723. }
  1724. userJSONBytes3, _ := json.Marshal(respJSON3)
  1725. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1726. utils.ErrorLog("解析失败:%v", err)
  1727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1728. return
  1729. }
  1730. } else {
  1731. data := make(map[string]interface{})
  1732. data["struct_3507s"] = struct3507_2
  1733. client := &http.Client{}
  1734. bytesData, _ := json.Marshal(data)
  1735. var req *http.Request
  1736. if miConfig.MdtrtareaAdmvs == "320921" {
  1737. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1738. } else {
  1739. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1740. }
  1741. resp, _ := client.Do(req)
  1742. defer resp.Body.Close()
  1743. body, ioErr := ioutil.ReadAll(resp.Body)
  1744. if ioErr != nil {
  1745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1746. }
  1747. var respJSON map[string]interface{}
  1748. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1751. return
  1752. }
  1753. var resSix10265 ResultSix10265 //1101结果
  1754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1755. result, _ := json.Marshal(respJSON)
  1756. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1757. utils.ErrorLog("解析失败:%v", err)
  1758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1759. return
  1760. }
  1761. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1762. //res.Output = resSix10265.Output
  1763. res2.ErrMsg = resSix10265.ErrMsg
  1764. res2.Cainfo = resSix10265.Cainfo
  1765. res2.WarnMsg = resSix10265.WarnMsg
  1766. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1767. res2.Infcode = infocode
  1768. }
  1769. if res2.Infcode == 0 {
  1770. item.IsChange = 0
  1771. item.BgBchno = ""
  1772. service.SaveDF2(item)
  1773. } else {
  1774. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1775. }
  1776. }
  1777. } else {
  1778. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1779. }
  1780. }
  1781. if item.IsSale == 1 && item.IsChange == 0 {
  1782. var res FJ3507Result
  1783. var struct3507 models.Struct3507
  1784. struct3507.FixmedinsBchno = item.Bchno
  1785. struct3507.InvDataType = "4"
  1786. struct3507.Opter = roles.UserName
  1787. struct3507.FixmedinsCode = miConfig.Code
  1788. struct3507.Code = miConfig.Code
  1789. struct3507.OrgName = miConfig.OrgName
  1790. struct3507.AccessKey = miConfig.AccessKey
  1791. struct3507.RequestUrl = miConfig.Url
  1792. struct3507.SecretKey = miConfig.SecretKey
  1793. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1794. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1795. struct3507.Url = miConfig.Url
  1796. struct3507.AppId = miConfig.Cainfo
  1797. struct3507.AppSecret = miConfig.AppSecret
  1798. struct3507.Enckey = miConfig.EncKey
  1799. struct3507.SignKey = miConfig.SignKey
  1800. struct3507.SecretKey = miConfig.SecretKey
  1801. //result, result1, _ := service.FJyb3507(struct3507)
  1802. //saveLog(result, result1, "3507", "3507")
  1803. //
  1804. //var respJSON3 map[string]interface{}
  1805. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1806. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1808. // return
  1809. //}
  1810. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1811. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1812. // utils.ErrorLog("解析失败:%v", err)
  1813. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1814. // return
  1815. //}
  1816. if miConfig.MdtrtareaAdmvs == "350500" {
  1817. result, result1, _ := service.FJyb3507(struct3507)
  1818. saveLog(result, result1, "3507", "3507")
  1819. var respJSON2 map[string]interface{}
  1820. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. return
  1824. }
  1825. userJSONBytes2, _ := json.Marshal(respJSON2)
  1826. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1827. utils.ErrorLog("解析失败:%v", err)
  1828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1829. return
  1830. }
  1831. } else {
  1832. data := make(map[string]interface{})
  1833. data["struct_3507s"] = struct3507
  1834. client := &http.Client{}
  1835. bytesData, _ := json.Marshal(data)
  1836. var req *http.Request
  1837. if miConfig.MdtrtareaAdmvs == "320921" {
  1838. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1839. } else {
  1840. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1841. }
  1842. resp, _ := client.Do(req)
  1843. defer resp.Body.Close()
  1844. body, ioErr := ioutil.ReadAll(resp.Body)
  1845. if ioErr != nil {
  1846. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1847. }
  1848. var respJSON map[string]interface{}
  1849. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1852. return
  1853. }
  1854. var resSix10265 ResultSix10265 //1101结果
  1855. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1856. result, _ := json.Marshal(respJSON)
  1857. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1858. utils.ErrorLog("解析失败:%v", err)
  1859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1860. return
  1861. }
  1862. res.InfRefmsgid = resSix10265.InfRefmsgid
  1863. //res.Output = resSix10265.Output
  1864. res.ErrMsg = resSix10265.ErrMsg
  1865. res.Cainfo = resSix10265.Cainfo
  1866. res.WarnMsg = resSix10265.WarnMsg
  1867. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1868. res.Infcode = infocode
  1869. }
  1870. if res.Infcode == 0 {
  1871. item.IsSale = 0
  1872. item.SaleDate = ""
  1873. service.SaveDF(item)
  1874. } else {
  1875. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1876. }
  1877. }
  1878. if item.IsSale == 2 && item.IsChange == 0 {
  1879. var res FJ3507Result
  1880. var struct3507 models.Struct3507
  1881. struct3507.FixmedinsBchno = item.Bchno
  1882. struct3507.InvDataType = "4"
  1883. struct3507.Opter = roles.UserName
  1884. struct3507.FixmedinsCode = miConfig.Code
  1885. struct3507.Code = miConfig.Code
  1886. struct3507.OrgName = miConfig.OrgName
  1887. struct3507.AccessKey = miConfig.AccessKey
  1888. struct3507.RequestUrl = miConfig.Url
  1889. struct3507.SecretKey = miConfig.SecretKey
  1890. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1891. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1892. struct3507.Url = miConfig.Url
  1893. struct3507.AppId = miConfig.Cainfo
  1894. struct3507.AppSecret = miConfig.AppSecret
  1895. struct3507.Enckey = miConfig.EncKey
  1896. struct3507.SignKey = miConfig.SignKey
  1897. struct3507.SecretKey = miConfig.SecretKey
  1898. //result, result1, _ := service.FJyb3507(struct3507)
  1899. //saveLog(result, result1, "3507", "3507")
  1900. //
  1901. //var respJSON3 map[string]interface{}
  1902. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1903. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1904. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1905. // return
  1906. //}
  1907. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1908. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1909. // utils.ErrorLog("解析失败:%v", err)
  1910. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1911. // return
  1912. //}
  1913. if miConfig.MdtrtareaAdmvs == "350500" {
  1914. result, result1, _ := service.FJyb3507(struct3507)
  1915. saveLog(result, result1, "3507", "3507")
  1916. var respJSON2 map[string]interface{}
  1917. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1918. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1920. return
  1921. }
  1922. userJSONBytes2, _ := json.Marshal(respJSON2)
  1923. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1924. utils.ErrorLog("解析失败:%v", err)
  1925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1926. return
  1927. }
  1928. } else {
  1929. data := make(map[string]interface{})
  1930. data["struct_3507s"] = struct3507
  1931. client := &http.Client{}
  1932. bytesData, _ := json.Marshal(data)
  1933. var req *http.Request
  1934. if miConfig.MdtrtareaAdmvs == "320921" {
  1935. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1936. } else {
  1937. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1938. }
  1939. resp, _ := client.Do(req)
  1940. defer resp.Body.Close()
  1941. body, ioErr := ioutil.ReadAll(resp.Body)
  1942. if ioErr != nil {
  1943. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1944. }
  1945. var respJSON map[string]interface{}
  1946. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1949. return
  1950. }
  1951. var resSix10265 ResultSix10265 //1101结果
  1952. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1953. result, _ := json.Marshal(respJSON)
  1954. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1955. utils.ErrorLog("解析失败:%v", err)
  1956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1957. return
  1958. }
  1959. res.InfRefmsgid = resSix10265.InfRefmsgid
  1960. //res.Output = resSix10265.Output
  1961. res.ErrMsg = resSix10265.ErrMsg
  1962. res.Cainfo = resSix10265.Cainfo
  1963. res.WarnMsg = resSix10265.WarnMsg
  1964. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1965. res.Infcode = infocode
  1966. }
  1967. if res.Infcode == 0 {
  1968. item.IsSale = 0
  1969. item.SaleDate = ""
  1970. item.Bchno = ""
  1971. service.SaveDF(item)
  1972. } else {
  1973. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1974. }
  1975. }
  1976. if item.IsSale == 0 && item.IsChange == 1 {
  1977. var res FJ3507Result
  1978. var struct3507 models.Struct3507
  1979. struct3507.FixmedinsBchno = item.BgBchno
  1980. struct3507.InvDataType = "2"
  1981. struct3507.Opter = roles.UserName
  1982. struct3507.FixmedinsCode = miConfig.Code
  1983. struct3507.Code = miConfig.Code
  1984. struct3507.OrgName = miConfig.OrgName
  1985. struct3507.AccessKey = miConfig.AccessKey
  1986. struct3507.RequestUrl = miConfig.Url
  1987. struct3507.SecretKey = miConfig.SecretKey
  1988. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1989. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1990. struct3507.Url = miConfig.Url
  1991. struct3507.AppId = miConfig.Cainfo
  1992. struct3507.AppSecret = miConfig.AppSecret
  1993. struct3507.Enckey = miConfig.EncKey
  1994. struct3507.SignKey = miConfig.SignKey
  1995. struct3507.SecretKey = miConfig.SecretKey
  1996. //result, result1, _ := service.FJyb3507(struct3507)
  1997. //saveLog(result, result1, "3507", "3507")
  1998. //
  1999. //var respJSON3 map[string]interface{}
  2000. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2001. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2002. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2003. // return
  2004. //}
  2005. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2006. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2007. // utils.ErrorLog("解析失败:%v", err)
  2008. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2009. // return
  2010. //}
  2011. if miConfig.MdtrtareaAdmvs == "350500" {
  2012. result, result1, _ := service.FJyb3507(struct3507)
  2013. saveLog(result, result1, "3507", "3507")
  2014. var respJSON2 map[string]interface{}
  2015. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2018. return
  2019. }
  2020. userJSONBytes2, _ := json.Marshal(respJSON2)
  2021. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2022. utils.ErrorLog("解析失败:%v", err)
  2023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2024. return
  2025. }
  2026. } else {
  2027. data := make(map[string]interface{})
  2028. data["struct_3507s"] = struct3507
  2029. client := &http.Client{}
  2030. bytesData, _ := json.Marshal(data)
  2031. var req *http.Request
  2032. if miConfig.MdtrtareaAdmvs == "320921" {
  2033. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2034. } else {
  2035. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2036. }
  2037. resp, _ := client.Do(req)
  2038. defer resp.Body.Close()
  2039. body, ioErr := ioutil.ReadAll(resp.Body)
  2040. if ioErr != nil {
  2041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2042. }
  2043. var respJSON map[string]interface{}
  2044. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2047. return
  2048. }
  2049. var resSix10265 ResultSix10265 //1101结果
  2050. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2051. result, _ := json.Marshal(respJSON)
  2052. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2053. utils.ErrorLog("解析失败:%v", err)
  2054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2055. return
  2056. }
  2057. res.InfRefmsgid = resSix10265.InfRefmsgid
  2058. //res.Output = resSix10265.Output
  2059. res.ErrMsg = resSix10265.ErrMsg
  2060. res.Cainfo = resSix10265.Cainfo
  2061. res.WarnMsg = resSix10265.WarnMsg
  2062. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2063. res.Infcode = infocode
  2064. }
  2065. if res.Infcode == 0 {
  2066. item.IsChange = 0
  2067. item.BgBchno = ""
  2068. service.SaveDF2(item)
  2069. } else {
  2070. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2071. }
  2072. }
  2073. }
  2074. if len(err) == 0 {
  2075. c.ServeSuccessJSON(map[string]interface{}{
  2076. "msg": "删除销售变更成功",
  2077. })
  2078. } else {
  2079. c.ServeSuccessJSON(map[string]interface{}{
  2080. "failed_code": -10,
  2081. "msg": err,
  2082. })
  2083. }
  2084. }
  2085. //func (c *HisApiController) DeleteXSandBGTwo() {
  2086. // patient_id, _ := c.GetInt64("patient_id")
  2087. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2088. // //id_arr := strings.Split(ids, ",")
  2089. // times := c.GetString("time", "")
  2090. // timeLayout := "2006-01-02"
  2091. // loc, _ := time.LoadLocation("Local")
  2092. // var stime, etime int64
  2093. // if times == "" {
  2094. // stime, etime = GetNowTime()
  2095. // } else {
  2096. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2097. // stime = stmp.Unix()
  2098. // etime = stime + 86399
  2099. // }
  2100. // advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2101. // var flows []*models.DrugFlow
  2102. // for _, item := range advicelist {
  2103. // flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.ID, times, c.GetAdminUserInfo().CurrentOrgId)
  2104. // flows = append(flows, flow...)
  2105. // }
  2106. //
  2107. // //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2108. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2109. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2110. //
  2111. // var err []string
  2112. // for _, item := range flows {
  2113. // if item.IsSale == 1 && item.IsChange == 1 {
  2114. // var res FJ3507Result
  2115. // var res2 FJ3507Result
  2116. //
  2117. // var struct3507 models.Struct3507
  2118. // struct3507.FixmedinsBchno = item.Bchno
  2119. // struct3507.InvDataType = "4"
  2120. // struct3507.Opter = roles.UserName
  2121. // struct3507.OrgName = miConfig.OrgName
  2122. // struct3507.AccessKey = miConfig.AccessKey
  2123. // struct3507.RequestUrl = miConfig.Url
  2124. // struct3507.FixmedinsCode = miConfig.Code
  2125. // struct3507.SecretKey = miConfig.SecretKey
  2126. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2127. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2128. // struct3507.Url = miConfig.Url
  2129. // struct3507.AppId = miConfig.Cainfo
  2130. // struct3507.AppSecret = miConfig.AppSecret
  2131. // struct3507.Enckey = miConfig.EncKey
  2132. // struct3507.SignKey = miConfig.SignKey
  2133. // struct3507.SecretKey = miConfig.SecretKey
  2134. //
  2135. // //result, result1, _ := service.FJyb3507(struct3507)
  2136. // //saveLog(result, result1, "3507", "3507")
  2137. //
  2138. // if miConfig.MdtrtareaAdmvs == "350500" {
  2139. // result, result1, _ := service.FJyb3507(struct3507)
  2140. // saveLog(result, result1, "3507", "3507")
  2141. // var respJSON2 map[string]interface{}
  2142. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2143. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2145. // return
  2146. // }
  2147. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2148. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2149. // utils.ErrorLog("解析失败:%v", err)
  2150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2151. // return
  2152. // }
  2153. // } else {
  2154. // data := make(map[string]interface{})
  2155. // data["struct_3507s"] = struct3507
  2156. // client := &http.Client{}
  2157. // bytesData, _ := json.Marshal(data)
  2158. // var req *http.Request
  2159. // if miConfig.MdtrtareaAdmvs == "320921" {
  2160. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2161. // } else {
  2162. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2163. // }
  2164. //
  2165. // resp, _ := client.Do(req)
  2166. // defer resp.Body.Close()
  2167. // body, ioErr := ioutil.ReadAll(resp.Body)
  2168. // if ioErr != nil {
  2169. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2170. // }
  2171. // var respJSON map[string]interface{}
  2172. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2173. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2174. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2175. // return
  2176. // }
  2177. // var resSix10265 ResultSix10265 //1101结果
  2178. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2179. // result, _ := json.Marshal(respJSON)
  2180. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2181. // utils.ErrorLog("解析失败:%v", err)
  2182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2183. // return
  2184. // }
  2185. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2186. // //res.Output = resSix10265.Output
  2187. // res.ErrMsg = resSix10265.ErrMsg
  2188. // res.Cainfo = resSix10265.Cainfo
  2189. // res.WarnMsg = resSix10265.WarnMsg
  2190. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2191. // res.Infcode = infocode
  2192. // }
  2193. //
  2194. // if res.Infcode == 0 {
  2195. // item.IsSale = 0
  2196. // item.SaleDate = ""
  2197. // item.Bchno = ""
  2198. //
  2199. // err2 := service.SaveDF(item)
  2200. // if err2 == nil {
  2201. // var struct3507_2 models.Struct3507
  2202. // struct3507_2.OrgName = miConfig.OrgName
  2203. // struct3507_2.AccessKey = miConfig.AccessKey
  2204. // struct3507_2.RequestUrl = miConfig.Url
  2205. // struct3507_2.Opter = roles.UserName
  2206. // struct3507_2.FixmedinsCode = miConfig.Code
  2207. // struct3507_2.Code = miConfig.Code
  2208. //
  2209. // struct3507_2.SecretKey = miConfig.SecretKey
  2210. // struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2211. // struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2212. // struct3507_2.Url = miConfig.Url
  2213. // struct3507_2.AppId = miConfig.Cainfo
  2214. // struct3507_2.AppSecret = miConfig.AppSecret
  2215. // struct3507_2.Enckey = miConfig.EncKey
  2216. // struct3507_2.SignKey = miConfig.SignKey
  2217. // struct3507_2.SecretKey = miConfig.SecretKey
  2218. // struct3507_2.FixmedinsBchno = item.BgBchno
  2219. // struct3507_2.InvDataType = "2"
  2220. //
  2221. // if miConfig.MdtrtareaAdmvs == "350500" {
  2222. // result11, result22, _ := service.FJyb3507(struct3507_2)
  2223. // saveLog(result11, result22, "3507", "3507")
  2224. //
  2225. // var respJSON3 map[string]interface{}
  2226. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2227. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2228. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2229. // return
  2230. // }
  2231. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2232. // if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2233. // utils.ErrorLog("解析失败:%v", err)
  2234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2235. // return
  2236. // }
  2237. // } else {
  2238. //
  2239. // data := make(map[string]interface{})
  2240. // data["struct_3507s"] = struct3507_2
  2241. // client := &http.Client{}
  2242. // bytesData, _ := json.Marshal(data)
  2243. // var req *http.Request
  2244. // if miConfig.MdtrtareaAdmvs == "320921" {
  2245. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2246. // } else {
  2247. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2248. // }
  2249. //
  2250. // resp, _ := client.Do(req)
  2251. // defer resp.Body.Close()
  2252. // body, ioErr := ioutil.ReadAll(resp.Body)
  2253. // if ioErr != nil {
  2254. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2255. // }
  2256. // var respJSON map[string]interface{}
  2257. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2258. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2259. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2260. // return
  2261. // }
  2262. // var resSix10265 ResultSix10265 //1101结果
  2263. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2264. // result, _ := json.Marshal(respJSON)
  2265. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2266. // utils.ErrorLog("解析失败:%v", err)
  2267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2268. // return
  2269. // }
  2270. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2271. // //res.Output = resSix10265.Output
  2272. // res2.ErrMsg = resSix10265.ErrMsg
  2273. // res2.Cainfo = resSix10265.Cainfo
  2274. // res2.WarnMsg = resSix10265.WarnMsg
  2275. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2276. // res2.Infcode = infocode
  2277. // }
  2278. //
  2279. // if res2.Infcode == 0 {
  2280. // item.IsChange = 0
  2281. // item.BgBchno = ""
  2282. // service.SaveDF2(item)
  2283. // } else {
  2284. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2285. // }
  2286. // }
  2287. // } else {
  2288. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2289. // }
  2290. //
  2291. // }
  2292. // if item.IsSale == 2 && item.IsChange == 1 {
  2293. // var res FJ3507Result
  2294. // var res2 FJ3507Result
  2295. //
  2296. // var struct3507 models.Struct3507
  2297. // struct3507.FixmedinsBchno = item.Bchno
  2298. // struct3507.InvDataType = "4"
  2299. // struct3507.Opter = roles.UserName
  2300. // struct3507.OrgName = miConfig.OrgName
  2301. // struct3507.AccessKey = miConfig.AccessKey
  2302. // struct3507.RequestUrl = miConfig.Url
  2303. // struct3507.FixmedinsCode = miConfig.Code
  2304. // struct3507.Code = miConfig.Code
  2305. //
  2306. // struct3507.SecretKey = miConfig.SecretKey
  2307. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2308. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2309. // struct3507.Url = miConfig.Url
  2310. // struct3507.AppId = miConfig.Cainfo
  2311. // struct3507.AppSecret = miConfig.AppSecret
  2312. // struct3507.Enckey = miConfig.EncKey
  2313. // struct3507.SignKey = miConfig.SignKey
  2314. // struct3507.SecretKey = miConfig.SecretKey
  2315. // //result, result1, _ := service.FJyb3507(struct3507)
  2316. // //saveLog(result, result1, "3507", "3507")
  2317. // //
  2318. // //var respJSON2 map[string]interface{}
  2319. // //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2320. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2321. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2322. // // return
  2323. // //}
  2324. // //userJSONBytes2, _ := json.Marshal(respJSON2)
  2325. // //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2326. // // utils.ErrorLog("解析失败:%v", err)
  2327. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2328. // // return
  2329. // //}
  2330. //
  2331. // if miConfig.MdtrtareaAdmvs == "350500" {
  2332. // result, result1, _ := service.FJyb3507(struct3507)
  2333. // saveLog(result, result1, "3507", "3507")
  2334. // var respJSON2 map[string]interface{}
  2335. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2336. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2337. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2338. // return
  2339. // }
  2340. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2341. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2342. // utils.ErrorLog("解析失败:%v", err)
  2343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2344. // return
  2345. // }
  2346. // } else {
  2347. // data := make(map[string]interface{})
  2348. // data["struct_3507s"] = struct3507
  2349. // client := &http.Client{}
  2350. // bytesData, _ := json.Marshal(data)
  2351. // var req *http.Request
  2352. // if miConfig.MdtrtareaAdmvs == "320921" {
  2353. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2354. // } else {
  2355. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2356. // }
  2357. //
  2358. // resp, _ := client.Do(req)
  2359. // defer resp.Body.Close()
  2360. // body, ioErr := ioutil.ReadAll(resp.Body)
  2361. // if ioErr != nil {
  2362. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2363. // }
  2364. // var respJSON map[string]interface{}
  2365. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2366. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2367. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2368. // return
  2369. // }
  2370. // var resSix10265 ResultSix10265 //1101结果
  2371. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2372. // result, _ := json.Marshal(respJSON)
  2373. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2374. // utils.ErrorLog("解析失败:%v", err)
  2375. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2376. // return
  2377. // }
  2378. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2379. // //res.Output = resSix10265.Output
  2380. // res.ErrMsg = resSix10265.ErrMsg
  2381. // res.Cainfo = resSix10265.Cainfo
  2382. // res.WarnMsg = resSix10265.WarnMsg
  2383. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2384. // res.Infcode = infocode
  2385. // }
  2386. //
  2387. // if res.Infcode == 0 {
  2388. // item.IsSale = 0
  2389. // item.SaleDate = ""
  2390. // item.Bchno = ""
  2391. // err2 := service.SaveDF(item)
  2392. // if err2 == nil {
  2393. // var struct3507_2 models.Struct3507
  2394. // struct3507_2.OrgName = miConfig.OrgName
  2395. // struct3507_2.AccessKey = miConfig.AccessKey
  2396. // struct3507_2.RequestUrl = miConfig.Url
  2397. // struct3507_2.Opter = roles.UserName
  2398. // struct3507_2.FixmedinsCode = miConfig.Code
  2399. // struct3507_2.Code = miConfig.Code
  2400. //
  2401. // struct3507_2.SecretKey = miConfig.SecretKey
  2402. // struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2403. // struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2404. // struct3507_2.Url = miConfig.Url
  2405. // struct3507_2.AppId = miConfig.Cainfo
  2406. // struct3507_2.AppSecret = miConfig.AppSecret
  2407. // struct3507_2.Enckey = miConfig.EncKey
  2408. // struct3507_2.SignKey = miConfig.SignKey
  2409. // struct3507_2.SecretKey = miConfig.SecretKey
  2410. // struct3507_2.FixmedinsBchno = item.BgBchno
  2411. // struct3507_2.InvDataType = "2"
  2412. //
  2413. // //result11, result22, _ := service.FJyb3507(struct3507_2)
  2414. // //saveLog(result11, result22, "3507", "3507")
  2415. // //var respJSON3 map[string]interface{}
  2416. // //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2417. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2418. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2419. // // return
  2420. // //}
  2421. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2422. // //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2423. // // utils.ErrorLog("解析失败:%v", err)
  2424. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2425. // // return
  2426. // //}
  2427. //
  2428. // if miConfig.MdtrtareaAdmvs == "350500" {
  2429. // result11, result22, _ := service.FJyb3507(struct3507_2)
  2430. // saveLog(result11, result22, "3507", "3507")
  2431. //
  2432. // var respJSON3 map[string]interface{}
  2433. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2434. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2435. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2436. // return
  2437. // }
  2438. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2439. // if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2440. // utils.ErrorLog("解析失败:%v", err)
  2441. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2442. // return
  2443. // }
  2444. // } else {
  2445. //
  2446. // data := make(map[string]interface{})
  2447. // data["struct_3507s"] = struct3507_2
  2448. // client := &http.Client{}
  2449. // bytesData, _ := json.Marshal(data)
  2450. // var req *http.Request
  2451. // if miConfig.MdtrtareaAdmvs == "320921" {
  2452. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2453. // } else {
  2454. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2455. // }
  2456. //
  2457. // resp, _ := client.Do(req)
  2458. // defer resp.Body.Close()
  2459. // body, ioErr := ioutil.ReadAll(resp.Body)
  2460. // if ioErr != nil {
  2461. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2462. // }
  2463. // var respJSON map[string]interface{}
  2464. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2465. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2466. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2467. // return
  2468. // }
  2469. // var resSix10265 ResultSix10265 //1101结果
  2470. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2471. // result, _ := json.Marshal(respJSON)
  2472. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2473. // utils.ErrorLog("解析失败:%v", err)
  2474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2475. // return
  2476. // }
  2477. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2478. // //res.Output = resSix10265.Output
  2479. // res2.ErrMsg = resSix10265.ErrMsg
  2480. // res2.Cainfo = resSix10265.Cainfo
  2481. // res2.WarnMsg = resSix10265.WarnMsg
  2482. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2483. // res2.Infcode = infocode
  2484. // }
  2485. // if res2.Infcode == 0 {
  2486. // item.IsChange = 0
  2487. // item.BgBchno = ""
  2488. // service.SaveDF2(item)
  2489. // } else {
  2490. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2491. // }
  2492. // }
  2493. // } else {
  2494. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2495. // }
  2496. //
  2497. // }
  2498. // if item.IsSale == 1 && item.IsChange == 0 {
  2499. //
  2500. // var res FJ3507Result
  2501. // var struct3507 models.Struct3507
  2502. // struct3507.FixmedinsBchno = item.Bchno
  2503. // struct3507.InvDataType = "4"
  2504. // struct3507.Opter = roles.UserName
  2505. // struct3507.FixmedinsCode = miConfig.Code
  2506. // struct3507.Code = miConfig.Code
  2507. //
  2508. // struct3507.OrgName = miConfig.OrgName
  2509. // struct3507.AccessKey = miConfig.AccessKey
  2510. // struct3507.RequestUrl = miConfig.Url
  2511. // struct3507.SecretKey = miConfig.SecretKey
  2512. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2513. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2514. // struct3507.Url = miConfig.Url
  2515. // struct3507.AppId = miConfig.Cainfo
  2516. // struct3507.AppSecret = miConfig.AppSecret
  2517. // struct3507.Enckey = miConfig.EncKey
  2518. // struct3507.SignKey = miConfig.SignKey
  2519. // struct3507.SecretKey = miConfig.SecretKey
  2520. // //result, result1, _ := service.FJyb3507(struct3507)
  2521. // //saveLog(result, result1, "3507", "3507")
  2522. // //
  2523. // //var respJSON3 map[string]interface{}
  2524. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2525. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2526. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2527. // // return
  2528. // //}
  2529. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2530. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2531. // // utils.ErrorLog("解析失败:%v", err)
  2532. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2533. // // return
  2534. // //}
  2535. // if miConfig.MdtrtareaAdmvs == "350500" {
  2536. // result, result1, _ := service.FJyb3507(struct3507)
  2537. // saveLog(result, result1, "3507", "3507")
  2538. // var respJSON2 map[string]interface{}
  2539. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2540. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2541. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2542. // return
  2543. // }
  2544. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2545. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2546. // utils.ErrorLog("解析失败:%v", err)
  2547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2548. // return
  2549. // }
  2550. // } else {
  2551. // data := make(map[string]interface{})
  2552. // data["struct_3507s"] = struct3507
  2553. // client := &http.Client{}
  2554. // bytesData, _ := json.Marshal(data)
  2555. // var req *http.Request
  2556. // if miConfig.MdtrtareaAdmvs == "320921" {
  2557. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2558. // } else {
  2559. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2560. // }
  2561. //
  2562. // resp, _ := client.Do(req)
  2563. // defer resp.Body.Close()
  2564. // body, ioErr := ioutil.ReadAll(resp.Body)
  2565. // if ioErr != nil {
  2566. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2567. // }
  2568. // var respJSON map[string]interface{}
  2569. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2570. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2572. // return
  2573. // }
  2574. // var resSix10265 ResultSix10265 //1101结果
  2575. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2576. // result, _ := json.Marshal(respJSON)
  2577. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2578. // utils.ErrorLog("解析失败:%v", err)
  2579. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2580. // return
  2581. // }
  2582. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2583. // //res.Output = resSix10265.Output
  2584. // res.ErrMsg = resSix10265.ErrMsg
  2585. // res.Cainfo = resSix10265.Cainfo
  2586. // res.WarnMsg = resSix10265.WarnMsg
  2587. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2588. // res.Infcode = infocode
  2589. // }
  2590. //
  2591. // if res.Infcode == 0 {
  2592. // item.IsSale = 0
  2593. // item.SaleDate = ""
  2594. // service.SaveDF(item)
  2595. // } else {
  2596. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2597. // }
  2598. // }
  2599. // if item.IsSale == 2 && item.IsChange == 0 {
  2600. //
  2601. // var res FJ3507Result
  2602. // var struct3507 models.Struct3507
  2603. // struct3507.FixmedinsBchno = item.Bchno
  2604. // struct3507.InvDataType = "4"
  2605. // struct3507.Opter = roles.UserName
  2606. // struct3507.FixmedinsCode = miConfig.Code
  2607. // struct3507.Code = miConfig.Code
  2608. //
  2609. // struct3507.OrgName = miConfig.OrgName
  2610. // struct3507.AccessKey = miConfig.AccessKey
  2611. // struct3507.RequestUrl = miConfig.Url
  2612. // struct3507.SecretKey = miConfig.SecretKey
  2613. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2614. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2615. // struct3507.Url = miConfig.Url
  2616. // struct3507.AppId = miConfig.Cainfo
  2617. // struct3507.AppSecret = miConfig.AppSecret
  2618. // struct3507.Enckey = miConfig.EncKey
  2619. // struct3507.SignKey = miConfig.SignKey
  2620. // struct3507.SecretKey = miConfig.SecretKey
  2621. // //result, result1, _ := service.FJyb3507(struct3507)
  2622. // //saveLog(result, result1, "3507", "3507")
  2623. // //
  2624. // //var respJSON3 map[string]interface{}
  2625. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2626. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2627. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2628. // // return
  2629. // //}
  2630. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2631. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2632. // // utils.ErrorLog("解析失败:%v", err)
  2633. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2634. // // return
  2635. // //}
  2636. // if miConfig.MdtrtareaAdmvs == "350500" {
  2637. // result, result1, _ := service.FJyb3507(struct3507)
  2638. // saveLog(result, result1, "3507", "3507")
  2639. // var respJSON2 map[string]interface{}
  2640. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2641. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2642. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2643. // return
  2644. // }
  2645. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2646. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2647. // utils.ErrorLog("解析失败:%v", err)
  2648. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2649. // return
  2650. // }
  2651. // } else {
  2652. // data := make(map[string]interface{})
  2653. // data["struct_3507s"] = struct3507
  2654. // client := &http.Client{}
  2655. // bytesData, _ := json.Marshal(data)
  2656. // var req *http.Request
  2657. // if miConfig.MdtrtareaAdmvs == "320921" {
  2658. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2659. // } else {
  2660. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2661. // }
  2662. //
  2663. // resp, _ := client.Do(req)
  2664. // defer resp.Body.Close()
  2665. // body, ioErr := ioutil.ReadAll(resp.Body)
  2666. // if ioErr != nil {
  2667. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2668. // }
  2669. // var respJSON map[string]interface{}
  2670. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2671. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2672. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2673. // return
  2674. // }
  2675. // var resSix10265 ResultSix10265 //1101结果
  2676. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2677. // result, _ := json.Marshal(respJSON)
  2678. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2679. // utils.ErrorLog("解析失败:%v", err)
  2680. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2681. // return
  2682. // }
  2683. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2684. // //res.Output = resSix10265.Output
  2685. // res.ErrMsg = resSix10265.ErrMsg
  2686. // res.Cainfo = resSix10265.Cainfo
  2687. // res.WarnMsg = resSix10265.WarnMsg
  2688. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2689. // res.Infcode = infocode
  2690. // }
  2691. //
  2692. // if res.Infcode == 0 {
  2693. // item.IsSale = 0
  2694. // item.SaleDate = ""
  2695. // item.Bchno = ""
  2696. //
  2697. // service.SaveDF(item)
  2698. // } else {
  2699. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2700. // }
  2701. // }
  2702. // if item.IsSale == 0 && item.IsChange == 1 {
  2703. //
  2704. // var res FJ3507Result
  2705. // var struct3507 models.Struct3507
  2706. // struct3507.FixmedinsBchno = item.BgBchno
  2707. // struct3507.InvDataType = "2"
  2708. // struct3507.Opter = roles.UserName
  2709. // struct3507.FixmedinsCode = miConfig.Code
  2710. // struct3507.Code = miConfig.Code
  2711. //
  2712. // struct3507.OrgName = miConfig.OrgName
  2713. // struct3507.AccessKey = miConfig.AccessKey
  2714. // struct3507.RequestUrl = miConfig.Url
  2715. // struct3507.SecretKey = miConfig.SecretKey
  2716. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2717. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2718. // struct3507.Url = miConfig.Url
  2719. // struct3507.AppId = miConfig.Cainfo
  2720. // struct3507.AppSecret = miConfig.AppSecret
  2721. // struct3507.Enckey = miConfig.EncKey
  2722. // struct3507.SignKey = miConfig.SignKey
  2723. // struct3507.SecretKey = miConfig.SecretKey
  2724. // //result, result1, _ := service.FJyb3507(struct3507)
  2725. // //saveLog(result, result1, "3507", "3507")
  2726. // //
  2727. // //var respJSON3 map[string]interface{}
  2728. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2729. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2730. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2731. // // return
  2732. // //}
  2733. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2734. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2735. // // utils.ErrorLog("解析失败:%v", err)
  2736. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2737. // // return
  2738. // //}
  2739. // if miConfig.MdtrtareaAdmvs == "350500" {
  2740. // result, result1, _ := service.FJyb3507(struct3507)
  2741. // saveLog(result, result1, "3507", "3507")
  2742. // var respJSON2 map[string]interface{}
  2743. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2744. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2745. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2746. // return
  2747. // }
  2748. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2749. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2750. // utils.ErrorLog("解析失败:%v", err)
  2751. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2752. // return
  2753. // }
  2754. // } else {
  2755. // data := make(map[string]interface{})
  2756. // data["struct_3507s"] = struct3507
  2757. // client := &http.Client{}
  2758. // bytesData, _ := json.Marshal(data)
  2759. // var req *http.Request
  2760. // if miConfig.MdtrtareaAdmvs == "320921" {
  2761. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2762. // } else {
  2763. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2764. // }
  2765. //
  2766. // resp, _ := client.Do(req)
  2767. // defer resp.Body.Close()
  2768. // body, ioErr := ioutil.ReadAll(resp.Body)
  2769. // if ioErr != nil {
  2770. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2771. // }
  2772. // var respJSON map[string]interface{}
  2773. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2774. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2775. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2776. // return
  2777. // }
  2778. // var resSix10265 ResultSix10265 //1101结果
  2779. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2780. // result, _ := json.Marshal(respJSON)
  2781. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2782. // utils.ErrorLog("解析失败:%v", err)
  2783. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2784. // return
  2785. // }
  2786. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2787. // //res.Output = resSix10265.Output
  2788. // res.ErrMsg = resSix10265.ErrMsg
  2789. // res.Cainfo = resSix10265.Cainfo
  2790. // res.WarnMsg = resSix10265.WarnMsg
  2791. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2792. // res.Infcode = infocode
  2793. // }
  2794. //
  2795. // if res.Infcode == 0 {
  2796. // item.IsChange = 0
  2797. // item.BgBchno = ""
  2798. // service.SaveDF2(item)
  2799. // } else {
  2800. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2801. // }
  2802. // }
  2803. // }
  2804. // if len(err) == 0 {
  2805. // c.ServeSuccessJSON(map[string]interface{}{
  2806. // "msg": "删除销售变更成功",
  2807. // })
  2808. //
  2809. // } else {
  2810. // c.ServeSuccessJSON(map[string]interface{}{
  2811. // "failed_code": -10,
  2812. // "msg": err,
  2813. // })
  2814. //
  2815. // }
  2816. //
  2817. //}
  2818. // 获取当天起止时间戳
  2819. func GetNowTime() (int64, int64) {
  2820. t := time.Now()
  2821. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2822. timesamp := addTime.Unix()
  2823. return timesamp, timesamp + 86399
  2824. }
  2825. //func (c *HisApiController) ChangeDrugfour() {
  2826. // patient_id, _ := c.GetInt64("patient_id")
  2827. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2828. // //id_arr := strings.Split(ids, ",")
  2829. // times := c.GetString("time", "")
  2830. // timeLayout := "2006-01-02"
  2831. // loc, _ := time.LoadLocation("Local")
  2832. // var stime, etime int64
  2833. // if times == "" {
  2834. // stime, etime = GetNowTime()
  2835. // } else {
  2836. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2837. // stime = stmp.Unix()
  2838. // etime = stime + 86399
  2839. // }
  2840. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2841. // var flows []*models.DrugFlow
  2842. // for _, item := range advicelist {
  2843. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.ID, times, c.GetAdminUserInfo().CurrentOrgId)
  2844. // flows = append(flows, flow...)
  2845. // }
  2846. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2847. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2848. // var err []string
  2849. //
  2850. // for _, item := range flows {
  2851. // var res3 ResultSix
  2852. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2853. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2854. // if prescription.OrderStatus == 2 {
  2855. // //已经结算
  2856. // //判断是否已经销售
  2857. // if item.IsSale == 1 { //是否已经销售,1是 0否
  2858. // //是否已经变更 1是 0否
  2859. // if item.IsChange == 0 { //没变更,进行变更操作
  2860. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2861. //
  2862. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2863. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  2864. // var respJSON3 map[string]interface{}
  2865. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2866. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2867. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2868. // return
  2869. // }
  2870. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2871. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2872. // utils.ErrorLog("解析失败:%v", err)
  2873. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2874. // return
  2875. // }
  2876. // if res3.Infcode == 0 {
  2877. // item.IsChange = 1
  2878. // item.BgBchno = bg_number
  2879. // service.SaveDF2(item)
  2880. // } else {
  2881. //
  2882. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2883. // }
  2884. // }
  2885. // } else { //没销售,
  2886. // var res FJ3507Result
  2887. // var res3507for10188 FJ3507ResultFor10188
  2888. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2889. //
  2890. // //进行商品销售接口
  2891. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2892. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2893. // var respJSON3 map[string]interface{}
  2894. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2895. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2896. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2897. // return
  2898. // }
  2899. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2900. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2901. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2902. // utils.ErrorLog("解析失败:%v", err)
  2903. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2904. // return
  2905. // }
  2906. // //if res3507for10188.Infcode
  2907. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  2908. // //res.Output = resSix10265.Output
  2909. // res.ErrMsg = res3507for10188.ErrMsg
  2910. // res.Cainfo = res3507for10188.Cainfo
  2911. // res.WarnMsg = res3507for10188.WarnMsg
  2912. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2913. // res.Infcode = infocode
  2914. // } else {
  2915. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2916. // utils.ErrorLog("解析失败:%v", err)
  2917. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2918. // return
  2919. // }
  2920. //
  2921. // }
  2922. // if res.Infcode == 0 {
  2923. // item.IsSale = 1
  2924. // item.Bchno = number
  2925. // item.SaleDate = time.Now().Format("2006-01-02")
  2926. //
  2927. // err5 := service.SaveDF(item)
  2928. // if err5 == nil {
  2929. // if item.IsChange == 0 { //没变更,进行变更操作
  2930. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2931. //
  2932. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2933. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  2934. //
  2935. // var respJSON3 map[string]interface{}
  2936. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2937. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2938. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2939. // return
  2940. // }
  2941. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2942. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2943. // utils.ErrorLog("解析失败:%v", err)
  2944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2945. // return
  2946. // }
  2947. // //if res3507for10188.Infcode
  2948. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2949. // //res.Output = resSix10265.Output
  2950. // res3.ErrMsg = res3507for10188.ErrMsg
  2951. // res3.Cainfo = res3507for10188.Cainfo
  2952. // res3.WarnMsg = res3507for10188.WarnMsg
  2953. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2954. // res3.Infcode = infocode
  2955. // } else {
  2956. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2957. // utils.ErrorLog("解析失败:%v", err)
  2958. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2959. // return
  2960. // }
  2961. // }
  2962. // if res3.Infcode == 0 {
  2963. // item.IsChange = 1
  2964. // item.BgBchno = bg_number
  2965. // service.SaveDF2(item)
  2966. // } else {
  2967. //
  2968. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2969. // }
  2970. // }
  2971. // }
  2972. // } else {
  2973. //
  2974. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  2975. // }
  2976. // }
  2977. //
  2978. // } else { //还没结,提示用户去结算,并药品追溯上传
  2979. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  2980. // }
  2981. // }
  2982. // }
  2983. // if len(err) == 0 {
  2984. // c.ServeSuccessJSON(map[string]interface{}{
  2985. // "msg": "销售变更成功",
  2986. // })
  2987. // } else {
  2988. // c.ServeSuccessJSON(map[string]interface{}{
  2989. // "failed_code": -10,
  2990. // "msg": err,
  2991. // })
  2992. // }
  2993. //}
  2994. func (c *HisApiController) ChangeDrugfour() {
  2995. patient_id, _ := c.GetInt64("patient_id")
  2996. admin_user_id, _ := c.GetInt64("admin_user_id")
  2997. //id_arr := strings.Split(ids, ",")
  2998. times := c.GetString("time", "")
  2999. timeLayout := "2006-01-02"
  3000. loc, _ := time.LoadLocation("Local")
  3001. var stime, etime int64
  3002. if times == "" {
  3003. stime, etime = GetNowTime()
  3004. } else {
  3005. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3006. stime = stmp.Unix()
  3007. etime = stime + 86399
  3008. }
  3009. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3010. var flows []*models.DrugFlow
  3011. for _, item := range advicelist {
  3012. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3013. flows = append(flows, flow...)
  3014. }
  3015. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3016. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3017. var err []string
  3018. for _, item := range flows {
  3019. var res3 ResultSix
  3020. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3021. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3022. if prescription.OrderStatus == 2 {
  3023. //已经结算
  3024. //判断是否已经销售
  3025. if item.IsSale == 1 { //是否已经销售,1是 0否
  3026. //是否已经变更 1是 0否
  3027. if item.IsChange == 0 { //没变更,进行变更操作
  3028. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  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. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3049. }
  3050. }
  3051. } else { //没销售,
  3052. var res FJ3507Result
  3053. var res3507for10188 FJ3507ResultFor10188
  3054. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3055. //进行商品销售接口
  3056. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3057. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3058. var respJSON3 map[string]interface{}
  3059. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3060. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3062. return
  3063. }
  3064. userJSONBytes3, _ := json.Marshal(respJSON3)
  3065. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3066. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3067. utils.ErrorLog("解析失败:%v", err)
  3068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3069. return
  3070. }
  3071. //if res3507for10188.Infcode
  3072. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3073. //res.Output = resSix10265.Output
  3074. res.ErrMsg = res3507for10188.ErrMsg
  3075. res.Cainfo = res3507for10188.Cainfo
  3076. res.WarnMsg = res3507for10188.WarnMsg
  3077. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3078. res.Infcode = infocode
  3079. } else {
  3080. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3081. utils.ErrorLog("解析失败:%v", err)
  3082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3083. return
  3084. }
  3085. }
  3086. if res.Infcode == 0 {
  3087. item.IsSale = 1
  3088. item.Bchno = number
  3089. item.SaleDate = time.Now().Format("2006-01-02")
  3090. err5 := service.SaveDF(item)
  3091. if err5 == nil {
  3092. if item.IsChange == 0 { //没变更,进行变更操作
  3093. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3094. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3095. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3096. var respJSON3 map[string]interface{}
  3097. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3100. return
  3101. }
  3102. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3103. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3104. utils.ErrorLog("解析失败:%v", err)
  3105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3106. return
  3107. }
  3108. //if res3507for10188.Infcode
  3109. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3110. //res.Output = resSix10265.Output
  3111. res3.ErrMsg = res3507for10188.ErrMsg
  3112. res3.Cainfo = res3507for10188.Cainfo
  3113. res3.WarnMsg = res3507for10188.WarnMsg
  3114. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3115. res3.Infcode = infocode
  3116. } else {
  3117. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3118. utils.ErrorLog("解析失败:%v", err)
  3119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3120. return
  3121. }
  3122. }
  3123. if res3.Infcode == 0 {
  3124. item.IsChange = 1
  3125. item.BgBchno = bg_number
  3126. service.SaveDF2(item)
  3127. } else {
  3128. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3129. }
  3130. }
  3131. }
  3132. } else {
  3133. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3134. }
  3135. }
  3136. } else { //还没结,提示用户去结算,并药品追溯上传
  3137. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3138. }
  3139. }
  3140. }
  3141. if len(err) == 0 {
  3142. c.ServeSuccessJSON(map[string]interface{}{
  3143. "msg": "销售变更成功",
  3144. })
  3145. } else {
  3146. c.ServeSuccessJSON(map[string]interface{}{
  3147. "failed_code": -10,
  3148. "msg": err,
  3149. })
  3150. }
  3151. }
  3152. func (c *HisApiController) ChangeDrug() {
  3153. ids := c.GetString("ids")
  3154. id_arr := strings.Split(ids, ",")
  3155. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3156. admin_user_id, _ := c.GetInt64("admin_user_id")
  3157. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3158. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3159. var err []string
  3160. for _, item := range flows {
  3161. var res3 ResultSix
  3162. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3163. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3164. if prescription.OrderStatus == 2 {
  3165. //已经结算
  3166. //判断是否已经销售
  3167. if item.IsSale == 1 { //是否已经销售,1是 0否
  3168. //是否已经变更 1是 0否
  3169. if item.IsChange == 0 { //没变更,进行变更操作
  3170. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3171. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3172. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3173. var respJSON3 map[string]interface{}
  3174. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3177. return
  3178. }
  3179. userJSONBytes3, _ := json.Marshal(respJSON3)
  3180. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3181. utils.ErrorLog("解析失败:%v", err)
  3182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3183. return
  3184. }
  3185. if res3.Infcode == 0 {
  3186. item.IsChange = 1
  3187. item.BgBchno = bg_number
  3188. service.SaveDF2(item)
  3189. } else {
  3190. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3191. }
  3192. }
  3193. } else { //没销售,
  3194. var res FJ3507Result
  3195. var res3507for10188 FJ3507ResultFor10188
  3196. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3197. //进行商品销售接口
  3198. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3199. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3200. var respJSON3 map[string]interface{}
  3201. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3204. return
  3205. }
  3206. userJSONBytes3, _ := json.Marshal(respJSON3)
  3207. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3208. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3209. utils.ErrorLog("解析失败:%v", err)
  3210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3211. return
  3212. }
  3213. //if res3507for10188.Infcode
  3214. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3215. //res.Output = resSix10265.Output
  3216. res.ErrMsg = res3507for10188.ErrMsg
  3217. res.Cainfo = res3507for10188.Cainfo
  3218. res.WarnMsg = res3507for10188.WarnMsg
  3219. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3220. res.Infcode = infocode
  3221. } else {
  3222. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3223. utils.ErrorLog("解析失败:%v", err)
  3224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3225. return
  3226. }
  3227. }
  3228. if res.Infcode == 0 {
  3229. item.IsSale = 1
  3230. item.Bchno = number
  3231. item.SaleDate = time.Now().Format("2006-01-02")
  3232. err5 := service.SaveDF(item)
  3233. if err5 == nil {
  3234. if item.IsChange == 0 { //没变更,进行变更操作
  3235. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3236. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3237. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3238. var respJSON3 map[string]interface{}
  3239. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3240. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3242. return
  3243. }
  3244. userJSONBytes3, _ := json.Marshal(respJSON3)
  3245. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3246. utils.ErrorLog("解析失败:%v", err)
  3247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3248. return
  3249. }
  3250. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3251. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3252. utils.ErrorLog("解析失败:%v", err)
  3253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3254. return
  3255. }
  3256. //if res3507for10188.Infcode
  3257. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3258. //res.Output = resSix10265.Output
  3259. res3.ErrMsg = res3507for10188.ErrMsg
  3260. res3.Cainfo = res3507for10188.Cainfo
  3261. res3.WarnMsg = res3507for10188.WarnMsg
  3262. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3263. res3.Infcode = infocode
  3264. } else {
  3265. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3266. utils.ErrorLog("解析失败:%v", err)
  3267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3268. return
  3269. }
  3270. }
  3271. if res3.Infcode == 0 {
  3272. item.IsChange = 1
  3273. item.BgBchno = bg_number
  3274. service.SaveDF2(item)
  3275. } else {
  3276. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3277. }
  3278. }
  3279. }
  3280. } else {
  3281. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3282. }
  3283. }
  3284. } else { //还没结算
  3285. var res3507for10188 FJ3507ResultFor10188
  3286. if item.IsChange == 0 { //没变更,进行变更操作
  3287. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3288. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3289. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3290. var respJSON3 map[string]interface{}
  3291. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3294. return
  3295. }
  3296. userJSONBytes3, _ := json.Marshal(respJSON3)
  3297. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3298. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3299. utils.ErrorLog("解析失败:%v", err)
  3300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3301. return
  3302. }
  3303. //if res3507for10188.Infcode
  3304. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3305. //res.Output = resSix10265.Output
  3306. res3.ErrMsg = res3507for10188.ErrMsg
  3307. res3.Cainfo = res3507for10188.Cainfo
  3308. res3.WarnMsg = res3507for10188.WarnMsg
  3309. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3310. res3.Infcode = infocode
  3311. } else {
  3312. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3313. utils.ErrorLog("解析失败:%v", err)
  3314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3315. return
  3316. }
  3317. }
  3318. if res3.Infcode == 0 {
  3319. item.IsChange = 1
  3320. item.BgBchno = bg_number
  3321. service.SaveDF2(item)
  3322. } else {
  3323. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3324. }
  3325. }
  3326. }
  3327. } else if item.ConsumableType == 7 {
  3328. var res3507for10188 FJ3507ResultFor10188
  3329. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3330. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3331. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3332. //判断是否已经销售
  3333. if item.IsSale == 2 { //是否已经销售,1是 0否
  3334. //是否已经变更 1是 0否
  3335. if item.IsChange == 0 { //没变更,进行变更操作
  3336. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3337. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3338. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3339. var respJSON3 map[string]interface{}
  3340. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3343. return
  3344. }
  3345. userJSONBytes3, _ := json.Marshal(respJSON3)
  3346. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3347. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3348. utils.ErrorLog("解析失败:%v", err)
  3349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3350. return
  3351. }
  3352. //if res3507for10188.Infcode
  3353. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3354. //res.Output = resSix10265.Output
  3355. res3.ErrMsg = res3507for10188.ErrMsg
  3356. res3.Cainfo = res3507for10188.Cainfo
  3357. res3.WarnMsg = res3507for10188.WarnMsg
  3358. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3359. res3.Infcode = infocode
  3360. } else {
  3361. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3362. utils.ErrorLog("解析失败:%v", err)
  3363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3364. return
  3365. }
  3366. }
  3367. if res3.Infcode == 0 {
  3368. item.IsChange = 1
  3369. item.BgBchno = bg_number
  3370. service.SaveDF2(item)
  3371. } else {
  3372. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3373. }
  3374. }
  3375. } else { //没销售,
  3376. //进行商品销售退货接口
  3377. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3378. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3379. saveLog(result111, result222, "3506", "销售退货")
  3380. var res7 FJ3507Result
  3381. //进行商品销售接口
  3382. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3383. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3384. var respJSON3 map[string]interface{}
  3385. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3388. return
  3389. }
  3390. userJSONBytes3, _ := json.Marshal(respJSON3)
  3391. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3392. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3393. utils.ErrorLog("解析失败:%v", err)
  3394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3395. return
  3396. }
  3397. //if res3507for10188.Infcode
  3398. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3399. //res.Output = resSix10265.Output
  3400. res7.ErrMsg = res3507for10188.ErrMsg
  3401. res7.Cainfo = res3507for10188.Cainfo
  3402. res7.WarnMsg = res3507for10188.WarnMsg
  3403. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3404. res7.Infcode = infocode
  3405. } else {
  3406. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3407. utils.ErrorLog("解析失败:%v", err)
  3408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3409. return
  3410. }
  3411. }
  3412. if res7.Infcode == 0 {
  3413. item.IsSale = 2
  3414. item.SaleDate = item.SaleDate
  3415. item.Bchno = number
  3416. service.SaveDF(item)
  3417. if item.IsChange == 0 { //没变更,进行变更操作
  3418. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3419. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3420. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3421. var respJSON3 map[string]interface{}
  3422. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3425. return
  3426. }
  3427. userJSONBytes3, _ := json.Marshal(respJSON3)
  3428. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3429. // utils.ErrorLog("解析失败:%v", err)
  3430. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3431. // return
  3432. //}
  3433. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3434. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3435. utils.ErrorLog("解析失败:%v", err)
  3436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3437. return
  3438. }
  3439. //if res3507for10188.Infcode
  3440. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3441. //res.Output = resSix10265.Output
  3442. res3.ErrMsg = res3507for10188.ErrMsg
  3443. res3.Cainfo = res3507for10188.Cainfo
  3444. res3.WarnMsg = res3507for10188.WarnMsg
  3445. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3446. res3.Infcode = infocode
  3447. } else {
  3448. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3449. utils.ErrorLog("解析失败:%v", err)
  3450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3451. return
  3452. }
  3453. }
  3454. if res3.Infcode == 0 {
  3455. item.IsChange = 1
  3456. item.BgBchno = bg_number
  3457. service.SaveDF2(item)
  3458. } else {
  3459. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3460. }
  3461. }
  3462. } else {
  3463. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3464. }
  3465. }
  3466. } else { //还没结算
  3467. if item.IsChange == 0 { //没变更,进行变更操作
  3468. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3469. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3470. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3471. var respJSON3 map[string]interface{}
  3472. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3475. return
  3476. }
  3477. userJSONBytes3, _ := json.Marshal(respJSON3)
  3478. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3479. // utils.ErrorLog("解析失败:%v", err)
  3480. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3481. // return
  3482. //}
  3483. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3484. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3485. utils.ErrorLog("解析失败:%v", err)
  3486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3487. return
  3488. }
  3489. //if res3507for10188.Infcode
  3490. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3491. //res.Output = resSix10265.Output
  3492. res3.ErrMsg = res3507for10188.ErrMsg
  3493. res3.Cainfo = res3507for10188.Cainfo
  3494. res3.WarnMsg = res3507for10188.WarnMsg
  3495. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3496. res3.Infcode = infocode
  3497. } else {
  3498. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3499. utils.ErrorLog("解析失败:%v", err)
  3500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3501. return
  3502. }
  3503. }
  3504. if res3.Infcode == 0 {
  3505. item.IsChange = 1
  3506. item.BgBchno = bg_number
  3507. service.SaveDF2(item)
  3508. } else {
  3509. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3510. }
  3511. }
  3512. }
  3513. }
  3514. }
  3515. if len(err) == 0 {
  3516. c.ServeSuccessJSON(map[string]interface{}{
  3517. "msg": "销售变更成功",
  3518. })
  3519. } else {
  3520. c.ServeSuccessJSON(map[string]interface{}{
  3521. "failed_code": -10,
  3522. "msg": err,
  3523. })
  3524. }
  3525. }
  3526. func (c *HisApiController) ChangeDrugtwo() {
  3527. //ids := c.GetString("ids")
  3528. //id_arr := strings.Split(ids, ",")
  3529. flows, _ := service.GetNewDrugFlowInfotwo()
  3530. admin_user_id, _ := c.GetInt64("admin_user_id")
  3531. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3532. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3533. var err []string
  3534. for _, item := range flows {
  3535. var res3 ResultSix
  3536. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3537. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3538. if prescription.OrderStatus == 2 {
  3539. //已经结算
  3540. //判断是否已经销售
  3541. if item.IsSale == 1 { //是否已经销售,1是 0否
  3542. //是否已经变更 1是 0否
  3543. if item.IsChange == 0 { //没变更,进行变更操作
  3544. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3545. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3546. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3547. var respJSON3 map[string]interface{}
  3548. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3551. return
  3552. }
  3553. userJSONBytes3, _ := json.Marshal(respJSON3)
  3554. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3555. utils.ErrorLog("解析失败:%v", err)
  3556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3557. return
  3558. }
  3559. if res3.Infcode == 0 {
  3560. item.IsChange = 1
  3561. item.BgBchno = bg_number
  3562. service.SaveDF2(item)
  3563. } else {
  3564. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3565. }
  3566. }
  3567. } else { //没销售,
  3568. var res FJ3507Result
  3569. var res3507for10188 FJ3507ResultFor10188
  3570. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3571. //进行商品销售接口
  3572. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3573. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3574. var respJSON3 map[string]interface{}
  3575. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3578. return
  3579. }
  3580. userJSONBytes3, _ := json.Marshal(respJSON3)
  3581. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3582. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3583. utils.ErrorLog("解析失败:%v", err)
  3584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3585. return
  3586. }
  3587. //if res3507for10188.Infcode
  3588. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3589. //res.Output = resSix10265.Output
  3590. res.ErrMsg = res3507for10188.ErrMsg
  3591. res.Cainfo = res3507for10188.Cainfo
  3592. res.WarnMsg = res3507for10188.WarnMsg
  3593. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3594. res.Infcode = infocode
  3595. } else {
  3596. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3597. utils.ErrorLog("解析失败:%v", err)
  3598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3599. return
  3600. }
  3601. }
  3602. if res.Infcode == 0 {
  3603. item.IsSale = 1
  3604. item.Bchno = number
  3605. item.SaleDate = time.Now().Format("2006-01-02")
  3606. err5 := service.SaveDF(item)
  3607. if err5 == nil {
  3608. if item.IsChange == 0 { //没变更,进行变更操作
  3609. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3610. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3611. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3612. var respJSON3 map[string]interface{}
  3613. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3616. return
  3617. }
  3618. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3619. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3620. utils.ErrorLog("解析失败:%v", err)
  3621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3622. return
  3623. }
  3624. //if res3507for10188.Infcode
  3625. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3626. //res.Output = resSix10265.Output
  3627. res3.ErrMsg = res3507for10188.ErrMsg
  3628. res3.Cainfo = res3507for10188.Cainfo
  3629. res3.WarnMsg = res3507for10188.WarnMsg
  3630. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3631. res3.Infcode = infocode
  3632. } else {
  3633. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3634. utils.ErrorLog("解析失败:%v", err)
  3635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3636. return
  3637. }
  3638. }
  3639. if res3.Infcode == 0 {
  3640. item.IsChange = 1
  3641. item.BgBchno = bg_number
  3642. service.SaveDF2(item)
  3643. } else {
  3644. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3645. }
  3646. }
  3647. }
  3648. } else {
  3649. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3650. }
  3651. }
  3652. } else { //还没结算
  3653. var res3507for10188 FJ3507ResultFor10188
  3654. if item.IsChange == 0 { //没变更,进行变更操作
  3655. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3656. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3657. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3658. var respJSON3 map[string]interface{}
  3659. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3662. return
  3663. }
  3664. userJSONBytes3, _ := json.Marshal(respJSON3)
  3665. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3666. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3667. utils.ErrorLog("解析失败:%v", err)
  3668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3669. return
  3670. }
  3671. //if res3507for10188.Infcode
  3672. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3673. //res.Output = resSix10265.Output
  3674. res3.ErrMsg = res3507for10188.ErrMsg
  3675. res3.Cainfo = res3507for10188.Cainfo
  3676. res3.WarnMsg = res3507for10188.WarnMsg
  3677. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3678. res3.Infcode = infocode
  3679. } else {
  3680. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3681. utils.ErrorLog("解析失败:%v", err)
  3682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3683. return
  3684. }
  3685. }
  3686. if res3.Infcode == 0 {
  3687. item.IsChange = 1
  3688. item.BgBchno = bg_number
  3689. service.SaveDF2(item)
  3690. } else {
  3691. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3692. }
  3693. }
  3694. }
  3695. } else if item.ConsumableType == 7 {
  3696. var res3507for10188 FJ3507ResultFor10188
  3697. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3698. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3699. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3700. //判断是否已经销售
  3701. if item.IsSale == 2 { //是否已经销售,1是 0否
  3702. //是否已经变更 1是 0否
  3703. if item.IsChange == 0 { //没变更,进行变更操作
  3704. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3705. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3706. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3707. var respJSON3 map[string]interface{}
  3708. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3711. return
  3712. }
  3713. userJSONBytes3, _ := json.Marshal(respJSON3)
  3714. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3715. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3716. utils.ErrorLog("解析失败:%v", err)
  3717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3718. return
  3719. }
  3720. //if res3507for10188.Infcode
  3721. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3722. //res.Output = resSix10265.Output
  3723. res3.ErrMsg = res3507for10188.ErrMsg
  3724. res3.Cainfo = res3507for10188.Cainfo
  3725. res3.WarnMsg = res3507for10188.WarnMsg
  3726. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3727. res3.Infcode = infocode
  3728. } else {
  3729. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3730. utils.ErrorLog("解析失败:%v", err)
  3731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3732. return
  3733. }
  3734. }
  3735. if res3.Infcode == 0 {
  3736. item.IsChange = 1
  3737. item.BgBchno = bg_number
  3738. service.SaveDF2(item)
  3739. } else {
  3740. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3741. }
  3742. }
  3743. } else { //没销售,
  3744. //进行商品销售退货接口
  3745. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3746. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3747. saveLog(result111, result222, "3506", "销售退货")
  3748. var res7 FJ3507Result
  3749. //进行商品销售接口
  3750. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3751. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3752. var respJSON3 map[string]interface{}
  3753. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3756. return
  3757. }
  3758. userJSONBytes3, _ := json.Marshal(respJSON3)
  3759. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3760. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3761. utils.ErrorLog("解析失败:%v", err)
  3762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3763. return
  3764. }
  3765. //if res3507for10188.Infcode
  3766. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3767. //res.Output = resSix10265.Output
  3768. res7.ErrMsg = res3507for10188.ErrMsg
  3769. res7.Cainfo = res3507for10188.Cainfo
  3770. res7.WarnMsg = res3507for10188.WarnMsg
  3771. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3772. res7.Infcode = infocode
  3773. } else {
  3774. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3775. utils.ErrorLog("解析失败:%v", err)
  3776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3777. return
  3778. }
  3779. }
  3780. if res7.Infcode == 0 {
  3781. item.IsSale = 2
  3782. item.SaleDate = item.SaleDate
  3783. item.Bchno = number
  3784. service.SaveDF(item)
  3785. if item.IsChange == 0 { //没变更,进行变更操作
  3786. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3787. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3788. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3789. var respJSON3 map[string]interface{}
  3790. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3791. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3793. return
  3794. }
  3795. userJSONBytes3, _ := json.Marshal(respJSON3)
  3796. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3797. // utils.ErrorLog("解析失败:%v", err)
  3798. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3799. // return
  3800. //}
  3801. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3802. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3803. utils.ErrorLog("解析失败:%v", err)
  3804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3805. return
  3806. }
  3807. //if res3507for10188.Infcode
  3808. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3809. //res.Output = resSix10265.Output
  3810. res3.ErrMsg = res3507for10188.ErrMsg
  3811. res3.Cainfo = res3507for10188.Cainfo
  3812. res3.WarnMsg = res3507for10188.WarnMsg
  3813. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3814. res3.Infcode = infocode
  3815. } else {
  3816. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3817. utils.ErrorLog("解析失败:%v", err)
  3818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3819. return
  3820. }
  3821. }
  3822. if res3.Infcode == 0 {
  3823. item.IsChange = 1
  3824. item.BgBchno = bg_number
  3825. service.SaveDF2(item)
  3826. } else {
  3827. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3828. }
  3829. }
  3830. } else {
  3831. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3832. }
  3833. }
  3834. } else { //还没结算
  3835. if item.IsChange == 0 { //没变更,进行变更操作
  3836. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3837. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3838. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3839. var respJSON3 map[string]interface{}
  3840. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3843. return
  3844. }
  3845. userJSONBytes3, _ := json.Marshal(respJSON3)
  3846. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3847. // utils.ErrorLog("解析失败:%v", err)
  3848. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3849. // return
  3850. //}
  3851. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3852. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3853. utils.ErrorLog("解析失败:%v", err)
  3854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3855. return
  3856. }
  3857. //if res3507for10188.Infcode
  3858. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3859. //res.Output = resSix10265.Output
  3860. res3.ErrMsg = res3507for10188.ErrMsg
  3861. res3.Cainfo = res3507for10188.Cainfo
  3862. res3.WarnMsg = res3507for10188.WarnMsg
  3863. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3864. res3.Infcode = infocode
  3865. } else {
  3866. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3867. utils.ErrorLog("解析失败:%v", err)
  3868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3869. return
  3870. }
  3871. }
  3872. if res3.Infcode == 0 {
  3873. item.IsChange = 1
  3874. item.BgBchno = bg_number
  3875. service.SaveDF2(item)
  3876. } else {
  3877. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3878. }
  3879. }
  3880. }
  3881. }
  3882. }
  3883. if len(err) == 0 {
  3884. c.ServeSuccessJSON(map[string]interface{}{
  3885. "msg": "销售变更成功",
  3886. })
  3887. } else {
  3888. c.ServeSuccessJSON(map[string]interface{}{
  3889. "failed_code": -10,
  3890. "msg": err,
  3891. })
  3892. }
  3893. }
  3894. func (c *HisApiController) ChangeDrugthree() {
  3895. //ids := c.GetString("ids")
  3896. //id_arr := strings.Split(ids, ",")
  3897. flows, _ := service.GetNewDrugFlowInfothree()
  3898. admin_user_id, _ := c.GetInt64("admin_user_id")
  3899. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3900. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3901. var err []string
  3902. for _, item := range flows {
  3903. var res3 ResultSix
  3904. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3905. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3906. if prescription.OrderStatus == 2 {
  3907. //已经结算
  3908. //判断是否已经销售
  3909. if item.IsSale == 1 { //是否已经销售,1是 0否
  3910. //是否已经变更 1是 0否
  3911. if item.IsChange == 0 { //没变更,进行变更操作
  3912. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3913. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3914. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3915. var respJSON3 map[string]interface{}
  3916. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3919. return
  3920. }
  3921. userJSONBytes3, _ := json.Marshal(respJSON3)
  3922. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3923. utils.ErrorLog("解析失败:%v", err)
  3924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3925. return
  3926. }
  3927. if res3.Infcode == 0 {
  3928. item.IsChange = 1
  3929. item.BgBchno = bg_number
  3930. service.SaveDF2(item)
  3931. } else {
  3932. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3933. }
  3934. }
  3935. } else { //没销售,
  3936. var res FJ3507Result
  3937. var res3507for10188 FJ3507ResultFor10188
  3938. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3939. //进行商品销售接口
  3940. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3941. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3942. var respJSON3 map[string]interface{}
  3943. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3944. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3946. return
  3947. }
  3948. userJSONBytes3, _ := json.Marshal(respJSON3)
  3949. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3950. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3951. utils.ErrorLog("解析失败:%v", err)
  3952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3953. return
  3954. }
  3955. //if res3507for10188.Infcode
  3956. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3957. //res.Output = resSix10265.Output
  3958. res.ErrMsg = res3507for10188.ErrMsg
  3959. res.Cainfo = res3507for10188.Cainfo
  3960. res.WarnMsg = res3507for10188.WarnMsg
  3961. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3962. res.Infcode = infocode
  3963. } else {
  3964. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3965. utils.ErrorLog("解析失败:%v", err)
  3966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3967. return
  3968. }
  3969. }
  3970. if res.Infcode == 0 {
  3971. item.IsSale = 1
  3972. item.Bchno = number
  3973. item.SaleDate = time.Now().Format("2006-01-02")
  3974. err5 := service.SaveDF(item)
  3975. if err5 == nil {
  3976. if item.IsChange == 0 { //没变更,进行变更操作
  3977. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3978. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3979. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3980. var respJSON3 map[string]interface{}
  3981. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3982. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3984. return
  3985. }
  3986. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  3987. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3988. utils.ErrorLog("解析失败:%v", err)
  3989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3990. return
  3991. }
  3992. //if res3507for10188.Infcode
  3993. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3994. //res.Output = resSix10265.Output
  3995. res3.ErrMsg = res3507for10188.ErrMsg
  3996. res3.Cainfo = res3507for10188.Cainfo
  3997. res3.WarnMsg = res3507for10188.WarnMsg
  3998. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3999. res3.Infcode = infocode
  4000. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4001. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4002. utils.ErrorLog("解析失败:%v", err)
  4003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4004. return
  4005. }
  4006. //if res3507for10188.Infcode
  4007. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4008. //res.Output = resSix10265.Output
  4009. res3.ErrMsg = res3507for10188.ErrMsg
  4010. res3.Cainfo = res3507for10188.Cainfo
  4011. res3.WarnMsg = res3507for10188.WarnMsg
  4012. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4013. res3.Infcode = infocode
  4014. } else {
  4015. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4016. utils.ErrorLog("解析失败:%v", err)
  4017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4018. return
  4019. }
  4020. }
  4021. if res3.Infcode == 0 {
  4022. item.IsChange = 1
  4023. item.BgBchno = bg_number
  4024. service.SaveDF2(item)
  4025. } else {
  4026. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4027. }
  4028. }
  4029. }
  4030. } else {
  4031. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4032. }
  4033. }
  4034. } else { //还没结算
  4035. var res3507for10188 FJ3507ResultFor10188
  4036. if item.IsChange == 0 { //没变更,进行变更操作
  4037. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4038. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4039. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4040. var respJSON3 map[string]interface{}
  4041. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4044. return
  4045. }
  4046. userJSONBytes3, _ := json.Marshal(respJSON3)
  4047. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4048. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4049. utils.ErrorLog("解析失败:%v", err)
  4050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4051. return
  4052. }
  4053. //if res3507for10188.Infcode
  4054. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4055. //res.Output = resSix10265.Output
  4056. res3.ErrMsg = res3507for10188.ErrMsg
  4057. res3.Cainfo = res3507for10188.Cainfo
  4058. res3.WarnMsg = res3507for10188.WarnMsg
  4059. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4060. res3.Infcode = infocode
  4061. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4062. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4063. utils.ErrorLog("解析失败:%v", err)
  4064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4065. return
  4066. }
  4067. //if res3507for10188.Infcode
  4068. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4069. //res.Output = resSix10265.Output
  4070. res3.ErrMsg = res3507for10188.ErrMsg
  4071. res3.Cainfo = res3507for10188.Cainfo
  4072. res3.WarnMsg = res3507for10188.WarnMsg
  4073. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4074. res3.Infcode = infocode
  4075. } else {
  4076. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4077. utils.ErrorLog("解析失败:%v", err)
  4078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4079. return
  4080. }
  4081. }
  4082. if res3.Infcode == 0 {
  4083. item.IsChange = 1
  4084. item.BgBchno = bg_number
  4085. service.SaveDF2(item)
  4086. } else {
  4087. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4088. }
  4089. }
  4090. }
  4091. } else if item.ConsumableType == 7 {
  4092. var res3507for10188 FJ3507ResultFor10188
  4093. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4094. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4095. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4096. //判断是否已经销售
  4097. if item.IsSale == 2 { //是否已经销售,1是 0否
  4098. //是否已经变更 1是 0否
  4099. if item.IsChange == 0 { //没变更,进行变更操作
  4100. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4101. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4102. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4103. var respJSON3 map[string]interface{}
  4104. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4107. return
  4108. }
  4109. userJSONBytes3, _ := json.Marshal(respJSON3)
  4110. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4111. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4112. utils.ErrorLog("解析失败:%v", err)
  4113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4114. return
  4115. }
  4116. //if res3507for10188.Infcode
  4117. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4118. //res.Output = resSix10265.Output
  4119. res3.ErrMsg = res3507for10188.ErrMsg
  4120. res3.Cainfo = res3507for10188.Cainfo
  4121. res3.WarnMsg = res3507for10188.WarnMsg
  4122. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4123. res3.Infcode = infocode
  4124. } else {
  4125. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4126. utils.ErrorLog("解析失败:%v", err)
  4127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4128. return
  4129. }
  4130. }
  4131. if res3.Infcode == 0 {
  4132. item.IsChange = 1
  4133. item.BgBchno = bg_number
  4134. service.SaveDF2(item)
  4135. } else {
  4136. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4137. }
  4138. }
  4139. } else { //没销售,
  4140. //进行商品销售退货接口
  4141. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4142. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4143. saveLog(result111, result222, "3506", "销售退货")
  4144. var res7 FJ3507Result
  4145. //进行商品销售接口
  4146. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4147. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4148. var respJSON3 map[string]interface{}
  4149. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4152. return
  4153. }
  4154. userJSONBytes3, _ := json.Marshal(respJSON3)
  4155. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4156. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4157. utils.ErrorLog("解析失败:%v", err)
  4158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4159. return
  4160. }
  4161. //if res3507for10188.Infcode
  4162. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4163. //res.Output = resSix10265.Output
  4164. res7.ErrMsg = res3507for10188.ErrMsg
  4165. res7.Cainfo = res3507for10188.Cainfo
  4166. res7.WarnMsg = res3507for10188.WarnMsg
  4167. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4168. res7.Infcode = infocode
  4169. } else {
  4170. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4171. utils.ErrorLog("解析失败:%v", err)
  4172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4173. return
  4174. }
  4175. }
  4176. if res7.Infcode == 0 {
  4177. item.IsSale = 2
  4178. item.SaleDate = item.SaleDate
  4179. item.Bchno = number
  4180. service.SaveDF(item)
  4181. if item.IsChange == 0 { //没变更,进行变更操作
  4182. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4183. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4184. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4185. var respJSON3 map[string]interface{}
  4186. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4187. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4189. return
  4190. }
  4191. userJSONBytes3, _ := json.Marshal(respJSON3)
  4192. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4193. // utils.ErrorLog("解析失败:%v", err)
  4194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4195. // return
  4196. //}
  4197. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4198. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4199. utils.ErrorLog("解析失败:%v", err)
  4200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4201. return
  4202. }
  4203. //if res3507for10188.Infcode
  4204. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4205. //res.Output = resSix10265.Output
  4206. res3.ErrMsg = res3507for10188.ErrMsg
  4207. res3.Cainfo = res3507for10188.Cainfo
  4208. res3.WarnMsg = res3507for10188.WarnMsg
  4209. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4210. res3.Infcode = infocode
  4211. } else {
  4212. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4213. utils.ErrorLog("解析失败:%v", err)
  4214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4215. return
  4216. }
  4217. }
  4218. if res3.Infcode == 0 {
  4219. item.IsChange = 1
  4220. item.BgBchno = bg_number
  4221. service.SaveDF2(item)
  4222. } else {
  4223. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4224. }
  4225. }
  4226. } else {
  4227. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4228. }
  4229. }
  4230. } else { //还没结算
  4231. if item.IsChange == 0 { //没变更,进行变更操作
  4232. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4233. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4234. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4235. var respJSON3 map[string]interface{}
  4236. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4237. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4239. return
  4240. }
  4241. userJSONBytes3, _ := json.Marshal(respJSON3)
  4242. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4243. // utils.ErrorLog("解析失败:%v", err)
  4244. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4245. // return
  4246. //}
  4247. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4248. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4249. utils.ErrorLog("解析失败:%v", err)
  4250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4251. return
  4252. }
  4253. //if res3507for10188.Infcode
  4254. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4255. //res.Output = resSix10265.Output
  4256. res3.ErrMsg = res3507for10188.ErrMsg
  4257. res3.Cainfo = res3507for10188.Cainfo
  4258. res3.WarnMsg = res3507for10188.WarnMsg
  4259. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4260. res3.Infcode = infocode
  4261. } else {
  4262. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4263. utils.ErrorLog("解析失败:%v", err)
  4264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4265. return
  4266. }
  4267. }
  4268. if res3.Infcode == 0 {
  4269. item.IsChange = 1
  4270. item.BgBchno = bg_number
  4271. service.SaveDF2(item)
  4272. } else {
  4273. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4274. }
  4275. }
  4276. }
  4277. }
  4278. }
  4279. if len(err) == 0 {
  4280. c.ServeSuccessJSON(map[string]interface{}{
  4281. "msg": "销售变更成功",
  4282. })
  4283. } else {
  4284. c.ServeSuccessJSON(map[string]interface{}{
  4285. "failed_code": -10,
  4286. "msg": err,
  4287. })
  4288. }
  4289. }
  4290. func (c *HisApiController) ChangeDrugTen() {
  4291. //ids := c.GetString("ids")
  4292. //id_arr := strings.Split(ids, ",")
  4293. now := time.Now()
  4294. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4295. flows, _ := service.GetNewDrugFlowInforTen(timestamp)
  4296. admin_user_id, _ := c.GetInt64("admin_user_id")
  4297. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4298. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4299. var err []string
  4300. for _, item := range flows {
  4301. var res3 ResultSix
  4302. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4303. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4304. if prescription.OrderStatus == 2 {
  4305. //已经结算
  4306. //判断是否已经销售
  4307. if item.IsSale == 1 { //是否已经销售,1是 0否
  4308. //是否已经变更 1是 0否
  4309. if item.IsChange == 0 { //没变更,进行变更操作
  4310. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4311. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4312. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4313. var respJSON3 map[string]interface{}
  4314. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4315. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4317. return
  4318. }
  4319. userJSONBytes3, _ := json.Marshal(respJSON3)
  4320. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4321. utils.ErrorLog("解析失败:%v", err)
  4322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4323. return
  4324. }
  4325. if res3.Infcode == 0 {
  4326. item.IsChange = 1
  4327. item.BgBchno = bg_number
  4328. service.SaveDF2(item)
  4329. } else {
  4330. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4331. }
  4332. }
  4333. } else { //没销售,
  4334. var res FJ3507Result
  4335. var res3507for10188 FJ3507ResultFor10188
  4336. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4337. //进行商品销售接口
  4338. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4339. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4340. var respJSON3 map[string]interface{}
  4341. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4344. return
  4345. }
  4346. userJSONBytes3, _ := json.Marshal(respJSON3)
  4347. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4348. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4349. utils.ErrorLog("解析失败:%v", err)
  4350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4351. return
  4352. }
  4353. //if res3507for10188.Infcode
  4354. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4355. //res.Output = resSix10265.Output
  4356. res.ErrMsg = res3507for10188.ErrMsg
  4357. res.Cainfo = res3507for10188.Cainfo
  4358. res.WarnMsg = res3507for10188.WarnMsg
  4359. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4360. res.Infcode = infocode
  4361. } else {
  4362. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4363. utils.ErrorLog("解析失败:%v", err)
  4364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4365. return
  4366. }
  4367. }
  4368. if res.Infcode == 0 {
  4369. item.IsSale = 1
  4370. item.Bchno = number
  4371. item.SaleDate = time.Now().Format("2006-01-02")
  4372. err5 := service.SaveDF(item)
  4373. if err5 == nil {
  4374. if item.IsChange == 0 { //没变更,进行变更操作
  4375. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4376. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4377. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4378. var respJSON3 map[string]interface{}
  4379. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4382. return
  4383. }
  4384. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4385. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4386. utils.ErrorLog("解析失败:%v", err)
  4387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4388. return
  4389. }
  4390. //if res3507for10188.Infcode
  4391. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4392. //res.Output = resSix10265.Output
  4393. res3.ErrMsg = res3507for10188.ErrMsg
  4394. res3.Cainfo = res3507for10188.Cainfo
  4395. res3.WarnMsg = res3507for10188.WarnMsg
  4396. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4397. res3.Infcode = infocode
  4398. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4399. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4400. utils.ErrorLog("解析失败:%v", err)
  4401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4402. return
  4403. }
  4404. //if res3507for10188.Infcode
  4405. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4406. //res.Output = resSix10265.Output
  4407. res3.ErrMsg = res3507for10188.ErrMsg
  4408. res3.Cainfo = res3507for10188.Cainfo
  4409. res3.WarnMsg = res3507for10188.WarnMsg
  4410. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4411. res3.Infcode = infocode
  4412. } else {
  4413. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4414. utils.ErrorLog("解析失败:%v", err)
  4415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4416. return
  4417. }
  4418. }
  4419. if res3.Infcode == 0 {
  4420. item.IsChange = 1
  4421. item.BgBchno = bg_number
  4422. service.SaveDF2(item)
  4423. } else {
  4424. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4425. }
  4426. }
  4427. }
  4428. } else {
  4429. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4430. }
  4431. }
  4432. } else { //还没结算
  4433. var res3507for10188 FJ3507ResultFor10188
  4434. if item.IsChange == 0 { //没变更,进行变更操作
  4435. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4436. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4437. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4438. var respJSON3 map[string]interface{}
  4439. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4440. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4442. return
  4443. }
  4444. userJSONBytes3, _ := json.Marshal(respJSON3)
  4445. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4446. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4447. utils.ErrorLog("解析失败:%v", err)
  4448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4449. return
  4450. }
  4451. //if res3507for10188.Infcode
  4452. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4453. //res.Output = resSix10265.Output
  4454. res3.ErrMsg = res3507for10188.ErrMsg
  4455. res3.Cainfo = res3507for10188.Cainfo
  4456. res3.WarnMsg = res3507for10188.WarnMsg
  4457. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4458. res3.Infcode = infocode
  4459. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4460. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4461. utils.ErrorLog("解析失败:%v", err)
  4462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4463. return
  4464. }
  4465. //if res3507for10188.Infcode
  4466. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4467. //res.Output = resSix10265.Output
  4468. res3.ErrMsg = res3507for10188.ErrMsg
  4469. res3.Cainfo = res3507for10188.Cainfo
  4470. res3.WarnMsg = res3507for10188.WarnMsg
  4471. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4472. res3.Infcode = infocode
  4473. } else {
  4474. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4475. utils.ErrorLog("解析失败:%v", err)
  4476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4477. return
  4478. }
  4479. }
  4480. if res3.Infcode == 0 {
  4481. item.IsChange = 1
  4482. item.BgBchno = bg_number
  4483. service.SaveDF2(item)
  4484. } else {
  4485. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4486. }
  4487. }
  4488. }
  4489. } else if item.ConsumableType == 7 {
  4490. var res3507for10188 FJ3507ResultFor10188
  4491. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4492. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4493. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4494. //判断是否已经销售
  4495. if item.IsSale == 2 { //是否已经销售,1是 0否
  4496. //是否已经变更 1是 0否
  4497. if item.IsChange == 0 { //没变更,进行变更操作
  4498. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4499. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4500. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4501. var respJSON3 map[string]interface{}
  4502. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4503. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4505. return
  4506. }
  4507. userJSONBytes3, _ := json.Marshal(respJSON3)
  4508. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4509. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4510. utils.ErrorLog("解析失败:%v", err)
  4511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4512. return
  4513. }
  4514. //if res3507for10188.Infcode
  4515. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4516. //res.Output = resSix10265.Output
  4517. res3.ErrMsg = res3507for10188.ErrMsg
  4518. res3.Cainfo = res3507for10188.Cainfo
  4519. res3.WarnMsg = res3507for10188.WarnMsg
  4520. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4521. res3.Infcode = infocode
  4522. } else {
  4523. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4524. utils.ErrorLog("解析失败:%v", err)
  4525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4526. return
  4527. }
  4528. }
  4529. if res3.Infcode == 0 {
  4530. item.IsChange = 1
  4531. item.BgBchno = bg_number
  4532. service.SaveDF2(item)
  4533. } else {
  4534. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4535. }
  4536. }
  4537. } else { //没销售,
  4538. //进行商品销售退货接口
  4539. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4540. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4541. saveLog(result111, result222, "3506", "销售退货")
  4542. var res7 FJ3507Result
  4543. //进行商品销售接口
  4544. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4545. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4546. var respJSON3 map[string]interface{}
  4547. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4550. return
  4551. }
  4552. userJSONBytes3, _ := json.Marshal(respJSON3)
  4553. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4554. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4555. utils.ErrorLog("解析失败:%v", err)
  4556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4557. return
  4558. }
  4559. //if res3507for10188.Infcode
  4560. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4561. //res.Output = resSix10265.Output
  4562. res7.ErrMsg = res3507for10188.ErrMsg
  4563. res7.Cainfo = res3507for10188.Cainfo
  4564. res7.WarnMsg = res3507for10188.WarnMsg
  4565. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4566. res7.Infcode = infocode
  4567. } else {
  4568. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4569. utils.ErrorLog("解析失败:%v", err)
  4570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4571. return
  4572. }
  4573. }
  4574. if res7.Infcode == 0 {
  4575. item.IsSale = 2
  4576. item.SaleDate = item.SaleDate
  4577. item.Bchno = number
  4578. service.SaveDF(item)
  4579. if item.IsChange == 0 { //没变更,进行变更操作
  4580. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4581. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4582. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4583. var respJSON3 map[string]interface{}
  4584. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4587. return
  4588. }
  4589. userJSONBytes3, _ := json.Marshal(respJSON3)
  4590. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4591. // utils.ErrorLog("解析失败:%v", err)
  4592. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4593. // return
  4594. //}
  4595. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4596. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4597. utils.ErrorLog("解析失败:%v", err)
  4598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4599. return
  4600. }
  4601. //if res3507for10188.Infcode
  4602. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4603. //res.Output = resSix10265.Output
  4604. res3.ErrMsg = res3507for10188.ErrMsg
  4605. res3.Cainfo = res3507for10188.Cainfo
  4606. res3.WarnMsg = res3507for10188.WarnMsg
  4607. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4608. res3.Infcode = infocode
  4609. } else {
  4610. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4611. utils.ErrorLog("解析失败:%v", err)
  4612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4613. return
  4614. }
  4615. }
  4616. if res3.Infcode == 0 {
  4617. item.IsChange = 1
  4618. item.BgBchno = bg_number
  4619. service.SaveDF2(item)
  4620. } else {
  4621. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4622. }
  4623. }
  4624. } else {
  4625. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4626. }
  4627. }
  4628. } else { //还没结算
  4629. if item.IsChange == 0 { //没变更,进行变更操作
  4630. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4631. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4632. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4633. var respJSON3 map[string]interface{}
  4634. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4637. return
  4638. }
  4639. userJSONBytes3, _ := json.Marshal(respJSON3)
  4640. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4641. // utils.ErrorLog("解析失败:%v", err)
  4642. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4643. // return
  4644. //}
  4645. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4646. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4647. utils.ErrorLog("解析失败:%v", err)
  4648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4649. return
  4650. }
  4651. //if res3507for10188.Infcode
  4652. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4653. //res.Output = resSix10265.Output
  4654. res3.ErrMsg = res3507for10188.ErrMsg
  4655. res3.Cainfo = res3507for10188.Cainfo
  4656. res3.WarnMsg = res3507for10188.WarnMsg
  4657. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4658. res3.Infcode = infocode
  4659. } else {
  4660. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4661. utils.ErrorLog("解析失败:%v", err)
  4662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4663. return
  4664. }
  4665. }
  4666. if res3.Infcode == 0 {
  4667. item.IsChange = 1
  4668. item.BgBchno = bg_number
  4669. service.SaveDF2(item)
  4670. } else {
  4671. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4672. }
  4673. }
  4674. }
  4675. }
  4676. }
  4677. if len(err) == 0 {
  4678. c.ServeSuccessJSON(map[string]interface{}{
  4679. "msg": "销售变更成功",
  4680. })
  4681. } else {
  4682. c.ServeSuccessJSON(map[string]interface{}{
  4683. "failed_code": -10,
  4684. "msg": err,
  4685. })
  4686. }
  4687. }
  4688. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4689. var struct3502 models.Struct3502
  4690. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4691. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4692. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4693. struct3502.FixmedinsCode = miConfig.Code
  4694. struct3502.Code = miConfig.Code
  4695. struct3502.Opter = role.UserName
  4696. struct3502.RxFlag = "0"
  4697. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4698. struct3502.OrgName = miConfig.OrgName
  4699. struct3502.AccessKey = miConfig.AccessKey
  4700. struct3502.RequestUrl = miConfig.Url
  4701. struct3502.SecretKey = miConfig.SecretKey
  4702. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4703. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4704. struct3502.Url = miConfig.Url
  4705. struct3502.AppId = miConfig.Cainfo
  4706. struct3502.AppSecret = miConfig.AppSecret
  4707. struct3502.Enckey = miConfig.EncKey
  4708. struct3502.SignKey = miConfig.SignKey
  4709. struct3502.SecretKey = miConfig.SecretKey
  4710. struct3502.InvChgType = chgType
  4711. struct3502.FixmedinsBchno = number
  4712. struct3502.Cnt = strconv.FormatInt(count, 10)
  4713. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4714. //result1, result2, _ := service.FJyb3502(struct3502)
  4715. if miConfig.MdtrtareaAdmvs == "350500" {
  4716. result1, result2, _ := service.FJyb3502(struct3502)
  4717. //saveLog(result1, result2, "3502", "3502")
  4718. return result1, result2
  4719. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4720. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4721. return result1, result2
  4722. } else {
  4723. data := make(map[string]interface{})
  4724. data["struct_3502s"] = struct3502
  4725. client := &http.Client{}
  4726. bytesData, _ := json.Marshal(data)
  4727. var req *http.Request
  4728. if miConfig.MdtrtareaAdmvs == "320921" {
  4729. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4730. } else {
  4731. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4732. }
  4733. resp, _ := client.Do(req)
  4734. defer resp.Body.Close()
  4735. body, ioErr := ioutil.ReadAll(resp.Body)
  4736. if ioErr != nil {
  4737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4738. }
  4739. var respJSON map[string]interface{}
  4740. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4742. }
  4743. //var resSix10265 ResultSix10265 //1101结果
  4744. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4745. result, _ := json.Marshal(respJSON)
  4746. return string(result), ""
  4747. }
  4748. }
  4749. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4750. var struct3505 models.Struct3505
  4751. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4752. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4753. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4754. struct3505.FixmedinsBchno = number
  4755. struct3505.Opter = role.UserName
  4756. struct3505.FixmedinsCode = miConfig.Code
  4757. struct3505.Code = miConfig.Code
  4758. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  4759. struct3505.PrscDrName = roles.UserName
  4760. if org_id == 10191 {
  4761. struct3505.PharName = "刘水山"
  4762. struct3505.PharPracCertNo = "2015026350260000002611351127"
  4763. }
  4764. if org_id == 10188 {
  4765. struct3505.PharName = "李汉清"
  4766. struct3505.PharPracCertNo = "30220200932022010034"
  4767. }
  4768. if org_id == 10217 {
  4769. struct3505.PharName = "张敏"
  4770. struct3505.PharPracCertNo = "30220230432090100108"
  4771. }
  4772. if org_id == 10318 {
  4773. struct3505.PharName = "邹刘阳"
  4774. struct3505.PharPracCertNo = "210441200001378"
  4775. }
  4776. order := service.GetHisOrderByNumber(pre.BatchNumber)
  4777. struct3505.SetlId = order.SetlId
  4778. struct3505.MdtrtSn = order.MdtrtId
  4779. struct3505.ManuLotnum = drug.Number
  4780. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  4781. struct3505.ExpyEnd = ""
  4782. struct3505.RxFlag = "0"
  4783. struct3505.TrdnFlag = "1"
  4784. struct3505.RtalDocno = order.Number
  4785. struct3505.Url = miConfig.Url
  4786. struct3505.AppId = miConfig.Cainfo
  4787. struct3505.AppSecret = miConfig.AppSecret
  4788. struct3505.Enckey = miConfig.EncKey
  4789. struct3505.SignKey = miConfig.SignKey
  4790. struct3505.SecretKey = miConfig.SecretKey
  4791. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  4792. struct3505.SelRetnCnt = strValue
  4793. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4794. struct3505.SelRetnOpterName = role.UserName
  4795. if order.IsMedicineInsurance == 1 {
  4796. struct3505.MdtrtSetlType = "1"
  4797. } else {
  4798. struct3505.MdtrtSetlType = "2"
  4799. }
  4800. struct3505.OrgName = miConfig.OrgName
  4801. struct3505.AccessKey = miConfig.AccessKey
  4802. struct3505.RequestUrl = miConfig.Url
  4803. struct3505.SecretKey = miConfig.SecretKey
  4804. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4805. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4806. struct3505.DrugTracCodg = drug.DrugCode
  4807. if miConfig.MdtrtareaAdmvs == "350500" {
  4808. result1, result2, _ := service.FJyb3505(struct3505)
  4809. return result1, result2
  4810. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4811. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  4812. return result1, result2
  4813. } else {
  4814. data := make(map[string]interface{})
  4815. data["struct_3505s"] = struct3505
  4816. client := &http.Client{}
  4817. bytesData, _ := json.Marshal(data)
  4818. var req *http.Request
  4819. if miConfig.MdtrtareaAdmvs == "320921" {
  4820. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  4821. } else {
  4822. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  4823. }
  4824. resp, _ := client.Do(req)
  4825. defer resp.Body.Close()
  4826. body, ioErr := ioutil.ReadAll(resp.Body)
  4827. if ioErr != nil {
  4828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4829. }
  4830. var respJSON map[string]interface{}
  4831. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4833. }
  4834. //var resSix10265 ResultSix10265 //1101结果
  4835. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4836. result, _ := json.Marshal(respJSON)
  4837. return string(result), ""
  4838. }
  4839. }
  4840. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4841. var struct3506 models.Struct3506
  4842. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4843. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4844. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4845. struct3506.FixmedinsCode = miConfig.Code
  4846. struct3506.Code = miConfig.Code
  4847. struct3506.FixmedinsBchno = number
  4848. struct3506.Opter = role.UserName
  4849. order := service.GetHisOrderByNumber(pre.BatchNumber)
  4850. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  4851. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  4852. struct3506.MdtrtSn = order.MdtrtId
  4853. struct3506.ExpyEnd = ""
  4854. struct3506.RxFlag = "0"
  4855. struct3506.TrdnFlag = "1"
  4856. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  4857. struct3506.SelRetnCnt = strValue
  4858. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4859. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  4860. struct3506.SelRetnOpterName = role.UserName
  4861. struct3506.OrgName = miConfig.OrgName
  4862. struct3506.AccessKey = miConfig.AccessKey
  4863. struct3506.RequestUrl = miConfig.Url
  4864. struct3506.SecretKey = miConfig.SecretKey
  4865. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4866. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4867. struct3506.Url = miConfig.Url
  4868. struct3506.AppId = miConfig.Cainfo
  4869. struct3506.AppSecret = miConfig.AppSecret
  4870. struct3506.Enckey = miConfig.EncKey
  4871. struct3506.SignKey = miConfig.SignKey
  4872. struct3506.SecretKey = miConfig.SecretKey
  4873. struct3506.DrugTracCodg = drug.DrugCode
  4874. if miConfig.MdtrtareaAdmvs == "350500" {
  4875. result1, result2, _ := service.FJyb3506(struct3506)
  4876. return result1, result2
  4877. } else {
  4878. data := make(map[string]interface{})
  4879. data["struct_3506s"] = struct3506
  4880. client := &http.Client{}
  4881. bytesData, _ := json.Marshal(data)
  4882. var req *http.Request
  4883. if miConfig.MdtrtareaAdmvs == "320921" {
  4884. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  4885. } else {
  4886. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  4887. }
  4888. resp, _ := client.Do(req)
  4889. defer resp.Body.Close()
  4890. body, ioErr := ioutil.ReadAll(resp.Body)
  4891. if ioErr != nil {
  4892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4893. }
  4894. var respJSON map[string]interface{}
  4895. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4897. }
  4898. //var resSix10265 ResultSix10265 //1101结果
  4899. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4900. result, _ := json.Marshal(respJSON)
  4901. return string(result), ""
  4902. }
  4903. }
  4904. func (c *HisApiController) Get1318() {
  4905. adminUser := c.GetAdminUserInfo()
  4906. admin_user_id, _ := c.GetInt64("admin_user_id")
  4907. code := c.GetString("code")
  4908. code = ""
  4909. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4910. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4911. api := ""
  4912. if miConfig.MdtrtareaAdmvs == "320921" {
  4913. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  4914. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  4915. } else {
  4916. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  4917. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  4918. }
  4919. resp, requestErr := http.Get(api)
  4920. if requestErr != nil {
  4921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4922. return
  4923. }
  4924. body, ioErr := ioutil.ReadAll(resp.Body)
  4925. if ioErr != nil {
  4926. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4928. return
  4929. }
  4930. var respJSON map[string]interface{}
  4931. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4934. return
  4935. }
  4936. //var res Result2406
  4937. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4938. result, _ := json.Marshal(respJSON)
  4939. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4940. utils.ErrorLog("解析失败:%v", err)
  4941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4942. return
  4943. }
  4944. if res.Infcode == "0" {
  4945. c.ServeSuccessJSON(map[string]interface{}{
  4946. "result": "",
  4947. })
  4948. } else {
  4949. c.ServeSuccessJSON(map[string]interface{}{
  4950. "failed_code": -10,
  4951. "msg": res.ErrMsg,
  4952. })
  4953. */return
  4954. //}
  4955. }
  4956. func (c *HisApiController) Get2503() {
  4957. adminUser := c.GetAdminUserInfo()
  4958. admin_user_id, _ := c.GetInt64("admin_user_id")
  4959. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4960. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4961. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  4962. }
  4963. func (c *HisApiController) Get2406() {
  4964. id, _ := c.GetInt64("id")
  4965. record_time := c.GetString("record_time")
  4966. his_patient_id, _ := c.GetInt64("his_patient_id")
  4967. admin_user_id, _ := c.GetInt64("admin_user_id")
  4968. diagnosis_id := c.GetString("diagnosis")
  4969. timeLayout := "2006-01-02"
  4970. loc, _ := time.LoadLocation("Local")
  4971. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4972. if err != nil {
  4973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4974. return
  4975. }
  4976. recordDateTime := theTime.Unix()
  4977. adminUser := c.GetAdminUserInfo()
  4978. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4979. var config []*models.HisXtDiagnoseConfig
  4980. for _, item := range diagnosis_ids {
  4981. id, _ := strconv.ParseInt(item, 10, 64)
  4982. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4983. config = append(config, &diagnosisConfig)
  4984. }
  4985. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4986. fmt.Println(his_patient_id)
  4987. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4988. //timestamp := time.Now().Unix()
  4989. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4990. var patientPrescription models.HisPrescriptionInfo
  4991. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4992. if patientPrescription.ID == 0 {
  4993. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4994. }
  4995. var res2 Result2406
  4996. if miConfig.MdtrtareaAdmvs == "341203" {
  4997. data := make(map[string]interface{})
  4998. client := &http.Client{}
  4999. data["psn_no"] = his.PsnNo
  5000. data["mdtrt_id"] = his.Number
  5001. data["operator"] = roles.UserName
  5002. data["cert_no"] = his.IdCardNo
  5003. data["org_name"] = miConfig.OrgName
  5004. data["psn_name"] = his.Name
  5005. data["ipt_otp_no"] = his.IptOtpNo
  5006. data["ipt_psn_sp_flag_type"] = "0901"
  5007. data["ipt_psn_sp_flag"] = "1"
  5008. data["fixmedins_code"] = miConfig.Code
  5009. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5010. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5011. data["url"] = miConfig.Url
  5012. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5013. bytesData, _ := json.Marshal(data)
  5014. var req *http.Request
  5015. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5016. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5017. resp, _ := client.Do(req)
  5018. defer resp.Body.Close()
  5019. body, ioErr := ioutil.ReadAll(resp.Body)
  5020. if ioErr != nil {
  5021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5023. return
  5024. }
  5025. var respJSON map[string]interface{}
  5026. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5029. return
  5030. }
  5031. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5032. if status == "0" {
  5033. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5034. c.ServeSuccessJSON(map[string]interface{}{
  5035. "failed_code": -10,
  5036. "msg": err_msg,
  5037. })
  5038. return
  5039. }
  5040. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5041. userJSONBytes, _ := json.Marshal(respJSON)
  5042. fmt.Println("log")
  5043. fmt.Println(string(userJSONBytes))
  5044. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5045. utils.ErrorLog("解析失败:%v", err)
  5046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5047. return
  5048. }
  5049. }
  5050. if res2.Infcode != 0 {
  5051. adminUser := c.GetAdminUserInfo()
  5052. errlog := &models.HisOrderError{
  5053. UserOrgId: adminUser.CurrentOrgId,
  5054. Ctime: time.Now().Unix(),
  5055. Mtime: time.Now().Unix(),
  5056. ErrMsg: res2.ErrMsg,
  5057. Status: 1,
  5058. PatientId: id,
  5059. RecordTime: recordDateTime,
  5060. Stage: 3,
  5061. }
  5062. service.CreateErrMsgLog(errlog)
  5063. c.ServeSuccessJSON(map[string]interface{}{
  5064. "failed_code": -10,
  5065. "msg": res2.ErrMsg,
  5066. })
  5067. return
  5068. } else {
  5069. c.ServeSuccessJSON(map[string]interface{}{
  5070. "msg": "上传成功",
  5071. })
  5072. return
  5073. }
  5074. }
  5075. func (c *HisApiController) Get4105() {
  5076. }
  5077. func (c *HisApiController) Post5302() {
  5078. patient_id, _ := c.GetInt64("id")
  5079. admin_user_id, _ := c.GetInt64("admin_user_id")
  5080. p, _ := service.GetHisPatientById(patient_id)
  5081. adminUser := c.GetAdminUserInfo()
  5082. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5083. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5084. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5085. }
  5086. func (c *HisApiController) Get4104() {
  5087. }
  5088. type Output struct {
  5089. CertNo string `json:"certno"`
  5090. PsnName string `json:"psn_name"`
  5091. CardNo string `json:"card_no"`
  5092. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5093. CardSN string `json:"card_sn"`
  5094. PsnCertType string `json:"psn_cert_type"`
  5095. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5096. MdtrtCertType string `json:"mdtrt_cert_type"`
  5097. QRCode string `json:"qrCode"`
  5098. EcToken string `json:"ecToken"`
  5099. }
  5100. type AHResponse struct {
  5101. Body AHBody `json:"body"`
  5102. Code int `json:"code"`
  5103. CSBCode int `json:"csbCode"`
  5104. Message string `json:"message"`
  5105. RequestID string `json:"requestId"`
  5106. State struct{} `json:"state"`
  5107. }
  5108. type AHBody struct {
  5109. ErrMsg string `json:"err_msg"`
  5110. InfRefMsgID string `json:"inf_refmsgid"`
  5111. InfCode int `json:"infcode"`
  5112. Output struct {
  5113. Result []struct {
  5114. BasMednFlag string `json:"bas_medn_flag"`
  5115. ChldMedcFlag string `json:"chld_medc_flag"`
  5116. ChrgitmLv string `json:"chrgitm_lv"`
  5117. Cnt float64 `json:"cnt"`
  5118. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5119. DrtReimFlag string `json:"drt_reim_flag"`
  5120. FeedetlSn string `json:"feedetl_sn"`
  5121. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5122. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5123. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5124. ListSpItemFlag string `json:"list_sp_item_flag"`
  5125. LmtUsedFlag string `json:"lmt_used_flag"`
  5126. MedChrgitmType string `json:"med_chrgitm_type"`
  5127. Memo string `json:"memo"`
  5128. OverlmtAmt float64 `json:"overlmt_amt"`
  5129. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5130. Pric float64 `json:"pric"`
  5131. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5132. SelfpayProp float64 `json:"selfpay_prop"`
  5133. } `json:"result"`
  5134. } `json:"output"`
  5135. }
  5136. type Response struct {
  5137. Output Output `json:"output"`
  5138. Infcode int `json:"infcode"`
  5139. InfRefMsgID string `json:"inf_refmsgid"`
  5140. RefMsgTime string `json:"refmsg_time"`
  5141. RespondTime string `json:"respond_time"`
  5142. ErrMsg string `json:"err_msg"`
  5143. WarnMsg string `json:"warn_msg"`
  5144. SignType string `json:"signtype"`
  5145. CAInfo string `json:"cainfo"`
  5146. }
  5147. func (c *HisApiController) Getquerydata() {
  5148. query_type, _ := c.GetInt64("type")
  5149. refd_setl_flag := c.GetString("refd_setl_flag")
  5150. med_type := c.GetString("med_type")
  5151. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5152. cert_no := c.GetString("cert_no")
  5153. psn_no := c.GetString("psn_no")
  5154. start_time := c.GetString("start_time")
  5155. end_time := c.GetString("end_time")
  5156. page, _ := c.GetInt64("page")
  5157. limit, _ := c.GetInt64("limit")
  5158. var bp models.BusinessParams5262
  5159. bp.RefdSetlFlag = refd_setl_flag
  5160. bp.MedType = med_type
  5161. bp.Certno = cert_no
  5162. bp.Psnno = psn_no
  5163. bp.QBegntime = start_time
  5164. bp.QEndtime = end_time
  5165. if query_type == 1 { //本地
  5166. Post5262(c, bp, page, limit)
  5167. } else { //异地
  5168. Post5267(c, bp, page, limit)
  5169. }
  5170. }
  5171. func (c *HisApiController) Drugscheck() {
  5172. admin_user_id, _ := c.GetInt64("admin_user_id")
  5173. adminUser := c.GetAdminUserInfo()
  5174. var queryResult []QueryResult
  5175. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5176. for _, item := range drugs {
  5177. result := QueryResult{
  5178. ID: item.ID,
  5179. Name: item.DrugName,
  5180. Code: item.MedicalInsuranceNumber,
  5181. List_type_code: "101",
  5182. }
  5183. queryResult = append(queryResult, result)
  5184. }
  5185. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5186. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5187. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5188. for _, item := range queryResult {
  5189. 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)
  5190. }
  5191. }
  5192. func (c *HisApiController) Goodcheck() {
  5193. admin_user_id, _ := c.GetInt64("admin_user_id")
  5194. adminUser := c.GetAdminUserInfo()
  5195. var queryResult []QueryResult
  5196. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5197. for _, item := range goods {
  5198. result := QueryResult{
  5199. ID: item.ID,
  5200. Name: item.GoodName,
  5201. Code: item.SocialSecurityDirectoryCode,
  5202. List_type_code: "301",
  5203. }
  5204. queryResult = append(queryResult, result)
  5205. }
  5206. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5207. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5208. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5209. for _, item := range queryResult {
  5210. 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)
  5211. //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)
  5212. }
  5213. }
  5214. func (c *HisApiController) Projectcheck() {
  5215. admin_user_id, _ := c.GetInt64("admin_user_id")
  5216. adminUser := c.GetAdminUserInfo()
  5217. var queryResult []QueryResult
  5218. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5219. for _, item := range projects {
  5220. result := QueryResult{
  5221. ID: item.ID,
  5222. Name: item.ProjectName,
  5223. Code: item.MedicalCode,
  5224. List_type_code: "201",
  5225. }
  5226. queryResult = append(queryResult, result)
  5227. }
  5228. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5229. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5230. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5231. for _, item := range queryResult {
  5232. 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)
  5233. }
  5234. }
  5235. //func (c *HisApiController)CancleDia(){
  5236. //
  5237. // id, _ := c.GetInt64("id")
  5238. // record_time := c.GetString("record_time")
  5239. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5240. //
  5241. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5242. //
  5243. // diagnosis_id := c.GetString("diagnosis")
  5244. // sick_type, _ := c.GetInt64("sick_type")
  5245. // reg_type, _ := c.GetInt64("p_type")
  5246. // begin_time := c.GetString("begin_time")
  5247. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5248. //
  5249. //
  5250. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5251. //
  5252. // fmt.Println(acct_used_flag)
  5253. //
  5254. //
  5255. // timeLayout := "2006-01-02"
  5256. // loc, _ := time.LoadLocation("Local")
  5257. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5258. // if err != nil {
  5259. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5260. // return
  5261. // }
  5262. // recordDateTime := theTime.Unix()
  5263. // adminUser := c.GetAdminUserInfo()
  5264. //
  5265. //
  5266. //
  5267. //
  5268. //
  5269. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5270. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5271. // var patientPrescription models.HisPrescriptionInfo
  5272. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5273. // if patientPrescription.ID == 0 {
  5274. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5275. // }
  5276. // //if patientPrescription.Do
  5277. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5278. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5279. //
  5280. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5281. //
  5282. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5283. //
  5284. // var config []*models.HisXtDiagnoseConfig
  5285. // for _, item := range diagnosis_ids {
  5286. // id, _ := strconv.ParseInt(item, 10, 64)
  5287. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5288. // config = append(config, &diagnosisConfig)
  5289. // }
  5290. //
  5291. // sickConfig, _ := service.FindSickById(sick_type)
  5292. //
  5293. //
  5294. // data := make(map[string]interface{})
  5295. // client := &http.Client{}
  5296. // data["psn_no"] = his.PsnNo
  5297. // data["mdtrt_id"] = his.Number
  5298. // data["doctor"] = roles.UserName
  5299. // data["department"] = department.Name
  5300. // data["org_name"] = miConfig.OrgName
  5301. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5302. // data["doctor_id"] = doctor_info.DoctorNumber
  5303. // data["new_doctor_name"] = doctor_info.UserName
  5304. // data["fixmedins_code"] = miConfig.Code
  5305. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5306. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5307. // data["secret_key"] = miConfig.SecretKey
  5308. // data["sick_code"] = sickConfig.CountryCode
  5309. // data["sick_name"] = sickConfig.ClassName
  5310. // data["url"] = miConfig.Url
  5311. // data["ak"] = miConfig.AccessKey
  5312. // data["begin_time"] = begin_time
  5313. // data["cainfo"] = miConfig.Cainfo
  5314. // data["is_vaild"] = "0"
  5315. //
  5316. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5317. // data["config"] = config
  5318. // bytesData, _ := json.Marshal(data)
  5319. //
  5320. // var req *http.Request
  5321. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5322. // resp, _ := client.Do(req)
  5323. // defer resp.Body.Close()
  5324. // body, ioErr := ioutil.ReadAll(resp.Body)
  5325. // if ioErr != nil {
  5326. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5327. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5328. // return
  5329. // }
  5330. // var respJSON map[string]interface{}
  5331. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5332. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5333. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5334. // return
  5335. // }
  5336. //
  5337. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5338. // userJSONBytes, _ := json.Marshal(respJSON)
  5339. // fmt.Println("log")
  5340. // fmt.Println(string(userJSONBytes))
  5341. //
  5342. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5343. // utils.ErrorLog("解析失败:%v", err)
  5344. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5345. // return
  5346. // }
  5347. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5348. // res2.Output = ressix10265.Output
  5349. // res2.ErrMsg = ressix10265.ErrMsg
  5350. // res2.Cainfo = ressix10265.Cainfo
  5351. // res2.WarnMsg = ressix10265.WarnMsg
  5352. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5353. // res2.Infcode = infocode
  5354. //
  5355. //}
  5356. func (c *HisApiController) Get4102() {
  5357. order_id, _ := c.GetInt64("order_id")
  5358. admin_user_id, _ := c.GetInt64("admin_user_id")
  5359. stas_type := c.GetString("stas_type")
  5360. order, _ := service.GetHisOrderByIDTwo(order_id)
  5361. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5362. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5363. var pp models.PublicParams
  5364. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5365. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5366. pp.FixmedinsName = miConfig.OrgName
  5367. pp.FixmedinsCode = miConfig.Code
  5368. pp.RequestUrl = miConfig.Url
  5369. pp.Cainfo = miConfig.Cainfo
  5370. pp.SecretKey = miConfig.SecretKey
  5371. pp.AccessKey = miConfig.AccessKey
  5372. pp.OpterName = curRoles.UserName
  5373. if miConfig.MdtrtareaAdmvs == "350500" {
  5374. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5375. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5376. saveLog(result, request, "4102", "清单确认")
  5377. var dat map[string]interface{}
  5378. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5379. fmt.Println(dat)
  5380. } else {
  5381. fmt.Println(err)
  5382. }
  5383. var empty ResultFourteen
  5384. userJSONBytes, _ := json.Marshal(dat)
  5385. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5386. utils.ErrorLog("解析失败:%v", err)
  5387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5388. return
  5389. }
  5390. if empty.Infcode == 0 {
  5391. c.ServeSuccessJSON(map[string]interface{}{
  5392. "msg": "确认成功",
  5393. })
  5394. return
  5395. }
  5396. } else {
  5397. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5398. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5399. result3, request3 := service.Jxyb4105(pp)
  5400. saveLog(result, request, "4102", "清单确认")
  5401. saveLog(result2, request2, "4103", "清单确认")
  5402. saveLog(result3, request3, "4105", "清单统计")
  5403. var dat map[string]interface{}
  5404. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5405. fmt.Println(dat)
  5406. } else {
  5407. fmt.Println(err)
  5408. }
  5409. var empty ResultFourteen
  5410. userJSONBytes, _ := json.Marshal(dat)
  5411. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5412. utils.ErrorLog("解析失败:%v", err)
  5413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5414. return
  5415. }
  5416. if empty.Infcode == 0 {
  5417. c.ServeSuccessJSON(map[string]interface{}{
  5418. "msg": "确认成功",
  5419. })
  5420. return
  5421. }
  5422. }
  5423. }
  5424. // 对账权限查询
  5425. func (c *HisApiController) Get3260() {
  5426. admin_user_id, _ := c.GetInt64("admin_user_id")
  5427. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5428. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5429. var api string
  5430. var res models.JSResult3260
  5431. if miConfig.MdtrtareaAdmvs == "320921" {
  5432. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5433. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5434. } else {
  5435. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5436. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5437. }
  5438. resp, requestErr := http.Get(api)
  5439. if requestErr != nil {
  5440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5441. return
  5442. }
  5443. body, ioErr := ioutil.ReadAll(resp.Body)
  5444. if ioErr != nil {
  5445. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5447. return
  5448. }
  5449. var respJSON map[string]interface{}
  5450. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5451. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5453. return
  5454. }
  5455. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5456. result, _ := json.Marshal(respJSON)
  5457. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5458. utils.ErrorLog("解析失败:%v", err)
  5459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5460. return
  5461. }
  5462. if res.Infcode == "0" {
  5463. c.ServeSuccessJSON(map[string]interface{}{
  5464. "result": res.Output.Data,
  5465. })
  5466. } else {
  5467. c.ServeSuccessJSON(map[string]interface{}{
  5468. "failed_code": -10,
  5469. "msg": res.ErrMsg,
  5470. })
  5471. return
  5472. }
  5473. }
  5474. func (c *HisApiController) Get3261() {
  5475. admin_user_id, _ := c.GetInt64("admin_user_id")
  5476. //month := c.GetString("month")
  5477. startTime := c.GetString("start_time")
  5478. //endTime, _ := c.GetString("end_time")
  5479. times := strings.Split(startTime, "-")
  5480. stmt_mon := times[0] + times[1]
  5481. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5482. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5483. var api string
  5484. var res models.JSResult3261
  5485. //var res10265 Result5301For10265
  5486. if miConfig.MdtrtareaAdmvs == "320921" {
  5487. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5488. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5489. } else {
  5490. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5491. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5492. }
  5493. resp, requestErr := http.Get(api)
  5494. if requestErr != nil {
  5495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5496. return
  5497. }
  5498. body, ioErr := ioutil.ReadAll(resp.Body)
  5499. if ioErr != nil {
  5500. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5502. return
  5503. }
  5504. var respJSON map[string]interface{}
  5505. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5508. return
  5509. }
  5510. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5511. result, _ := json.Marshal(respJSON)
  5512. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5513. utils.ErrorLog("解析失败:%v", err)
  5514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5515. return
  5516. }
  5517. if res.Infcode == "0" {
  5518. c.ServeSuccessJSON(map[string]interface{}{
  5519. "result": res.Output,
  5520. })
  5521. } else {
  5522. c.ServeSuccessJSON(map[string]interface{}{
  5523. "failed_code": -10,
  5524. "msg": res.ErrMsg,
  5525. })
  5526. return
  5527. }
  5528. }
  5529. type TempFun struct {
  5530. FundKey string
  5531. FundCode string
  5532. }
  5533. func (c *HisApiController) Get3262() {
  5534. admin_user_id, _ := c.GetInt64("admin_user_id")
  5535. startTime := c.GetString("start_time")
  5536. endTime := c.GetString("end_time")
  5537. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5538. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5539. //timeLayout := "2006-01-02"
  5540. //loc, _ := time.LoadLocation("Local")
  5541. //var theStartTIme int64
  5542. //if len(startTime) > 0 {
  5543. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  5544. // if err != nil {
  5545. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5546. // return
  5547. // }
  5548. // theStartTIme = theTime.Unix()
  5549. //}
  5550. //var theEndtTIme int64
  5551. //if len(endTime) > 0 {
  5552. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  5553. // if err != nil {
  5554. // utils.ErrorLog(err.Error())
  5555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5556. // return
  5557. // }
  5558. // theEndtTIme = theTime.Unix()
  5559. //}
  5560. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5561. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5562. for _, team := range datas {
  5563. fmt.Println(team.PsnTime)
  5564. for _, team_two := range datas_two {
  5565. fmt.Println(team_two.PsnTime)
  5566. if team.FundKey == team_two.FundKey {
  5567. fmt.Println(team_two.PsnTime)
  5568. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  5569. fmt.Println(team.PsnTime)
  5570. }
  5571. }
  5572. }
  5573. fmt.Println("1111")
  5574. fmt.Println(datas)
  5575. fmt.Println("1111")
  5576. var twos []models.FixMonRecDetailFileInTwo
  5577. for _, team := range datas {
  5578. var two models.FixMonRecDetailFileInTwo
  5579. two.MedType = team.MedType
  5580. two.Insutype = team.Insutype
  5581. two.PsnType = team.PsnType
  5582. two.MedType = team.MedType
  5583. two.FixBlngAdmdvs = "999999"
  5584. two.InsuAdmdvs = "555555"
  5585. two.PsnTime = team.PsnTime
  5586. two.PsnCnt = team.PsnCnt
  5587. two.FundKey = team.FundKey
  5588. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  5589. fps, _ := strconv.ParseFloat(team.Fund, 64)
  5590. ia, _ := strconv.ParseFloat(team.Amt, 64)
  5591. two.MedfeeSumAmt = ms
  5592. two.InscpAmt = ia
  5593. two.FundPaySumAmt = fps
  5594. twos = append(twos, two)
  5595. }
  5596. //startTime := c.GetString("start_time")
  5597. //endTime, _ := c.GetString("end_time")
  5598. times := strings.Split(startTime, "-")
  5599. stmt_mon := times[0] + times[1]
  5600. var funs []models.FundDetail
  5601. for _, item := range datas {
  5602. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  5603. funs = append(funs, fun...)
  5604. }
  5605. var funInfos []models.Fund
  5606. //for _, item := range funs {
  5607. // var rf []models.FundInfo
  5608. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  5609. // for _, subitem := range rf {
  5610. // var fund models.Fund
  5611. // fund.FundCode = subitem.FundPayType
  5612. // fund.FundName = subitem.FundPayTypeName
  5613. // fund.FundAmt = subitem.FundPayAmt
  5614. // fund.FundKey = item.FundKey
  5615. // fund.InsuAdmdvs = "555555"
  5616. // fund.FixBlngAdmdvs = "999999"
  5617. // funInfos = append(funInfos, fund)
  5618. // }
  5619. //}
  5620. var tempFuns []TempFun
  5621. for _, funInfo := range funInfos {
  5622. var tempFun TempFun
  5623. tempFun.FundKey = funInfo.FundKey
  5624. tempFun.FundCode = funInfo.FundCode
  5625. tempFuns = append(tempFuns, tempFun)
  5626. }
  5627. tempFuns = RemoveRepeatedFunElement(tempFuns)
  5628. fmt.Println(tempFuns)
  5629. var funInfosTwo []models.Fund
  5630. decimal.DivisionPrecision = 2
  5631. for _, item := range tempFuns {
  5632. var fund models.Fund
  5633. for _, subItem := range funInfos {
  5634. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  5635. fund.FundKey = subItem.FundKey
  5636. fund.InsuAdmdvs = subItem.InsuAdmdvs
  5637. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  5638. fund.FundName = subItem.FundName
  5639. fund.FundCode = subItem.FundCode
  5640. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  5641. }
  5642. }
  5643. funInfosTwo = append(funInfosTwo, fund)
  5644. }
  5645. fmt.Println("funInfosTwo")
  5646. fmt.Println(funInfosTwo)
  5647. var upld_btch string
  5648. var empty models.JSResultEmpty
  5649. data := make(map[string]interface{})
  5650. data["org_name"] = miConfig.OrgName
  5651. data["doctor"] = curRoles.UserName
  5652. data["doctor_name"] = curRoles.UserName
  5653. data["fixmedins_code"] = miConfig.Code
  5654. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5655. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5656. data["secret_key"] = miConfig.SecretKey
  5657. data["url"] = miConfig.Url
  5658. data["ak"] = miConfig.AccessKey
  5659. data["cainfo"] = miConfig.Cainfo
  5660. data["datas"] = twos
  5661. data["fund"] = funInfosTwo
  5662. fmt.Println(twos)
  5663. month := time.Unix(1557042972, 0).Format("1")
  5664. year := time.Now().Format("2006")
  5665. month = time.Now().Format("01")
  5666. day := time.Now().Format("02")
  5667. hour := time.Now().Format("15")
  5668. min := time.Now().Format("04")
  5669. sec := time.Now().Format("05")
  5670. fix_fill_date := year + month + day + hour + min + sec
  5671. data["fix_fill_dept"] = miConfig.OrgName
  5672. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  5673. data["fix_fill_psn"] = curRoles.UserName
  5674. data["fix_fill_date"] = fix_fill_date
  5675. data["stmt_loc"] = "2"
  5676. data["setl_mon"] = stmt_mon
  5677. upld_btch = "0"
  5678. data["upld_btch"] = upld_btch
  5679. //fmt.Println(data)
  5680. client := &http.Client{}
  5681. bytesData, _ := json.Marshal(data)
  5682. var req *http.Request
  5683. if miConfig.MdtrtareaAdmvs == "320921" {
  5684. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  5685. } else {
  5686. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  5687. }
  5688. resp, _ := client.Do(req)
  5689. defer resp.Body.Close()
  5690. body, ioErr := ioutil.ReadAll(resp.Body)
  5691. if ioErr != nil {
  5692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5694. }
  5695. var respJSON map[string]interface{}
  5696. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5699. }
  5700. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5701. //fmt.Println(respJSON)
  5702. result, _ := json.Marshal(respJSON)
  5703. //fmt.Println(result)
  5704. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  5705. utils.ErrorLog("解析失败:%v", err)
  5706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5707. }
  5708. if empty.Infcode != "0" {
  5709. c.ServeSuccessJSON(map[string]interface{}{
  5710. "failed_code": -10,
  5711. "msg": empty.ErrMsg,
  5712. })
  5713. return
  5714. } else {
  5715. c.ServeSuccessJSON(map[string]interface{}{
  5716. "msg": "上传成功",
  5717. })
  5718. return
  5719. }
  5720. }
  5721. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  5722. newArr = make([]TempFun, 0)
  5723. for i := 0; i < len(arr); i++ {
  5724. repeat := false
  5725. for j := i + 1; j < len(arr); j++ {
  5726. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  5727. repeat = true
  5728. break
  5729. }
  5730. }
  5731. if !repeat {
  5732. newArr = append(newArr, arr[i])
  5733. }
  5734. }
  5735. return
  5736. }
  5737. func (c *HisApiController) Get3263() {
  5738. admin_user_id, _ := c.GetInt64("admin_user_id")
  5739. startTime := c.GetString("start_time")
  5740. //endTime, _ := c.GetString("end_time")
  5741. times := strings.Split(startTime, "-")
  5742. setl_mon := times[0] + times[1]
  5743. upld_btch := "0"
  5744. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5745. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5746. var result3263 models.JSResult3263
  5747. data := make(map[string]interface{})
  5748. data["org_name"] = miConfig.OrgName
  5749. data["doctor"] = curRoles.UserName
  5750. data["doctor_name"] = curRoles.UserName
  5751. data["fixmedins_code"] = miConfig.Code
  5752. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5753. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5754. data["secret_key"] = miConfig.SecretKey
  5755. data["url"] = miConfig.Url
  5756. data["ak"] = miConfig.AccessKey
  5757. data["cainfo"] = miConfig.Cainfo
  5758. data["setl_mon"] = setl_mon
  5759. data["stmt_loc"] = "2"
  5760. data["upld_btch"] = upld_btch
  5761. client := &http.Client{}
  5762. bytesData, _ := json.Marshal(data)
  5763. var req *http.Request
  5764. if miConfig.MdtrtareaAdmvs == "320921" {
  5765. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5766. } else {
  5767. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5768. }
  5769. resp, _ := client.Do(req)
  5770. defer resp.Body.Close()
  5771. body, ioErr := ioutil.ReadAll(resp.Body)
  5772. if ioErr != nil {
  5773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5775. }
  5776. var respJSON map[string]interface{}
  5777. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5780. }
  5781. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5782. fmt.Println(respJSON)
  5783. result, _ := json.Marshal(respJSON)
  5784. fmt.Println(result)
  5785. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  5786. utils.ErrorLog("解析失败:%v", err)
  5787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5788. }
  5789. if result3263.Infcode != "0" {
  5790. c.ServeSuccessJSON(map[string]interface{}{
  5791. "failed_code": -10,
  5792. "msg": result3263.ErrMsg,
  5793. })
  5794. return
  5795. } else {
  5796. c.ServeSuccessJSON(map[string]interface{}{
  5797. "list": result3263.Output,
  5798. })
  5799. return
  5800. }
  5801. }
  5802. func (c *HisApiController) Get3264() {
  5803. admin_user_id, _ := c.GetInt64("admin_user_id")
  5804. startTime := c.GetString("start_time")
  5805. //endTime, _ := c.GetString("end_time")
  5806. times := strings.Split(startTime, "-")
  5807. setl_mon := times[0] + times[1]
  5808. upld_btch := "0"
  5809. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5810. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5811. //solidify_id := []
  5812. var result3263 models.JSResult3263
  5813. data := make(map[string]interface{})
  5814. data["org_name"] = miConfig.OrgName
  5815. data["doctor"] = curRoles.UserName
  5816. data["doctor_name"] = curRoles.UserName
  5817. data["fixmedins_code"] = miConfig.Code
  5818. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5819. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5820. data["secret_key"] = miConfig.SecretKey
  5821. data["url"] = miConfig.Url
  5822. data["ak"] = miConfig.AccessKey
  5823. data["cainfo"] = miConfig.Cainfo
  5824. data["setl_mon"] = setl_mon
  5825. data["stmt_loc"] = "2"
  5826. data["upld_btch"] = upld_btch
  5827. client := &http.Client{}
  5828. bytesData, _ := json.Marshal(data)
  5829. var req3263 *http.Request
  5830. if miConfig.MdtrtareaAdmvs == "320921" {
  5831. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5832. } else {
  5833. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5834. }
  5835. resp, _ := client.Do(req3263)
  5836. defer resp.Body.Close()
  5837. body, ioErr := ioutil.ReadAll(resp.Body)
  5838. if ioErr != nil {
  5839. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5841. }
  5842. var respJSON3263 map[string]interface{}
  5843. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  5844. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5846. }
  5847. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5848. fmt.Println(respJSON3263)
  5849. result, _ := json.Marshal(respJSON3263)
  5850. fmt.Println(result)
  5851. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  5852. utils.ErrorLog("解析失败:%v", err)
  5853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5854. }
  5855. var ids []string
  5856. for _, item := range result3263.Output {
  5857. ids = append(ids, item.SolidifyID)
  5858. }
  5859. var empty models.JSResultEmpty
  5860. data2 := make(map[string]interface{})
  5861. data2["org_name"] = miConfig.OrgName
  5862. data2["doctor"] = curRoles.UserName
  5863. data2["doctor_name"] = curRoles.UserName
  5864. data2["fixmedins_code"] = miConfig.Code
  5865. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5866. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5867. data2["secret_key"] = miConfig.SecretKey
  5868. data2["url"] = miConfig.Url
  5869. data2["ak"] = miConfig.AccessKey
  5870. data2["cainfo"] = miConfig.Cainfo
  5871. data2["setl_mon"] = setl_mon
  5872. data2["stmt_loc"] = "2"
  5873. data2["upld_btch"] = upld_btch
  5874. data2["solidify_id"] = ids
  5875. client2 := &http.Client{}
  5876. bytesData2, _ := json.Marshal(data2)
  5877. var req *http.Request
  5878. if miConfig.MdtrtareaAdmvs == "320921" {
  5879. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  5880. } else {
  5881. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  5882. }
  5883. resp2, _ := client2.Do(req)
  5884. defer resp.Body.Close()
  5885. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5886. if ioErr2 != nil {
  5887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5889. }
  5890. var respJSON map[string]interface{}
  5891. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  5892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5894. }
  5895. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5896. fmt.Println(respJSON)
  5897. result2, _ := json.Marshal(respJSON)
  5898. fmt.Println(result2)
  5899. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  5900. utils.ErrorLog("解析失败:%v", err)
  5901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5902. }
  5903. if empty.Infcode != "0" {
  5904. c.ServeSuccessJSON(map[string]interface{}{
  5905. "failed_code": -10,
  5906. "msg": empty.ErrMsg,
  5907. })
  5908. return
  5909. } else {
  5910. c.ServeSuccessJSON(map[string]interface{}{
  5911. "msg": "",
  5912. })
  5913. return
  5914. }
  5915. }
  5916. func (c *HisApiController) Get3265() {
  5917. admin_user_id, _ := c.GetInt64("admin_user_id")
  5918. startTime := c.GetString("start_time")
  5919. //endTime, _ := c.GetString("end_time")
  5920. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5921. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5922. times := strings.Split(startTime, "-")
  5923. setl_mon := times[0] + times[1]
  5924. var upld_btch string
  5925. upld_btch = "0"
  5926. //var empty models.JSResultEmpty
  5927. var result3265 models.JSResult3264
  5928. var result3263 models.JSResult3263
  5929. data2 := make(map[string]interface{})
  5930. data2["org_name"] = miConfig.OrgName
  5931. data2["doctor"] = curRoles.UserName
  5932. data2["doctor_name"] = curRoles.UserName
  5933. data2["fixmedins_code"] = miConfig.Code
  5934. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5935. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5936. data2["secret_key"] = miConfig.SecretKey
  5937. data2["url"] = miConfig.Url
  5938. data2["ak"] = miConfig.AccessKey
  5939. data2["cainfo"] = miConfig.Cainfo
  5940. data2["setl_mon"] = setl_mon
  5941. data2["stmt_loc"] = "2"
  5942. data2["upld_btch"] = upld_btch
  5943. client2 := &http.Client{}
  5944. bytesData2, _ := json.Marshal(data2)
  5945. var req3263 *http.Request
  5946. if miConfig.MdtrtareaAdmvs == "320921" {
  5947. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  5948. } else {
  5949. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  5950. }
  5951. resp2, _ := client2.Do(req3263)
  5952. defer resp2.Body.Close()
  5953. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5954. if ioErr2 != nil {
  5955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5957. }
  5958. var respJSON3263 map[string]interface{}
  5959. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  5960. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5962. }
  5963. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5964. fmt.Println(respJSON3263)
  5965. result2, _ := json.Marshal(respJSON3263)
  5966. fmt.Println(result2)
  5967. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  5968. utils.ErrorLog("解析失败:%v", err)
  5969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5970. }
  5971. var ids []string
  5972. for _, item := range result3263.Output {
  5973. ids = append(ids, item.SolidifyID)
  5974. }
  5975. data := make(map[string]interface{})
  5976. data["org_name"] = miConfig.OrgName
  5977. data["doctor"] = curRoles.UserName
  5978. data["doctor_name"] = curRoles.UserName
  5979. data["fixmedins_code"] = miConfig.Code
  5980. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5981. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5982. data["secret_key"] = miConfig.SecretKey
  5983. data["url"] = miConfig.Url
  5984. data["ak"] = miConfig.AccessKey
  5985. data["cainfo"] = miConfig.Cainfo
  5986. data["setl_mon"] = setl_mon
  5987. data["solidify_id"] = ids
  5988. month := time.Unix(1557042972, 0).Format("1")
  5989. year := time.Now().Format("2006")
  5990. month = time.Now().Format("01")
  5991. day := time.Now().Format("02")
  5992. hour := time.Now().Format("15")
  5993. min := time.Now().Format("04")
  5994. sec := time.Now().Format("05")
  5995. fix_fill_date := year + month + day + hour + min + sec
  5996. data["fix_fill_dept"] = miConfig.OrgName
  5997. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  5998. data["fix_fill_psn"] = curRoles.UserName
  5999. data["fix_fill_date"] = fix_fill_date
  6000. data["stmt_loc"] = "2"
  6001. data["upld_btch"] = upld_btch
  6002. client := &http.Client{}
  6003. bytesData, _ := json.Marshal(data)
  6004. var req *http.Request
  6005. if miConfig.MdtrtareaAdmvs == "320921" {
  6006. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6007. } else {
  6008. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6009. }
  6010. resp, _ := client.Do(req)
  6011. defer resp.Body.Close()
  6012. body, ioErr := ioutil.ReadAll(resp.Body)
  6013. if ioErr != nil {
  6014. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6016. }
  6017. var respJSON map[string]interface{}
  6018. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6021. }
  6022. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6023. fmt.Println(respJSON)
  6024. result, _ := json.Marshal(respJSON)
  6025. fmt.Println(result)
  6026. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6027. utils.ErrorLog("解析失败:%v", err)
  6028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6029. }
  6030. if result3265.Infcode != "0" {
  6031. c.ServeSuccessJSON(map[string]interface{}{
  6032. "failed_code": -10,
  6033. "msg": result3265.ErrMsg,
  6034. })
  6035. return
  6036. } else {
  6037. c.ServeSuccessJSON(map[string]interface{}{
  6038. "info": result3265.Output,
  6039. })
  6040. return
  6041. }
  6042. }
  6043. func (c *HisApiController) Get3266() {
  6044. admin_user_id, _ := c.GetInt64("admin_user_id")
  6045. startTime := c.GetString("start_time")
  6046. //endTime, _ := c.GetString("end_time")
  6047. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6048. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6049. times := strings.Split(startTime, "-")
  6050. stmt_mon := times[0] + times[1]
  6051. var upld_btch string
  6052. //var empty models.JSResultEmpty
  6053. var result3265 models.JSResult3264
  6054. data := make(map[string]interface{})
  6055. data["org_name"] = miConfig.OrgName
  6056. data["doctor"] = curRoles.UserName
  6057. data["doctor_name"] = curRoles.UserName
  6058. data["fixmedins_code"] = miConfig.Code
  6059. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6060. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6061. data["secret_key"] = miConfig.SecretKey
  6062. data["url"] = miConfig.Url
  6063. data["ak"] = miConfig.AccessKey
  6064. data["cainfo"] = miConfig.Cainfo
  6065. data["setl_mon"] = stmt_mon
  6066. month := time.Unix(1557042972, 0).Format("1")
  6067. year := time.Now().Format("2006")
  6068. month = time.Now().Format("01")
  6069. day := time.Now().Format("02")
  6070. hour := time.Now().Format("15")
  6071. min := time.Now().Format("04")
  6072. sec := time.Now().Format("05")
  6073. fix_fill_date := year + month + day + hour + min + sec
  6074. data["fix_fill_dept"] = miConfig.OrgName
  6075. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6076. data["fix_fill_psn"] = curRoles.UserName
  6077. data["fix_fill_date"] = fix_fill_date
  6078. data["stmt_loc"] = "2"
  6079. upld_btch = "0"
  6080. data["upld_btch"] = upld_btch
  6081. client := &http.Client{}
  6082. bytesData, _ := json.Marshal(data)
  6083. var req *http.Request
  6084. if miConfig.MdtrtareaAdmvs == "320921" {
  6085. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6086. } else {
  6087. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6088. }
  6089. resp, _ := client.Do(req)
  6090. defer resp.Body.Close()
  6091. body, ioErr := ioutil.ReadAll(resp.Body)
  6092. if ioErr != nil {
  6093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6095. }
  6096. var respJSON map[string]interface{}
  6097. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6100. }
  6101. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6102. fmt.Println(respJSON)
  6103. result, _ := json.Marshal(respJSON)
  6104. fmt.Println(result)
  6105. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6106. utils.ErrorLog("解析失败:%v", err)
  6107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6108. }
  6109. if result3265.Infcode != "0" {
  6110. c.ServeSuccessJSON(map[string]interface{}{
  6111. "failed_code": -10,
  6112. "msg": result3265.ErrMsg,
  6113. })
  6114. return
  6115. } else {
  6116. c.ServeSuccessJSON(map[string]interface{}{
  6117. "info": result3265.Output,
  6118. })
  6119. return
  6120. }
  6121. }
  6122. func (c *HisApiController) Get3267() {
  6123. admin_user_id, _ := c.GetInt64("admin_user_id")
  6124. startTime := c.GetString("start_time")
  6125. //endTime, _ := c.GetString("end_time")
  6126. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6127. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6128. times := strings.Split(startTime, "-")
  6129. setl_mon := times[0] + times[1]
  6130. var upld_btch string
  6131. //var empty models.JSResultEmpty
  6132. var result3265 models.JSResult3264
  6133. upld_btch = "0"
  6134. data := make(map[string]interface{})
  6135. data["org_name"] = miConfig.OrgName
  6136. data["doctor"] = curRoles.UserName
  6137. data["doctor_name"] = curRoles.UserName
  6138. data["fixmedins_code"] = miConfig.Code
  6139. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6140. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6141. data["secret_key"] = miConfig.SecretKey
  6142. data["url"] = miConfig.Url
  6143. data["ak"] = miConfig.AccessKey
  6144. data["cainfo"] = miConfig.Cainfo
  6145. data["setl_mon"] = setl_mon
  6146. data["stmt_loc"] = "2"
  6147. data["upld_btch"] = upld_btch
  6148. client := &http.Client{}
  6149. bytesData, _ := json.Marshal(data)
  6150. var req *http.Request
  6151. if miConfig.MdtrtareaAdmvs == "320921" {
  6152. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6153. } else {
  6154. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6155. }
  6156. resp, _ := client.Do(req)
  6157. defer resp.Body.Close()
  6158. body, ioErr := ioutil.ReadAll(resp.Body)
  6159. if ioErr != nil {
  6160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6162. }
  6163. var respJSON map[string]interface{}
  6164. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6167. }
  6168. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6169. fmt.Println(respJSON)
  6170. result, _ := json.Marshal(respJSON)
  6171. fmt.Println(result)
  6172. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6173. utils.ErrorLog("解析失败:%v", err)
  6174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6175. }
  6176. if result3265.Infcode != "0" {
  6177. c.ServeSuccessJSON(map[string]interface{}{
  6178. "failed_code": -10,
  6179. "msg": result3265.ErrMsg,
  6180. })
  6181. return
  6182. } else {
  6183. c.ServeSuccessJSON(map[string]interface{}{
  6184. "info": result3265.Output.Data,
  6185. })
  6186. return
  6187. }
  6188. }
  6189. func (c *HisApiController) Get3268() {
  6190. admin_user_id, _ := c.GetInt64("admin_user_id")
  6191. startTime := c.GetString("start_time")
  6192. endTime := c.GetString("end_time")
  6193. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6194. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6195. times := strings.Split(startTime, "-")
  6196. setl_mon := times[0] + times[1]
  6197. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6198. var twos []models.FixMonRecDetailFileInTwo
  6199. var funs []models.FundDetail
  6200. for _, item := range datas {
  6201. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6202. funs = append(funs, fun...)
  6203. }
  6204. var funInfos []models.Fund
  6205. //for _, item := range funs {
  6206. // var rf []models.FundInfo
  6207. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6208. // for _, subitem := range rf {
  6209. // var fund models.Fund
  6210. // fund.FundCode = subitem.FundPayType
  6211. // fund.FundName = subitem.FundPayTypeName
  6212. // fund.FundAmt = subitem.FundPayAmt
  6213. // fund.FundKey = item.FundKey
  6214. // fund.InsuAdmdvs = "555555"
  6215. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6216. // funInfos = append(funInfos, fund)
  6217. // }
  6218. //}
  6219. for _, team := range datas {
  6220. var two models.FixMonRecDetailFileInTwo
  6221. two.SetlDate = time.Now().Format("2006-01-02")
  6222. two.MedType = team.MedType
  6223. two.Insutype = team.Insutype
  6224. two.PsnType = team.PsnType
  6225. two.MedType = team.MedType
  6226. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6227. two.InsuAdmdvs = team.InsuAdmdvs
  6228. two.PsnTime = team.PsnTime
  6229. two.PsnCnt = team.PsnCnt
  6230. two.FundKey = team.FundKey
  6231. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6232. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6233. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6234. two.MedfeeSumAmt = ms
  6235. two.InscpAmt = ia
  6236. two.FundPaySumAmt = fps
  6237. twos = append(twos, two)
  6238. }
  6239. var upld_btch string
  6240. upld_btch = "0"
  6241. var empty models.JSResultEmpty
  6242. data := make(map[string]interface{})
  6243. data["org_name"] = miConfig.OrgName
  6244. data["doctor"] = curRoles.UserName
  6245. data["doctor_name"] = curRoles.UserName
  6246. data["fixmedins_code"] = miConfig.Code
  6247. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6248. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6249. data["secret_key"] = miConfig.SecretKey
  6250. data["url"] = miConfig.Url
  6251. data["ak"] = miConfig.AccessKey
  6252. data["cainfo"] = miConfig.Cainfo
  6253. data["datas"] = twos
  6254. data["fund"] = funInfos
  6255. data["setl_mon"] = setl_mon
  6256. month := time.Unix(1557042972, 0).Format("1")
  6257. year := time.Now().Format("2006")
  6258. month = time.Now().Format("01")
  6259. day := time.Now().Format("02")
  6260. hour := time.Now().Format("15")
  6261. min := time.Now().Format("04")
  6262. sec := time.Now().Format("05")
  6263. fix_fill_date := year + month + day + hour + min + sec
  6264. data["fix_fill_dept"] = miConfig.OrgName
  6265. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6266. data["fix_fill_psn"] = curRoles.UserName
  6267. data["fix_fill_date"] = fix_fill_date
  6268. data["stmt_loc"] = "2"
  6269. data["upld_btch"] = upld_btch
  6270. client := &http.Client{}
  6271. bytesData, _ := json.Marshal(data)
  6272. var req *http.Request
  6273. if miConfig.MdtrtareaAdmvs == "320921" {
  6274. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6275. } else {
  6276. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6277. }
  6278. resp, _ := client.Do(req)
  6279. defer resp.Body.Close()
  6280. body, ioErr := ioutil.ReadAll(resp.Body)
  6281. if ioErr != nil {
  6282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6284. }
  6285. var respJSON map[string]interface{}
  6286. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6289. }
  6290. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6291. fmt.Println(respJSON)
  6292. result, _ := json.Marshal(respJSON)
  6293. fmt.Println(result)
  6294. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6295. utils.ErrorLog("解析失败:%v", err)
  6296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6297. }
  6298. if empty.Infcode != "0" {
  6299. c.ServeSuccessJSON(map[string]interface{}{
  6300. "failed_code": -10,
  6301. "msg": empty.ErrMsg,
  6302. })
  6303. return
  6304. } else {
  6305. c.ServeSuccessJSON(map[string]interface{}{
  6306. "msg": "上传成功",
  6307. })
  6308. return
  6309. }
  6310. }
  6311. func (c *HisApiController) Get3269() {
  6312. admin_user_id, _ := c.GetInt64("admin_user_id")
  6313. startTime := c.GetString("start_time")
  6314. //endTime, _ := c.GetString("end_time")
  6315. times := strings.Split(startTime, "-")
  6316. setl_mon := times[0] + times[1]
  6317. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6318. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6319. var result3263 models.JSResult3263
  6320. data := make(map[string]interface{})
  6321. data["org_name"] = miConfig.OrgName
  6322. data["doctor"] = curRoles.UserName
  6323. data["doctor_name"] = curRoles.UserName
  6324. data["fixmedins_code"] = miConfig.Code
  6325. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6326. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6327. data["secret_key"] = miConfig.SecretKey
  6328. data["url"] = miConfig.Url
  6329. data["ak"] = miConfig.AccessKey
  6330. data["cainfo"] = miConfig.Cainfo
  6331. data["setl_mon"] = setl_mon
  6332. data["stmt_loc"] = "2"
  6333. client := &http.Client{}
  6334. bytesData, _ := json.Marshal(data)
  6335. var req *http.Request
  6336. if miConfig.MdtrtareaAdmvs == "320921" {
  6337. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6338. } else {
  6339. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6340. }
  6341. resp, _ := client.Do(req)
  6342. defer resp.Body.Close()
  6343. body, ioErr := ioutil.ReadAll(resp.Body)
  6344. if ioErr != nil {
  6345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6347. }
  6348. var respJSON map[string]interface{}
  6349. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6352. }
  6353. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6354. fmt.Println(respJSON)
  6355. result, _ := json.Marshal(respJSON)
  6356. fmt.Println(result)
  6357. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6358. utils.ErrorLog("解析失败:%v", err)
  6359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6360. }
  6361. if result3263.Infcode != "0" {
  6362. c.ServeSuccessJSON(map[string]interface{}{
  6363. "failed_code": -10,
  6364. "msg": result3263.ErrMsg,
  6365. })
  6366. return
  6367. } else {
  6368. c.ServeSuccessJSON(map[string]interface{}{
  6369. "msg": "上传成功",
  6370. })
  6371. return
  6372. }
  6373. }
  6374. func (c *HisApiController) Get3270() {
  6375. admin_user_id, _ := c.GetInt64("admin_user_id")
  6376. startTime := c.GetString("start_time")
  6377. //endTime, _ := c.GetString("end_time")
  6378. times := strings.Split(startTime, "-")
  6379. setl_mon := times[0] + times[1]
  6380. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6381. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6382. var result3263 models.JSResult3263
  6383. data2 := make(map[string]interface{})
  6384. data2["org_name"] = miConfig.OrgName
  6385. data2["doctor"] = curRoles.UserName
  6386. data2["doctor_name"] = curRoles.UserName
  6387. data2["fixmedins_code"] = miConfig.Code
  6388. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6389. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6390. data2["secret_key"] = miConfig.SecretKey
  6391. data2["url"] = miConfig.Url
  6392. data2["ak"] = miConfig.AccessKey
  6393. data2["cainfo"] = miConfig.Cainfo
  6394. data2["setl_mon"] = setl_mon
  6395. data2["stmt_loc"] = "2"
  6396. client2 := &http.Client{}
  6397. bytesData2, _ := json.Marshal(data2)
  6398. var req3263 *http.Request
  6399. if miConfig.MdtrtareaAdmvs == "320921" {
  6400. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6401. } else {
  6402. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6403. }
  6404. resp2, _ := client2.Do(req3263)
  6405. defer resp2.Body.Close()
  6406. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6407. if ioErr2 != nil {
  6408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6410. }
  6411. var respJSON3263 map[string]interface{}
  6412. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6415. }
  6416. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6417. fmt.Println(respJSON3263)
  6418. result2, _ := json.Marshal(respJSON3263)
  6419. fmt.Println(result2)
  6420. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6421. utils.ErrorLog("解析失败:%v", err)
  6422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6423. }
  6424. var ids []string
  6425. for _, item := range result3263.Output {
  6426. ids = append(ids, item.SolidifyID)
  6427. }
  6428. var result3264 models.JSResult3264
  6429. data := make(map[string]interface{})
  6430. data["org_name"] = miConfig.OrgName
  6431. data["doctor"] = curRoles.UserName
  6432. data["doctor_name"] = curRoles.UserName
  6433. data["fixmedins_code"] = miConfig.Code
  6434. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6435. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6436. data["secret_key"] = miConfig.SecretKey
  6437. data["url"] = miConfig.Url
  6438. data["ak"] = miConfig.AccessKey
  6439. data["cainfo"] = miConfig.Cainfo
  6440. data["setl_mon"] = setl_mon
  6441. data["stmt_loc"] = "2"
  6442. data["solidify_id"] = ids
  6443. client := &http.Client{}
  6444. bytesData, _ := json.Marshal(data)
  6445. var req *http.Request
  6446. if miConfig.MdtrtareaAdmvs == "320921" {
  6447. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6448. } else {
  6449. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6450. }
  6451. resp, _ := client.Do(req)
  6452. defer resp.Body.Close()
  6453. body, ioErr := ioutil.ReadAll(resp.Body)
  6454. if ioErr != nil {
  6455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6457. }
  6458. var respJSON map[string]interface{}
  6459. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6462. }
  6463. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6464. fmt.Println(respJSON)
  6465. result, _ := json.Marshal(respJSON)
  6466. fmt.Println(result)
  6467. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  6468. utils.ErrorLog("解析失败:%v", err)
  6469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6470. }
  6471. if result3264.Infcode != "0" {
  6472. c.ServeSuccessJSON(map[string]interface{}{
  6473. "failed_code": -10,
  6474. "msg": result3264.ErrMsg,
  6475. })
  6476. return
  6477. } else {
  6478. c.ServeSuccessJSON(map[string]interface{}{
  6479. "info": result3264.Output,
  6480. })
  6481. return
  6482. }
  6483. }
  6484. func (c *HisApiController) Get3271() {
  6485. admin_user_id, _ := c.GetInt64("admin_user_id")
  6486. startTime := c.GetString("start_time")
  6487. //endTime, _ := c.GetString("end_time")
  6488. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6489. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6490. times := strings.Split(startTime, "-")
  6491. setl_mon := times[0] + times[1]
  6492. //var empty models.JSResultEmpty
  6493. var result3265 models.JSResult3264
  6494. var result3263 models.JSResult3263
  6495. data2 := make(map[string]interface{})
  6496. data2["org_name"] = miConfig.OrgName
  6497. data2["doctor"] = curRoles.UserName
  6498. data2["doctor_name"] = curRoles.UserName
  6499. data2["fixmedins_code"] = miConfig.Code
  6500. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6501. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6502. data2["secret_key"] = miConfig.SecretKey
  6503. data2["url"] = miConfig.Url
  6504. data2["ak"] = miConfig.AccessKey
  6505. data2["cainfo"] = miConfig.Cainfo
  6506. data2["setl_mon"] = setl_mon
  6507. data2["stmt_loc"] = "2"
  6508. client2 := &http.Client{}
  6509. bytesData2, _ := json.Marshal(data2)
  6510. var req3263 *http.Request
  6511. if miConfig.MdtrtareaAdmvs == "320921" {
  6512. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6513. } else {
  6514. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6515. }
  6516. resp2, _ := client2.Do(req3263)
  6517. defer resp2.Body.Close()
  6518. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6519. if ioErr2 != nil {
  6520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6522. }
  6523. var respJSON3263 map[string]interface{}
  6524. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6527. }
  6528. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6529. fmt.Println(respJSON3263)
  6530. result2, _ := json.Marshal(respJSON3263)
  6531. fmt.Println(result2)
  6532. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6533. utils.ErrorLog("解析失败:%v", err)
  6534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6535. }
  6536. var ids []string
  6537. for _, item := range result3263.Output {
  6538. ids = append(ids, item.SolidifyID)
  6539. }
  6540. data := make(map[string]interface{})
  6541. data["org_name"] = miConfig.OrgName
  6542. data["doctor"] = curRoles.UserName
  6543. data["doctor_name"] = curRoles.UserName
  6544. data["fixmedins_code"] = miConfig.Code
  6545. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6546. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6547. data["secret_key"] = miConfig.SecretKey
  6548. data["url"] = miConfig.Url
  6549. data["ak"] = miConfig.AccessKey
  6550. data["cainfo"] = miConfig.Cainfo
  6551. data["setl_mon"] = setl_mon
  6552. data["solidify_id"] = ids
  6553. month := time.Unix(1557042972, 0).Format("1")
  6554. year := time.Now().Format("2006")
  6555. month = time.Now().Format("01")
  6556. day := time.Now().Format("02")
  6557. hour := time.Now().Format("15")
  6558. min := time.Now().Format("04")
  6559. sec := time.Now().Format("05")
  6560. fix_fill_date := year + month + day + hour + min + sec
  6561. data["fix_fill_dept"] = miConfig.OrgName
  6562. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6563. data["fix_fill_psn"] = curRoles.UserName
  6564. data["fix_fill_date"] = fix_fill_date
  6565. data["stmt_loc"] = "2"
  6566. client := &http.Client{}
  6567. bytesData, _ := json.Marshal(data)
  6568. var req *http.Request
  6569. if miConfig.MdtrtareaAdmvs == "320921" {
  6570. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6571. } else {
  6572. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6573. }
  6574. resp, _ := client.Do(req)
  6575. defer resp.Body.Close()
  6576. body, ioErr := ioutil.ReadAll(resp.Body)
  6577. if ioErr != nil {
  6578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6580. }
  6581. var respJSON map[string]interface{}
  6582. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6585. }
  6586. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6587. fmt.Println(respJSON)
  6588. result, _ := json.Marshal(respJSON)
  6589. fmt.Println(result)
  6590. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6591. utils.ErrorLog("解析失败:%v", err)
  6592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6593. }
  6594. if result3265.Infcode != "0" {
  6595. c.ServeSuccessJSON(map[string]interface{}{
  6596. "failed_code": -10,
  6597. "msg": result3265.ErrMsg,
  6598. })
  6599. return
  6600. } else {
  6601. c.ServeSuccessJSON(map[string]interface{}{
  6602. "info": result3265.Output.Data,
  6603. })
  6604. return
  6605. }
  6606. }
  6607. func (c *HisApiController) Get3272() {
  6608. admin_user_id, _ := c.GetInt64("admin_user_id")
  6609. startTime := c.GetString("start_time")
  6610. //endTime, _ := c.GetString("end_time")
  6611. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6612. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6613. times := strings.Split(startTime, "-")
  6614. setl_mon := times[0] + times[1]
  6615. var upld_btch string
  6616. //var empty models.JSResultEmpty
  6617. var result3265 models.JSResult3264
  6618. data := make(map[string]interface{})
  6619. data["org_name"] = miConfig.OrgName
  6620. data["doctor"] = curRoles.UserName
  6621. data["doctor_name"] = curRoles.UserName
  6622. data["fixmedins_code"] = miConfig.Code
  6623. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6624. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6625. data["secret_key"] = miConfig.SecretKey
  6626. data["url"] = miConfig.Url
  6627. data["ak"] = miConfig.AccessKey
  6628. data["cainfo"] = miConfig.Cainfo
  6629. data["setl_mon"] = setl_mon
  6630. month := time.Unix(1557042972, 0).Format("1")
  6631. year := time.Now().Format("2006")
  6632. month = time.Now().Format("01")
  6633. day := time.Now().Format("02")
  6634. hour := time.Now().Format("15")
  6635. min := time.Now().Format("04")
  6636. sec := time.Now().Format("05")
  6637. fix_fill_date := year + month + day + hour + min + sec
  6638. data["fix_fill_dept"] = miConfig.OrgName
  6639. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6640. data["fix_fill_psn"] = curRoles.UserName
  6641. data["fix_fill_date"] = fix_fill_date
  6642. data["stmt_loc"] = "2"
  6643. data["upld_btch"] = upld_btch
  6644. client := &http.Client{}
  6645. bytesData, _ := json.Marshal(data)
  6646. var req *http.Request
  6647. if miConfig.MdtrtareaAdmvs == "320921" {
  6648. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  6649. } else {
  6650. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  6651. }
  6652. resp, _ := client.Do(req)
  6653. defer resp.Body.Close()
  6654. body, ioErr := ioutil.ReadAll(resp.Body)
  6655. if ioErr != nil {
  6656. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6658. }
  6659. var respJSON map[string]interface{}
  6660. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6663. }
  6664. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6665. fmt.Println(respJSON)
  6666. result, _ := json.Marshal(respJSON)
  6667. fmt.Println(result)
  6668. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6669. utils.ErrorLog("解析失败:%v", err)
  6670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6671. }
  6672. if result3265.Infcode != "0" {
  6673. c.ServeSuccessJSON(map[string]interface{}{
  6674. "failed_code": -10,
  6675. "msg": result3265.ErrMsg,
  6676. })
  6677. return
  6678. } else {
  6679. c.ServeSuccessJSON(map[string]interface{}{
  6680. "info": result3265.Output,
  6681. })
  6682. return
  6683. }
  6684. }
  6685. func (c *HisApiController) Get3273() {
  6686. admin_user_id, _ := c.GetInt64("admin_user_id")
  6687. startTime := c.GetString("start_time")
  6688. //endTime, _ := c.GetString("end_time")
  6689. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6690. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6691. times := strings.Split(startTime, "-")
  6692. setl_mon := times[0] + times[1]
  6693. var result3265 models.JSResult3264
  6694. data := make(map[string]interface{})
  6695. data["org_name"] = miConfig.OrgName
  6696. data["doctor"] = curRoles.UserName
  6697. data["doctor_name"] = curRoles.UserName
  6698. data["fixmedins_code"] = miConfig.Code
  6699. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6700. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6701. data["secret_key"] = miConfig.SecretKey
  6702. data["url"] = miConfig.Url
  6703. data["ak"] = miConfig.AccessKey
  6704. data["cainfo"] = miConfig.Cainfo
  6705. data["setl_mon"] = setl_mon
  6706. data["stmt_loc"] = "2"
  6707. client := &http.Client{}
  6708. bytesData, _ := json.Marshal(data)
  6709. var req *http.Request
  6710. if miConfig.MdtrtareaAdmvs == "320921" {
  6711. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  6712. } else {
  6713. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  6714. }
  6715. resp, _ := client.Do(req)
  6716. defer resp.Body.Close()
  6717. body, ioErr := ioutil.ReadAll(resp.Body)
  6718. if ioErr != nil {
  6719. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6721. }
  6722. var respJSON map[string]interface{}
  6723. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6726. }
  6727. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6728. fmt.Println(respJSON)
  6729. result, _ := json.Marshal(respJSON)
  6730. fmt.Println(result)
  6731. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6732. utils.ErrorLog("解析失败:%v", err)
  6733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6734. }
  6735. if result3265.Infcode != "0" {
  6736. c.ServeSuccessJSON(map[string]interface{}{
  6737. "failed_code": -10,
  6738. "msg": result3265.ErrMsg,
  6739. })
  6740. return
  6741. } else {
  6742. c.ServeSuccessJSON(map[string]interface{}{
  6743. "info": result3265.Output.Data,
  6744. })
  6745. return
  6746. }
  6747. }
  6748. func (c *HisApiController) Get3274() {
  6749. //if miConfig.MdtrtareaAdmvs == "320921" {
  6750. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6751. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6752. // "&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
  6753. //
  6754. //} else {
  6755. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6756. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6757. // "&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
  6758. //
  6759. //}
  6760. }
  6761. func (c *HisApiController) Get3275() {
  6762. //if miConfig.MdtrtareaAdmvs == "320921" {
  6763. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6764. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6765. // "&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
  6766. //
  6767. //} else {
  6768. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6769. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6770. // "&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
  6771. //
  6772. //}
  6773. }
  6774. func (c *HisApiController) Get3276() {
  6775. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6776. //month := c.GetString("month")
  6777. //
  6778. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6779. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6780. //var api string
  6781. //var res Result5301
  6782. //
  6783. //if miConfig.MdtrtareaAdmvs == "320921" {
  6784. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6785. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6786. //} else {
  6787. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6788. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6789. //}
  6790. //
  6791. //resp, requestErr := http.Get(api)
  6792. //if requestErr != nil {
  6793. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6794. // return
  6795. //}
  6796. //
  6797. //body, ioErr := ioutil.ReadAll(resp.Body)
  6798. //if ioErr != nil {
  6799. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6800. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6801. // return
  6802. //}
  6803. //var respJSON map[string]interface{}
  6804. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6805. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6807. // return
  6808. //}
  6809. //
  6810. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6811. //result, _ := json.Marshal(respJSON)
  6812. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6813. // utils.ErrorLog("解析失败:%v", err)
  6814. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6815. // return
  6816. //}
  6817. }
  6818. func (c *HisApiController) Get3277() {
  6819. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6820. //month := c.GetString("month")
  6821. //
  6822. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6823. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6824. //var api string
  6825. //var res Result5301
  6826. //
  6827. //if miConfig.MdtrtareaAdmvs == "320921" {
  6828. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6829. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6830. //} else {
  6831. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6832. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6833. //}
  6834. //
  6835. //resp, requestErr := http.Get(api)
  6836. //if requestErr != nil {
  6837. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6838. // return
  6839. //}
  6840. //
  6841. //body, ioErr := ioutil.ReadAll(resp.Body)
  6842. //if ioErr != nil {
  6843. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6844. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6845. // return
  6846. //}
  6847. //var respJSON map[string]interface{}
  6848. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6849. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6850. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6851. // return
  6852. //}
  6853. //
  6854. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6855. //result, _ := json.Marshal(respJSON)
  6856. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6857. // utils.ErrorLog("解析失败:%v", err)
  6858. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6859. // return
  6860. //}
  6861. }
  6862. func (c *HisApiController) GetCFYLJG001() {
  6863. admin_user_id, _ := c.GetInt64("admin_user_id")
  6864. patient_id, _ := c.GetInt64("patient_id")
  6865. his_patient_id, _ := c.GetInt64("his_patient_id")
  6866. record_time := c.GetString("record_time")
  6867. admin_user_id = 3626
  6868. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6869. psn, _ := service.GetPsnByPatientId(patient_id)
  6870. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6871. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6872. var cFYLJG001 models.CFYLJG001
  6873. timeLayout := "2006-01-02"
  6874. loc, _ := time.LoadLocation("Local")
  6875. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6876. if err != nil {
  6877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6878. return
  6879. }
  6880. recordDateTime := theTime.Unix()
  6881. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6882. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6883. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6884. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  6885. //dept, _ := service.GetDepartMentDetail(info.Departments)
  6886. for _, item := range prescriptions {
  6887. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  6888. if his.IdCardType == 1 {
  6889. bas := strings.Split(psn.CardInfo, "|")
  6890. basNumber := bas[1]
  6891. fmt.Println(basNumber)
  6892. card_sn := bas[3]
  6893. card_no := bas[2]
  6894. cFYLJG001.MdtrtCertType = "03"
  6895. cFYLJG001.CardSn = card_sn
  6896. cFYLJG001.MdtrtCertNo = card_no
  6897. cFYLJG001.EcToken = ""
  6898. cFYLJG001.AuthNo = ""
  6899. } else if his.IdCardType == 2 {
  6900. cFYLJG001.MdtrtCertType = "02"
  6901. cFYLJG001.CardSn = ""
  6902. cFYLJG001.MdtrtCertNo = his.IdCardNo
  6903. cFYLJG001.EcToken = ""
  6904. cFYLJG001.AuthNo = ""
  6905. } else if his.IdCardType == 4 {
  6906. cFYLJG001.MdtrtCertType = "01"
  6907. cFYLJG001.CardSn = ""
  6908. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  6909. cFYLJG001.EcToken = psn.VerifyNumber
  6910. cFYLJG001.AuthNo = ""
  6911. }
  6912. cFYLJG001.BizTypeCode = "01"
  6913. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  6914. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  6915. cFYLJG001.RxTypeCode = "1"
  6916. tempTime := time.Unix(item.PreTime, 0)
  6917. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  6918. cFYLJG001.PrscTime = timeFormatOne
  6919. var count float64
  6920. if item.Type == 1 {
  6921. for _, sumItem := range item.HisDoctorAdviceInfo {
  6922. count = count + sumItem.PrescribingNumber
  6923. }
  6924. }
  6925. cFYLJG001.RxDrugCnt = count
  6926. cFYLJG001.ValiDays = "5"
  6927. ts := time.Unix(item.PreTime, 0)
  6928. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  6929. tempTime3 := time.Unix(record_time2, 0)
  6930. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  6931. cFYLJG001.ValiEndTime = timeFormat3
  6932. cFYLJG001.RxCotnFlag = "0"
  6933. for _, subItem := range item.HisDoctorAdviceInfo {
  6934. var drug models.RxDrug
  6935. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  6936. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  6937. drug.RxItemTypeCode = "11"
  6938. drug.DrugDosform = "乳膏剂" //TODO
  6939. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  6940. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6941. }
  6942. drug.MedcWayDscr = subItem.DeliveryWay
  6943. tempTime2 := time.Unix(subItem.StartTime, 0)
  6944. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  6945. drug.MedcBegntime = timeFormatTwo
  6946. if subItem.Day > 0 {
  6947. ts := time.Unix(subItem.StartTime, 0)
  6948. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  6949. tempTime4 := time.Unix(record_time, 0)
  6950. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  6951. drug.MedcEndtime = timeFormat5
  6952. } else {
  6953. tempTime2 := time.Unix(subItem.StartTime, 0)
  6954. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  6955. drug.MedcEndtime = timeFormatTwo
  6956. }
  6957. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  6958. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  6959. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  6960. drug.DrugCnt = subItem.PrescribingNumber
  6961. drug.DrugDosunt = subItem.PrescribingNumberUnit
  6962. drug.DrugGenname = subItem.AdviceName
  6963. drug.MedcWayCodg = subItem.DeliveryWay
  6964. //drug.DrugTotlcnt = subItem.PrescribingNumber
  6965. drug.SinDoscnt = subItem.SingleDose
  6966. drug.SinDosunt = subItem.SingleDoseUnit
  6967. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  6968. drug.UsedFrquName = subItem.ExecutionFrequency
  6969. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6970. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  6971. drug.HospApprFlag = "1"
  6972. cFYLJG001.List = append(cFYLJG001.List, drug)
  6973. }
  6974. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  6975. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  6976. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  6977. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  6978. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  6979. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  6980. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  6981. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  6982. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  6983. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  6984. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  6985. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  6986. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  6987. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  6988. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  6989. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  6990. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  6991. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  6992. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  6993. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  6994. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  6995. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  6996. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  6997. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  6998. tempTime2 := time.Now().Unix()
  6999. tempTime6 := time.Unix(tempTime2, 0)
  7000. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7001. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7002. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7003. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7004. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7005. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7006. //memo := make(map[string]interface{})
  7007. //inputData := make(map[string]interface{}, 0)
  7008. //type MyData struct {
  7009. // Insutype string `json:"insutype"`
  7010. //}
  7011. //
  7012. // data := MyData{
  7013. // Insutype: his.Insutype,
  7014. //}
  7015. //
  7016. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7017. var config []*models.HisXtDiagnoseConfig
  7018. for _, item := range diagnosis_ids {
  7019. id, _ := strconv.ParseInt(item, 10, 64)
  7020. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7021. config = append(config, &diagnosisConfig)
  7022. }
  7023. for index, subitem := range config {
  7024. if index == 0 {
  7025. var dia models.DiseInfo
  7026. dia.DiagType = "1"
  7027. dia.MaindiagFlag = "1"
  7028. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7029. dia.DiagCode = subitem.CountryCode
  7030. dia.DiagName = subitem.ClassName
  7031. dia.DiagDept = "肾内科"
  7032. dia.DiagDrNo = doctor.DoctorNumber
  7033. dia.DiagDrName = doctor.UserName
  7034. tempTime3 := time.Unix(item.PreTime, 0)
  7035. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7036. dia.DiagTime = timeFormatTwo
  7037. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7038. } else {
  7039. var dia models.DiseInfo
  7040. dia.DiagType = "1"
  7041. dia.MaindiagFlag = "0"
  7042. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7043. dia.DiagCode = subitem.CountryCode
  7044. dia.DiagName = subitem.ClassName
  7045. dia.DiagDept = "肾内科"
  7046. dia.DiagDrNo = doctor.DoctorNumber
  7047. dia.DiagDrName = doctor.UserName
  7048. tempTime3 := time.Unix(item.PreTime, 0)
  7049. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7050. dia.DiagTime = timeFormatTwo
  7051. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7052. }
  7053. }
  7054. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7055. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7056. var res ResultCFYLJG001
  7057. var respJSON2 map[string]interface{}
  7058. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7059. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7061. return
  7062. }
  7063. userJSONBytes2, _ := json.Marshal(respJSON2)
  7064. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7065. utils.ErrorLog("解析失败:%v", err)
  7066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7067. return
  7068. }
  7069. if res.Infcode == -1 {
  7070. c.ServeSuccessJSON(map[string]interface{}{
  7071. "failed_code": -10,
  7072. "msg": res.ErrMsg,
  7073. })
  7074. return
  7075. } else {
  7076. var flow models.HisPrescriptionFlow
  7077. flow.Ctime = time.Now().Unix()
  7078. flow.SignDigest = ""
  7079. flow.RxTraceCode = res.Output.RxTraceCode
  7080. flow.HiRxno = res.Output.HiRxno
  7081. flow.MID = his.Number
  7082. flow.Status = 1
  7083. flow.DCode = doctor_info.DoctorNumber
  7084. flow.OriginalRxFile = ""
  7085. flow.OriginalValue = ""
  7086. flow.SignCertDn = ""
  7087. flow.UserOrgId = 10454
  7088. flow.SignCertSn = ""
  7089. flow.Mtime = time.Now().Unix()
  7090. service.Createflow(&flow)
  7091. c.ServeSuccessJSON(map[string]interface{}{
  7092. "msg": "上传成功",
  7093. })
  7094. }
  7095. }
  7096. }
  7097. func (c *HisApiController) GetCFYLJG002() {
  7098. admin_user_id, _ := c.GetInt64("admin_user_id")
  7099. his_patient_id, _ := c.GetInt64("his_patient_id")
  7100. record_time := c.GetString("record_time")
  7101. admin_user_id = 3626
  7102. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7103. //id, _ := c.GetInt64("id")
  7104. admin_user_id = 3626
  7105. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7106. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7107. flow, _ := service.Getflowtwo(his.Number)
  7108. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7109. //record_time := c.GetString("record_time")
  7110. patient_id, _ := c.GetInt64("patient_id")
  7111. //patient_id = 23834
  7112. //record_time = "2023-09-18"
  7113. timeLayout := "2006-01-02"
  7114. loc, _ := time.LoadLocation("Local")
  7115. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7116. if err != nil {
  7117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7118. return
  7119. }
  7120. recordDateTime := theTime.Unix()
  7121. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7122. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7123. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7124. dept, _ := service.GetDepartMentDetail(info.Departments)
  7125. inputData := make(map[string]interface{})
  7126. inputData["rxTraceCode"] = flow.RxTraceCode
  7127. inputData["hiRxno"] = flow.HiRxno
  7128. inputData["mdtrtId"] = flow.MID
  7129. inputData["patnName"] = his.PsnName
  7130. inputData["psnCertType"] = his.PsnCertType
  7131. inputData["certno"] = his.Certno
  7132. inputData["fixmedinsName"] = miConfig.OrgName
  7133. inputData["fixmedinsCode"] = miConfig.Code
  7134. inputData["drCode"] = doctor_info.DoctorNumber
  7135. inputData["prscDrName"] = doctor_info.UserName
  7136. inputData["pharDeptName"] = dept.Name
  7137. inputData["pharDeptCode"] = dept.Number
  7138. inputData["pharProfttlCodg"] = dept.Name
  7139. inputData["pharProfttlName"] = ""
  7140. inputData["pharCode"] = "HY440309002107"
  7141. inputData["pharCertType"] = "01"
  7142. inputData["pharCertno"] = "430482199408260023"
  7143. inputData["pharName"] = "彭斯遥"
  7144. inputData["pharPracCertNo"] = ""
  7145. tempTime2 := time.Unix(info.Ctime, 0)
  7146. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7147. inputData["pharChkTime"] = timeFormatTwo
  7148. bytesData, _ := json.Marshal(inputData)
  7149. fmt.Println(string(bytesData))
  7150. encoded := base64.StdEncoding.EncodeToString(bytesData)
  7151. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7152. if err != nil {
  7153. fmt.Println("Error reading PDF file:", err)
  7154. return
  7155. }
  7156. // 将 PDF 文件内容进行 Base64 编码
  7157. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7158. fmt.Println(err)
  7159. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7160. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7161. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7162. var res2 Result002
  7163. var respJSON2 map[string]interface{}
  7164. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7167. return
  7168. }
  7169. userJSONBytes2, _ := json.Marshal(respJSON2)
  7170. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7171. utils.ErrorLog("解析失败:%v", err)
  7172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7173. return
  7174. }
  7175. if res2.Infcode == 0 {
  7176. flow.Ctime = time.Now().Unix()
  7177. flow.SignDigest = res2.Output.SignDigest
  7178. flow.RxFile = res2.Output.RxFile
  7179. flow.MID = his.Number
  7180. flow.Status = 1
  7181. flow.DCode = doctor_info.DoctorNumber
  7182. flow.OriginalRxFile = rx_encoded
  7183. flow.OriginalValue = encoded
  7184. flow.SignCertDn = res2.Output.SignCertDn
  7185. flow.SignCertSn = res2.Output.SignCertSn
  7186. flow.Mtime = time.Now().Unix()
  7187. service.Saveflow(flow)
  7188. c.ServeSuccessJSON(map[string]interface{}{
  7189. "msg": "预签名成功",
  7190. })
  7191. } else {
  7192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7193. return
  7194. }
  7195. }
  7196. func (c *HisApiController) GetCFYLJG003() {
  7197. admin_user_id, _ := c.GetInt64("admin_user_id")
  7198. his_patient_id, _ := c.GetInt64("his_patient_id")
  7199. record_time := c.GetString("record_time")
  7200. admin_user_id = 3626
  7201. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7202. //id, _ := c.GetInt64("id")
  7203. admin_user_id = 3626
  7204. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7205. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7206. flow, _ := service.Getflowtwo(his.Number)
  7207. //id = 3
  7208. patient_id, _ := c.GetInt64("patient_id")
  7209. //patient_id = 23834
  7210. //record_time = "2023-09-18"
  7211. timeLayout := "2006-01-02"
  7212. loc, _ := time.LoadLocation("Local")
  7213. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7214. if err != nil {
  7215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7216. return
  7217. }
  7218. recordDateTime := theTime.Unix()
  7219. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7220. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7221. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7222. dept, _ := service.GetDepartMentDetail(info.Departments)
  7223. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7224. var cFYLJG003 models.CFYLJG003
  7225. cFYLJG003.RxTraceCode = flow.RxTraceCode
  7226. cFYLJG003.HiRxno = flow.HiRxno
  7227. cFYLJG003.MdtrtID = flow.MID
  7228. cFYLJG003.PatnName = his.Name
  7229. cFYLJG003.Certno = his.Certno
  7230. cFYLJG003.FixmedinsName = miConfig.OrgName
  7231. cFYLJG003.FixmedinsCode = miConfig.Code
  7232. cFYLJG003.DrCode = doctor_info.DoctorNumber
  7233. cFYLJG003.PrscDrName = doctor_info.UserName
  7234. cFYLJG003.PharDeptName = dept.Name
  7235. cFYLJG003.PharDeptCode = dept.Number
  7236. cFYLJG003.PharCode = "HY440309002107"
  7237. cFYLJG003.PharCertType = "01"
  7238. cFYLJG003.PharCertno = "430482199408260023"
  7239. cFYLJG003.PharName = "彭斯遥"
  7240. cFYLJG003.PsnCertType = "01"
  7241. cFYLJG003.RxFile = flow.RxFile
  7242. cFYLJG003.SignDigest = flow.SignDigest
  7243. cFYLJG003.FixmedinsCode = miConfig.Code
  7244. cFYLJG003.PsnCertType = "01"
  7245. cFYLJG003.PharProfttlCodg = dept.Name
  7246. //inputData["pharProfttlCodg"] =dept.Name
  7247. tempTime2 := time.Unix(info.Ctime, 0)
  7248. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7249. cFYLJG003.PharChkTime = timeFormatTwo
  7250. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7251. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7252. var res ResultCFYLJG003
  7253. var respJSON2 map[string]interface{}
  7254. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7257. return
  7258. }
  7259. userJSONBytes2, _ := json.Marshal(respJSON2)
  7260. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7261. utils.ErrorLog("解析失败:%v", err)
  7262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7263. return
  7264. }
  7265. if res.Infcode == -1 {
  7266. c.ServeSuccessJSON(map[string]interface{}{
  7267. "failed_code": -10,
  7268. "msg": res.ErrMsg,
  7269. })
  7270. return
  7271. } else {
  7272. c.ServeSuccessJSON(map[string]interface{}{
  7273. "info": res.Output,
  7274. })
  7275. }
  7276. }
  7277. func (c *HisApiController) GetCFYLJG004() {
  7278. admin_user_id, _ := c.GetInt64("admin_user_id")
  7279. his_patient_id, _ := c.GetInt64("his_patient_id")
  7280. record_time := c.GetString("record_time")
  7281. admin_user_id = 3626
  7282. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7283. //id, _ := c.GetInt64("id")
  7284. admin_user_id = 3626
  7285. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7286. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7287. flow, _ := service.Getflowtwo(his.Number)
  7288. //id = 3
  7289. patient_id, _ := c.GetInt64("patient_id")
  7290. //patient_id = 23834
  7291. //record_time = "2023-09-18"
  7292. timeLayout := "2006-01-02"
  7293. loc, _ := time.LoadLocation("Local")
  7294. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7295. if err != nil {
  7296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7297. return
  7298. }
  7299. recordDateTime := theTime.Unix()
  7300. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7301. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7302. var cFYLJG004 models.CFYLJG004
  7303. cFYLJG004.HiRxno = flow.HiRxno
  7304. cFYLJG004.FixmedinsCode = miConfig.Code
  7305. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7306. cFYLJG004.UndoDrCertType = "01"
  7307. cFYLJG004.UndoRea = "撤销处方"
  7308. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7309. cFYLJG004.UndoDrName = doctor_info.UserName
  7310. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7311. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7312. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7313. var res ResultCFYLJG004
  7314. var respJSON2 map[string]interface{}
  7315. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7318. return
  7319. }
  7320. userJSONBytes2, _ := json.Marshal(respJSON2)
  7321. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7322. utils.ErrorLog("解析失败:%v", err)
  7323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7324. return
  7325. }
  7326. if res.Infcode == -1 {
  7327. c.ServeSuccessJSON(map[string]interface{}{
  7328. "failed_code": -10,
  7329. "msg": res.ErrMsg,
  7330. })
  7331. return
  7332. } else {
  7333. flow.Status = 0
  7334. service.Saveflow(flow)
  7335. c.ServeSuccessJSON(map[string]interface{}{
  7336. "msg": "撤销成功",
  7337. })
  7338. return
  7339. }
  7340. }
  7341. func (c *HisApiController) GetCFYLJG005() {
  7342. admin_user_id, _ := c.GetInt64("admin_user_id")
  7343. his_patient_id, _ := c.GetInt64("his_patient_id")
  7344. //record_time := c.GetString("record_time")
  7345. admin_user_id = 3626
  7346. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7347. //id, _ := c.GetInt64("id")
  7348. admin_user_id = 3626
  7349. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7350. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7351. flow, _ := service.Getflowtwo(his.Number)
  7352. //id = 3
  7353. var cFYLJG005 models.CFYLJG005
  7354. //patient_id, _ := c.GetInt64("patient_id")
  7355. cFYLJG005.HiRxno = flow.HiRxno
  7356. cFYLJG005.MdtrtID = flow.MID
  7357. cFYLJG005.EcToken = ""
  7358. cFYLJG005.PsnName = his.Name
  7359. cFYLJG005.PsnCertType = "01"
  7360. cFYLJG005.Certno = his.IdCardNo
  7361. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7362. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7363. var res ResultCFYLJG005
  7364. var respJSON2 map[string]interface{}
  7365. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7368. return
  7369. }
  7370. userJSONBytes2, _ := json.Marshal(respJSON2)
  7371. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7372. utils.ErrorLog("解析失败:%v", err)
  7373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7374. return
  7375. }
  7376. if res.Infcode == -1 {
  7377. c.ServeSuccessJSON(map[string]interface{}{
  7378. "failed_code": -10,
  7379. "msg": res.ErrMsg,
  7380. })
  7381. return
  7382. } else {
  7383. c.ServeSuccessJSON(map[string]interface{}{
  7384. "info": res.Output,
  7385. })
  7386. return
  7387. }
  7388. }
  7389. func (c *HisApiController) GetCFYLJG006() {
  7390. admin_user_id, _ := c.GetInt64("admin_user_id")
  7391. his_patient_id, _ := c.GetInt64("his_patient_id")
  7392. admin_user_id = 3626
  7393. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7394. //id, _ := c.GetInt64("id")
  7395. admin_user_id = 3626
  7396. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7397. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7398. flow, _ := service.Getflowtwo(his.Number)
  7399. //id = 3
  7400. patient_id, _ := c.GetInt64("patient_id")
  7401. var cFYLJG006 models.CFYLJG006
  7402. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7403. cFYLJG006.HiRxno = flow.HiRxno
  7404. cFYLJG006.MdtrtID = flow.MID
  7405. cFYLJG006.PsnName = patient.Name
  7406. cFYLJG006.PsnCertType = "01"
  7407. cFYLJG006.Certno = patient.IdCardNo
  7408. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  7409. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  7410. var res ResultCFYLJG006
  7411. var respJSON2 map[string]interface{}
  7412. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7415. return
  7416. }
  7417. userJSONBytes2, _ := json.Marshal(respJSON2)
  7418. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7419. utils.ErrorLog("解析失败:%v", err)
  7420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7421. return
  7422. }
  7423. if res.Infcode == -1 {
  7424. c.ServeSuccessJSON(map[string]interface{}{
  7425. "failed_code": -10,
  7426. "msg": res.ErrMsg,
  7427. })
  7428. return
  7429. } else {
  7430. c.ServeSuccessJSON(map[string]interface{}{
  7431. "info": res.Output,
  7432. })
  7433. return
  7434. }
  7435. }
  7436. func (c *HisApiController) GetCFYLJG007() {
  7437. admin_user_id, _ := c.GetInt64("admin_user_id")
  7438. his_patient_id, _ := c.GetInt64("his_patient_id")
  7439. admin_user_id = 3626
  7440. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7441. //id, _ := c.GetInt64("id")
  7442. admin_user_id = 3626
  7443. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7444. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7445. flow, _ := service.Getflowtwo(his.Number)
  7446. //id = 3
  7447. patient_id, _ := c.GetInt64("patient_id")
  7448. var cFYLJG007 models.CFYLJG007
  7449. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7450. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7451. cFYLJG007.HiRxno = flow.HiRxno
  7452. cFYLJG007.MdtrtID = flow.MID
  7453. cFYLJG007.PsnNo = his.PsnNo
  7454. cFYLJG007.PsnCertType = "01"
  7455. cFYLJG007.Certno = patient.IdCardNo
  7456. cFYLJG007.PsnName = patient.Name
  7457. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  7458. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  7459. var res ResultCFYLJG007
  7460. var respJSON2 map[string]interface{}
  7461. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7464. return
  7465. }
  7466. userJSONBytes2, _ := json.Marshal(respJSON2)
  7467. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7468. utils.ErrorLog("解析失败:%v", err)
  7469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7470. return
  7471. }
  7472. if res.Infcode == -1 {
  7473. c.ServeSuccessJSON(map[string]interface{}{
  7474. "failed_code": -10,
  7475. "msg": res.ErrMsg,
  7476. })
  7477. return
  7478. } else {
  7479. c.ServeSuccessJSON(map[string]interface{}{
  7480. "info": res,
  7481. })
  7482. return
  7483. }
  7484. }
  7485. func (c *HisApiController) GetCFYLJG008() {
  7486. admin_user_id, _ := c.GetInt64("admin_user_id")
  7487. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7488. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7489. var cFYLJG008 models.CFYLJG008
  7490. //id, _ := c.GetInt64("id")
  7491. patient_id, _ := c.GetInt64("patient_id")
  7492. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7493. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7494. //id = 3
  7495. //flow, _ := service.Getflow(id)
  7496. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7497. //
  7498. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7499. //patient_id, _ := c.GetInt64("patient_id")
  7500. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7501. record_time := c.GetString("record_time")
  7502. admin_user_id = 3626
  7503. patient_id = 19424
  7504. //his_patient_id = 263947
  7505. record_time = "2023-08-29"
  7506. timeLayout := "2006-01-02"
  7507. loc, _ := time.LoadLocation("Local")
  7508. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7509. if err != nil {
  7510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7511. return
  7512. }
  7513. recordDateTime := theTime.Unix()
  7514. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7515. cFYLJG008.FixmedinsName = ""
  7516. cFYLJG008.Lat = ""
  7517. cFYLJG008.Lng = ""
  7518. cFYLJG008.OrderType = "1"
  7519. cFYLJG008.PoolareaNo = ""
  7520. cFYLJG008.Lng = ""
  7521. cFYLJG008.PageNum = 1
  7522. cFYLJG008.PageSize = 10
  7523. var MPI models.MedinsProdInvChgDDTO
  7524. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  7525. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  7526. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  7527. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  7528. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  7529. var res ResultCFYLJG008
  7530. var respJSON2 map[string]interface{}
  7531. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7534. return
  7535. }
  7536. userJSONBytes2, _ := json.Marshal(respJSON2)
  7537. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7538. utils.ErrorLog("解析失败:%v", err)
  7539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7540. return
  7541. }
  7542. if res.Infcode == -1 {
  7543. c.ServeSuccessJSON(map[string]interface{}{
  7544. "failed_code": -10,
  7545. "msg": res.ErrMsg,
  7546. })
  7547. return
  7548. } else {
  7549. c.ServeSuccessJSON(map[string]interface{}{
  7550. "info": res.Output,
  7551. })
  7552. return
  7553. }
  7554. }
  7555. func (c *HisApiController) GetBL4201A() {
  7556. order_id, _ := c.GetInt64("order_id")
  7557. admin_user_id, _ := c.GetInt64("admin_user_id")
  7558. order, _ := service.GetHisOrderByIDTwo(order_id)
  7559. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7560. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  7561. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  7562. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7563. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7564. department, _ := service.GetDepartMentDetail(his.Departments)
  7565. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7566. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7567. if order.ID == 0 {
  7568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7569. return
  7570. }
  7571. var struct4201A models.Struct4201A
  7572. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  7573. for _, items := range order_info {
  7574. memo := make(map[string]interface{})
  7575. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7576. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7577. fsiOPFLD.MedType = "14"
  7578. fsiOPFLD.BkkpSn = items.FeedetlSn
  7579. fsiOPFLD.FixmedinsCode = miConfig.Code
  7580. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7581. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7582. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7583. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7584. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7585. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7586. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7587. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7588. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7589. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7590. fsiOPFLD.BilgDeptName = department.Name
  7591. fsiOPFLD.BilgDeptCodg = department.Number
  7592. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7593. fsiOPFLD.BilgDrName = doctor.UserName
  7594. fsiOPFLD.MedChrgitmType = "09"
  7595. memo["hosp_appr_flag"] = "1"
  7596. memo["invoice_no"] = order.MdtrtId
  7597. memo["memo"] = "自费"
  7598. bytesData, _ := json.Marshal(memo)
  7599. fsiOPFLD.Memo = string(bytesData)
  7600. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7601. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7602. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7603. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7604. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7605. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7606. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7607. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7608. fsiOPFLD.BilgDeptName = department.Name
  7609. fsiOPFLD.BilgDeptCodg = department.Number
  7610. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7611. fsiOPFLD.BilgDrName = doctor.UserName
  7612. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7613. case 0:
  7614. break
  7615. case 1:
  7616. fsiOPFLD.MedChrgitmType = "14"
  7617. break
  7618. case 2:
  7619. fsiOPFLD.MedChrgitmType = "05"
  7620. break
  7621. case 3:
  7622. fsiOPFLD.MedChrgitmType = "03"
  7623. break
  7624. case 4:
  7625. fsiOPFLD.MedChrgitmType = "03"
  7626. break
  7627. case 5:
  7628. fsiOPFLD.MedChrgitmType = "08"
  7629. break
  7630. case 6:
  7631. fsiOPFLD.MedChrgitmType = "14"
  7632. break
  7633. case 7:
  7634. fsiOPFLD.MedChrgitmType = "14"
  7635. break
  7636. case 8:
  7637. fsiOPFLD.MedChrgitmType = "03"
  7638. break
  7639. case 9:
  7640. fsiOPFLD.MedChrgitmType = "14"
  7641. break
  7642. case 10:
  7643. fsiOPFLD.MedChrgitmType = "14"
  7644. break
  7645. case 11:
  7646. fsiOPFLD.MedChrgitmType = "06"
  7647. break
  7648. case 12:
  7649. fsiOPFLD.MedChrgitmType = "12"
  7650. break
  7651. case 13:
  7652. fsiOPFLD.MedChrgitmType = "01"
  7653. break
  7654. case 14:
  7655. fsiOPFLD.MedChrgitmType = "04"
  7656. break
  7657. case 15:
  7658. fsiOPFLD.MedChrgitmType = "14"
  7659. break
  7660. }
  7661. memo["hosp_appr_flag"] = "1"
  7662. memo["invoice_no"] = order.MdtrtId
  7663. memo["memo"] = "自费"
  7664. bytesData, _ := json.Marshal(memo)
  7665. fsiOPFLD.Memo = string(bytesData)
  7666. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7667. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  7668. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7669. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7670. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7671. fsiOPFLD.BilgDeptName = department.Name
  7672. fsiOPFLD.BilgDeptCodg = department.Number
  7673. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7674. fsiOPFLD.BilgDrName = doctor.UserName
  7675. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7676. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7677. fsiOPFLD.MedChrgitmType = "08"
  7678. memo["hosp_appr_flag"] = "1"
  7679. memo["invoice_no"] = order.MdtrtId
  7680. memo["memo"] = "自费"
  7681. bytesData, _ := json.Marshal(memo)
  7682. fsiOPFLD.Memo = string(bytesData)
  7683. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7684. }
  7685. }
  7686. }
  7687. for _, items := range order_info_two {
  7688. memo := make(map[string]interface{})
  7689. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7690. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7691. fsiOPFLD.MedType = "14"
  7692. fsiOPFLD.BkkpSn = items.FeedetlSn
  7693. fsiOPFLD.FixmedinsCode = miConfig.Code
  7694. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7695. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7696. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7697. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7698. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7699. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7700. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7701. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7702. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7703. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7704. fsiOPFLD.BilgDeptName = department.Name
  7705. fsiOPFLD.BilgDeptCodg = department.Number
  7706. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7707. fsiOPFLD.BilgDrName = doctor.UserName
  7708. fsiOPFLD.MedChrgitmType = "09"
  7709. memo["hosp_appr_flag"] = "1"
  7710. memo["invoice_no"] = order.MdtrtId
  7711. memo["memo"] = "自费"
  7712. bytesData, _ := json.Marshal(memo)
  7713. fsiOPFLD.Memo = string(bytesData)
  7714. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7715. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7716. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7717. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7718. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7719. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7720. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7721. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7722. fsiOPFLD.BilgDeptName = department.Name
  7723. fsiOPFLD.BilgDeptCodg = department.Number
  7724. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7725. fsiOPFLD.BilgDrName = doctor.UserName
  7726. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7727. case 0:
  7728. break
  7729. case 1:
  7730. fsiOPFLD.MedChrgitmType = "14"
  7731. break
  7732. case 2:
  7733. fsiOPFLD.MedChrgitmType = "05"
  7734. break
  7735. case 3:
  7736. fsiOPFLD.MedChrgitmType = "03"
  7737. break
  7738. case 4:
  7739. fsiOPFLD.MedChrgitmType = "03"
  7740. break
  7741. case 5:
  7742. fsiOPFLD.MedChrgitmType = "08"
  7743. break
  7744. case 6:
  7745. fsiOPFLD.MedChrgitmType = "14"
  7746. break
  7747. case 7:
  7748. fsiOPFLD.MedChrgitmType = "14"
  7749. break
  7750. case 8:
  7751. fsiOPFLD.MedChrgitmType = "03"
  7752. break
  7753. case 9:
  7754. fsiOPFLD.MedChrgitmType = "14"
  7755. break
  7756. case 10:
  7757. fsiOPFLD.MedChrgitmType = "14"
  7758. break
  7759. case 11:
  7760. fsiOPFLD.MedChrgitmType = "06"
  7761. break
  7762. case 12:
  7763. fsiOPFLD.MedChrgitmType = "12"
  7764. break
  7765. case 13:
  7766. fsiOPFLD.MedChrgitmType = "01"
  7767. break
  7768. case 14:
  7769. fsiOPFLD.MedChrgitmType = "04"
  7770. break
  7771. case 15:
  7772. fsiOPFLD.MedChrgitmType = "14"
  7773. break
  7774. }
  7775. memo["hosp_appr_flag"] = "1"
  7776. memo["invoice_no"] = order.MdtrtId
  7777. memo["memo"] = "自费"
  7778. bytesData, _ := json.Marshal(memo)
  7779. fsiOPFLD.Memo = string(bytesData)
  7780. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7781. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  7782. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7783. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7784. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7785. fsiOPFLD.BilgDeptName = department.Name
  7786. fsiOPFLD.BilgDeptCodg = department.Number
  7787. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7788. fsiOPFLD.BilgDrName = doctor.UserName
  7789. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7790. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7791. fsiOPFLD.MedChrgitmType = "08"
  7792. memo["hosp_appr_flag"] = "1"
  7793. memo["invoice_no"] = order.MdtrtId
  7794. memo["memo"] = "自费"
  7795. bytesData, _ := json.Marshal(memo)
  7796. fsiOPFLD.Memo = string(bytesData)
  7797. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7798. }
  7799. }
  7800. }
  7801. fmt.Println(fsiOPFLDs)
  7802. struct4201A.Fopfd = fsiOPFLDs
  7803. fmt.Println(struct4201A.Fopfd)
  7804. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  7805. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  7806. var res2 ResultSix
  7807. var respJSON2 map[string]interface{}
  7808. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7811. return
  7812. }
  7813. userJSONBytes2, _ := json.Marshal(respJSON2)
  7814. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7815. utils.ErrorLog("解析失败:%v", err)
  7816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7817. return
  7818. }
  7819. if res2.Infcode != 0 {
  7820. c.ServeSuccessJSON(map[string]interface{}{
  7821. "failed_code": -10,
  7822. "msg": res2.ErrMsg,
  7823. })
  7824. return
  7825. } else {
  7826. order.IsUploadOrderInfo = 1
  7827. service.UpdateOrder(order)
  7828. c.ServeSuccessJSON(map[string]interface{}{
  7829. "msg": "上传成功",
  7830. })
  7831. }
  7832. }
  7833. func (c *HisApiController) Get2505() {
  7834. admin_user_id, _ := c.GetInt64("admin_user_id")
  7835. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  7836. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7837. 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)
  7838. }
  7839. func (c *HisApiController) Get4201A() {
  7840. order_id, _ := c.GetInt64("order_id")
  7841. admin_user_id, _ := c.GetInt64("admin_user_id")
  7842. order, _ := service.GetHisOrderByIDTwo(order_id)
  7843. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7844. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  7845. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  7846. //order_info = append(order_info, order_info_two...)
  7847. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7848. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7849. department, _ := service.GetDepartMentDetail(his.Departments)
  7850. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7851. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7852. if order.ID == 0 {
  7853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7854. return
  7855. }
  7856. var struct4201A models.Struct4201A
  7857. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  7858. for _, items := range order_info {
  7859. memo := make(map[string]interface{})
  7860. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7861. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7862. fsiOPFLD.MedType = "14"
  7863. fsiOPFLD.BkkpSn = items.FeedetlSn
  7864. fsiOPFLD.FixmedinsCode = miConfig.Code
  7865. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7866. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7867. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7868. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7869. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7870. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7871. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7872. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7873. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7874. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7875. fsiOPFLD.BilgDeptName = department.Name
  7876. fsiOPFLD.BilgDeptCodg = department.Number
  7877. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7878. fsiOPFLD.BilgDrName = doctor.UserName
  7879. fsiOPFLD.MedChrgitmType = "09"
  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. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7887. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7888. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7889. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7890. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7891. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7892. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7893. fsiOPFLD.BilgDeptName = department.Name
  7894. fsiOPFLD.BilgDeptCodg = department.Number
  7895. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7896. fsiOPFLD.BilgDrName = doctor.UserName
  7897. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7898. case 0:
  7899. break
  7900. case 1:
  7901. fsiOPFLD.MedChrgitmType = "14"
  7902. break
  7903. case 2:
  7904. fsiOPFLD.MedChrgitmType = "05"
  7905. break
  7906. case 3:
  7907. fsiOPFLD.MedChrgitmType = "03"
  7908. break
  7909. case 4:
  7910. fsiOPFLD.MedChrgitmType = "03"
  7911. break
  7912. case 5:
  7913. fsiOPFLD.MedChrgitmType = "08"
  7914. break
  7915. case 6:
  7916. fsiOPFLD.MedChrgitmType = "14"
  7917. break
  7918. case 7:
  7919. fsiOPFLD.MedChrgitmType = "14"
  7920. break
  7921. case 8:
  7922. fsiOPFLD.MedChrgitmType = "03"
  7923. break
  7924. case 9:
  7925. fsiOPFLD.MedChrgitmType = "14"
  7926. break
  7927. case 10:
  7928. fsiOPFLD.MedChrgitmType = "14"
  7929. break
  7930. case 11:
  7931. fsiOPFLD.MedChrgitmType = "06"
  7932. break
  7933. case 12:
  7934. fsiOPFLD.MedChrgitmType = "12"
  7935. break
  7936. case 13:
  7937. fsiOPFLD.MedChrgitmType = "01"
  7938. break
  7939. case 14:
  7940. fsiOPFLD.MedChrgitmType = "04"
  7941. break
  7942. case 15:
  7943. fsiOPFLD.MedChrgitmType = "14"
  7944. break
  7945. }
  7946. memo["hosp_appr_flag"] = "1"
  7947. memo["invoice_no"] = order.MdtrtId
  7948. memo["memo"] = "自费"
  7949. bytesData, _ := json.Marshal(memo)
  7950. fsiOPFLD.Memo = string(bytesData)
  7951. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7952. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  7953. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7954. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7955. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7956. fsiOPFLD.BilgDeptName = department.Name
  7957. fsiOPFLD.BilgDeptCodg = department.Number
  7958. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7959. fsiOPFLD.BilgDrName = doctor.UserName
  7960. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7961. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7962. fsiOPFLD.MedChrgitmType = "08"
  7963. memo["hosp_appr_flag"] = "1"
  7964. memo["invoice_no"] = order.MdtrtId
  7965. memo["memo"] = "自费"
  7966. bytesData, _ := json.Marshal(memo)
  7967. fsiOPFLD.Memo = string(bytesData)
  7968. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7969. }
  7970. }
  7971. }
  7972. for _, items := range order_info_two {
  7973. memo := make(map[string]interface{})
  7974. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7975. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7976. fsiOPFLD.MedType = "14"
  7977. fsiOPFLD.BkkpSn = items.FeedetlSn
  7978. fsiOPFLD.FixmedinsCode = miConfig.Code
  7979. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7980. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7981. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7982. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7983. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7984. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7985. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7986. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7987. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7988. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7989. fsiOPFLD.BilgDeptName = department.Name
  7990. fsiOPFLD.BilgDeptCodg = department.Number
  7991. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7992. fsiOPFLD.BilgDrName = doctor.UserName
  7993. fsiOPFLD.MedChrgitmType = "09"
  7994. memo["hosp_appr_flag"] = "1"
  7995. memo["invoice_no"] = order.MdtrtId
  7996. memo["memo"] = "自费"
  7997. bytesData, _ := json.Marshal(memo)
  7998. fsiOPFLD.Memo = string(bytesData)
  7999. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8000. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8001. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8002. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8003. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8004. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8005. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8006. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8007. fsiOPFLD.BilgDeptName = department.Name
  8008. fsiOPFLD.BilgDeptCodg = department.Number
  8009. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8010. fsiOPFLD.BilgDrName = doctor.UserName
  8011. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8012. case 0:
  8013. break
  8014. case 1:
  8015. fsiOPFLD.MedChrgitmType = "14"
  8016. break
  8017. case 2:
  8018. fsiOPFLD.MedChrgitmType = "05"
  8019. break
  8020. case 3:
  8021. fsiOPFLD.MedChrgitmType = "03"
  8022. break
  8023. case 4:
  8024. fsiOPFLD.MedChrgitmType = "03"
  8025. break
  8026. case 5:
  8027. fsiOPFLD.MedChrgitmType = "08"
  8028. break
  8029. case 6:
  8030. fsiOPFLD.MedChrgitmType = "14"
  8031. break
  8032. case 7:
  8033. fsiOPFLD.MedChrgitmType = "14"
  8034. break
  8035. case 8:
  8036. fsiOPFLD.MedChrgitmType = "03"
  8037. break
  8038. case 9:
  8039. fsiOPFLD.MedChrgitmType = "14"
  8040. break
  8041. case 10:
  8042. fsiOPFLD.MedChrgitmType = "14"
  8043. break
  8044. case 11:
  8045. fsiOPFLD.MedChrgitmType = "06"
  8046. break
  8047. case 12:
  8048. fsiOPFLD.MedChrgitmType = "12"
  8049. break
  8050. case 13:
  8051. fsiOPFLD.MedChrgitmType = "01"
  8052. break
  8053. case 14:
  8054. fsiOPFLD.MedChrgitmType = "04"
  8055. break
  8056. case 15:
  8057. fsiOPFLD.MedChrgitmType = "14"
  8058. break
  8059. }
  8060. memo["hosp_appr_flag"] = "1"
  8061. memo["invoice_no"] = order.MdtrtId
  8062. memo["memo"] = "自费"
  8063. bytesData, _ := json.Marshal(memo)
  8064. fsiOPFLD.Memo = string(bytesData)
  8065. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8066. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8067. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8068. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8069. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8070. fsiOPFLD.BilgDeptName = department.Name
  8071. fsiOPFLD.BilgDeptCodg = department.Number
  8072. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8073. fsiOPFLD.BilgDrName = doctor.UserName
  8074. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8075. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8076. fsiOPFLD.MedChrgitmType = "08"
  8077. memo["hosp_appr_flag"] = "1"
  8078. memo["invoice_no"] = order.MdtrtId
  8079. memo["memo"] = "自费"
  8080. bytesData, _ := json.Marshal(memo)
  8081. fsiOPFLD.Memo = string(bytesData)
  8082. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8083. }
  8084. }
  8085. }
  8086. fmt.Println(fsiOPFLDs)
  8087. struct4201A.Fopfd = fsiOPFLDs
  8088. fmt.Println(struct4201A.Fopfd)
  8089. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8090. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8091. var res2 ResultSix
  8092. var respJSON2 map[string]interface{}
  8093. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8096. return
  8097. }
  8098. userJSONBytes2, _ := json.Marshal(respJSON2)
  8099. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8100. utils.ErrorLog("解析失败:%v", err)
  8101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8102. return
  8103. }
  8104. if res2.Infcode != 0 {
  8105. c.ServeSuccessJSON(map[string]interface{}{
  8106. "failed_code": -10,
  8107. "msg": res2.ErrMsg,
  8108. })
  8109. return
  8110. } else {
  8111. order.IsUploadOrderInfo = 1
  8112. service.UpdateOrder(order)
  8113. c.ServeSuccessJSON(map[string]interface{}{
  8114. "msg": "上传成功",
  8115. })
  8116. }
  8117. }
  8118. func (c *HisApiController) Get4202() {
  8119. order_id, _ := c.GetInt64("order_id")
  8120. admin_user_id, _ := c.GetInt64("admin_user_id")
  8121. order, _ := service.GetHisOrderByIDTwo(order_id)
  8122. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8123. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8124. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8125. if order.ID == 0 {
  8126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8127. return
  8128. }
  8129. var struct4202 models.Struct4202
  8130. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8131. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8132. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8133. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8134. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8135. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8136. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8137. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8138. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8139. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8140. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8141. var config []*models.HisXtDiagnoseConfig
  8142. for _, item := range diagnosis_ids {
  8143. id, _ := strconv.ParseInt(item, 10, 64)
  8144. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8145. config = append(config, &diagnosisConfig)
  8146. }
  8147. var tempDiaginfos []models.OwnPayPatnDiagListD
  8148. for index, item := range config {
  8149. if index == 0 {
  8150. var tempDiaginfo models.OwnPayPatnDiagListD
  8151. tempDiaginfo.InoutDiagType = "1"
  8152. tempDiaginfo.DiagCode = item.CountryCode
  8153. tempDiaginfo.DiagName = item.CountryContentName
  8154. tempDiaginfo.DiagType = "1"
  8155. tempDiaginfo.DiagSrtNo = "1"
  8156. tempDiaginfo.MaindiagFlag = "1"
  8157. tempDiaginfo.ValiFlag = "1"
  8158. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8159. } else {
  8160. var tempDiaginfo models.OwnPayPatnDiagListD
  8161. tempDiaginfo.DiagCode = item.CountryCode
  8162. tempDiaginfo.DiagName = item.CountryContentName
  8163. tempDiaginfo.DiagType = "2"
  8164. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8165. tempDiaginfo.MaindiagFlag = "0"
  8166. tempDiaginfo.ValiFlag = "1"
  8167. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8168. }
  8169. }
  8170. struct4202.ODiagListD = tempDiaginfos
  8171. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8172. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8173. var res2 ResultSix
  8174. var respJSON2 map[string]interface{}
  8175. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8178. return
  8179. }
  8180. userJSONBytes2, _ := json.Marshal(respJSON2)
  8181. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8182. utils.ErrorLog("解析失败:%v", err)
  8183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8184. return
  8185. }
  8186. if res2.Infcode != 0 {
  8187. c.ServeSuccessJSON(map[string]interface{}{
  8188. "failed_code": -10,
  8189. "msg": res2.ErrMsg,
  8190. })
  8191. return
  8192. } else {
  8193. order.IsUploadDiagnose = 1
  8194. service.UpdateOrder(order)
  8195. c.ServeSuccessJSON(map[string]interface{}{
  8196. "msg": "上传成功",
  8197. })
  8198. }
  8199. }
  8200. func (c *HisApiController) Get4203() {
  8201. admin_user_id, _ := c.GetInt64("admin_user_id")
  8202. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8203. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8204. order_id, _ := c.GetInt64("order_id")
  8205. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8206. number := ""
  8207. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8208. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8209. if his.ID == 0 {
  8210. number = hospital.Number
  8211. } else {
  8212. number = his.Number
  8213. }
  8214. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8215. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8216. var res2 ResultSix
  8217. var respJSON2 map[string]interface{}
  8218. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8221. return
  8222. }
  8223. userJSONBytes2, _ := json.Marshal(respJSON2)
  8224. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8225. utils.ErrorLog("解析失败:%v", err)
  8226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8227. return
  8228. }
  8229. if res2.Infcode != 0 {
  8230. c.ServeSuccessJSON(map[string]interface{}{
  8231. "failed_code": -10,
  8232. "msg": res2.ErrMsg,
  8233. })
  8234. return
  8235. } else {
  8236. order.IsUploadSuccess = 1
  8237. service.UpdateOrderTwo(order)
  8238. c.ServeSuccessJSON(map[string]interface{}{
  8239. "msg": "上传成功",
  8240. })
  8241. }
  8242. }
  8243. func (c *HisApiController) Get4205() {
  8244. order_id, _ := c.GetInt64("order_id")
  8245. admin_user_id, _ := c.GetInt64("admin_user_id")
  8246. fapiao_code := c.GetString("fapiao_code")
  8247. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8248. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8249. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8250. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8251. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8252. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8253. //order_info = append(order_info, order_info_two...)
  8254. department, _ := service.GetDepartMentDetail(his.Departments)
  8255. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8256. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8257. if order.ID == 0 {
  8258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8259. return
  8260. }
  8261. var struct4201A models.Struct4201A
  8262. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8263. for _, items := range order_info {
  8264. memo := make(map[string]interface{})
  8265. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8266. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8267. fsiOPFLD.MedType = pre.MedType
  8268. fsiOPFLD.FixmedinsCode = miConfig.Code
  8269. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8270. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8271. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8272. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8273. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8274. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8275. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8276. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8277. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8278. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8279. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8280. fsiOPFLD.BilgDeptName = department.Name
  8281. fsiOPFLD.BilgDeptCodg = department.Number
  8282. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8283. fsiOPFLD.BilgDrName = doctor.UserName
  8284. fsiOPFLD.MedChrgitmType = "09"
  8285. memo["hosp_appr_flag"] = "1"
  8286. memo["invoice_no"] = fapiao_code
  8287. memo["memo"] = "自费"
  8288. bytesData, _ := json.Marshal(memo)
  8289. fsiOPFLD.Memo = string(bytesData)
  8290. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8291. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8292. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8293. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8294. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8295. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8296. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8297. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8298. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8299. fsiOPFLD.BilgDeptName = department.Name
  8300. fsiOPFLD.BilgDeptCodg = department.Number
  8301. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8302. fsiOPFLD.BilgDrName = doctor.UserName
  8303. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8304. case 0:
  8305. break
  8306. case 1:
  8307. fsiOPFLD.MedChrgitmType = "14"
  8308. break
  8309. case 2:
  8310. fsiOPFLD.MedChrgitmType = "05"
  8311. break
  8312. case 3:
  8313. fsiOPFLD.MedChrgitmType = "03"
  8314. break
  8315. case 4:
  8316. fsiOPFLD.MedChrgitmType = "03"
  8317. break
  8318. case 5:
  8319. fsiOPFLD.MedChrgitmType = "08"
  8320. break
  8321. case 6:
  8322. fsiOPFLD.MedChrgitmType = "14"
  8323. break
  8324. case 7:
  8325. fsiOPFLD.MedChrgitmType = "14"
  8326. break
  8327. case 8:
  8328. fsiOPFLD.MedChrgitmType = "03"
  8329. break
  8330. case 9:
  8331. fsiOPFLD.MedChrgitmType = "14"
  8332. break
  8333. case 10:
  8334. fsiOPFLD.MedChrgitmType = "14"
  8335. break
  8336. case 11:
  8337. fsiOPFLD.MedChrgitmType = "06"
  8338. break
  8339. case 12:
  8340. fsiOPFLD.MedChrgitmType = "12"
  8341. break
  8342. case 13:
  8343. fsiOPFLD.MedChrgitmType = "01"
  8344. break
  8345. case 14:
  8346. fsiOPFLD.MedChrgitmType = "04"
  8347. break
  8348. case 15:
  8349. fsiOPFLD.MedChrgitmType = "14"
  8350. break
  8351. }
  8352. memo["hosp_appr_flag"] = "1"
  8353. memo["invoice_no"] = fapiao_code
  8354. memo["memo"] = "自费"
  8355. bytesData, _ := json.Marshal(memo)
  8356. fsiOPFLD.Memo = string(bytesData)
  8357. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8358. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8359. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8360. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8361. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8362. fsiOPFLD.BilgDeptName = department.Name
  8363. fsiOPFLD.BilgDeptCodg = department.Number
  8364. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8365. fsiOPFLD.BilgDrName = doctor.UserName
  8366. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8367. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8368. fsiOPFLD.MedChrgitmType = "08"
  8369. memo["hosp_appr_flag"] = "1"
  8370. memo["invoice_no"] = fapiao_code
  8371. memo["memo"] = "自费"
  8372. bytesData, _ := json.Marshal(memo)
  8373. fsiOPFLD.Memo = string(bytesData)
  8374. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8375. }
  8376. }
  8377. }
  8378. for _, items := range order_info_two {
  8379. memo := make(map[string]interface{})
  8380. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8381. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8382. fsiOPFLD.MedType = pre.MedType
  8383. fsiOPFLD.BkkpSn = items.FeedetlSn
  8384. fsiOPFLD.FixmedinsCode = miConfig.Code
  8385. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8386. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8387. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8388. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8389. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8390. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8391. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8392. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8393. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8394. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8395. fsiOPFLD.BilgDeptName = department.Name
  8396. fsiOPFLD.BilgDeptCodg = department.Number
  8397. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8398. fsiOPFLD.BilgDrName = doctor.UserName
  8399. fsiOPFLD.MedChrgitmType = "09"
  8400. memo["hosp_appr_flag"] = "1"
  8401. memo["invoice_no"] = fapiao_code
  8402. memo["memo"] = "自费"
  8403. bytesData, _ := json.Marshal(memo)
  8404. fsiOPFLD.Memo = string(bytesData)
  8405. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8406. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8407. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8408. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8409. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8410. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8411. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8412. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8413. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8414. fsiOPFLD.BilgDeptName = department.Name
  8415. fsiOPFLD.BilgDeptCodg = department.Number
  8416. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8417. fsiOPFLD.BilgDrName = doctor.UserName
  8418. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8419. case 0:
  8420. break
  8421. case 1:
  8422. fsiOPFLD.MedChrgitmType = "14"
  8423. break
  8424. case 2:
  8425. fsiOPFLD.MedChrgitmType = "05"
  8426. break
  8427. case 3:
  8428. fsiOPFLD.MedChrgitmType = "03"
  8429. break
  8430. case 4:
  8431. fsiOPFLD.MedChrgitmType = "03"
  8432. break
  8433. case 5:
  8434. fsiOPFLD.MedChrgitmType = "08"
  8435. break
  8436. case 6:
  8437. fsiOPFLD.MedChrgitmType = "14"
  8438. break
  8439. case 7:
  8440. fsiOPFLD.MedChrgitmType = "14"
  8441. break
  8442. case 8:
  8443. fsiOPFLD.MedChrgitmType = "03"
  8444. break
  8445. case 9:
  8446. fsiOPFLD.MedChrgitmType = "14"
  8447. break
  8448. case 10:
  8449. fsiOPFLD.MedChrgitmType = "14"
  8450. break
  8451. case 11:
  8452. fsiOPFLD.MedChrgitmType = "06"
  8453. break
  8454. case 12:
  8455. fsiOPFLD.MedChrgitmType = "12"
  8456. break
  8457. case 13:
  8458. fsiOPFLD.MedChrgitmType = "01"
  8459. break
  8460. case 14:
  8461. fsiOPFLD.MedChrgitmType = "04"
  8462. break
  8463. case 15:
  8464. fsiOPFLD.MedChrgitmType = "14"
  8465. break
  8466. }
  8467. memo["hosp_appr_flag"] = "1"
  8468. memo["invoice_no"] = fapiao_code
  8469. memo["memo"] = "自费"
  8470. bytesData, _ := json.Marshal(memo)
  8471. fsiOPFLD.Memo = string(bytesData)
  8472. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8473. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8474. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8475. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8476. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8477. fsiOPFLD.BilgDeptName = department.Name
  8478. fsiOPFLD.BilgDeptCodg = department.Number
  8479. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8480. fsiOPFLD.BilgDrName = doctor.UserName
  8481. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8482. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8483. fsiOPFLD.MedChrgitmType = "08"
  8484. memo["hosp_appr_flag"] = "1"
  8485. memo["invoice_no"] = fapiao_code
  8486. memo["memo"] = "自费"
  8487. bytesData, _ := json.Marshal(memo)
  8488. fsiOPFLD.Memo = string(bytesData)
  8489. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8490. }
  8491. }
  8492. }
  8493. fmt.Println(fsiOPFLDs)
  8494. struct4201A.Fopfd = fsiOPFLDs
  8495. fmt.Println(struct4201A.Fopfd)
  8496. var struct4202 models.Struct4202
  8497. timeLayout := "2006-01-02 15:04:05"
  8498. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  8499. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8500. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8501. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8502. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8503. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8504. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8505. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  8506. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  8507. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8508. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8509. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8510. var config []*models.HisXtDiagnoseConfig
  8511. for _, item := range diagnosis_ids {
  8512. id, _ := strconv.ParseInt(item, 10, 64)
  8513. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8514. config = append(config, &diagnosisConfig)
  8515. }
  8516. var tempDiaginfos []models.OwnPayPatnDiagListD
  8517. for index, item := range config {
  8518. if index == 0 {
  8519. var tempDiaginfo models.OwnPayPatnDiagListD
  8520. tempDiaginfo.InoutDiagType = "1"
  8521. tempDiaginfo.DiagCode = item.CountryCode
  8522. tempDiaginfo.DiagName = item.CountryContentName
  8523. tempDiaginfo.DiagType = "1"
  8524. tempDiaginfo.DiagSrtNo = "1"
  8525. tempDiaginfo.MaindiagFlag = "1"
  8526. tempDiaginfo.ValiFlag = "1"
  8527. tempDiaginfo.DiagDrName = doctor.UserName
  8528. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8529. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8530. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8531. } else {
  8532. var tempDiaginfo models.OwnPayPatnDiagListD
  8533. tempDiaginfo.DiagCode = item.CountryCode
  8534. tempDiaginfo.DiagName = item.CountryContentName
  8535. tempDiaginfo.DiagType = "2"
  8536. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8537. tempDiaginfo.MaindiagFlag = "0"
  8538. tempDiaginfo.ValiFlag = "1"
  8539. tempDiaginfo.DiagDrName = doctor.UserName
  8540. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8541. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8542. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8543. }
  8544. }
  8545. struct4202.ODiagListD = tempDiaginfos
  8546. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  8547. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  8548. var res2 ResultSix
  8549. var respJSON2 map[string]interface{}
  8550. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8553. return
  8554. }
  8555. userJSONBytes2, _ := json.Marshal(respJSON2)
  8556. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8557. utils.ErrorLog("解析失败:%v", err)
  8558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8559. return
  8560. }
  8561. if res2.Infcode != 0 {
  8562. c.ServeSuccessJSON(map[string]interface{}{
  8563. "failed_code": -10,
  8564. "msg": res2.ErrMsg,
  8565. })
  8566. return
  8567. } else {
  8568. order.IsUploadDiagnose = 1
  8569. order.IsUploadOrderInfo = 1
  8570. service.UpdateOrderTwo(order)
  8571. c.ServeSuccessJSON(map[string]interface{}{
  8572. "msg": "上传成功",
  8573. })
  8574. }
  8575. }
  8576. func (c *HisApiController) Get4207() {
  8577. admin_user_id, _ := c.GetInt64("admin_user_id")
  8578. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8579. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8580. order_id, _ := c.GetInt64("order_id")
  8581. order, _ := service.GetHisOrderByIDTwo(order_id)
  8582. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8583. var struct4207 models.Struct4207
  8584. struct4207.PageNum = "1"
  8585. struct4207.PageSize = "1000"
  8586. struct4207.FixmedinsCode = miConfig.Code
  8587. struct4207.FixmedinsMdtrtID = order.Number
  8588. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  8589. saveLog(result, requestLog, "4207", "查询")
  8590. var res2 ResultSix
  8591. var respJSON2 map[string]interface{}
  8592. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8595. return
  8596. }
  8597. userJSONBytes2, _ := json.Marshal(respJSON2)
  8598. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8599. utils.ErrorLog("解析失败:%v", err)
  8600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8601. return
  8602. }
  8603. if res2.Infcode != 0 {
  8604. c.ServeSuccessJSON(map[string]interface{}{
  8605. "failed_code": -10,
  8606. "msg": res2.ErrMsg,
  8607. })
  8608. return
  8609. } else {
  8610. c.ServeSuccessJSON(map[string]interface{}{
  8611. "msg": "查询成功",
  8612. })
  8613. }
  8614. }
  8615. func (c *HisApiController) Get4208() {
  8616. admin_user_id, _ := c.GetInt64("admin_user_id")
  8617. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8618. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8619. order_id, _ := c.GetInt64("order_id")
  8620. order, _ := service.GetHisOrderByIDTwo(order_id)
  8621. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8622. var struct4208 models.Struct4208
  8623. struct4208.PageNum = "1"
  8624. struct4208.PageSize = "1000"
  8625. struct4208.PsnCertType = "01"
  8626. struct4208.Certno = his.Certno
  8627. struct4208.MedType = order.MedType
  8628. struct4208.PsnName = his.Name
  8629. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  8630. saveLog(result, requestLog, "4208", "查询")
  8631. var res2 ResultSix
  8632. var respJSON2 map[string]interface{}
  8633. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8634. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8636. return
  8637. }
  8638. userJSONBytes2, _ := json.Marshal(respJSON2)
  8639. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8640. utils.ErrorLog("解析失败:%v", err)
  8641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8642. return
  8643. }
  8644. if res2.Infcode != 0 {
  8645. c.ServeSuccessJSON(map[string]interface{}{
  8646. "failed_code": -10,
  8647. "msg": res2.ErrMsg,
  8648. })
  8649. return
  8650. } else {
  8651. c.ServeSuccessJSON(map[string]interface{}{
  8652. "msg": "查询成功",
  8653. })
  8654. }
  8655. }
  8656. func (c *HisApiController) Get4209() {
  8657. admin_user_id, _ := c.GetInt64("admin_user_id")
  8658. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8659. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8660. order_id, _ := c.GetInt64("order_id")
  8661. order, _ := service.GetHisOrderByIDTwo(order_id)
  8662. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8663. var struct4209 models.Struct4209
  8664. struct4209.FixmedinsMdtrtID = order.Number
  8665. struct4209.FixmedinsCode = miConfig.Code
  8666. struct4209.PageSize = "1000"
  8667. struct4209.PageNum = "1"
  8668. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  8669. saveLog(result, requestLog, "4209", "查询")
  8670. var res2 ResultSix
  8671. var respJSON2 map[string]interface{}
  8672. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8675. return
  8676. }
  8677. userJSONBytes2, _ := json.Marshal(respJSON2)
  8678. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8679. utils.ErrorLog("解析失败:%v", err)
  8680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8681. return
  8682. }
  8683. if res2.Infcode != 0 {
  8684. c.ServeSuccessJSON(map[string]interface{}{
  8685. "failed_code": -10,
  8686. "msg": res2.ErrMsg,
  8687. })
  8688. return
  8689. } else {
  8690. c.ServeSuccessJSON(map[string]interface{}{
  8691. "msg": "查询成功",
  8692. })
  8693. }
  8694. }
  8695. type Result3101 struct {
  8696. Infcode string `json:"infcode"`
  8697. InfRefmsgid string `json:"inf_refmsgid"`
  8698. RefmsgTime string `json:"refmsg_time"`
  8699. RespondTime string `json:"respond_time"`
  8700. Enctype string `json:"enctype"`
  8701. Signtype string `json:"signtype"`
  8702. ErrMsg string `json:"err_msg"`
  8703. Output struct {
  8704. Result []struct {
  8705. JudgeResultDetailDtos []struct {
  8706. VolaItemType string `json:"vola_item_type"`
  8707. MdtrtID string `json:"mdtrt_id"`
  8708. JrdID string `json:"jrd_id"`
  8709. PatnID string `json:"patn_id"`
  8710. RxID string `json:"rx_id"`
  8711. VolaAmt interface{} `json:"vola_amt"`
  8712. } `json:"judge_result_detail_dtos"`
  8713. RuleID string `json:"rule_id"`
  8714. VolaEvid string `json:"vola_evid"`
  8715. MdtrtID string `json:"mdtrt_id"`
  8716. RuleName string `json:"rule_name"`
  8717. VolaAmtStas string `json:"vola_amt_stas"`
  8718. JrID string `json:"jr_id"`
  8719. PatnID string `json:"patn_id"`
  8720. SevDeg string `json:"sev_deg"`
  8721. VolaAmt float64 `json:"vola_amt"`
  8722. VolaBhvrType string `json:"vola_bhvr_type"`
  8723. VolaCont string `json:"vola_cont"`
  8724. } `json:"result"`
  8725. } `json:"output"`
  8726. }
  8727. type Resultgd3101 struct {
  8728. Infcode int64 `json:"infcode"`
  8729. InfRefmsgid string `json:"inf_refmsgid"`
  8730. RefmsgTime string `json:"refmsg_time"`
  8731. RespondTime string `json:"respond_time"`
  8732. Enctype string `json:"enctype"`
  8733. Signtype string `json:"signtype"`
  8734. ErrMsg string `json:"err_msg"`
  8735. Output struct {
  8736. Result []struct {
  8737. JudgeResultDetailDtos []struct {
  8738. VolaItemType string `json:"vola_item_type"`
  8739. MdtrtID string `json:"mdtrt_id"`
  8740. JrdID string `json:"jrd_id"`
  8741. PatnID string `json:"patn_id"`
  8742. RxID string `json:"rx_id"`
  8743. VolaAmt interface{} `json:"vola_amt"`
  8744. } `json:"judge_result_detail_dtos"`
  8745. RuleID string `json:"rule_id"`
  8746. VolaEvid string `json:"vola_evid"`
  8747. MdtrtID string `json:"mdtrt_id"`
  8748. RuleName string `json:"rule_name"`
  8749. VolaAmtStas string `json:"vola_amt_stas"`
  8750. JrID string `json:"jr_id"`
  8751. PatnID string `json:"patn_id"`
  8752. SevDeg string `json:"sev_deg"`
  8753. VolaAmt float64 `json:"vola_amt"`
  8754. VolaBhvrType string `json:"vola_bhvr_type"`
  8755. VolaCont string `json:"vola_cont"`
  8756. } `json:"result"`
  8757. } `json:"output"`
  8758. }
  8759. func (c *HisApiController) ReadEleToken() {
  8760. admin_user_id, _ := c.GetInt64("admin_user_id")
  8761. his_patient_id, _ := c.GetInt64("his_patient_id")
  8762. adminUser := c.GetAdminUserInfo()
  8763. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8764. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8765. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8766. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8767. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  8768. if len(tokens) > 0 {
  8769. c.ServeSuccessJSON(map[string]interface{}{
  8770. "msg": "读取成功",
  8771. })
  8772. } else {
  8773. c.ServeSuccessJSON(map[string]interface{}{
  8774. "failed_code": -10,
  8775. "msg": "读取失败",
  8776. })
  8777. }
  8778. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8779. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  8780. if len(tokens) > 0 {
  8781. c.ServeSuccessJSON(map[string]interface{}{
  8782. "msg": "读取成功",
  8783. })
  8784. } else {
  8785. c.ServeSuccessJSON(map[string]interface{}{
  8786. "failed_code": -10,
  8787. "msg": "读取失败",
  8788. })
  8789. }
  8790. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8791. var api string
  8792. 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 +
  8793. "&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"
  8794. resp, requestErr := http.Get(api)
  8795. if requestErr != nil {
  8796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8797. }
  8798. body, ioErr := ioutil.ReadAll(resp.Body)
  8799. if ioErr != nil {
  8800. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8802. }
  8803. var respJSON map[string]interface{}
  8804. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8807. return
  8808. }
  8809. var status string
  8810. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8811. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8812. var token string
  8813. var res ResultTwo //1101结果
  8814. var res10265 ResultTwo10265 //1101结果
  8815. if status == "0" { //读卡成功
  8816. var card_info string //卡信息
  8817. var busi_card_info string
  8818. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8819. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8820. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8821. fmt.Println(card_info)
  8822. fmt.Println(busi_card_info)
  8823. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8824. result, _ := json.Marshal(respJSON)
  8825. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8826. utils.ErrorLog("解析失败:%v", err)
  8827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8828. return
  8829. }
  8830. res.ErrMsg = res10265.ErrMsg
  8831. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8832. res.Infcode = infocode
  8833. res.Output = res10265.Output
  8834. res.InfRefmsgid = res10265.InfRefmsgid
  8835. if res.Infcode == 0 {
  8836. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8837. if err == gorm.ErrRecordNotFound {
  8838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8839. return
  8840. } else if err != nil {
  8841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8842. return
  8843. } else {
  8844. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8845. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8846. infoStr := string(Iinfos)
  8847. idetinfoStr := string(Idetinfos)
  8848. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  8849. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8850. psn := &models.HisPsn{
  8851. PsnNo: res.Output.Baseinfo.PsnNo,
  8852. PatientId: patient.ID,
  8853. Certno: res.Output.Baseinfo.Certno,
  8854. Gend: res.Output.Baseinfo.Gend,
  8855. Naty: res.Output.Baseinfo.Naty,
  8856. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8857. PsnName: res.Output.Baseinfo.PsnName,
  8858. Age: float64(age),
  8859. Brdy: b,
  8860. Idetinfo: idetinfoStr,
  8861. Insuinfo: infoStr,
  8862. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8863. CardInfo: card_info,
  8864. VerifyNumber: token,
  8865. IdCardType: 4,
  8866. }
  8867. var rf []*ResultFive
  8868. json.Unmarshal([]byte(infoStr), &rf)
  8869. var insutypes []*ResultFive
  8870. var insutype string
  8871. var is390 int = 0
  8872. var is310 int = 0
  8873. for _, item := range rf {
  8874. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8875. insutypes = append(insutypes, item)
  8876. }
  8877. }
  8878. if len(insutypes) == 1 {
  8879. insutype = insutypes[0].Insutype
  8880. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8881. } else {
  8882. for _, i := range insutypes {
  8883. if i.Insutype == "390" {
  8884. is390 = 1
  8885. }
  8886. if i.Insutype == "310" {
  8887. is310 = 1
  8888. }
  8889. }
  8890. }
  8891. if is390 == 1 {
  8892. insutype = "390"
  8893. }
  8894. if is310 == 1 {
  8895. insutype = "310"
  8896. }
  8897. if len(insutypes) == 0 {
  8898. insutype = "310"
  8899. }
  8900. service.CreateHisPsn(psn)
  8901. c.ServeSuccessJSON(map[string]interface{}{
  8902. "patient": patient,
  8903. "number": token,
  8904. "insutype": insutype,
  8905. })
  8906. }
  8907. } else {
  8908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8909. return
  8910. }
  8911. } else { //读卡失败
  8912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8913. return
  8914. }
  8915. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8916. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  8917. if len(errMsg) == 0 {
  8918. type ELeData struct {
  8919. Data struct {
  8920. IdNo string `json:"idNo"`
  8921. IdType string `json:"idType"`
  8922. UserName string `json:"userName"`
  8923. EcToken string `json:"ecToken"`
  8924. InsuOrg string `json:"insuOrg"`
  8925. Gender string `json:"gender"`
  8926. Birthday string `json:"birthday"`
  8927. Nationality string `json:"nationality"`
  8928. Email string `json:"email"`
  8929. Extra string `json:"extra"`
  8930. } `json:"data"`
  8931. Code int `json:"code"`
  8932. Message string `json:"message"`
  8933. }
  8934. var ele ELeData
  8935. err := json.Unmarshal([]byte(outPutInfo), &ele)
  8936. if err != nil {
  8937. utils.ErrorLog("解析失败:%v", err)
  8938. }
  8939. token := ele.Data.EcToken
  8940. if len(token) > 0 {
  8941. psn := &models.HisPsn{
  8942. PsnNo: his.PsnNo,
  8943. Age: 0,
  8944. PatientId: his.PatientId,
  8945. Certno: his.Certno,
  8946. Brdy: his.Brdy,
  8947. Gend: his.Gend,
  8948. Naty: his.Naty,
  8949. PsnCertType: his.PsnCertType,
  8950. PsnName: his.PsnName,
  8951. Idetinfo: his.Idetinfo,
  8952. Insuinfo: his.Iinfo,
  8953. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8954. CardInfo: outPutInfo,
  8955. VerifyNumber: token,
  8956. }
  8957. service.CreateHisPsn(psn)
  8958. }
  8959. if len(token) > 0 {
  8960. c.ServeSuccessJSON(map[string]interface{}{
  8961. "msg": "读取成功",
  8962. })
  8963. } else {
  8964. c.ServeSuccessJSON(map[string]interface{}{
  8965. "failed_code": -10,
  8966. "msg": "读取失败",
  8967. })
  8968. }
  8969. }
  8970. } else if miConfig.MdtrtareaAdmvs == "360302" {
  8971. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  8972. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  8973. type ELeData struct {
  8974. Data struct {
  8975. IdNo string `json:"idNo"`
  8976. IdType string `json:"idType"`
  8977. UserName string `json:"userName"`
  8978. EcToken string `json:"ecToken"`
  8979. InsuOrg string `json:"insuOrg"`
  8980. Gender string `json:"gender"`
  8981. Birthday string `json:"birthday"`
  8982. Nationality string `json:"nationality"`
  8983. Email string `json:"email"`
  8984. Extra string `json:"extra"`
  8985. } `json:"data"`
  8986. Code int `json:"code"`
  8987. Message string `json:"message"`
  8988. }
  8989. var ele ELeData
  8990. err := json.Unmarshal([]byte(result), &ele)
  8991. if err != nil {
  8992. utils.ErrorLog("解析失败:%v", err)
  8993. }
  8994. token := ele.Data.EcToken
  8995. token = Remove0000(token)
  8996. fmt.Println(ele.Data.UserName)
  8997. 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)
  8998. saveLog(result2, requestLog2, "1101", "获取人员信息")
  8999. var res ResultTwo
  9000. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9001. utils.ErrorLog("解析失败:%v", err)
  9002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9003. return
  9004. }
  9005. if res.Infcode == 0 {
  9006. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9007. if err == gorm.ErrRecordNotFound {
  9008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9009. return
  9010. } else if err != nil {
  9011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9012. return
  9013. } else {
  9014. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9015. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9016. infoStr := string(Iinfos)
  9017. idetinfoStr := string(Idetinfos)
  9018. psn := &models.HisPsn{
  9019. PsnNo: res.Output.Baseinfo.PsnNo,
  9020. PatientId: patient.ID,
  9021. Certno: res.Output.Baseinfo.Certno,
  9022. Gend: res.Output.Baseinfo.Gend,
  9023. Naty: res.Output.Baseinfo.Naty,
  9024. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9025. PsnName: res.Output.Baseinfo.PsnName,
  9026. Idetinfo: idetinfoStr,
  9027. Insuinfo: infoStr,
  9028. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9029. CardInfo: "",
  9030. VerifyNumber: token,
  9031. }
  9032. service.CreateHisPsn(psn)
  9033. c.ServeSuccessJSON(map[string]interface{}{
  9034. "patient": patient,
  9035. "number": token,
  9036. })
  9037. }
  9038. } else {
  9039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9040. return
  9041. }
  9042. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9043. //if initFlag == 0 {
  9044. //c.TestGetJiangXiBasBaseInit()
  9045. //}
  9046. //if initEleFlag == 0 {
  9047. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9048. //}
  9049. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9050. utils.ErrorLog("解析失败:%v", json_result)
  9051. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9052. type ELeData struct {
  9053. Data struct {
  9054. IdNo string `json:"idNo"`
  9055. IdType string `json:"idType"`
  9056. UserName string `json:"userName"`
  9057. EcToken string `json:"ecToken"`
  9058. InsuOrg string `json:"insuOrg"`
  9059. Gender string `json:"gender"`
  9060. Birthday string `json:"birthday"`
  9061. Nationality string `json:"nationality"`
  9062. Email string `json:"email"`
  9063. Extra string `json:"extra"`
  9064. } `json:"data"`
  9065. Code int `json:"code"`
  9066. Message string `json:"message"`
  9067. }
  9068. var ele ELeData
  9069. err := json.Unmarshal([]byte(json_result), &ele)
  9070. if err != nil {
  9071. utils.ErrorLog("解析失败:%v", err)
  9072. }
  9073. token := ele.Data.EcToken
  9074. token = Remove0000(token)
  9075. //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)
  9076. 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)
  9077. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9078. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9079. var res ResultTwo
  9080. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9081. utils.ErrorLog("解析失败:%v", err)
  9082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9083. return
  9084. }
  9085. if res.Infcode == 0 {
  9086. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9087. if err == gorm.ErrRecordNotFound {
  9088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9089. return
  9090. } else if err != nil {
  9091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9092. return
  9093. } else {
  9094. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9095. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9096. infoStr := string(Iinfos)
  9097. idetinfoStr := string(Idetinfos)
  9098. psn := &models.HisPsn{
  9099. PsnNo: res.Output.Baseinfo.PsnNo,
  9100. PatientId: patient.ID,
  9101. Certno: res.Output.Baseinfo.Certno,
  9102. Gend: res.Output.Baseinfo.Gend,
  9103. Naty: res.Output.Baseinfo.Naty,
  9104. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9105. PsnName: res.Output.Baseinfo.PsnName,
  9106. Idetinfo: idetinfoStr,
  9107. Insuinfo: infoStr,
  9108. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9109. CardInfo: "",
  9110. VerifyNumber: token,
  9111. InsuplcAdmdvs: ele.Data.InsuOrg,
  9112. }
  9113. service.CreateHisPsn(psn)
  9114. c.ServeSuccessJSON(map[string]interface{}{
  9115. "patient": patient,
  9116. "number": token,
  9117. })
  9118. }
  9119. } else {
  9120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9121. return
  9122. }
  9123. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9124. res := c.GetoleInfo()
  9125. if res.Infcode == 0 {
  9126. var result string
  9127. if res.Output.MdtrtCertType == "01" {
  9128. 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)
  9129. } else if res.Output.MdtrtCertType == "02" {
  9130. 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)
  9131. } else if res.Output.MdtrtCertType == "03" {
  9132. 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)
  9133. }
  9134. var dat map[string]interface{}
  9135. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9136. fmt.Println(dat)
  9137. } else {
  9138. fmt.Println(err)
  9139. }
  9140. userJSONBytes, _ := json.Marshal(dat)
  9141. var res2 ResultTwo
  9142. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9143. utils.ErrorLog("解析失败:%v", err)
  9144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9145. return
  9146. }
  9147. if res2.Infcode == 0 {
  9148. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9149. if err == gorm.ErrRecordNotFound {
  9150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9151. return
  9152. } else if err != nil {
  9153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9154. return
  9155. } else {
  9156. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9157. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9158. infoStr := string(Iinfos)
  9159. idetinfoStr := string(Idetinfos)
  9160. var rf []*ResultFive
  9161. json.Unmarshal([]byte(infoStr), &rf)
  9162. var insutypes []*ResultFive
  9163. var insutype string
  9164. var is390 int = 0
  9165. var is310 int = 0
  9166. //var insuplc_admdvs string
  9167. for _, item := range rf {
  9168. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9169. insutypes = append(insutypes, item)
  9170. }
  9171. }
  9172. if len(insutypes) == 1 {
  9173. insutype = insutypes[0].Insutype
  9174. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9175. } else {
  9176. for _, i := range insutypes {
  9177. if i.Insutype == "390" {
  9178. is390 = 1
  9179. }
  9180. if i.Insutype == "310" {
  9181. is310 = 1
  9182. }
  9183. }
  9184. }
  9185. if is390 == 1 {
  9186. insutype = "390"
  9187. }
  9188. if is310 == 1 {
  9189. insutype = "310"
  9190. }
  9191. if len(insutypes) == 0 {
  9192. insutype = "310"
  9193. }
  9194. psn := &models.HisPsn{
  9195. PsnNo: res2.Output.Baseinfo.PsnNo,
  9196. PatientId: patient.ID,
  9197. Certno: res2.Output.Baseinfo.Certno,
  9198. Gend: res2.Output.Baseinfo.Gend,
  9199. Naty: res2.Output.Baseinfo.Naty,
  9200. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9201. PsnName: res2.Output.Baseinfo.PsnName,
  9202. Idetinfo: idetinfoStr,
  9203. Insuinfo: infoStr,
  9204. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9205. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9206. VerifyNumber: res.Output.EcToken,
  9207. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9208. }
  9209. service.CreateHisPsn(psn)
  9210. c.ServeSuccessJSON(map[string]interface{}{
  9211. "patient": patient,
  9212. "number": res.Output.CardNo,
  9213. "insutype": insutype,
  9214. })
  9215. }
  9216. } else {
  9217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9218. return
  9219. }
  9220. } else {
  9221. c.ServeSuccessJSON(map[string]interface{}{
  9222. "failed_code": -10,
  9223. "msg": res.ErrMsg,
  9224. })
  9225. }
  9226. } else {
  9227. //if initFlag == 0 {
  9228. // c.TestGetBasBaseInit()
  9229. //}
  9230. //token := c.GetEleBaseInfo()
  9231. //token = Remove0000(token)
  9232. type ELeData struct {
  9233. Code string `json:"code"`
  9234. Data struct {
  9235. Aac002 string `json:"aac002"`
  9236. Aaz500 string `json:"aaz500"`
  9237. ActCardNo string `json:"actCardNo"`
  9238. Bab520 string `json:"bab520"`
  9239. Bkz543 string `json:"bkz543"`
  9240. BusinessType string `json:"businessType"`
  9241. CertfCodg string `json:"certfCodg"`
  9242. EcIndexNo string `json:"ecIndexNo"`
  9243. EcToken string `json:"ecToken"`
  9244. ID0000 string `json:"id0000"`
  9245. IDNo string `json:"idNo"`
  9246. IDType string `json:"idType"`
  9247. Idcode string `json:"idcode"`
  9248. IdentityToken string `json:"identity_token"`
  9249. InsuOrg string `json:"insuOrg"`
  9250. OfficeID string `json:"officeId"`
  9251. OfficeName string `json:"officeName"`
  9252. OperatorID string `json:"operatorId"`
  9253. OperatorName string `json:"operatorName"`
  9254. OrgID string `json:"orgId"`
  9255. UserName string `json:"userName"`
  9256. } `json:"data"`
  9257. Infno interface{} `json:"infno"`
  9258. Message string `json:"message"`
  9259. OrgID string `json:"orgId"`
  9260. TransType string `json:"transType"`
  9261. }
  9262. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9263. fmt.Println(result)
  9264. outPutInfo := Remove0000(result)
  9265. fmt.Println(outPutInfo)
  9266. var ele ELeData
  9267. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9268. if err != nil {
  9269. utils.ErrorLog("解析失败:%v", err)
  9270. }
  9271. token := ele.Data.EcToken
  9272. var result2 string
  9273. var requestLog2 string
  9274. if len(token) > 0 {
  9275. if strings.Contains(ele.Data.IDNo, "HKG") {
  9276. 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)
  9277. } else {
  9278. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  9279. }
  9280. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9281. var res ResultTwo
  9282. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9283. utils.ErrorLog("解析失败:%v", err)
  9284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9285. return
  9286. }
  9287. if res.Infcode == 0 {
  9288. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9289. if err == gorm.ErrRecordNotFound {
  9290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9291. return
  9292. } else if err != nil {
  9293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9294. return
  9295. } else {
  9296. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9297. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9298. infoStr := string(Iinfos)
  9299. idetinfoStr := string(Idetinfos)
  9300. psn := &models.HisPsn{
  9301. PsnNo: res.Output.Baseinfo.PsnNo,
  9302. PatientId: patient.ID,
  9303. Certno: res.Output.Baseinfo.Certno,
  9304. Gend: res.Output.Baseinfo.Gend,
  9305. Naty: res.Output.Baseinfo.Naty,
  9306. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9307. PsnName: res.Output.Baseinfo.PsnName,
  9308. Idetinfo: idetinfoStr,
  9309. Insuinfo: infoStr,
  9310. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9311. CardInfo: "",
  9312. VerifyNumber: token,
  9313. }
  9314. service.CreateHisPsn(psn)
  9315. c.ServeSuccessJSON(map[string]interface{}{
  9316. "msg": "读取成功",
  9317. })
  9318. }
  9319. } else {
  9320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9321. return
  9322. }
  9323. } else {
  9324. c.ServeSuccessJSON(map[string]interface{}{
  9325. "failed_code": -10,
  9326. "msg": "读取失败",
  9327. })
  9328. }
  9329. }
  9330. }
  9331. func (c *HisApiController) ReadEleFace() {
  9332. admin_user_id, _ := c.GetInt64("admin_user_id")
  9333. //his_patient_id, _ := c.GetInt64("his_patient_id")
  9334. adminUser := c.GetAdminUserInfo()
  9335. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9336. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9337. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9338. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9339. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9340. if len(tokens) > 0 {
  9341. c.ServeSuccessJSON(map[string]interface{}{
  9342. "msg": "读取成功",
  9343. })
  9344. } else {
  9345. c.ServeSuccessJSON(map[string]interface{}{
  9346. "failed_code": -10,
  9347. "msg": "读取失败",
  9348. })
  9349. }
  9350. }
  9351. }
  9352. func (c *HisApiController) Get9001() {
  9353. adminUser := c.GetAdminUserInfo()
  9354. admin_user_id, _ := c.GetInt64("admin_user_id")
  9355. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9356. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9357. if miConfig.MdtrtareaAdmvs == "350500" {
  9358. service.GetFjAuthorizationInfo(miConfig.Code)
  9359. } else if miConfig.MdtrtareaAdmvs == "131023" {
  9360. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9361. var dat map[string]interface{}
  9362. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9363. fmt.Println(dat)
  9364. } else {
  9365. fmt.Println(err)
  9366. }
  9367. userJSONBytes, _ := json.Marshal(dat)
  9368. var res models.Result9001
  9369. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9370. utils.ErrorLog("解析失败:%v", err)
  9371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9372. return
  9373. }
  9374. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9375. fmt.Println(miConfig.SecretKey)
  9376. var res models.Result9001Two
  9377. 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 +
  9378. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  9379. resp, requestErr := http.Get(api)
  9380. if requestErr != nil {
  9381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9382. return
  9383. }
  9384. body, ioErr := ioutil.ReadAll(resp.Body)
  9385. if ioErr != nil {
  9386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9388. return
  9389. }
  9390. var respJSON map[string]interface{}
  9391. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9394. return
  9395. }
  9396. status := respJSON["data"].(map[string]interface{})["status"].(string)
  9397. if status == "0" {
  9398. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  9399. c.ServeSuccessJSON(map[string]interface{}{
  9400. "failed_code": -10,
  9401. "msg": err_msg,
  9402. })
  9403. return
  9404. }
  9405. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9406. result, _ := json.Marshal(respJSON)
  9407. fmt.Println("log")
  9408. fmt.Println(string(result))
  9409. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9410. utils.ErrorLog("解析失败:%v", err)
  9411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9412. return
  9413. }
  9414. if res.Infcode == 0 {
  9415. sign := models.HisSignIn{
  9416. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9417. SignNo: res.Output.Signinoutb.SignNo,
  9418. SignTime: "",
  9419. Ctime: time.Now().Unix(),
  9420. Mtime: time.Now().Unix(),
  9421. Status: 1,
  9422. InputLog: "",
  9423. OutputLog: "",
  9424. FixmedinsCode: miConfig.Code,
  9425. }
  9426. err := service.CreateSignIn(&sign)
  9427. if err == nil {
  9428. c.ServeSuccessJSON(map[string]interface{}{
  9429. "msg": "签到成功",
  9430. })
  9431. }
  9432. } else {
  9433. c.ServeSuccessJSON(map[string]interface{}{
  9434. "failed_code": -10,
  9435. "msg": res.ErrMsg,
  9436. })
  9437. return
  9438. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9439. //return
  9440. }
  9441. } else {
  9442. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  9443. var dat map[string]interface{}
  9444. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9445. fmt.Println(dat)
  9446. } else {
  9447. fmt.Println(err)
  9448. }
  9449. userJSONBytes, _ := json.Marshal(dat)
  9450. var res models.Result9001
  9451. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9452. utils.ErrorLog("解析失败:%v", err)
  9453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9454. return
  9455. }
  9456. if res.Infcode == 0 {
  9457. sign := models.HisSignIn{
  9458. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9459. SignNo: res.Output.Signinoutb.SignNo,
  9460. SignTime: res.Output.Signinoutb.SignTime,
  9461. Ctime: time.Now().Unix(),
  9462. Mtime: time.Now().Unix(),
  9463. Status: 1,
  9464. InputLog: "",
  9465. OutputLog: "",
  9466. FixmedinsCode: miConfig.Code,
  9467. }
  9468. err := service.CreateSignIn(&sign)
  9469. if err == nil {
  9470. c.ServeSuccessJSON(map[string]interface{}{
  9471. "msg": "签到成功",
  9472. })
  9473. }
  9474. }
  9475. }
  9476. }
  9477. 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) {
  9478. var res Result3101
  9479. adminUser := c.GetAdminUserInfo()
  9480. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9481. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9482. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9483. //record_time := c.GetString("record_time")
  9484. //trig_scen := c.GetString("trig_scen")
  9485. timeLayout := "2006-01-02"
  9486. loc, _ := time.LoadLocation("Local")
  9487. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9488. if err != nil {
  9489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9490. return res
  9491. }
  9492. recordDateTime := theTime.Unix()
  9493. var patientPrescription models.HisPrescriptionInfo
  9494. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9495. //if patientPrescription.ID == 0 {
  9496. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9497. //}
  9498. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9499. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9500. //
  9501. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  9502. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9503. var pp models.PublicParams
  9504. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9505. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9506. pp.FixmedinsName = miConfig.OrgName
  9507. pp.FixmedinsCode = miConfig.Code
  9508. pp.RequestUrl = miConfig.Url
  9509. pp.Cainfo = miConfig.Cainfo
  9510. pp.SecretKey = miConfig.SecretKey
  9511. pp.AccessKey = miConfig.AccessKey
  9512. pp.OpterName = roles.UserName
  9513. var config []*models.HisXtDiagnoseConfig
  9514. for _, item := range diagnosis_ids {
  9515. id, _ := strconv.ParseInt(item, 10, 64)
  9516. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9517. config = append(config, &diagnosisConfig)
  9518. }
  9519. var pd models.PatientDtos
  9520. pd.PatnID = his.PsnNo
  9521. pd.PatnName = his.Name
  9522. pd.Gend = his.Gend
  9523. pd.Brdy = his.Brdy
  9524. pd.Poolarea = miConfig.MdtrtareaAdmvs
  9525. pd.CurrMdtrtID = his.Number
  9526. var fed models.FsiEncounterDtos
  9527. fed.MdtrtID = his.Number
  9528. fed.MedinsID = miConfig.Code
  9529. fed.MedinsName = miConfig.OrgName
  9530. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  9531. fed.MedMdtrtType = "1"
  9532. fed.MedinsType = "1"
  9533. fed.MedinsLv = "11"
  9534. tm := time.Unix(his.RecordDate, 0)
  9535. s_tm := tm.Format("2006-01-02 15:04:05")
  9536. fed.AdmDate = s_tm
  9537. fed.DscgDate = s_tm
  9538. fed.DscgMainDiseCodg = config[0].CountryCode
  9539. fed.DscgMainDiseName = config[0].CountryContentName
  9540. //诊断信息
  9541. var fdds []*models.FsiDiagnoseDtos
  9542. for index, item := range config {
  9543. if index == 0 {
  9544. var fdd models.FsiDiagnoseDtos
  9545. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9546. fdd.InoutDiseType = "1"
  9547. fdd.MaindiseFlag = "1"
  9548. fdd.DiseDate = s_tm
  9549. fdd.DiasSrtNo = "1"
  9550. fdd.DiseName = item.CountryContentName
  9551. fdd.DiseCodg = item.CountryCode
  9552. fdds = append(fdds, &fdd)
  9553. } else {
  9554. var fdd models.FsiDiagnoseDtos
  9555. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9556. fdd.InoutDiseType = "1"
  9557. fdd.MaindiseFlag = "1"
  9558. fdd.DiseDate = s_tm
  9559. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  9560. fdd.DiseName = item.CountryContentName
  9561. fdd.DiseCodg = item.CountryCode
  9562. fdds = append(fdds, &fdd)
  9563. }
  9564. }
  9565. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  9566. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  9567. fed.AdmDeptName = de.Name
  9568. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  9569. fed.DscgDeptName = de.Name
  9570. fed.MedMdtrtType = "1"
  9571. fed.MedType = "11"
  9572. //if his.Insutype == "390" {
  9573. // fed.MedType = "1402"
  9574. //} else {
  9575. // fed.MedType = "9933"
  9576. //}
  9577. var orders []*models.FsiOrderDtos
  9578. if trig_scen == "2" {
  9579. //处方医嘱信息
  9580. for _, item := range prescriptions {
  9581. for _, subItem := range item.HisDoctorAdviceInfo {
  9582. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9583. var order models.FsiOrderDtos
  9584. order.RxID = strconv.FormatInt(item.ID, 10)
  9585. order.Rxno = strconv.FormatInt(item.ID, 10)
  9586. order.LongDrordFlag = "0"
  9587. order.HilistType = "1"
  9588. order.ChrgType = "1"
  9589. order.DrordBhvr = "-"
  9590. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9591. order.HosplistName = subItem.BaseDrugLib.DrugName
  9592. order.HilistLv = "1"
  9593. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9594. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9595. order.HosplistName = subItem.BaseDrugLib.DrugName
  9596. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  9597. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9598. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  9599. order.OwnpayAmt = ""
  9600. order.SelfpayAmt = ""
  9601. order.Spec = ""
  9602. order.SpecUnt = ""
  9603. order.DrordBegnDate = s_tm
  9604. order.DrordStopDate = ""
  9605. order.DrordDrCodg = doctor_info.DoctorNumber
  9606. order.DrordDeptName = department.Name
  9607. order.DrordDeptCodg = department.Number
  9608. order.DrordDrName = doctor_info.UserName
  9609. order.DrordDrProfttl = "234"
  9610. order.CurrDrordFlag = "1"
  9611. orders = append(orders, &order)
  9612. }
  9613. }
  9614. for _, subItem := range item.HisPrescriptionProject {
  9615. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  9616. var order models.FsiOrderDtos
  9617. order.RxID = strconv.FormatInt(item.ID, 10)
  9618. order.Rxno = strconv.FormatInt(item.ID, 10)
  9619. order.LongDrordFlag = "0"
  9620. order.HilistType = "1"
  9621. order.ChrgType = "1"
  9622. order.DrordBhvr = "-"
  9623. order.HilistCode = subItem.HisProject.MedicalCode
  9624. order.HosplistName = subItem.HisProject.ProjectName
  9625. order.HilistLv = "1"
  9626. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9627. order.HosplistCode = subItem.HisProject.MedicalCode
  9628. order.HosplistName = subItem.HisProject.ProjectName
  9629. order.Cnt = subItem.Count
  9630. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9631. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9632. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9633. order.OwnpayAmt = ""
  9634. order.SelfpayAmt = ""
  9635. order.Spec = ""
  9636. order.SpecUnt = ""
  9637. order.DrordBegnDate = s_tm
  9638. order.DrordStopDate = ""
  9639. order.DrordDrCodg = doctor_info.DoctorNumber
  9640. order.DrordDeptName = department.Name
  9641. order.DrordDeptCodg = department.Number
  9642. order.DrordDrName = doctor_info.UserName
  9643. order.DrordDrProfttl = "234"
  9644. order.CurrDrordFlag = "1"
  9645. orders = append(orders, &order)
  9646. }
  9647. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  9648. var order models.FsiOrderDtos
  9649. order.RxID = strconv.FormatInt(item.ID, 10)
  9650. order.Rxno = strconv.FormatInt(item.ID, 10)
  9651. order.LongDrordFlag = "0"
  9652. order.HilistType = "1"
  9653. order.ChrgType = "1"
  9654. order.DrordBhvr = "-"
  9655. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9656. order.HosplistName = subItem.GoodInfo.GoodName
  9657. order.HilistLv = "1"
  9658. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9659. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9660. order.HosplistName = subItem.GoodInfo.GoodName
  9661. order.Cnt = subItem.Count
  9662. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9663. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9664. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9665. order.OwnpayAmt = ""
  9666. order.SelfpayAmt = ""
  9667. order.Spec = ""
  9668. order.SpecUnt = ""
  9669. order.DrordBegnDate = s_tm
  9670. order.DrordStopDate = ""
  9671. order.DrordDrCodg = doctor_info.DoctorNumber
  9672. order.DrordDeptName = department.Name
  9673. order.DrordDeptCodg = department.Number
  9674. order.DrordDrName = doctor_info.UserName
  9675. order.DrordDrProfttl = "234"
  9676. order.CurrDrordFlag = "1"
  9677. orders = append(orders, &order)
  9678. }
  9679. }
  9680. }
  9681. //处方医嘱信息
  9682. }
  9683. fed.MatnStas = "0"
  9684. fed.MedfeeSumamt = "0"
  9685. fed.OwnpayAmt = "0"
  9686. fed.SelfpayAmt = "0"
  9687. fed.AcctPayamt = "0"
  9688. fed.MaAmt = "0"
  9689. fed.HifpPayamt = "0"
  9690. fed.SetlTotlnum = "1"
  9691. fed.Insutype = his.Insutype
  9692. fed.ReimFlag = "0"
  9693. fed.OutSetlFlag = "0"
  9694. var fopd []*models.FsiOperationDtosData
  9695. data := make(map[string]interface{})
  9696. data["fed"] = fed
  9697. data["fdd"] = fdds
  9698. data["fod"] = orders
  9699. data["pd"] = pd
  9700. data["pp"] = pp
  9701. data["fopd"] = fopd
  9702. data["trig_scen"] = trig_scen
  9703. fmt.Println(data)
  9704. fmt.Println(fed)
  9705. fmt.Println(fdds)
  9706. fmt.Println(orders)
  9707. fmt.Println(pd)
  9708. fmt.Println(pp)
  9709. fmt.Println(fopd)
  9710. client := &http.Client{}
  9711. bytesData, _ := json.Marshal(data)
  9712. var req *http.Request
  9713. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9714. if miConfig.MdtrtareaAdmvs == "320921" {
  9715. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9716. } else {
  9717. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9718. }
  9719. resp, _ := client.Do(req)
  9720. defer resp.Body.Close()
  9721. body, ioErr := ioutil.ReadAll(resp.Body)
  9722. if ioErr != nil {
  9723. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9725. return res
  9726. }
  9727. var respJSON map[string]interface{}
  9728. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9729. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9731. return res
  9732. }
  9733. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  9734. fmt.Println(respJSON)
  9735. result, _ := json.Marshal(respJSON)
  9736. fmt.Println(result)
  9737. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9738. utils.ErrorLog("解析失败:%v", err)
  9739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9740. return res
  9741. }
  9742. return res
  9743. } else {
  9744. //if miConfig.MdtrtareaAdmvs == "441202" {
  9745. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  9746. saveLog(output, input, "3101", "事前")
  9747. if err := json.Unmarshal([]byte(output), &res); err != nil {
  9748. utils.ErrorLog("解析失败:%v", err)
  9749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9750. return
  9751. }
  9752. return res
  9753. //}
  9754. }
  9755. }
  9756. 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) {
  9757. adminUser := c.GetAdminUserInfo()
  9758. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9759. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9760. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9761. //record_time := c.GetString("record_time")
  9762. //trig_scen := c.GetString("trig_scen")
  9763. timeLayout := "2006-01-02"
  9764. loc, _ := time.LoadLocation("Local")
  9765. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9766. if err != nil {
  9767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9768. return res
  9769. }
  9770. recordDateTime := theTime.Unix()
  9771. var patientPrescription models.HisPrescriptionInfo
  9772. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9773. if patientPrescription.ID == 0 {
  9774. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9775. }
  9776. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9777. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9778. //
  9779. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  9780. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9781. var pp models.PublicParams
  9782. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9783. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9784. pp.FixmedinsName = miConfig.OrgName
  9785. pp.FixmedinsCode = miConfig.Code
  9786. pp.RequestUrl = miConfig.Url
  9787. pp.Cainfo = miConfig.Cainfo
  9788. pp.SecretKey = miConfig.SecretKey
  9789. pp.AccessKey = miConfig.AccessKey
  9790. pp.OpterName = roles.UserName
  9791. var config []*models.HisXtDiagnoseConfig
  9792. for _, item := range diagnosis_ids {
  9793. id, _ := strconv.ParseInt(item, 10, 64)
  9794. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9795. config = append(config, &diagnosisConfig)
  9796. }
  9797. var pd models.PatientDtos
  9798. pd.PatnID = his.PsnNo
  9799. pd.PatnName = his.Name
  9800. pd.Gend = his.Gend
  9801. pd.Brdy = his.Brdy
  9802. pd.Poolarea = his.InsuplcAdmdvs
  9803. pd.CurrMdtrtID = his.Number
  9804. var fed models.FsiEncounterDtos
  9805. fed.MdtrtID = his.Number
  9806. fed.MedinsID = miConfig.Code
  9807. fed.MedinsName = miConfig.OrgName
  9808. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  9809. fed.MedMdtrtType = "1"
  9810. fed.MedinsType = "1"
  9811. fed.MedinsLv = "11"
  9812. tm := time.Unix(his.RecordDate, 0)
  9813. s_tm := tm.Format("2006-01-02 15:04:05")
  9814. fed.AdmDate = s_tm
  9815. fed.DscgDate = s_tm
  9816. fed.DscgMainDiseCodg = config[0].CountryCode
  9817. fed.DscgMainDiseName = config[0].CountryContentName
  9818. //诊断信息
  9819. var fdds []*models.FsiDiagnoseDtos
  9820. for index, item := range config {
  9821. if index == 0 {
  9822. var fdd models.FsiDiagnoseDtos
  9823. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9824. fdd.InoutDiseType = "1"
  9825. fdd.MaindiseFlag = "1"
  9826. fdd.DiseDate = s_tm
  9827. fdd.DiasSrtNo = "1"
  9828. fdd.DiseName = item.CountryContentName
  9829. fdd.DiseCodg = item.CountryCode
  9830. fdds = append(fdds, &fdd)
  9831. } else {
  9832. var fdd models.FsiDiagnoseDtos
  9833. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9834. fdd.InoutDiseType = "1"
  9835. fdd.MaindiseFlag = "1"
  9836. fdd.DiseDate = s_tm
  9837. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  9838. fdd.DiseName = item.CountryContentName
  9839. fdd.DiseCodg = item.CountryCode
  9840. fdds = append(fdds, &fdd)
  9841. }
  9842. }
  9843. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  9844. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  9845. fed.AdmDeptName = department.Name
  9846. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  9847. fed.DscgDeptName = department.Name
  9848. fed.MedMdtrtType = "1"
  9849. fed.MedType = "11"
  9850. //if his.Insutype == "390" {
  9851. // fed.MedType = "1402"
  9852. //} else {
  9853. // fed.MedType = "9933"
  9854. //}
  9855. var orders []*models.FsiOrderDtos
  9856. if trig_scen == "2" {
  9857. //处方医嘱信息
  9858. for _, item := range prescriptions {
  9859. for _, subItem := range item.HisDoctorAdviceInfo {
  9860. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9861. var order models.FsiOrderDtos
  9862. order.RxID = strconv.FormatInt(item.ID, 10)
  9863. order.Rxno = strconv.FormatInt(item.ID, 10)
  9864. order.LongDrordFlag = "0"
  9865. order.HilistType = "1"
  9866. order.ChrgType = "1"
  9867. order.DrordBhvr = "-"
  9868. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9869. order.HosplistName = subItem.BaseDrugLib.DrugName
  9870. order.HilistLv = "1"
  9871. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9872. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9873. order.HosplistName = subItem.BaseDrugLib.DrugName
  9874. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  9875. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9876. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  9877. order.OwnpayAmt = ""
  9878. order.SelfpayAmt = ""
  9879. order.Spec = ""
  9880. order.SpecUnt = ""
  9881. order.DrordBegnDate = s_tm
  9882. order.DrordStopDate = ""
  9883. order.DrordDrCodg = doctor_info.DoctorNumber
  9884. order.DrordDeptName = department.Name
  9885. order.DrordDeptCodg = department.Number
  9886. order.DrordDrName = doctor_info.UserName
  9887. order.DrordDrProfttl = "234"
  9888. order.CurrDrordFlag = "1"
  9889. orders = append(orders, &order)
  9890. }
  9891. }
  9892. for _, subItem := range item.HisPrescriptionProject {
  9893. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  9894. var order models.FsiOrderDtos
  9895. order.RxID = strconv.FormatInt(item.ID, 10)
  9896. order.Rxno = strconv.FormatInt(item.ID, 10)
  9897. order.LongDrordFlag = "0"
  9898. order.HilistType = "1"
  9899. order.ChrgType = "1"
  9900. order.DrordBhvr = "-"
  9901. order.HilistCode = subItem.HisProject.MedicalCode
  9902. order.HosplistName = subItem.HisProject.ProjectName
  9903. order.HilistLv = "1"
  9904. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9905. order.HosplistCode = subItem.HisProject.MedicalCode
  9906. order.HosplistName = subItem.HisProject.ProjectName
  9907. order.Cnt = subItem.Count
  9908. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9909. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9910. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9911. order.OwnpayAmt = ""
  9912. order.SelfpayAmt = ""
  9913. order.Spec = ""
  9914. order.SpecUnt = ""
  9915. order.DrordBegnDate = s_tm
  9916. order.DrordStopDate = ""
  9917. order.DrordDrCodg = doctor_info.DoctorNumber
  9918. order.DrordDeptName = department.Name
  9919. order.DrordDeptCodg = department.Number
  9920. order.DrordDrName = doctor_info.UserName
  9921. order.DrordDrProfttl = "234"
  9922. order.CurrDrordFlag = "1"
  9923. orders = append(orders, &order)
  9924. }
  9925. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  9926. var order models.FsiOrderDtos
  9927. order.RxID = strconv.FormatInt(item.ID, 10)
  9928. order.Rxno = strconv.FormatInt(item.ID, 10)
  9929. order.LongDrordFlag = "0"
  9930. order.HilistType = "1"
  9931. order.ChrgType = "1"
  9932. order.DrordBhvr = "-"
  9933. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9934. order.HosplistName = subItem.GoodInfo.GoodName
  9935. order.HilistLv = "1"
  9936. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9937. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9938. order.HosplistName = subItem.GoodInfo.GoodName
  9939. order.Cnt = subItem.Count
  9940. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9941. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9942. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9943. order.OwnpayAmt = ""
  9944. order.SelfpayAmt = ""
  9945. order.Spec = ""
  9946. order.SpecUnt = ""
  9947. order.DrordBegnDate = s_tm
  9948. order.DrordStopDate = ""
  9949. order.DrordDrCodg = doctor_info.DoctorNumber
  9950. order.DrordDeptName = department.Name
  9951. order.DrordDeptCodg = department.Number
  9952. order.DrordDrName = doctor_info.UserName
  9953. order.DrordDrProfttl = "234"
  9954. order.CurrDrordFlag = "1"
  9955. orders = append(orders, &order)
  9956. }
  9957. }
  9958. }
  9959. //处方医嘱信息
  9960. }
  9961. fed.MatnStas = "0"
  9962. fed.MedfeeSumamt = "0"
  9963. fed.OwnpayAmt = "0"
  9964. fed.SelfpayAmt = "0"
  9965. fed.AcctPayamt = "0"
  9966. fed.MaAmt = "0"
  9967. fed.HifpPayamt = "0"
  9968. fed.SetlTotlnum = "1"
  9969. fed.Insutype = his.Insutype
  9970. fed.ReimFlag = "0"
  9971. fed.OutSetlFlag = "0"
  9972. var fopd []*models.FsiOperationDtosData
  9973. data := make(map[string]interface{})
  9974. data["fed"] = fed
  9975. data["fdd"] = fdds
  9976. data["fod"] = orders
  9977. data["pd"] = pd
  9978. data["pp"] = pp
  9979. data["fopd"] = fopd
  9980. data["trig_scen"] = trig_scen
  9981. fmt.Println(data)
  9982. fmt.Println(fed)
  9983. fmt.Println(fdds)
  9984. fmt.Println(orders)
  9985. fmt.Println(pd)
  9986. fmt.Println(pp)
  9987. fmt.Println(fopd)
  9988. client := &http.Client{}
  9989. bytesData, _ := json.Marshal(data)
  9990. var req *http.Request
  9991. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9992. if miConfig.MdtrtareaAdmvs == "320921" {
  9993. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9994. } else {
  9995. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9996. }
  9997. resp, _ := client.Do(req)
  9998. defer resp.Body.Close()
  9999. body, ioErr := ioutil.ReadAll(resp.Body)
  10000. if ioErr != nil {
  10001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10003. return res
  10004. }
  10005. var respJSON map[string]interface{}
  10006. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10009. return res
  10010. }
  10011. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10012. fmt.Println(respJSON)
  10013. result, _ := json.Marshal(respJSON)
  10014. fmt.Println(result)
  10015. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10016. utils.ErrorLog("解析失败:%v", err)
  10017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10018. return res
  10019. }
  10020. return res
  10021. } else {
  10022. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10023. saveLog(output, input, "3101", "事前")
  10024. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10025. utils.ErrorLog("解析失败:%v", err)
  10026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10027. return
  10028. }
  10029. return res
  10030. }
  10031. return res
  10032. }
  10033. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10034. ////patient_id, _ := c.GetInt64("patient_id")
  10035. //order_id, _ := c.GetInt64("order_id")
  10036. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10037. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10038. //trig_scen := c.GetString("trig_scen")
  10039. adminUser := c.GetAdminUserInfo()
  10040. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10041. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10042. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10043. record_time := c.GetString("record_time")
  10044. order, _ := service.GetHisOrderByID(order_id)
  10045. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10046. timeLayout := "2006-01-02"
  10047. loc, _ := time.LoadLocation("Local")
  10048. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10049. if err != nil {
  10050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10051. return
  10052. }
  10053. recordDateTime := theTime.Unix()
  10054. var patientPrescription models.HisPrescriptionInfo
  10055. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10056. if patientPrescription.ID == 0 {
  10057. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10058. }
  10059. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10060. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10061. //
  10062. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10063. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10064. var pp models.PublicParams
  10065. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10066. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10067. pp.FixmedinsName = miConfig.OrgName
  10068. pp.FixmedinsCode = miConfig.Code
  10069. pp.RequestUrl = miConfig.Url
  10070. pp.Cainfo = miConfig.Cainfo
  10071. pp.SecretKey = miConfig.SecretKey
  10072. pp.AccessKey = miConfig.AccessKey
  10073. pp.OpterName = roles.UserName
  10074. var config []*models.HisXtDiagnoseConfig
  10075. for _, item := range diagnosis_ids {
  10076. id, _ := strconv.ParseInt(item, 10, 64)
  10077. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10078. config = append(config, &diagnosisConfig)
  10079. }
  10080. var pd models.PatientDtos
  10081. pd.PatnID = his.PsnNo
  10082. pd.PatnName = his.Name
  10083. pd.Gend = his.Gend
  10084. pd.Brdy = psn_info.Brdy
  10085. pd.Poolarea = his.InsuplcAdmdvs
  10086. pd.CurrMdtrtID = his.Number
  10087. var fed models.FsiEncounterDtos
  10088. fed.MdtrtID = his.Number
  10089. fed.MedinsID = miConfig.Code
  10090. fed.MedinsName = miConfig.OrgName
  10091. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10092. fed.MedMdtrtType = "1"
  10093. fed.MedinsType = "1"
  10094. fed.MedinsLv = "11"
  10095. tm := time.Unix(his.RecordDate, 0)
  10096. s_tm := tm.Format("2006-01-02 15:04:05")
  10097. fed.AdmDate = s_tm
  10098. fed.DscgDate = s_tm
  10099. fed.DscgMainDiseCodg = config[0].CountryCode
  10100. fed.DscgMainDiseName = config[0].CountryContentName
  10101. //诊断信息
  10102. var fdds []*models.FsiDiagnoseDtos
  10103. for index, item := range config {
  10104. if index == 0 {
  10105. var fdd models.FsiDiagnoseDtos
  10106. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10107. fdd.InoutDiseType = "1"
  10108. fdd.MaindiseFlag = "1"
  10109. fdd.DiseDate = s_tm
  10110. fdd.DiasSrtNo = "1"
  10111. fdd.DiseName = item.CountryContentName
  10112. fdd.DiseCodg = item.CountryCode
  10113. fdds = append(fdds, &fdd)
  10114. } else {
  10115. var fdd models.FsiDiagnoseDtos
  10116. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10117. fdd.InoutDiseType = "1"
  10118. fdd.MaindiseFlag = "1"
  10119. fdd.DiseDate = s_tm
  10120. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10121. fdd.DiseName = item.CountryContentName
  10122. fdd.DiseCodg = item.CountryCode
  10123. fdds = append(fdds, &fdd)
  10124. }
  10125. }
  10126. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10127. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10128. fed.AdmDeptName = department.Name
  10129. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10130. fed.DscgDeptName = department.Name
  10131. fed.MedType = order.MedType
  10132. //处方医嘱信息
  10133. var orders []*models.FsiOrderDtos
  10134. //for _, item := range prescriptions {
  10135. // for _, subItem := range item.HisDoctorAdviceInfo {
  10136. // var order models.FsiOrderDtos
  10137. // order.RxID = strconv.FormatInt(item.ID, 10)
  10138. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10139. // order.LongDrordFlag = "0"
  10140. // order.HilistType = "1"
  10141. // order.ChrgType = "1"
  10142. // order.DrordBhvr = "-"
  10143. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10144. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10145. // order.HilistLv = "1"
  10146. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10147. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10148. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10149. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10150. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10151. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10152. // order.OwnpayAmt = ""
  10153. // order.SelfpayAmt = ""
  10154. // order.Spec = ""
  10155. // order.SpecUnt = ""
  10156. // order.DrordBegnDate = s_tm
  10157. // order.DrordStopDate = ""
  10158. // order.DrordDrCodg = "1"
  10159. // order.DrordDeptName = department.Name
  10160. // order.DrordDrCodg = "1"
  10161. // order.DrordDrName = doctor_info.UserName
  10162. // order.DrordDrProfttl = ""
  10163. // order.CurrDrordFlag = "1"
  10164. // orders = append(orders, &order)
  10165. // }
  10166. // for _, subItem := range item.HisPrescriptionProject {
  10167. // if subItem.Type == 2 {
  10168. // var order models.FsiOrderDtos
  10169. // order.RxID = strconv.FormatInt(item.ID, 10)
  10170. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10171. // order.LongDrordFlag = "0"
  10172. // order.HilistType = "1"
  10173. // order.ChrgType = "1"
  10174. // order.DrordBhvr = "-"
  10175. // order.HilistCode = subItem.HisProject.MedicalCode
  10176. // order.HosplistName = subItem.HisProject.ProjectName
  10177. // order.HilistLv = "1"
  10178. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10179. // order.HosplistCode = subItem.HisProject.MedicalCode
  10180. // order.HosplistName = subItem.HisProject.ProjectName
  10181. // order.Cnt = subItem.Count
  10182. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10183. //
  10184. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10185. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10186. // order.OwnpayAmt = ""
  10187. // order.SelfpayAmt = ""
  10188. // order.Spec = ""
  10189. // order.SpecUnt = ""
  10190. // order.DrordBegnDate = s_tm
  10191. // order.DrordStopDate = ""
  10192. // order.DrordDrCodg = "1"
  10193. // order.DrordDeptName = department.Name
  10194. // order.DrordDrCodg = "1"
  10195. // order.DrordDrName = doctor_info.UserName
  10196. // order.DrordDrProfttl = ""
  10197. // order.CurrDrordFlag = "1"
  10198. // orders = append(orders, &order)
  10199. //
  10200. // }
  10201. // if subItem.Type == 3 {
  10202. //
  10203. // var order models.FsiOrderDtos
  10204. // order.RxID = strconv.FormatInt(item.ID, 10)
  10205. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10206. // order.LongDrordFlag = "0"
  10207. // order.HilistType = "1"
  10208. // order.ChrgType = "1"
  10209. // order.DrordBhvr = "-"
  10210. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10211. // order.HosplistName = subItem.GoodInfo.GoodName
  10212. // order.HilistLv = "1"
  10213. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10214. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10215. // order.HosplistName = subItem.GoodInfo.GoodName
  10216. // order.Cnt = subItem.Count
  10217. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10218. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10219. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10220. // order.OwnpayAmt = ""
  10221. // order.SelfpayAmt = ""
  10222. // order.Spec = ""
  10223. // order.SpecUnt = ""
  10224. // order.DrordBegnDate = s_tm
  10225. // order.DrordStopDate = ""
  10226. // order.DrordDrCodg = "1"
  10227. // order.DrordDeptName = department.Name
  10228. // order.DrordDrCodg = "1"
  10229. // order.DrordDrName = doctor_info.UserName
  10230. // order.DrordDrProfttl = ""
  10231. // order.CurrDrordFlag = "1"
  10232. // orders = append(orders, &order)
  10233. //
  10234. // }
  10235. // }
  10236. //}
  10237. for _, item := range prescriptions {
  10238. for _, subItem := range item.HisDoctorAdviceInfo {
  10239. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10240. var order models.FsiOrderDtos
  10241. order.RxID = strconv.FormatInt(item.ID, 10)
  10242. order.Rxno = strconv.FormatInt(item.ID, 10)
  10243. order.LongDrordFlag = "0"
  10244. order.HilistType = "1"
  10245. order.ChrgType = "1"
  10246. order.DrordBhvr = "-"
  10247. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10248. order.HosplistName = subItem.BaseDrugLib.DrugName
  10249. order.HilistLv = "1"
  10250. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10251. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10252. order.HosplistName = subItem.BaseDrugLib.DrugName
  10253. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10254. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10255. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10256. order.OwnpayAmt = ""
  10257. order.SelfpayAmt = ""
  10258. order.Spec = ""
  10259. order.SpecUnt = ""
  10260. order.DrordBegnDate = s_tm
  10261. order.DrordStopDate = ""
  10262. order.DrordDrCodg = doctor_info.DoctorNumber
  10263. order.DrordDeptName = department.Name
  10264. order.DrordDeptCodg = department.Number
  10265. order.DrordDrName = doctor_info.UserName
  10266. order.DrordDrProfttl = "234"
  10267. order.CurrDrordFlag = "1"
  10268. orders = append(orders, &order)
  10269. }
  10270. }
  10271. for _, subItem := range item.HisPrescriptionProject {
  10272. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10273. var order models.FsiOrderDtos
  10274. order.RxID = strconv.FormatInt(item.ID, 10)
  10275. order.Rxno = strconv.FormatInt(item.ID, 10)
  10276. order.LongDrordFlag = "0"
  10277. order.HilistType = "1"
  10278. order.ChrgType = "1"
  10279. order.DrordBhvr = "-"
  10280. order.HilistCode = subItem.HisProject.MedicalCode
  10281. order.HosplistName = subItem.HisProject.ProjectName
  10282. order.HilistLv = "1"
  10283. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10284. order.HosplistCode = subItem.HisProject.MedicalCode
  10285. order.HosplistName = subItem.HisProject.ProjectName
  10286. order.Cnt = subItem.Count
  10287. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10288. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10289. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10290. order.OwnpayAmt = ""
  10291. order.SelfpayAmt = ""
  10292. order.Spec = ""
  10293. order.SpecUnt = ""
  10294. order.DrordBegnDate = s_tm
  10295. order.DrordStopDate = ""
  10296. order.DrordDrCodg = doctor_info.DoctorNumber
  10297. order.DrordDeptName = department.Name
  10298. order.DrordDeptCodg = department.Number
  10299. order.DrordDrName = doctor_info.UserName
  10300. order.DrordDrProfttl = "234"
  10301. order.CurrDrordFlag = "1"
  10302. orders = append(orders, &order)
  10303. }
  10304. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10305. var order models.FsiOrderDtos
  10306. order.RxID = strconv.FormatInt(item.ID, 10)
  10307. order.Rxno = strconv.FormatInt(item.ID, 10)
  10308. order.LongDrordFlag = "0"
  10309. order.HilistType = "1"
  10310. order.ChrgType = "1"
  10311. order.DrordBhvr = "0"
  10312. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10313. order.HosplistName = subItem.GoodInfo.GoodName
  10314. order.HilistLv = "1"
  10315. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10316. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10317. order.HosplistName = subItem.GoodInfo.GoodName
  10318. order.Cnt = subItem.Count
  10319. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10320. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10321. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10322. order.OwnpayAmt = ""
  10323. order.SelfpayAmt = ""
  10324. order.Spec = ""
  10325. order.SpecUnt = ""
  10326. order.DrordBegnDate = s_tm
  10327. order.DrordStopDate = ""
  10328. order.DrordDrCodg = doctor_info.DoctorNumber
  10329. order.DrordDeptName = department.Name
  10330. order.DrordDeptCodg = department.Number
  10331. order.DrordDrName = doctor_info.UserName
  10332. order.DrordDrProfttl = "234"
  10333. order.CurrDrordFlag = "1"
  10334. orders = append(orders, &order)
  10335. }
  10336. }
  10337. }
  10338. //处方医嘱信息
  10339. fed.MatnStas = "0"
  10340. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  10341. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  10342. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  10343. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  10344. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  10345. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  10346. fed.SetlTotlnum = "1"
  10347. fed.Insutype = his.Insutype
  10348. fed.ReimFlag = "0"
  10349. fed.OutSetlFlag = "0"
  10350. var fopd []*models.FsiOperationDtosData
  10351. data := make(map[string]interface{})
  10352. data["fed"] = fed
  10353. data["fdd"] = fdds
  10354. data["fod"] = orders
  10355. data["pd"] = pd
  10356. data["pp"] = pp
  10357. data["fopd"] = fopd
  10358. data["trig_scen"] = trig_scen
  10359. client := &http.Client{}
  10360. bytesData, _ := json.Marshal(data)
  10361. var req *http.Request
  10362. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10363. if miConfig.MdtrtareaAdmvs == "320921" {
  10364. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10365. } else {
  10366. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10367. }
  10368. resp, _ := client.Do(req)
  10369. defer resp.Body.Close()
  10370. body, ioErr := ioutil.ReadAll(resp.Body)
  10371. if ioErr != nil {
  10372. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10374. return res
  10375. }
  10376. var respJSON map[string]interface{}
  10377. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10378. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10380. return res
  10381. }
  10382. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10383. result, _ := json.Marshal(respJSON)
  10384. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10385. utils.ErrorLog("解析失败:%v", err)
  10386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10387. return res
  10388. }
  10389. return res
  10390. } else {
  10391. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10392. saveLog(output, input, "3102", "事中")
  10393. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10394. utils.ErrorLog("解析失败:%v", err)
  10395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10396. return
  10397. }
  10398. return res
  10399. }
  10400. return res
  10401. }
  10402. 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) {
  10403. var res Resultgd3101
  10404. adminUser := c.GetAdminUserInfo()
  10405. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10406. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10407. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10408. //record_time := c.GetString("record_time")
  10409. //trig_scen := c.GetString("trig_scen")
  10410. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  10411. //psn_info, _ := service.GetPatientId(patient_id)
  10412. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  10413. timeLayout := "2006-01-02"
  10414. loc, _ := time.LoadLocation("Local")
  10415. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10416. if err != nil {
  10417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10418. return res
  10419. }
  10420. recordDateTime := theTime.Unix()
  10421. var patientPrescription models.HisPrescriptionInfo
  10422. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10423. //if patientPrescription.ID == 0 {
  10424. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10425. //}
  10426. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10427. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10428. //
  10429. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10430. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10431. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  10432. var pp models.PublicParams
  10433. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10434. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10435. pp.FixmedinsName = miConfig.OrgName
  10436. pp.FixmedinsCode = miConfig.Code
  10437. pp.RequestUrl = miConfig.Url
  10438. pp.Cainfo = miConfig.Cainfo
  10439. pp.SecretKey = miConfig.SecretKey
  10440. pp.AccessKey = miConfig.AccessKey
  10441. pp.OpterName = roles.UserName
  10442. var config []*models.HisXtDiagnoseConfig
  10443. for _, item := range diagnosis_ids {
  10444. id, _ := strconv.ParseInt(item, 10, 64)
  10445. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10446. config = append(config, &diagnosisConfig)
  10447. }
  10448. var pd models.PatientDtos
  10449. pd.PatnID = his.PsnNo
  10450. pd.PatnName = his.Name
  10451. pd.Gend = his.Gend
  10452. pd.Brdy = str
  10453. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10454. pd.CurrMdtrtID = his.Number
  10455. var fed models.FsiEncounterDtos
  10456. fed.MdtrtID = his.Number
  10457. fed.MedinsID = miConfig.Code
  10458. fed.MedinsName = miConfig.OrgName
  10459. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10460. fed.MedMdtrtType = "1"
  10461. fed.MedinsType = "1"
  10462. fed.MedinsLv = "11"
  10463. tm := time.Unix(his.RecordDate, 0)
  10464. s_tm := tm.Format("2006-01-02 15:04:05")
  10465. fed.AdmDate = s_tm
  10466. fed.DscgDate = s_tm
  10467. fed.DscgMainDiseCodg = config[0].CountryCode
  10468. fed.DscgMainDiseName = config[0].CountryContentName
  10469. //诊断信息
  10470. var fdds []*models.FsiDiagnoseDtos
  10471. for index, item := range config {
  10472. if index == 0 {
  10473. var fdd models.FsiDiagnoseDtos
  10474. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10475. fdd.InoutDiseType = "1"
  10476. fdd.MaindiseFlag = "1"
  10477. fdd.DiseDate = s_tm
  10478. fdd.DiasSrtNo = "1"
  10479. fdd.DiseName = item.CountryContentName
  10480. fdd.DiseCodg = item.CountryCode
  10481. fdds = append(fdds, &fdd)
  10482. } else {
  10483. var fdd models.FsiDiagnoseDtos
  10484. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10485. fdd.InoutDiseType = "1"
  10486. fdd.MaindiseFlag = "1"
  10487. fdd.DiseDate = s_tm
  10488. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10489. fdd.DiseName = item.CountryContentName
  10490. fdd.DiseCodg = item.CountryCode
  10491. fdds = append(fdds, &fdd)
  10492. }
  10493. }
  10494. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10495. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10496. fed.AdmDeptName = de.Name
  10497. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10498. fed.DscgDeptName = de.Name
  10499. fed.MedMdtrtType = "1"
  10500. fed.MedType = "11"
  10501. //if his.Insutype == "390" {
  10502. // fed.MedType = "1402"
  10503. //} else {
  10504. // fed.MedType = "9933"
  10505. //}
  10506. var orders []*models.FsiOrderDtos
  10507. if trig_scen == "2" {
  10508. //处方医嘱信息
  10509. for _, item := range prescriptions {
  10510. for _, subItem := range item.HisDoctorAdviceInfo {
  10511. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10512. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  10513. var order models.FsiOrderDtos
  10514. order.RxID = strconv.FormatInt(item.ID, 10)
  10515. order.Rxno = strconv.FormatInt(item.ID, 10)
  10516. order.LongDrordFlag = "0"
  10517. order.HilistType = "1"
  10518. order.ChrgType = "1"
  10519. order.DrordBhvr = "0"
  10520. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10521. order.HosplistName = subItem.BaseDrugLib.DrugName
  10522. order.HilistLv = "1"
  10523. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10524. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10525. order.HosplistName = subItem.BaseDrugLib.DrugName
  10526. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10527. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10528. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10529. order.OwnpayAmt = ""
  10530. order.SelfpayAmt = ""
  10531. order.Spec = spec
  10532. order.SpecUnt = subItem.PrescribingNumberUnit
  10533. order.DrordBegnDate = s_tm
  10534. order.DrordStopDate = ""
  10535. order.DrordDrCodg = doctor_info.DoctorNumber
  10536. order.DrordDeptName = department.Name
  10537. order.DrordDeptCodg = department.Number
  10538. order.DrordDrName = doctor_info.UserName
  10539. order.DrordDrProfttl = "234"
  10540. order.CurrDrordFlag = "1"
  10541. orders = append(orders, &order)
  10542. }
  10543. }
  10544. for _, subItem := range item.HisPrescriptionProject {
  10545. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10546. var order models.FsiOrderDtos
  10547. order.RxID = strconv.FormatInt(item.ID, 10)
  10548. order.Rxno = strconv.FormatInt(item.ID, 10)
  10549. order.LongDrordFlag = "0"
  10550. order.HilistType = "1"
  10551. order.ChrgType = "1"
  10552. order.DrordBhvr = "0"
  10553. order.HilistCode = subItem.HisProject.MedicalCode
  10554. order.HosplistName = subItem.HisProject.ProjectName
  10555. order.HilistLv = "1"
  10556. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10557. order.HosplistCode = subItem.HisProject.MedicalCode
  10558. order.HosplistName = subItem.HisProject.ProjectName
  10559. order.Cnt = subItem.Count
  10560. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10561. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10562. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10563. order.OwnpayAmt = ""
  10564. order.SelfpayAmt = ""
  10565. order.Spec = subItem.Unit
  10566. order.SpecUnt = subItem.Unit
  10567. order.DrordBegnDate = s_tm
  10568. order.DrordStopDate = ""
  10569. order.DrordDrCodg = doctor_info.DoctorNumber
  10570. order.DrordDeptName = department.Name
  10571. order.DrordDeptCodg = department.Number
  10572. order.DrordDrName = doctor_info.UserName
  10573. order.DrordDrProfttl = "234"
  10574. order.CurrDrordFlag = "1"
  10575. orders = append(orders, &order)
  10576. }
  10577. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10578. var order models.FsiOrderDtos
  10579. order.RxID = strconv.FormatInt(item.ID, 10)
  10580. order.Rxno = strconv.FormatInt(item.ID, 10)
  10581. order.LongDrordFlag = "0"
  10582. order.HilistType = "1"
  10583. order.ChrgType = "1"
  10584. order.DrordBhvr = "0"
  10585. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10586. order.HosplistName = subItem.GoodInfo.GoodName
  10587. order.HilistLv = "1"
  10588. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10589. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10590. order.HosplistName = subItem.GoodInfo.GoodName
  10591. order.Cnt = subItem.Count
  10592. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10593. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10594. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10595. order.OwnpayAmt = ""
  10596. order.SelfpayAmt = ""
  10597. order.Spec = subItem.GoodInfo.SpecificationName
  10598. order.SpecUnt = subItem.Unit
  10599. order.DrordBegnDate = s_tm
  10600. order.DrordStopDate = ""
  10601. order.DrordDrCodg = doctor_info.DoctorNumber
  10602. order.DrordDeptName = department.Name
  10603. order.DrordDeptCodg = department.Number
  10604. order.DrordDrName = doctor_info.UserName
  10605. order.DrordDrProfttl = "234"
  10606. order.CurrDrordFlag = "1"
  10607. orders = append(orders, &order)
  10608. }
  10609. }
  10610. }
  10611. //处方医嘱信息
  10612. }
  10613. fed.MatnStas = "0"
  10614. fed.MedfeeSumamt = "0"
  10615. fed.OwnpayAmt = "0"
  10616. fed.SelfpayAmt = "0"
  10617. fed.AcctPayamt = "0"
  10618. fed.MaAmt = "0"
  10619. fed.HifpPayamt = "0"
  10620. fed.SetlTotlnum = "1"
  10621. fed.Insutype = his.Insutype
  10622. fed.ReimFlag = "0"
  10623. fed.OutSetlFlag = "0"
  10624. var fopd []*models.FsiOperationDtosData
  10625. data := make(map[string]interface{})
  10626. data["fed"] = fed
  10627. data["fdd"] = fdds
  10628. data["fod"] = orders
  10629. data["pd"] = pd
  10630. data["pp"] = pp
  10631. data["fopd"] = fopd
  10632. data["trig_scen"] = trig_scen
  10633. fmt.Println(data)
  10634. fmt.Println(fed)
  10635. fmt.Println(fdds)
  10636. fmt.Println(orders)
  10637. fmt.Println(pd)
  10638. fmt.Println(pp)
  10639. fmt.Println(fopd)
  10640. client := &http.Client{}
  10641. bytesData, _ := json.Marshal(data)
  10642. var req *http.Request
  10643. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10644. if miConfig.MdtrtareaAdmvs == "320921" {
  10645. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10646. } else {
  10647. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10648. }
  10649. resp, _ := client.Do(req)
  10650. defer resp.Body.Close()
  10651. body, ioErr := ioutil.ReadAll(resp.Body)
  10652. if ioErr != nil {
  10653. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10655. return res
  10656. }
  10657. var respJSON map[string]interface{}
  10658. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10659. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10661. return res
  10662. }
  10663. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10664. fmt.Println(respJSON)
  10665. result, _ := json.Marshal(respJSON)
  10666. fmt.Println(result)
  10667. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10668. utils.ErrorLog("解析失败:%v", err)
  10669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10670. return res
  10671. }
  10672. return res
  10673. } else {
  10674. //if miConfig.MdtrtareaAdmvs == "441202" {
  10675. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10676. saveLog(output, input, "3101", "事前")
  10677. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10678. utils.ErrorLog("解析失败:%v", err)
  10679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10680. return
  10681. }
  10682. return res
  10683. //}
  10684. }
  10685. }
  10686. 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) {
  10687. adminUser := c.GetAdminUserInfo()
  10688. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10689. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10690. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10691. //record_time := c.GetString("record_time")
  10692. //trig_scen := c.GetString("trig_scen")
  10693. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  10694. timeLayout := "2006-01-02"
  10695. loc, _ := time.LoadLocation("Local")
  10696. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10697. if err != nil {
  10698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10699. return res
  10700. }
  10701. recordDateTime := theTime.Unix()
  10702. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  10703. var patientPrescription models.HisPrescriptionInfo
  10704. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10705. if patientPrescription.ID == 0 {
  10706. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10707. }
  10708. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10709. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10710. //
  10711. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10712. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10713. var pp models.PublicParams
  10714. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10715. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10716. pp.FixmedinsName = miConfig.OrgName
  10717. pp.FixmedinsCode = miConfig.Code
  10718. pp.RequestUrl = miConfig.Url
  10719. pp.Cainfo = miConfig.Cainfo
  10720. pp.SecretKey = miConfig.SecretKey
  10721. pp.AccessKey = miConfig.AccessKey
  10722. pp.OpterName = roles.UserName
  10723. var config []*models.HisXtDiagnoseConfig
  10724. for _, item := range diagnosis_ids {
  10725. id, _ := strconv.ParseInt(item, 10, 64)
  10726. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10727. config = append(config, &diagnosisConfig)
  10728. }
  10729. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  10730. var pd models.PatientDtos
  10731. pd.PatnID = his.PsnNo
  10732. pd.PatnName = his.Name
  10733. pd.Gend = his.Gend
  10734. pd.Brdy = str
  10735. pd.Poolarea = his.InsuplcAdmdvs
  10736. pd.CurrMdtrtID = his.Number
  10737. var fed models.FsiEncounterDtos
  10738. fed.MdtrtID = his.Number
  10739. fed.MedinsID = miConfig.Code
  10740. fed.MedinsName = miConfig.OrgName
  10741. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10742. fed.MedMdtrtType = "1"
  10743. fed.MedinsType = "1"
  10744. fed.MedinsLv = "11"
  10745. tm := time.Unix(his.RecordDate, 0)
  10746. s_tm := tm.Format("2006-01-02 15:04:05")
  10747. fed.AdmDate = s_tm
  10748. fed.DscgDate = s_tm
  10749. fed.DscgMainDiseCodg = config[0].CountryCode
  10750. fed.DscgMainDiseName = config[0].CountryContentName
  10751. //诊断信息
  10752. var fdds []*models.FsiDiagnoseDtos
  10753. for index, item := range config {
  10754. if index == 0 {
  10755. var fdd models.FsiDiagnoseDtos
  10756. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10757. fdd.InoutDiseType = "1"
  10758. fdd.MaindiseFlag = "1"
  10759. fdd.DiseDate = s_tm
  10760. fdd.DiasSrtNo = "1"
  10761. fdd.DiseName = item.CountryContentName
  10762. fdd.DiseCodg = item.CountryCode
  10763. fdds = append(fdds, &fdd)
  10764. } else {
  10765. var fdd models.FsiDiagnoseDtos
  10766. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10767. fdd.InoutDiseType = "1"
  10768. fdd.MaindiseFlag = "1"
  10769. fdd.DiseDate = s_tm
  10770. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10771. fdd.DiseName = item.CountryContentName
  10772. fdd.DiseCodg = item.CountryCode
  10773. fdds = append(fdds, &fdd)
  10774. }
  10775. }
  10776. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10777. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10778. fed.AdmDeptName = department.Name
  10779. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10780. fed.DscgDeptName = department.Name
  10781. fed.MedMdtrtType = "1"
  10782. fed.MedType = "11"
  10783. //if his.Insutype == "390" {
  10784. // fed.MedType = "1402"
  10785. //} else {
  10786. // fed.MedType = "9933"
  10787. //}
  10788. var orders []*models.FsiOrderDtos
  10789. if trig_scen == "2" {
  10790. //处方医嘱信息
  10791. for _, item := range prescriptions {
  10792. for _, subItem := range item.HisDoctorAdviceInfo {
  10793. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10794. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  10795. var order models.FsiOrderDtos
  10796. order.RxID = strconv.FormatInt(item.ID, 10)
  10797. order.Rxno = strconv.FormatInt(item.ID, 10)
  10798. order.LongDrordFlag = "0"
  10799. order.HilistType = "1"
  10800. order.ChrgType = "1"
  10801. order.DrordBhvr = "0"
  10802. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10803. order.HosplistName = subItem.BaseDrugLib.DrugName
  10804. order.HilistLv = "1"
  10805. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10806. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10807. order.HosplistName = subItem.BaseDrugLib.DrugName
  10808. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10809. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10810. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10811. order.OwnpayAmt = ""
  10812. order.SelfpayAmt = ""
  10813. order.Spec = spec
  10814. order.SpecUnt = subItem.PrescribingNumberUnit
  10815. order.DrordBegnDate = s_tm
  10816. order.DrordStopDate = ""
  10817. order.DrordDrCodg = doctor_info.DoctorNumber
  10818. order.DrordDeptName = department.Name
  10819. order.DrordDeptCodg = department.Number
  10820. order.DrordDrName = doctor_info.UserName
  10821. order.DrordDrProfttl = "234"
  10822. order.CurrDrordFlag = "1"
  10823. orders = append(orders, &order)
  10824. }
  10825. }
  10826. for _, subItem := range item.HisPrescriptionProject {
  10827. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10828. var order models.FsiOrderDtos
  10829. order.RxID = strconv.FormatInt(item.ID, 10)
  10830. order.Rxno = strconv.FormatInt(item.ID, 10)
  10831. order.LongDrordFlag = "0"
  10832. order.HilistType = "1"
  10833. order.ChrgType = "1"
  10834. order.DrordBhvr = "0"
  10835. order.HilistCode = subItem.HisProject.MedicalCode
  10836. order.HosplistName = subItem.HisProject.ProjectName
  10837. order.HilistLv = "1"
  10838. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10839. order.HosplistCode = subItem.HisProject.MedicalCode
  10840. order.HosplistName = subItem.HisProject.ProjectName
  10841. order.Cnt = subItem.Count
  10842. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10843. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10844. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10845. order.OwnpayAmt = ""
  10846. order.SelfpayAmt = ""
  10847. order.Spec = subItem.Unit
  10848. order.SpecUnt = subItem.Unit
  10849. order.DrordBegnDate = s_tm
  10850. order.DrordStopDate = ""
  10851. order.DrordDrCodg = doctor_info.DoctorNumber
  10852. order.DrordDeptName = department.Name
  10853. order.DrordDeptCodg = department.Number
  10854. order.DrordDrName = doctor_info.UserName
  10855. order.DrordDrProfttl = "234"
  10856. order.CurrDrordFlag = "1"
  10857. orders = append(orders, &order)
  10858. }
  10859. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10860. var order models.FsiOrderDtos
  10861. order.RxID = strconv.FormatInt(item.ID, 10)
  10862. order.Rxno = strconv.FormatInt(item.ID, 10)
  10863. order.LongDrordFlag = "0"
  10864. order.HilistType = "1"
  10865. order.ChrgType = "1"
  10866. order.DrordBhvr = "0"
  10867. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10868. order.HosplistName = subItem.GoodInfo.GoodName
  10869. order.HilistLv = "1"
  10870. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10871. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10872. order.HosplistName = subItem.GoodInfo.GoodName
  10873. order.Cnt = subItem.Count
  10874. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10875. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10876. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10877. order.OwnpayAmt = ""
  10878. order.SelfpayAmt = ""
  10879. order.Spec = subItem.GoodInfo.SpecificationName
  10880. order.SpecUnt = subItem.Unit
  10881. order.DrordBegnDate = s_tm
  10882. order.DrordStopDate = ""
  10883. order.DrordDrCodg = doctor_info.DoctorNumber
  10884. order.DrordDeptName = department.Name
  10885. order.DrordDeptCodg = department.Number
  10886. order.DrordDrName = doctor_info.UserName
  10887. order.DrordDrProfttl = "234"
  10888. order.CurrDrordFlag = "1"
  10889. orders = append(orders, &order)
  10890. }
  10891. }
  10892. }
  10893. //处方医嘱信息
  10894. }
  10895. fed.MatnStas = "0"
  10896. fed.MedfeeSumamt = "0"
  10897. fed.OwnpayAmt = "0"
  10898. fed.SelfpayAmt = "0"
  10899. fed.AcctPayamt = "0"
  10900. fed.MaAmt = "0"
  10901. fed.HifpPayamt = "0"
  10902. fed.SetlTotlnum = "1"
  10903. fed.Insutype = his.Insutype
  10904. fed.ReimFlag = "0"
  10905. fed.OutSetlFlag = "0"
  10906. var fopd []*models.FsiOperationDtosData
  10907. data := make(map[string]interface{})
  10908. data["fed"] = fed
  10909. data["fdd"] = fdds
  10910. data["fod"] = orders
  10911. data["pd"] = pd
  10912. data["pp"] = pp
  10913. data["fopd"] = fopd
  10914. data["trig_scen"] = trig_scen
  10915. fmt.Println(data)
  10916. fmt.Println(fed)
  10917. fmt.Println(fdds)
  10918. fmt.Println(orders)
  10919. fmt.Println(pd)
  10920. fmt.Println(pp)
  10921. fmt.Println(fopd)
  10922. client := &http.Client{}
  10923. bytesData, _ := json.Marshal(data)
  10924. var req *http.Request
  10925. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10926. if miConfig.MdtrtareaAdmvs == "320921" {
  10927. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10928. } else {
  10929. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10930. }
  10931. resp, _ := client.Do(req)
  10932. defer resp.Body.Close()
  10933. body, ioErr := ioutil.ReadAll(resp.Body)
  10934. if ioErr != nil {
  10935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10937. return res
  10938. }
  10939. var respJSON map[string]interface{}
  10940. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10943. return res
  10944. }
  10945. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10946. fmt.Println(respJSON)
  10947. result, _ := json.Marshal(respJSON)
  10948. fmt.Println(result)
  10949. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10950. utils.ErrorLog("解析失败:%v", err)
  10951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10952. return res
  10953. }
  10954. return res
  10955. } else {
  10956. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10957. saveLog(output, input, "3101", "事前")
  10958. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10959. utils.ErrorLog("解析失败:%v", err)
  10960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10961. return
  10962. }
  10963. return res
  10964. }
  10965. return res
  10966. }
  10967. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  10968. ////patient_id, _ := c.GetInt64("patient_id")
  10969. //order_id, _ := c.GetInt64("order_id")
  10970. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10971. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10972. //trig_scen := c.GetString("trig_scen")
  10973. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  10974. //utils.ErrorLog("解析失败:%v", psn_info)
  10975. adminUser := c.GetAdminUserInfo()
  10976. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10977. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10978. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10979. record_time := c.GetString("record_time")
  10980. order, _ := service.GetHisOrderByID(order_id)
  10981. timeLayout := "2006-01-02"
  10982. loc, _ := time.LoadLocation("Local")
  10983. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10984. if err != nil {
  10985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10986. return
  10987. }
  10988. recordDateTime := theTime.Unix()
  10989. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  10990. var patientPrescription models.HisPrescriptionInfo
  10991. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10992. if patientPrescription.ID == 0 {
  10993. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10994. }
  10995. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10996. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10997. //
  10998. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10999. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11000. var pp models.PublicParams
  11001. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11002. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11003. pp.FixmedinsName = miConfig.OrgName
  11004. pp.FixmedinsCode = miConfig.Code
  11005. pp.RequestUrl = miConfig.Url
  11006. pp.Cainfo = miConfig.Cainfo
  11007. pp.SecretKey = miConfig.SecretKey
  11008. pp.AccessKey = miConfig.AccessKey
  11009. pp.OpterName = roles.UserName
  11010. var config []*models.HisXtDiagnoseConfig
  11011. for _, item := range diagnosis_ids {
  11012. id, _ := strconv.ParseInt(item, 10, 64)
  11013. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11014. config = append(config, &diagnosisConfig)
  11015. }
  11016. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11017. var pd models.PatientDtos
  11018. pd.PatnID = his.PsnNo
  11019. pd.PatnName = his.Name
  11020. pd.Gend = his.Gend
  11021. pd.Brdy = str
  11022. pd.Poolarea = his.InsuplcAdmdvs
  11023. pd.CurrMdtrtID = his.Number
  11024. var fed models.FsiEncounterDtos
  11025. fed.MdtrtID = his.Number
  11026. fed.MedinsID = miConfig.Code
  11027. fed.MedinsName = miConfig.OrgName
  11028. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11029. fed.MedMdtrtType = "1"
  11030. fed.MedinsType = "1"
  11031. fed.MedinsLv = "11"
  11032. tm := time.Unix(his.RecordDate, 0)
  11033. s_tm := tm.Format("2006-01-02 15:04:05")
  11034. fed.AdmDate = s_tm
  11035. fed.DscgDate = s_tm
  11036. fed.DscgMainDiseCodg = config[0].CountryCode
  11037. fed.DscgMainDiseName = config[0].CountryContentName
  11038. //诊断信息
  11039. var fdds []*models.FsiDiagnoseDtos
  11040. for index, item := range config {
  11041. if index == 0 {
  11042. var fdd models.FsiDiagnoseDtos
  11043. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11044. fdd.InoutDiseType = "1"
  11045. fdd.MaindiseFlag = "1"
  11046. fdd.DiseDate = s_tm
  11047. fdd.DiasSrtNo = "1"
  11048. fdd.DiseName = item.CountryContentName
  11049. fdd.DiseCodg = item.CountryCode
  11050. fdds = append(fdds, &fdd)
  11051. } else {
  11052. var fdd models.FsiDiagnoseDtos
  11053. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11054. fdd.InoutDiseType = "1"
  11055. fdd.MaindiseFlag = "1"
  11056. fdd.DiseDate = s_tm
  11057. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11058. fdd.DiseName = item.CountryContentName
  11059. fdd.DiseCodg = item.CountryCode
  11060. fdds = append(fdds, &fdd)
  11061. }
  11062. }
  11063. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11064. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11065. fed.AdmDeptName = department.Name
  11066. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11067. fed.DscgDeptName = department.Name
  11068. fed.MedType = order.MedType
  11069. //处方医嘱信息
  11070. var orders []*models.FsiOrderDtos
  11071. //for _, item := range prescriptions {
  11072. // for _, subItem := range item.HisDoctorAdviceInfo {
  11073. // var order models.FsiOrderDtos
  11074. // order.RxID = strconv.FormatInt(item.ID, 10)
  11075. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11076. // order.LongDrordFlag = "0"
  11077. // order.HilistType = "1"
  11078. // order.ChrgType = "1"
  11079. // order.DrordBhvr = "-"
  11080. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11081. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11082. // order.HilistLv = "1"
  11083. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11084. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11085. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11086. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11087. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11088. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11089. // order.OwnpayAmt = ""
  11090. // order.SelfpayAmt = ""
  11091. // order.Spec = ""
  11092. // order.SpecUnt = ""
  11093. // order.DrordBegnDate = s_tm
  11094. // order.DrordStopDate = ""
  11095. // order.DrordDrCodg = "1"
  11096. // order.DrordDeptName = department.Name
  11097. // order.DrordDrCodg = "1"
  11098. // order.DrordDrName = doctor_info.UserName
  11099. // order.DrordDrProfttl = ""
  11100. // order.CurrDrordFlag = "1"
  11101. // orders = append(orders, &order)
  11102. // }
  11103. // for _, subItem := range item.HisPrescriptionProject {
  11104. // if subItem.Type == 2 {
  11105. // var order models.FsiOrderDtos
  11106. // order.RxID = strconv.FormatInt(item.ID, 10)
  11107. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11108. // order.LongDrordFlag = "0"
  11109. // order.HilistType = "1"
  11110. // order.ChrgType = "1"
  11111. // order.DrordBhvr = "-"
  11112. // order.HilistCode = subItem.HisProject.MedicalCode
  11113. // order.HosplistName = subItem.HisProject.ProjectName
  11114. // order.HilistLv = "1"
  11115. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11116. // order.HosplistCode = subItem.HisProject.MedicalCode
  11117. // order.HosplistName = subItem.HisProject.ProjectName
  11118. // order.Cnt = subItem.Count
  11119. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11120. //
  11121. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11122. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11123. // order.OwnpayAmt = ""
  11124. // order.SelfpayAmt = ""
  11125. // order.Spec = ""
  11126. // order.SpecUnt = ""
  11127. // order.DrordBegnDate = s_tm
  11128. // order.DrordStopDate = ""
  11129. // order.DrordDrCodg = "1"
  11130. // order.DrordDeptName = department.Name
  11131. // order.DrordDrCodg = "1"
  11132. // order.DrordDrName = doctor_info.UserName
  11133. // order.DrordDrProfttl = ""
  11134. // order.CurrDrordFlag = "1"
  11135. // orders = append(orders, &order)
  11136. //
  11137. // }
  11138. // if subItem.Type == 3 {
  11139. //
  11140. // var order models.FsiOrderDtos
  11141. // order.RxID = strconv.FormatInt(item.ID, 10)
  11142. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11143. // order.LongDrordFlag = "0"
  11144. // order.HilistType = "1"
  11145. // order.ChrgType = "1"
  11146. // order.DrordBhvr = "-"
  11147. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11148. // order.HosplistName = subItem.GoodInfo.GoodName
  11149. // order.HilistLv = "1"
  11150. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11151. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11152. // order.HosplistName = subItem.GoodInfo.GoodName
  11153. // order.Cnt = subItem.Count
  11154. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11155. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11156. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11157. // order.OwnpayAmt = ""
  11158. // order.SelfpayAmt = ""
  11159. // order.Spec = ""
  11160. // order.SpecUnt = ""
  11161. // order.DrordBegnDate = s_tm
  11162. // order.DrordStopDate = ""
  11163. // order.DrordDrCodg = "1"
  11164. // order.DrordDeptName = department.Name
  11165. // order.DrordDrCodg = "1"
  11166. // order.DrordDrName = doctor_info.UserName
  11167. // order.DrordDrProfttl = ""
  11168. // order.CurrDrordFlag = "1"
  11169. // orders = append(orders, &order)
  11170. //
  11171. // }
  11172. // }
  11173. //}
  11174. for _, item := range prescriptions {
  11175. for _, subItem := range item.HisDoctorAdviceInfo {
  11176. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11177. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11178. var order models.FsiOrderDtos
  11179. order.RxID = strconv.FormatInt(item.ID, 10)
  11180. order.Rxno = strconv.FormatInt(item.ID, 10)
  11181. order.LongDrordFlag = "0"
  11182. order.HilistType = "1"
  11183. order.ChrgType = "1"
  11184. order.DrordBhvr = "0"
  11185. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11186. order.HosplistName = subItem.BaseDrugLib.DrugName
  11187. order.HilistLv = "1"
  11188. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11189. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11190. order.HosplistName = subItem.BaseDrugLib.DrugName
  11191. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11192. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11193. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11194. order.OwnpayAmt = ""
  11195. order.SelfpayAmt = ""
  11196. order.Spec = spec
  11197. order.SpecUnt = subItem.PrescribingNumberUnit
  11198. order.DrordBegnDate = s_tm
  11199. order.DrordStopDate = ""
  11200. order.DrordDrCodg = doctor_info.DoctorNumber
  11201. order.DrordDeptName = department.Name
  11202. order.DrordDeptCodg = department.Number
  11203. order.DrordDrName = doctor_info.UserName
  11204. order.DrordDrProfttl = "234"
  11205. order.CurrDrordFlag = "1"
  11206. orders = append(orders, &order)
  11207. }
  11208. }
  11209. for _, subItem := range item.HisPrescriptionProject {
  11210. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11211. var order models.FsiOrderDtos
  11212. order.RxID = strconv.FormatInt(item.ID, 10)
  11213. order.Rxno = strconv.FormatInt(item.ID, 10)
  11214. order.LongDrordFlag = "0"
  11215. order.HilistType = "1"
  11216. order.ChrgType = "1"
  11217. order.DrordBhvr = "0"
  11218. order.HilistCode = subItem.HisProject.MedicalCode
  11219. order.HosplistName = subItem.HisProject.ProjectName
  11220. order.HilistLv = "1"
  11221. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11222. order.HosplistCode = subItem.HisProject.MedicalCode
  11223. order.HosplistName = subItem.HisProject.ProjectName
  11224. order.Cnt = subItem.Count
  11225. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11226. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11227. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11228. order.OwnpayAmt = ""
  11229. order.SelfpayAmt = ""
  11230. order.Spec = subItem.Unit
  11231. order.SpecUnt = subItem.Unit
  11232. order.DrordBegnDate = s_tm
  11233. order.DrordStopDate = ""
  11234. order.DrordDrCodg = doctor_info.DoctorNumber
  11235. order.DrordDeptName = department.Name
  11236. order.DrordDeptCodg = department.Number
  11237. order.DrordDrName = doctor_info.UserName
  11238. order.DrordDrProfttl = "234"
  11239. order.CurrDrordFlag = "1"
  11240. orders = append(orders, &order)
  11241. }
  11242. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11243. var order models.FsiOrderDtos
  11244. order.RxID = strconv.FormatInt(item.ID, 10)
  11245. order.Rxno = strconv.FormatInt(item.ID, 10)
  11246. order.LongDrordFlag = "0"
  11247. order.HilistType = "1"
  11248. order.ChrgType = "1"
  11249. order.DrordBhvr = "0"
  11250. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11251. order.HosplistName = subItem.GoodInfo.GoodName
  11252. order.HilistLv = "1"
  11253. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11254. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11255. order.HosplistName = subItem.GoodInfo.GoodName
  11256. order.Cnt = subItem.Count
  11257. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11258. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11259. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11260. order.OwnpayAmt = ""
  11261. order.SelfpayAmt = ""
  11262. order.Spec = subItem.GoodInfo.SpecificationName
  11263. order.SpecUnt = subItem.Unit
  11264. order.DrordBegnDate = s_tm
  11265. order.DrordStopDate = ""
  11266. order.DrordDrCodg = doctor_info.DoctorNumber
  11267. order.DrordDeptName = department.Name
  11268. order.DrordDeptCodg = department.Number
  11269. order.DrordDrName = doctor_info.UserName
  11270. order.DrordDrProfttl = "234"
  11271. order.CurrDrordFlag = "1"
  11272. orders = append(orders, &order)
  11273. }
  11274. }
  11275. }
  11276. //处方医嘱信息
  11277. fed.MatnStas = "0"
  11278. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11279. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11280. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11281. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11282. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11283. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11284. fed.SetlTotlnum = "1"
  11285. fed.Insutype = his.Insutype
  11286. fed.ReimFlag = "0"
  11287. fed.OutSetlFlag = "0"
  11288. var fopd []*models.FsiOperationDtosData
  11289. data := make(map[string]interface{})
  11290. data["fed"] = fed
  11291. data["fdd"] = fdds
  11292. data["fod"] = orders
  11293. data["pd"] = pd
  11294. data["pp"] = pp
  11295. data["fopd"] = fopd
  11296. data["trig_scen"] = trig_scen
  11297. client := &http.Client{}
  11298. bytesData, _ := json.Marshal(data)
  11299. var req *http.Request
  11300. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11301. if miConfig.MdtrtareaAdmvs == "320921" {
  11302. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11303. } else {
  11304. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11305. }
  11306. resp, _ := client.Do(req)
  11307. defer resp.Body.Close()
  11308. body, ioErr := ioutil.ReadAll(resp.Body)
  11309. if ioErr != nil {
  11310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11312. return res
  11313. }
  11314. var respJSON map[string]interface{}
  11315. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11318. return res
  11319. }
  11320. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11321. result, _ := json.Marshal(respJSON)
  11322. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11323. utils.ErrorLog("解析失败:%v", err)
  11324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11325. return res
  11326. }
  11327. return res
  11328. } else {
  11329. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11330. saveLog(output, input, "3102", "事中")
  11331. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11332. utils.ErrorLog("解析失败:%v", err)
  11333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11334. return
  11335. }
  11336. return res
  11337. }
  11338. return res
  11339. }
  11340. func (c *HisApiController) Check() {
  11341. psn_no := c.GetString("psn_no")
  11342. in := c.GetString("in")
  11343. mt := c.GetString("mt")
  11344. baseParams := models.BaseParams{
  11345. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  11346. FixmedinsCode: "H15049901371",
  11347. InsuplcAdmdvs: "150499",
  11348. MdtrtareaAdmvs: "150499",
  11349. OrgName: "赤峰费森血液透析中心",
  11350. Doctor: "1111",
  11351. }
  11352. service.Gdyb2001(baseParams, psn_no, in, mt)
  11353. }
  11354. func (c *HisApiController) GetPsnNcdsInfo() {
  11355. admin_user_id, _ := c.GetInt64("admin_user_id")
  11356. patient_id, _ := c.GetInt64("patient_id")
  11357. //id, _ := c.GetInt64("id")
  11358. adminUser := c.GetAdminUserInfo()
  11359. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11360. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11361. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  11362. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11363. //psn_record, _ := service.GetP(id)
  11364. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11365. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  11366. //
  11367. //if psn_record.ID == 0 {
  11368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  11369. // return
  11370. //}
  11371. var res Result5301
  11372. var res10265 Result5301For10265
  11373. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11374. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11375. var api string
  11376. if miConfig.MdtrtareaAdmvs == "320921" {
  11377. 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 +
  11378. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11379. } else {
  11380. 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 +
  11381. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11382. }
  11383. resp, requestErr := http.Get(api)
  11384. if requestErr != nil {
  11385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11386. return
  11387. }
  11388. body, ioErr := ioutil.ReadAll(resp.Body)
  11389. if ioErr != nil {
  11390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11392. return
  11393. }
  11394. var respJSON map[string]interface{}
  11395. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11398. return
  11399. }
  11400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11401. result, _ := json.Marshal(respJSON)
  11402. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11403. utils.ErrorLog("解析失败:%v", err)
  11404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11405. return
  11406. }
  11407. res.ErrMsg = res10265.ErrMsg
  11408. res.Output = res10265.Output
  11409. res.InfRefmsgid = res10265.InfRefmsgid
  11410. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11411. res.Infcode = infocode
  11412. } else if miConfig.MdtrtareaAdmvs == "341203" {
  11413. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11414. var api string
  11415. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  11416. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11417. resp, requestErr := http.Get(api)
  11418. if requestErr != nil {
  11419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11420. return
  11421. }
  11422. body, ioErr := ioutil.ReadAll(resp.Body)
  11423. if ioErr != nil {
  11424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11426. return
  11427. }
  11428. var respJSON map[string]interface{}
  11429. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11432. return
  11433. }
  11434. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11435. if status == "0" {
  11436. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11437. c.ServeSuccessJSON(map[string]interface{}{
  11438. "failed_code": -10,
  11439. "msg": err_msg,
  11440. })
  11441. return
  11442. }
  11443. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11444. result, _ := json.Marshal(respJSON)
  11445. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11446. utils.ErrorLog("解析失败:%v", err)
  11447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11448. return
  11449. }
  11450. } else if miConfig.MdtrtareaAdmvs == "360302" {
  11451. p, _ := service.GetHisPatientById(patient_id)
  11452. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11453. var dat map[string]interface{}
  11454. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11455. fmt.Println(dat)
  11456. } else {
  11457. fmt.Println(err)
  11458. }
  11459. userJSONBytes, _ := json.Marshal(dat)
  11460. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11461. utils.ErrorLog("解析失败:%v", err)
  11462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11463. return
  11464. }
  11465. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11466. p, _ := service.GetHisPatientById(patient_id)
  11467. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11468. var dat map[string]interface{}
  11469. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11470. fmt.Println(dat)
  11471. } else {
  11472. fmt.Println(err)
  11473. }
  11474. userJSONBytes, _ := json.Marshal(dat)
  11475. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11476. utils.ErrorLog("解析失败:%v", err)
  11477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11478. return
  11479. }
  11480. } else if miConfig.MdtrtareaAdmvs == "420200" {
  11481. p, _ := service.GetHisPatientById(patient_id)
  11482. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  11483. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11484. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11485. resp, requestErr := http.Get(api)
  11486. if requestErr != nil {
  11487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11488. return
  11489. }
  11490. body, ioErr := ioutil.ReadAll(resp.Body)
  11491. if ioErr != nil {
  11492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11494. return
  11495. }
  11496. var respJSON map[string]interface{}
  11497. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11500. return
  11501. }
  11502. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11503. result, _ := json.Marshal(respJSON)
  11504. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11505. utils.ErrorLog("解析失败:%v", err)
  11506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11507. return
  11508. }
  11509. } else if miConfig.MdtrtareaAdmvs == "420902" {
  11510. p, _ := service.GetHisPatientById(patient_id)
  11511. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  11512. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11513. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11514. resp, requestErr := http.Get(api)
  11515. if requestErr != nil {
  11516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11517. return
  11518. }
  11519. body, ioErr := ioutil.ReadAll(resp.Body)
  11520. if ioErr != nil {
  11521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11523. return
  11524. }
  11525. var respJSON map[string]interface{}
  11526. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11529. return
  11530. }
  11531. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11532. result, _ := json.Marshal(respJSON)
  11533. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11534. utils.ErrorLog("解析失败:%v", err)
  11535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11536. return
  11537. }
  11538. } else if miConfig.MdtrtareaAdmvs == "421182" {
  11539. p, _ := service.GetHisPatientById(patient_id)
  11540. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  11541. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11542. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11543. resp, requestErr := http.Get(api)
  11544. if requestErr != nil {
  11545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11546. return
  11547. }
  11548. body, ioErr := ioutil.ReadAll(resp.Body)
  11549. if ioErr != nil {
  11550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11552. return
  11553. }
  11554. var respJSON map[string]interface{}
  11555. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11558. return
  11559. }
  11560. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11561. result, _ := json.Marshal(respJSON)
  11562. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11563. utils.ErrorLog("解析失败:%v", err)
  11564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11565. return
  11566. }
  11567. } else if miConfig.MdtrtareaAdmvs == "420902" {
  11568. p, _ := service.GetHisPatientById(patient_id)
  11569. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  11570. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11571. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11572. resp, requestErr := http.Get(api)
  11573. if requestErr != nil {
  11574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11575. return
  11576. }
  11577. body, ioErr := ioutil.ReadAll(resp.Body)
  11578. if ioErr != nil {
  11579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11581. return
  11582. }
  11583. var respJSON map[string]interface{}
  11584. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11587. return
  11588. }
  11589. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11590. result, _ := json.Marshal(respJSON)
  11591. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11592. utils.ErrorLog("解析失败:%v", err)
  11593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11594. return
  11595. }
  11596. } else if miConfig.MdtrtareaAdmvs == "421300" {
  11597. p, _ := service.GetHisPatientById(patient_id)
  11598. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  11599. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11600. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11601. resp, requestErr := http.Get(api)
  11602. if requestErr != nil {
  11603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11604. return
  11605. }
  11606. body, ioErr := ioutil.ReadAll(resp.Body)
  11607. if ioErr != nil {
  11608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11610. return
  11611. }
  11612. var respJSON map[string]interface{}
  11613. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11616. return
  11617. }
  11618. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11619. result, _ := json.Marshal(respJSON)
  11620. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11621. utils.ErrorLog("解析失败:%v", err)
  11622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11623. return
  11624. }
  11625. } else if miConfig.MdtrtareaAdmvs == "441799" {
  11626. p, _ := service.GetHisPatientById(patient_id)
  11627. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  11628. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11629. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11630. resp, requestErr := http.Get(api)
  11631. if requestErr != nil {
  11632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11633. return
  11634. }
  11635. body, ioErr := ioutil.ReadAll(resp.Body)
  11636. if ioErr != nil {
  11637. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11639. return
  11640. }
  11641. var respJSON map[string]interface{}
  11642. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11645. return
  11646. }
  11647. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11648. result, _ := json.Marshal(respJSON)
  11649. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11650. utils.ErrorLog("解析失败:%v", err)
  11651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11652. return
  11653. }
  11654. } else {
  11655. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  11656. var dat map[string]interface{}
  11657. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11658. fmt.Println(dat)
  11659. } else {
  11660. fmt.Println(err)
  11661. }
  11662. userJSONBytes, _ := json.Marshal(dat)
  11663. if miConfig.Code == "H15049901371" {
  11664. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  11665. utils.ErrorLog("解析失败:%v", err)
  11666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11667. return
  11668. }
  11669. res.InfRefmsgid = res10265.InfRefmsgid
  11670. res.Output = res10265.Output
  11671. res.ErrMsg = res10265.ErrMsg
  11672. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11673. res.Infcode = infocode
  11674. } else {
  11675. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11676. utils.ErrorLog("解析失败:%v", err)
  11677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11678. return
  11679. }
  11680. }
  11681. }
  11682. if res.Infcode == 0 {
  11683. c.ServeSuccessJSON(map[string]interface{}{
  11684. "result": res.Output.Result,
  11685. })
  11686. }
  11687. }
  11688. func (c *HisApiController) CheckInsutype() {
  11689. his_patient_id, _ := c.GetInt64("his_patient_id")
  11690. admin_user_id, _ := c.GetInt64("admin_user_id")
  11691. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11692. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11693. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11694. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11695. var dat map[string]interface{}
  11696. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11697. fmt.Println(dat)
  11698. } else {
  11699. fmt.Println(err)
  11700. }
  11701. userJSONBytes, _ := json.Marshal(dat)
  11702. var res Result90100
  11703. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11704. utils.ErrorLog("解析失败:%v", err)
  11705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11706. return
  11707. }
  11708. if res.Infcode != 0 {
  11709. c.ServeSuccessJSON(map[string]interface{}{
  11710. "failed_code": -10,
  11711. "msg": res.ErrMsg,
  11712. })
  11713. return
  11714. } else {
  11715. fmt.Println(res)
  11716. }
  11717. }
  11718. func (c *HisApiController) CheckCardPWD() {
  11719. card_pwd := c.GetString("card_pwd")
  11720. his_patient_id, _ := c.GetInt64("his_patient_id")
  11721. admin_user_id, _ := c.GetInt64("admin_user_id")
  11722. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11723. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11724. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11725. psn, _ := service.GetPsnByPatientId(his.PatientId)
  11726. bas := strings.Split(psn.CardInfo, "|")
  11727. basNumber := bas[2]
  11728. if psn.InsuplcAdmdvs[:4] == "4403" {
  11729. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  11730. var dat map[string]interface{}
  11731. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11732. fmt.Println(dat)
  11733. } else {
  11734. fmt.Println(err)
  11735. }
  11736. userJSONBytes, _ := json.Marshal(dat)
  11737. var res Result90991
  11738. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11739. utils.ErrorLog("解析失败:%v", err)
  11740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11741. return
  11742. }
  11743. if res.Infcode != 0 {
  11744. c.ServeSuccessJSON(map[string]interface{}{
  11745. "failed_code": -10,
  11746. "msg": res.ErrMsg,
  11747. })
  11748. return
  11749. } else {
  11750. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  11751. var msg string
  11752. switch res.Output.Result.CardStat {
  11753. case "00":
  11754. msg = "未激活"
  11755. break
  11756. case "10":
  11757. msg = "激活"
  11758. break
  11759. case "20":
  11760. msg = "窗口挂失"
  11761. break
  11762. case "21":
  11763. msg = "电话挂失"
  11764. break
  11765. case "22":
  11766. msg = "单位网上申报挂失"
  11767. break
  11768. case "23":
  11769. msg = "保健办挂失"
  11770. break
  11771. case "24":
  11772. msg = "个人网上挂失"
  11773. break
  11774. case "25":
  11775. msg = "网上服务大厅挂失"
  11776. break
  11777. case "30":
  11778. msg = "注销"
  11779. break
  11780. case "40":
  11781. msg = "回收"
  11782. break
  11783. case "99":
  11784. msg = "制卡中(无效卡)"
  11785. break
  11786. }
  11787. c.ServeSuccessJSON(map[string]interface{}{
  11788. "failed_code": -10,
  11789. "msg": msg,
  11790. })
  11791. return
  11792. } else {
  11793. c.ServeSuccessJSON(map[string]interface{}{
  11794. "msg": "校验成功",
  11795. })
  11796. return
  11797. }
  11798. }
  11799. } else {
  11800. c.ServeSuccessJSON(map[string]interface{}{
  11801. "msg": "校验成功",
  11802. })
  11803. return
  11804. }
  11805. }
  11806. func (c *HisApiController) CheckCardPWDTwo() {
  11807. //card_pwd := c.GetString("card_pwd")
  11808. //his_patient_id, _ := c.GetInt64("his_patient_id")
  11809. admin_user_id, _ := c.GetInt64("admin_user_id")
  11810. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11811. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11812. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  11813. var dat map[string]interface{}
  11814. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11815. fmt.Println(dat)
  11816. } else {
  11817. fmt.Println(err)
  11818. }
  11819. userJSONBytes, _ := json.Marshal(dat)
  11820. var res Result90991
  11821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11822. utils.ErrorLog("解析失败:%v", err)
  11823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11824. return
  11825. }
  11826. if res.Infcode != 0 {
  11827. c.ServeSuccessJSON(map[string]interface{}{
  11828. "failed_code": -10,
  11829. "msg": res.ErrMsg,
  11830. })
  11831. return
  11832. } else {
  11833. if res.Output.Result.SscnoCheckStat == "0" {
  11834. var msg string
  11835. switch res.Output.Result.CardStat {
  11836. case "00":
  11837. msg = "未激活"
  11838. break
  11839. case "10":
  11840. msg = "激活"
  11841. break
  11842. case "20":
  11843. msg = "窗口挂失"
  11844. break
  11845. case "21":
  11846. msg = "电话挂失"
  11847. break
  11848. case "22":
  11849. msg = "单位网上申报挂失"
  11850. break
  11851. case "23":
  11852. msg = "保健办挂失"
  11853. break
  11854. case "24":
  11855. msg = "个人网上挂失"
  11856. break
  11857. case "25":
  11858. msg = "网上服务大厅挂失"
  11859. break
  11860. case "30":
  11861. msg = "注销"
  11862. break
  11863. case "40":
  11864. msg = "回收"
  11865. break
  11866. case "99":
  11867. msg = "制卡中(无效卡)"
  11868. break
  11869. }
  11870. c.ServeSuccessJSON(map[string]interface{}{
  11871. "failed_code": -10,
  11872. "msg": msg,
  11873. })
  11874. return
  11875. } else {
  11876. c.ServeSuccessJSON(map[string]interface{}{
  11877. "msg": "校验成功",
  11878. })
  11879. return
  11880. }
  11881. }
  11882. }
  11883. type ELeCertData struct {
  11884. Data struct {
  11885. Extra string `json:"extra"`
  11886. IDNo string `json:"idNo"`
  11887. IDType string `json:"idType"`
  11888. EcToken string `json:"ecToken"`
  11889. InsuOrg string `json:"insuOrg"`
  11890. UserName string `json:"userName"`
  11891. EcIndexNo string `json:"ecIndexNo"`
  11892. Gender string `json:"gender"`
  11893. Birthday string `json:"birthday"`
  11894. Nationality string `json:"nationality"`
  11895. Email string `json:"email"`
  11896. } `json:"OutData"`
  11897. }
  11898. func (c *HisApiController) ReadCard() {
  11899. id_card_type, _ := c.GetInt64("id_card_type")
  11900. admin_user_id, _ := c.GetInt64("admin_user_id")
  11901. certificates, _ := c.GetInt64("certificates")
  11902. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  11903. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11904. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11905. switch id_card_type {
  11906. case 1:
  11907. if miConfig.MdtrtareaAdmvs == "421300" {
  11908. var res ResultTwo
  11909. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  11910. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11911. "&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)
  11912. resp, requestErr := http.Get(api)
  11913. if requestErr != nil {
  11914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11915. return
  11916. }
  11917. body, ioErr := ioutil.ReadAll(resp.Body)
  11918. if ioErr != nil {
  11919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11921. return
  11922. }
  11923. var respJSON map[string]interface{}
  11924. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11927. return
  11928. }
  11929. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11930. result, _ := json.Marshal(respJSON)
  11931. fmt.Println("log")
  11932. fmt.Println(string(result))
  11933. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11934. utils.ErrorLog("解析失败:%v", err)
  11935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11936. return
  11937. }
  11938. if res.Infcode == 0 {
  11939. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11940. if err == gorm.ErrRecordNotFound {
  11941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11942. return
  11943. } else if err != nil {
  11944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11945. return
  11946. } else {
  11947. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11948. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11949. infoStr := string(Iinfos)
  11950. idetinfoStr := string(Idetinfos)
  11951. var rf []*ResultFive
  11952. json.Unmarshal([]byte(infoStr), &rf)
  11953. var insutypes []*ResultFive
  11954. var insutype string
  11955. var is390 int = 0
  11956. var is310 int = 0
  11957. for _, item := range rf {
  11958. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  11959. insutypes = append(insutypes, item)
  11960. }
  11961. }
  11962. if len(insutypes) == 1 {
  11963. insutype = insutypes[0].Insutype
  11964. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11965. } else {
  11966. for _, i := range insutypes {
  11967. if i.Insutype == "390" {
  11968. is390 = 1
  11969. }
  11970. if i.Insutype == "310" {
  11971. is310 = 1
  11972. }
  11973. }
  11974. }
  11975. if is390 == 1 {
  11976. insutype = "390"
  11977. }
  11978. if is310 == 1 {
  11979. insutype = "310"
  11980. }
  11981. if len(insutypes) == 0 {
  11982. insutype = "390"
  11983. }
  11984. var insuplc_admdvs string
  11985. for _, item := range rf {
  11986. if item.Insutype == insutype {
  11987. insuplc_admdvs = item.InsuplcAdmdvs
  11988. }
  11989. }
  11990. if strings.Contains(insuplc_admdvs, "4213") {
  11991. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  11992. }
  11993. psn := &models.HisPsn{
  11994. PsnNo: res.Output.Baseinfo.PsnNo,
  11995. PatientId: patient.ID,
  11996. Certno: res.Output.Baseinfo.Certno,
  11997. Gend: res.Output.Baseinfo.Gend,
  11998. Naty: res.Output.Baseinfo.Naty,
  11999. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12000. PsnName: res.Output.Baseinfo.PsnName,
  12001. Idetinfo: idetinfoStr,
  12002. Insuinfo: infoStr,
  12003. InsuplcAdmdvs: insuplc_admdvs,
  12004. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12005. }
  12006. service.CreateHisPsn(psn)
  12007. c.ServeSuccessJSON(map[string]interface{}{
  12008. "patient": patient,
  12009. "number": res.Output.Baseinfo.Certno,
  12010. })
  12011. }
  12012. } else {
  12013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12014. return
  12015. }
  12016. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12017. var res ResultTwo
  12018. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12019. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12020. "&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)
  12021. resp, requestErr := http.Get(api)
  12022. if requestErr != nil {
  12023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12024. return
  12025. }
  12026. body, ioErr := ioutil.ReadAll(resp.Body)
  12027. if ioErr != nil {
  12028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12030. return
  12031. }
  12032. var respJSON map[string]interface{}
  12033. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12036. return
  12037. }
  12038. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12039. result, _ := json.Marshal(respJSON)
  12040. fmt.Println("log")
  12041. fmt.Println(string(result))
  12042. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12043. utils.ErrorLog("解析失败:%v", err)
  12044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12045. return
  12046. }
  12047. if res.Infcode == 0 {
  12048. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12049. if err == gorm.ErrRecordNotFound {
  12050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12051. return
  12052. } else if err != nil {
  12053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12054. return
  12055. } else {
  12056. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12057. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12058. infoStr := string(Iinfos)
  12059. idetinfoStr := string(Idetinfos)
  12060. psn := &models.HisPsn{
  12061. PsnNo: res.Output.Baseinfo.PsnNo,
  12062. PatientId: patient.ID,
  12063. Certno: res.Output.Baseinfo.Certno,
  12064. Gend: res.Output.Baseinfo.Gend,
  12065. Naty: res.Output.Baseinfo.Naty,
  12066. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12067. PsnName: res.Output.Baseinfo.PsnName,
  12068. Idetinfo: idetinfoStr,
  12069. Insuinfo: infoStr,
  12070. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12071. }
  12072. service.CreateHisPsn(psn)
  12073. var rf []*ResultFive
  12074. json.Unmarshal([]byte(infoStr), &rf)
  12075. var insutypes []*ResultFive
  12076. var insutype string
  12077. var is390 int = 0
  12078. var is310 int = 0
  12079. for _, item := range rf {
  12080. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12081. insutypes = append(insutypes, item)
  12082. }
  12083. }
  12084. if len(insutypes) == 1 {
  12085. insutype = insutypes[0].Insutype
  12086. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12087. } else {
  12088. for _, i := range insutypes {
  12089. if i.Insutype == "390" {
  12090. is390 = 1
  12091. }
  12092. if i.Insutype == "310" {
  12093. is310 = 1
  12094. }
  12095. }
  12096. }
  12097. if is390 == 1 {
  12098. insutype = "390"
  12099. }
  12100. if is310 == 1 {
  12101. insutype = "310"
  12102. }
  12103. if len(insutypes) == 0 {
  12104. insutype = "310"
  12105. }
  12106. c.ServeSuccessJSON(map[string]interface{}{
  12107. "patient": patient,
  12108. "number": res.Output.Baseinfo.Certno,
  12109. "insutype": insutype,
  12110. })
  12111. }
  12112. } else {
  12113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12114. return
  12115. }
  12116. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12117. var res ResultTwo
  12118. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12119. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12120. "&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)
  12121. resp, requestErr := http.Get(api)
  12122. if requestErr != nil {
  12123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12124. return
  12125. }
  12126. body, ioErr := ioutil.ReadAll(resp.Body)
  12127. if ioErr != nil {
  12128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12130. return
  12131. }
  12132. var respJSON map[string]interface{}
  12133. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12136. return
  12137. }
  12138. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12139. result, _ := json.Marshal(respJSON)
  12140. fmt.Println("log")
  12141. fmt.Println(string(result))
  12142. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12143. utils.ErrorLog("解析失败:%v", err)
  12144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12145. return
  12146. }
  12147. if res.Infcode == 0 {
  12148. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12149. if err == gorm.ErrRecordNotFound {
  12150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12151. return
  12152. } else if err != nil {
  12153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12154. return
  12155. } else {
  12156. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12157. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12158. infoStr := string(Iinfos)
  12159. idetinfoStr := string(Idetinfos)
  12160. var rf []*ResultFive
  12161. json.Unmarshal([]byte(infoStr), &rf)
  12162. var insutypes []*ResultFive
  12163. var insutype string
  12164. var is390 int = 0
  12165. var is310 int = 0
  12166. for _, item := range rf {
  12167. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12168. insutypes = append(insutypes, item)
  12169. }
  12170. }
  12171. if len(insutypes) == 1 {
  12172. insutype = insutypes[0].Insutype
  12173. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12174. } else {
  12175. for _, i := range insutypes {
  12176. if i.Insutype == "390" {
  12177. is390 = 1
  12178. }
  12179. if i.Insutype == "310" {
  12180. is310 = 1
  12181. }
  12182. }
  12183. }
  12184. if is390 == 1 {
  12185. insutype = "390"
  12186. }
  12187. if is310 == 1 {
  12188. insutype = "310"
  12189. }
  12190. if len(insutypes) == 0 {
  12191. insutype = "390"
  12192. }
  12193. var insuplc_admdvs string
  12194. for _, item := range rf {
  12195. if item.Insutype == insutype {
  12196. insuplc_admdvs = item.InsuplcAdmdvs
  12197. }
  12198. }
  12199. psn := &models.HisPsn{
  12200. PsnNo: res.Output.Baseinfo.PsnNo,
  12201. PatientId: patient.ID,
  12202. Certno: res.Output.Baseinfo.Certno,
  12203. Gend: res.Output.Baseinfo.Gend,
  12204. Naty: res.Output.Baseinfo.Naty,
  12205. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12206. PsnName: res.Output.Baseinfo.PsnName,
  12207. Idetinfo: idetinfoStr,
  12208. Insuinfo: infoStr,
  12209. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12210. InsuplcAdmdvs: insuplc_admdvs,
  12211. }
  12212. service.CreateHisPsn(psn)
  12213. for _, item := range rf {
  12214. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12215. insutypes = append(insutypes, item)
  12216. }
  12217. }
  12218. if len(insutypes) == 1 {
  12219. insutype = insutypes[0].Insutype
  12220. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12221. } else {
  12222. for _, i := range insutypes {
  12223. if i.Insutype == "390" {
  12224. is390 = 1
  12225. }
  12226. if i.Insutype == "310" {
  12227. is310 = 1
  12228. }
  12229. }
  12230. }
  12231. if is390 == 1 {
  12232. insutype = "390"
  12233. }
  12234. if is310 == 1 {
  12235. insutype = "310"
  12236. }
  12237. if len(insutypes) == 0 {
  12238. insutype = "310"
  12239. }
  12240. c.ServeSuccessJSON(map[string]interface{}{
  12241. "patient": patient,
  12242. "number": res.Output.Baseinfo.Certno,
  12243. "insutype": insutype,
  12244. })
  12245. }
  12246. } else {
  12247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12248. return
  12249. }
  12250. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12251. var res ResultTwo
  12252. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  12253. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12254. "&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)
  12255. resp, requestErr := http.Get(api)
  12256. if requestErr != nil {
  12257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12258. return
  12259. }
  12260. body, ioErr := ioutil.ReadAll(resp.Body)
  12261. if ioErr != nil {
  12262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12264. return
  12265. }
  12266. var respJSON map[string]interface{}
  12267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12270. return
  12271. }
  12272. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12273. result, _ := json.Marshal(respJSON)
  12274. fmt.Println("log")
  12275. fmt.Println(string(result))
  12276. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12277. utils.ErrorLog("解析失败:%v", err)
  12278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12279. return
  12280. }
  12281. if res.Infcode == 0 {
  12282. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12283. if err == gorm.ErrRecordNotFound {
  12284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12285. return
  12286. } else if err != nil {
  12287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12288. return
  12289. } else {
  12290. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12291. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12292. infoStr := string(Iinfos)
  12293. idetinfoStr := string(Idetinfos)
  12294. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12295. psn := &models.HisPsn{
  12296. PsnNo: res.Output.Baseinfo.PsnNo,
  12297. PatientId: patient.ID,
  12298. Certno: res.Output.Baseinfo.Certno,
  12299. Brdy: b,
  12300. Age: float64(age),
  12301. Gend: res.Output.Baseinfo.Gend,
  12302. Naty: res.Output.Baseinfo.Naty,
  12303. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12304. PsnName: res.Output.Baseinfo.PsnName,
  12305. Idetinfo: idetinfoStr,
  12306. Insuinfo: infoStr,
  12307. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12308. }
  12309. service.CreateHisPsn(psn)
  12310. var rf []*ResultFive
  12311. json.Unmarshal([]byte(infoStr), &rf)
  12312. var insutypes []*ResultFive
  12313. var insutype string
  12314. var is390 int = 0
  12315. var is310 int = 0
  12316. for _, item := range rf {
  12317. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12318. insutypes = append(insutypes, item)
  12319. }
  12320. }
  12321. if len(insutypes) == 1 {
  12322. insutype = insutypes[0].Insutype
  12323. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12324. } else {
  12325. for _, i := range insutypes {
  12326. if i.Insutype == "390" {
  12327. is390 = 1
  12328. }
  12329. if i.Insutype == "310" {
  12330. is310 = 1
  12331. }
  12332. }
  12333. }
  12334. if is390 == 1 {
  12335. insutype = "390"
  12336. }
  12337. if is310 == 1 {
  12338. insutype = "310"
  12339. }
  12340. if len(insutypes) == 0 {
  12341. insutype = "310"
  12342. }
  12343. c.ServeSuccessJSON(map[string]interface{}{
  12344. "patient": patient,
  12345. "number": res.Output.Baseinfo.Certno,
  12346. "insutype": insutype,
  12347. })
  12348. }
  12349. } else {
  12350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12351. return
  12352. }
  12353. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12354. var api string
  12355. if miConfig.MdtrtareaAdmvs == "320921" {
  12356. 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 +
  12357. "&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
  12358. fmt.Println(api)
  12359. } else {
  12360. 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 +
  12361. "&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)
  12362. }
  12363. resp, requestErr := http.Get(api)
  12364. if requestErr != nil {
  12365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12366. return
  12367. }
  12368. body, ioErr := ioutil.ReadAll(resp.Body)
  12369. if ioErr != nil {
  12370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12372. return
  12373. }
  12374. var respJSON map[string]interface{}
  12375. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12378. return
  12379. }
  12380. var status string
  12381. status = respJSON["data"].(map[string]interface{})["status"].(string)
  12382. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  12383. //console.log()
  12384. fmt.Println("type===")
  12385. fmt.Println(card_type)
  12386. var token string
  12387. var res ResultTwo //1101结果
  12388. var res10265 ResultTwo10265 //1101结果
  12389. var card_info string //卡信息
  12390. var busi_card_info string
  12391. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  12392. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12393. if status == "0" { //读卡成功
  12394. if card_type == "1" {
  12395. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12396. result, _ := json.Marshal(respJSON)
  12397. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12398. utils.ErrorLog("解析失败:%v", err)
  12399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12400. return
  12401. }
  12402. res.ErrMsg = res10265.ErrMsg
  12403. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12404. res.Infcode = infocode
  12405. res.Output = res10265.Output
  12406. res.InfRefmsgid = res10265.InfRefmsgid
  12407. } else {
  12408. //var card_info string //卡信息
  12409. //var busi_card_info string
  12410. token = respJSON["data"].(map[string]interface{})["token"].(string)
  12411. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12412. //fmt.Println(card_info)
  12413. //fmt.Println(busi_card_info)
  12414. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12415. result, _ := json.Marshal(respJSON)
  12416. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12417. utils.ErrorLog("解析失败:%v", err)
  12418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12419. return
  12420. }
  12421. res.ErrMsg = res10265.ErrMsg
  12422. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12423. res.Infcode = infocode
  12424. res.Output = res10265.Output
  12425. res.InfRefmsgid = res10265.InfRefmsgid
  12426. }
  12427. if res.Infcode == 0 {
  12428. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12429. if err == gorm.ErrRecordNotFound {
  12430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12431. return
  12432. } else if err != nil {
  12433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12434. return
  12435. } else {
  12436. if card_type == "1" {
  12437. bas := strings.Split(card_info, "|")
  12438. basNumber := bas[2]
  12439. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12440. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12441. infoStr := string(Iinfos)
  12442. idetinfoStr := string(Idetinfos)
  12443. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12444. psn := &models.HisPsn{
  12445. PsnNo: res.Output.Baseinfo.PsnNo,
  12446. PatientId: patient.ID,
  12447. Certno: res.Output.Baseinfo.Certno,
  12448. Brdy: b,
  12449. Age: float64(age),
  12450. Gend: res.Output.Baseinfo.Gend,
  12451. Naty: res.Output.Baseinfo.Naty,
  12452. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12453. PsnName: res.Output.Baseinfo.PsnName,
  12454. Idetinfo: idetinfoStr,
  12455. Insuinfo: infoStr,
  12456. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12457. CardInfo: card_info,
  12458. VerifyNumber: busi_card_info,
  12459. }
  12460. service.CreateHisPsn(psn)
  12461. var rf []*ResultFive
  12462. json.Unmarshal([]byte(infoStr), &rf)
  12463. var insutypes []*ResultFive
  12464. var insutype string
  12465. var is390 int = 0
  12466. var is310 int = 0
  12467. for _, item := range rf {
  12468. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12469. insutypes = append(insutypes, item)
  12470. }
  12471. }
  12472. if len(insutypes) == 1 {
  12473. insutype = insutypes[0].Insutype
  12474. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12475. } else {
  12476. for _, i := range insutypes {
  12477. if i.Insutype == "390" {
  12478. is390 = 1
  12479. }
  12480. if i.Insutype == "310" {
  12481. is310 = 1
  12482. }
  12483. }
  12484. }
  12485. if is390 == 1 {
  12486. insutype = "390"
  12487. }
  12488. if is310 == 1 {
  12489. insutype = "310"
  12490. }
  12491. if len(insutypes) == 0 {
  12492. insutype = "310"
  12493. }
  12494. c.ServeSuccessJSON(map[string]interface{}{
  12495. "patient": patient,
  12496. "number": basNumber,
  12497. "insutype": insutype,
  12498. })
  12499. } else {
  12500. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12501. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12502. infoStr := string(Iinfos)
  12503. idetinfoStr := string(Idetinfos)
  12504. psn := &models.HisPsn{
  12505. PsnNo: res.Output.Baseinfo.PsnNo,
  12506. PatientId: patient.ID,
  12507. Certno: res.Output.Baseinfo.Certno,
  12508. Gend: res.Output.Baseinfo.Gend,
  12509. Naty: res.Output.Baseinfo.Naty,
  12510. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12511. PsnName: res.Output.Baseinfo.PsnName,
  12512. Idetinfo: idetinfoStr,
  12513. Insuinfo: infoStr,
  12514. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12515. CardInfo: card_info,
  12516. VerifyNumber: token,
  12517. }
  12518. service.CreateHisPsn(psn)
  12519. c.ServeSuccessJSON(map[string]interface{}{
  12520. "patient": patient,
  12521. "number": token,
  12522. })
  12523. }
  12524. }
  12525. } else {
  12526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12527. return
  12528. }
  12529. } else { //读卡失败
  12530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12531. return
  12532. }
  12533. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12534. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  12535. cardnum = DeleteExtraSpaceTwo(cardnum)
  12536. cardCode = DeleteExtraSpaceTwo(cardCode)
  12537. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  12538. name = DeleteExtraSpaceTwo(name)
  12539. errmsg = DeleteExtraSpaceTwo(errmsg)
  12540. cardnum = Remove0000(cardnum)
  12541. cardCode = Remove0000(cardCode)
  12542. id_card_no = Remove0000(id_card_no)
  12543. name = Remove0000(name)
  12544. errmsg = Remove0000(errmsg)
  12545. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  12546. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  12547. //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)
  12548. //fmt.Println(result2)
  12549. //fmt.Println(requestLog2)
  12550. //fmt.Println(errMsgLog2)
  12551. 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)
  12552. saveLog(result, requestLog, "1101", "获取人员信息")
  12553. fmt.Println(errMsgLog)
  12554. if len(errMsgLog) > 0 {
  12555. } else {
  12556. var dat map[string]interface{}
  12557. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12558. fmt.Println(dat)
  12559. } else {
  12560. fmt.Println(err)
  12561. }
  12562. userJSONBytes, _ := json.Marshal(dat)
  12563. var res ResultTwo
  12564. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12565. utils.ErrorLog("解析失败:%v", err)
  12566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12567. return
  12568. }
  12569. res.ErrMsg = errMsgLog
  12570. if res.Infcode == 0 {
  12571. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12572. if err == gorm.ErrRecordNotFound {
  12573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12574. return
  12575. } else if err != nil {
  12576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12577. return
  12578. } else {
  12579. fmt.Println(res)
  12580. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12581. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12582. infoStr := string(Iinfos)
  12583. idetinfoStr := string(Idetinfos)
  12584. var rf []*ResultFive
  12585. json.Unmarshal([]byte(infoStr), &rf)
  12586. var insutypes []*ResultFive
  12587. var insutype string
  12588. var is390 int = 0
  12589. var is310 int = 0
  12590. for _, item := range rf {
  12591. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12592. insutypes = append(insutypes, item)
  12593. }
  12594. }
  12595. if len(insutypes) == 1 {
  12596. insutype = insutypes[0].Insutype
  12597. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12598. } else {
  12599. for _, i := range insutypes {
  12600. if i.Insutype == "390" {
  12601. is390 = 1
  12602. }
  12603. if i.Insutype == "310" {
  12604. is310 = 1
  12605. }
  12606. }
  12607. }
  12608. if is390 == 1 {
  12609. insutype = "390"
  12610. }
  12611. if is310 == 1 {
  12612. insutype = "310"
  12613. }
  12614. if len(insutypes) == 0 {
  12615. insutype = "390"
  12616. }
  12617. var insuplc_admdvs string
  12618. for _, item := range rf {
  12619. if item.Insutype == insutype {
  12620. insuplc_admdvs = item.InsuplcAdmdvs
  12621. }
  12622. }
  12623. psn := &models.HisPsn{
  12624. PsnNo: res.Output.Baseinfo.PsnNo,
  12625. PatientId: patient.ID,
  12626. Certno: res.Output.Baseinfo.Certno,
  12627. Gend: res.Output.Baseinfo.Gend,
  12628. Naty: res.Output.Baseinfo.Naty,
  12629. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12630. PsnName: res.Output.Baseinfo.PsnName,
  12631. Idetinfo: idetinfoStr,
  12632. Insuinfo: infoStr,
  12633. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12634. CardInfo: basStr,
  12635. VerifyNumber: "",
  12636. InsuplcAdmdvs: insuplc_admdvs,
  12637. }
  12638. service.CreateHisPsn(psn)
  12639. c.ServeSuccessJSON(map[string]interface{}{
  12640. "patient": patient,
  12641. "number": cardnum,
  12642. "insutype": insutype,
  12643. })
  12644. }
  12645. } else {
  12646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12647. return
  12648. }
  12649. }
  12650. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12651. fmt.Println(initFlag)
  12652. fmt.Println("initFlag")
  12653. if initFlag == 0 {
  12654. c.TestGetJiangXiBasBaseInit()
  12655. }
  12656. basStr := c.GetBasBaseInfo()
  12657. if len(basStr) == 0 {
  12658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12659. return
  12660. }
  12661. fmt.Println(basStr)
  12662. bas := strings.Split(basStr, "|")
  12663. basNumber := bas[1]
  12664. fmt.Println(basNumber)
  12665. card_sn := bas[3]
  12666. fmt.Println(card_sn)
  12667. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  12668. 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)
  12669. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  12670. var dat map[string]interface{}
  12671. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12672. fmt.Println(dat)
  12673. } else {
  12674. fmt.Println(err)
  12675. }
  12676. userJSONBytes, _ := json.Marshal(dat)
  12677. var res ResultTwo
  12678. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12679. utils.ErrorLog("解析失败:%v", err)
  12680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12681. return
  12682. }
  12683. if res.Infcode == 0 {
  12684. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  12685. if err == gorm.ErrRecordNotFound {
  12686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12687. return
  12688. } else if err != nil {
  12689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12690. return
  12691. } else {
  12692. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12693. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12694. infoStr := string(Iinfos)
  12695. idetinfoStr := string(Idetinfos)
  12696. var rf []*ResultFive
  12697. json.Unmarshal([]byte(infoStr), &rf)
  12698. var insutypes []*ResultFive
  12699. var insutype string
  12700. var is390 int = 0
  12701. var is310 int = 0
  12702. var insuplc_admdvs string
  12703. for _, item := range rf {
  12704. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12705. insutypes = append(insutypes, item)
  12706. }
  12707. }
  12708. if len(insutypes) == 1 {
  12709. insutype = insutypes[0].Insutype
  12710. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12711. } else {
  12712. for _, i := range insutypes {
  12713. if i.Insutype == "390" {
  12714. is390 = 1
  12715. }
  12716. if i.Insutype == "310" {
  12717. is310 = 1
  12718. }
  12719. }
  12720. }
  12721. if is390 == 1 {
  12722. insutype = "390"
  12723. }
  12724. if is310 == 1 {
  12725. insutype = "310"
  12726. }
  12727. if len(insutypes) == 0 {
  12728. insutype = "310"
  12729. }
  12730. for _, item := range rf {
  12731. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  12732. insuplc_admdvs = item.InsuplcAdmdvs
  12733. }
  12734. }
  12735. psn := &models.HisPsn{
  12736. PsnNo: res.Output.Baseinfo.PsnNo,
  12737. PatientId: patient.ID,
  12738. Certno: res.Output.Baseinfo.Certno,
  12739. Gend: res.Output.Baseinfo.Gend,
  12740. Naty: res.Output.Baseinfo.Naty,
  12741. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12742. PsnName: res.Output.Baseinfo.PsnName,
  12743. Idetinfo: idetinfoStr,
  12744. Insuinfo: infoStr,
  12745. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12746. CardInfo: basStr,
  12747. InsuplcAdmdvs: insuplc_admdvs,
  12748. VerifyNumber: "",
  12749. }
  12750. service.CreateHisPsn(psn)
  12751. c.ServeSuccessJSON(map[string]interface{}{
  12752. "patient": patient,
  12753. "number": basNumber,
  12754. "insutype": insutype,
  12755. })
  12756. }
  12757. } else {
  12758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12759. return
  12760. }
  12761. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12762. fmt.Println(initFlag)
  12763. fmt.Println("initFlag")
  12764. if initFlag == 0 {
  12765. c.TestGetHnBasBaseInit()
  12766. }
  12767. basStr := c.GetBasBaseInfo()
  12768. if len(basStr) == 0 {
  12769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12770. return
  12771. }
  12772. fmt.Println(basStr)
  12773. bas := strings.Split(basStr, "|")
  12774. basNumber := bas[1]
  12775. fmt.Println(basNumber)
  12776. card_sn := bas[3]
  12777. card_no := bas[2]
  12778. fmt.Println(card_sn)
  12779. name := bas[4]
  12780. name = ConvertToString(name, "gbk", "utf-8")
  12781. 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)
  12782. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  12783. var dat map[string]interface{}
  12784. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12785. fmt.Println(dat)
  12786. } else {
  12787. fmt.Println(err)
  12788. }
  12789. userJSONBytes, _ := json.Marshal(dat)
  12790. var res ResultTwo
  12791. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12792. utils.ErrorLog("解析失败:%v", err)
  12793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12794. return
  12795. }
  12796. if res.Infcode == 0 {
  12797. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  12798. if err == gorm.ErrRecordNotFound {
  12799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12800. return
  12801. } else if err != nil {
  12802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12803. return
  12804. } else {
  12805. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12806. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12807. infoStr := string(Iinfos)
  12808. idetinfoStr := string(Idetinfos)
  12809. psn := &models.HisPsn{
  12810. PsnNo: res.Output.Baseinfo.PsnNo,
  12811. PatientId: patient.ID,
  12812. Certno: res.Output.Baseinfo.Certno,
  12813. Gend: res.Output.Baseinfo.Gend,
  12814. Naty: res.Output.Baseinfo.Naty,
  12815. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12816. PsnName: res.Output.Baseinfo.PsnName,
  12817. Idetinfo: idetinfoStr,
  12818. Insuinfo: infoStr,
  12819. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12820. CardInfo: basStr,
  12821. VerifyNumber: "",
  12822. }
  12823. service.CreateHisPsn(psn)
  12824. var rf []*ResultFive
  12825. json.Unmarshal([]byte(infoStr), &rf)
  12826. var insutypes []*ResultFive
  12827. var insutype string
  12828. var is390 int = 0
  12829. var is310 int = 0
  12830. for _, item := range rf {
  12831. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12832. insutypes = append(insutypes, item)
  12833. }
  12834. }
  12835. if len(insutypes) == 1 {
  12836. insutype = insutypes[0].Insutype
  12837. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12838. } else {
  12839. for _, i := range insutypes {
  12840. if i.Insutype == "390" {
  12841. is390 = 1
  12842. }
  12843. if i.Insutype == "310" {
  12844. is310 = 1
  12845. }
  12846. }
  12847. }
  12848. if is390 == 1 {
  12849. insutype = "390"
  12850. }
  12851. if is310 == 1 {
  12852. insutype = "310"
  12853. }
  12854. if len(insutypes) == 0 {
  12855. insutype = "310"
  12856. }
  12857. c.ServeSuccessJSON(map[string]interface{}{
  12858. "patient": patient,
  12859. "number": basNumber,
  12860. "insutype": insutype,
  12861. })
  12862. }
  12863. } else {
  12864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12865. return
  12866. }
  12867. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12868. var api string
  12869. 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 +
  12870. "&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
  12871. fmt.Println(api)
  12872. resp, requestErr := http.Get(api)
  12873. if requestErr != nil {
  12874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12875. return
  12876. }
  12877. body, ioErr := ioutil.ReadAll(resp.Body)
  12878. if ioErr != nil {
  12879. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12881. return
  12882. }
  12883. var respJSON map[string]interface{}
  12884. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12887. return
  12888. }
  12889. var res ResultTwo //1101结果
  12890. var res10265 ResultTwo10265 //1101结果
  12891. var card_info string //卡信息
  12892. token := respJSON["data"].(map[string]interface{})["token"].(string)
  12893. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12894. result, _ := json.Marshal(respJSON)
  12895. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12896. utils.ErrorLog("解析失败:%v", err)
  12897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12898. return
  12899. }
  12900. res.ErrMsg = res10265.ErrMsg
  12901. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12902. res.Infcode = infocode
  12903. res.Output = res10265.Output
  12904. res.InfRefmsgid = res10265.InfRefmsgid
  12905. if res.Infcode == 0 {
  12906. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12907. if err == gorm.ErrRecordNotFound {
  12908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12909. return
  12910. } else if err != nil {
  12911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12912. return
  12913. } else {
  12914. bas := strings.Split(card_info, "|")
  12915. basNumber := bas[2]
  12916. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12917. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12918. infoStr := string(Iinfos)
  12919. idetinfoStr := string(Idetinfos)
  12920. psn := &models.HisPsn{
  12921. PsnNo: res.Output.Baseinfo.PsnNo,
  12922. PatientId: patient.ID,
  12923. Certno: res.Output.Baseinfo.Certno,
  12924. Gend: res.Output.Baseinfo.Gend,
  12925. Naty: res.Output.Baseinfo.Naty,
  12926. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12927. PsnName: res.Output.Baseinfo.PsnName,
  12928. Idetinfo: idetinfoStr,
  12929. Insuinfo: infoStr,
  12930. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12931. CardInfo: card_info,
  12932. VerifyNumber: token,
  12933. }
  12934. service.CreateHisPsn(psn)
  12935. var rf []*ResultFive
  12936. json.Unmarshal([]byte(infoStr), &rf)
  12937. var insutypes []*ResultFive
  12938. var insutype string
  12939. var is390 int = 0
  12940. var is310 int = 0
  12941. for _, item := range rf {
  12942. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12943. insutypes = append(insutypes, item)
  12944. }
  12945. }
  12946. if len(insutypes) == 1 {
  12947. insutype = insutypes[0].Insutype
  12948. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12949. } else {
  12950. for _, i := range insutypes {
  12951. if i.Insutype == "390" {
  12952. is390 = 1
  12953. }
  12954. if i.Insutype == "310" {
  12955. is310 = 1
  12956. }
  12957. }
  12958. }
  12959. if is390 == 1 {
  12960. insutype = "390"
  12961. }
  12962. if is310 == 1 {
  12963. insutype = "310"
  12964. }
  12965. if len(insutypes) == 0 {
  12966. insutype = "310"
  12967. }
  12968. c.ServeSuccessJSON(map[string]interface{}{
  12969. "patient": patient,
  12970. "number": basNumber,
  12971. "insutype": insutype,
  12972. })
  12973. }
  12974. } else {
  12975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12976. return
  12977. }
  12978. } else if miConfig.MdtrtareaAdmvs == "450721" {
  12979. res := c.GetoleInfo()
  12980. if res.Infcode == 0 {
  12981. var result string
  12982. if res.Output.MdtrtCertType == "01" {
  12983. 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)
  12984. } else if res.Output.MdtrtCertType == "02" {
  12985. 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)
  12986. } else if res.Output.MdtrtCertType == "03" {
  12987. 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)
  12988. }
  12989. var dat map[string]interface{}
  12990. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12991. fmt.Println(dat)
  12992. } else {
  12993. fmt.Println(err)
  12994. }
  12995. userJSONBytes, _ := json.Marshal(dat)
  12996. var res2 ResultTwo
  12997. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12998. utils.ErrorLog("解析失败:%v", err)
  12999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13000. return
  13001. }
  13002. if res2.Infcode == 0 {
  13003. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13004. if err == gorm.ErrRecordNotFound {
  13005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13006. return
  13007. } else if err != nil {
  13008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13009. return
  13010. } else {
  13011. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13012. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13013. infoStr := string(Iinfos)
  13014. idetinfoStr := string(Idetinfos)
  13015. var rf []*ResultFive
  13016. json.Unmarshal([]byte(infoStr), &rf)
  13017. var insutypes []*ResultFive
  13018. var insutype string
  13019. var is390 int = 0
  13020. var is310 int = 0
  13021. //var insuplc_admdvs string
  13022. for _, item := range rf {
  13023. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13024. insutypes = append(insutypes, item)
  13025. }
  13026. }
  13027. if len(insutypes) == 1 {
  13028. insutype = insutypes[0].Insutype
  13029. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13030. } else {
  13031. for _, i := range insutypes {
  13032. if i.Insutype == "390" {
  13033. is390 = 1
  13034. }
  13035. if i.Insutype == "310" {
  13036. is310 = 1
  13037. }
  13038. }
  13039. }
  13040. if is390 == 1 {
  13041. insutype = "390"
  13042. }
  13043. if is310 == 1 {
  13044. insutype = "310"
  13045. }
  13046. if len(insutypes) == 0 {
  13047. insutype = "310"
  13048. }
  13049. psn := &models.HisPsn{
  13050. PsnNo: res2.Output.Baseinfo.PsnNo,
  13051. PatientId: patient.ID,
  13052. Certno: res2.Output.Baseinfo.Certno,
  13053. Gend: res2.Output.Baseinfo.Gend,
  13054. Naty: res2.Output.Baseinfo.Naty,
  13055. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  13056. PsnName: res2.Output.Baseinfo.PsnName,
  13057. Idetinfo: idetinfoStr,
  13058. Insuinfo: infoStr,
  13059. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13060. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  13061. VerifyNumber: res.Output.EcToken,
  13062. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  13063. }
  13064. if res.Output.MdtrtCertType == "01" {
  13065. psn.VerifyNumber = res.Output.EcToken
  13066. //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)
  13067. } else if res.Output.MdtrtCertType == "02" {
  13068. psn.VerifyNumber = res.Output.MdtrtCertNo
  13069. //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)
  13070. } else if res.Output.MdtrtCertType == "03" {
  13071. psn.VerifyNumber = res.Output.MdtrtCertNo
  13072. //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)
  13073. }
  13074. var balc float64
  13075. for _, item := range rf {
  13076. if item.Insutype == insutype {
  13077. balc = item.Balc
  13078. }
  13079. }
  13080. service.CreateHisPsn(psn)
  13081. c.ServeSuccessJSON(map[string]interface{}{
  13082. "patient": patient,
  13083. "number": res.Output.CardNo,
  13084. "insutype": insutype,
  13085. "blac": balc,
  13086. "desc": idetinfoStr,
  13087. })
  13088. }
  13089. } else {
  13090. c.ServeSuccessJSON(map[string]interface{}{
  13091. "failed_code": -10,
  13092. "msg": res2.ErrMsg,
  13093. })
  13094. }
  13095. } else {
  13096. c.ServeSuccessJSON(map[string]interface{}{
  13097. "failed_code": -10,
  13098. "msg": res.ErrMsg,
  13099. })
  13100. }
  13101. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13102. var api string
  13103. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13104. "&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
  13105. fmt.Println(api)
  13106. resp, requestErr := http.Get(api)
  13107. if requestErr != nil {
  13108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13109. return
  13110. }
  13111. body, ioErr := ioutil.ReadAll(resp.Body)
  13112. if ioErr != nil {
  13113. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13115. return
  13116. }
  13117. var respJSON map[string]interface{}
  13118. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13121. return
  13122. }
  13123. var status string
  13124. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13125. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13126. //console.log()
  13127. fmt.Println("type===")
  13128. fmt.Println(card_type)
  13129. var token string
  13130. var res ResultTwo //1101结果
  13131. //var res10265 ResultTwoesultTwo10265 //1101结果
  13132. var card_info string //卡信息
  13133. var busi_card_info string
  13134. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13135. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13136. if status == "0" { //读卡成功
  13137. if card_type == "1" {
  13138. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13139. result, _ := json.Marshal(respJSON)
  13140. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13141. utils.ErrorLog("解析失败:%v", err)
  13142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13143. return
  13144. }
  13145. } else {
  13146. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13147. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13148. result, _ := json.Marshal(respJSON)
  13149. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13150. utils.ErrorLog("解析失败:%v", err)
  13151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13152. return
  13153. }
  13154. }
  13155. if res.Infcode == 0 {
  13156. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13157. if err == gorm.ErrRecordNotFound {
  13158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13159. return
  13160. } else if err != nil {
  13161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13162. return
  13163. } else {
  13164. if card_type == "1" {
  13165. bas := strings.Split(card_info, "|")
  13166. basNumber := bas[2]
  13167. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13168. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13169. infoStr := string(Iinfos)
  13170. idetinfoStr := string(Idetinfos)
  13171. psn := &models.HisPsn{
  13172. PsnNo: res.Output.Baseinfo.PsnNo,
  13173. PatientId: patient.ID,
  13174. Certno: res.Output.Baseinfo.Certno,
  13175. Gend: res.Output.Baseinfo.Gend,
  13176. Naty: res.Output.Baseinfo.Naty,
  13177. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13178. PsnName: res.Output.Baseinfo.PsnName,
  13179. Idetinfo: idetinfoStr,
  13180. Insuinfo: infoStr,
  13181. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13182. CardInfo: card_info,
  13183. VerifyNumber: busi_card_info,
  13184. }
  13185. service.CreateHisPsn(psn)
  13186. var rf []*ResultFive
  13187. json.Unmarshal([]byte(infoStr), &rf)
  13188. var insutypes []*ResultFive
  13189. var insutype string
  13190. var is390 int = 0
  13191. var is310 int = 0
  13192. for _, item := range rf {
  13193. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13194. insutypes = append(insutypes, item)
  13195. }
  13196. }
  13197. if len(insutypes) == 1 {
  13198. insutype = insutypes[0].Insutype
  13199. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13200. } else {
  13201. for _, i := range insutypes {
  13202. if i.Insutype == "390" {
  13203. is390 = 1
  13204. }
  13205. if i.Insutype == "310" {
  13206. is310 = 1
  13207. }
  13208. }
  13209. }
  13210. if is390 == 1 {
  13211. insutype = "390"
  13212. }
  13213. if is310 == 1 {
  13214. insutype = "310"
  13215. }
  13216. if len(insutypes) == 0 {
  13217. insutype = "310"
  13218. }
  13219. c.ServeSuccessJSON(map[string]interface{}{
  13220. "patient": patient,
  13221. "number": basNumber,
  13222. "insutype": insutype,
  13223. })
  13224. } else {
  13225. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13226. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13227. infoStr := string(Iinfos)
  13228. idetinfoStr := string(Idetinfos)
  13229. psn := &models.HisPsn{
  13230. PsnNo: res.Output.Baseinfo.PsnNo,
  13231. PatientId: patient.ID,
  13232. Certno: res.Output.Baseinfo.Certno,
  13233. Gend: res.Output.Baseinfo.Gend,
  13234. Naty: res.Output.Baseinfo.Naty,
  13235. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13236. PsnName: res.Output.Baseinfo.PsnName,
  13237. Idetinfo: idetinfoStr,
  13238. Insuinfo: infoStr,
  13239. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13240. CardInfo: card_info,
  13241. VerifyNumber: token,
  13242. }
  13243. service.CreateHisPsn(psn)
  13244. c.ServeSuccessJSON(map[string]interface{}{
  13245. "patient": patient,
  13246. "number": token,
  13247. })
  13248. }
  13249. }
  13250. } else {
  13251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13252. return
  13253. }
  13254. } else { //读卡失败
  13255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13256. return
  13257. }
  13258. } else {
  13259. if initFlag == 0 {
  13260. c.TestGetBasBaseInit()
  13261. }
  13262. basStr := c.GetBasBaseInfo()
  13263. if len(basStr) == 0 {
  13264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13265. return
  13266. }
  13267. fmt.Println(basStr)
  13268. bas := strings.Split(basStr, "|")
  13269. basNumber := bas[1]
  13270. fmt.Println(basNumber)
  13271. card_sn := bas[3]
  13272. fmt.Println(card_sn)
  13273. cardNumber := bas[2]
  13274. fmt.Println(cardNumber)
  13275. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  13276. var result string
  13277. if bas[0][:2] == "44" {
  13278. 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)
  13279. } else {
  13280. 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)
  13281. }
  13282. var dat map[string]interface{}
  13283. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13284. fmt.Println(dat)
  13285. } else {
  13286. fmt.Println(err)
  13287. }
  13288. userJSONBytes, _ := json.Marshal(dat)
  13289. var res ResultTwo
  13290. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13291. utils.ErrorLog("解析失败:%v", err)
  13292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13293. return
  13294. }
  13295. if res.Infcode == 0 {
  13296. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13297. if err == gorm.ErrRecordNotFound {
  13298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13299. return
  13300. } else if err != nil {
  13301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13302. return
  13303. } else {
  13304. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13305. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13306. infoStr := string(Iinfos)
  13307. idetinfoStr := string(Idetinfos)
  13308. var rf []*ResultFive
  13309. json.Unmarshal([]byte(infoStr), &rf)
  13310. var insutypes []*ResultFive
  13311. var insutype string
  13312. var is390 int = 0
  13313. var is310 int = 0
  13314. var insuplc_admdvs string
  13315. for _, item := range rf {
  13316. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13317. insutypes = append(insutypes, item)
  13318. }
  13319. }
  13320. if len(insutypes) == 1 {
  13321. insutype = insutypes[0].Insutype
  13322. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13323. } else {
  13324. for _, i := range insutypes {
  13325. if i.Insutype == "390" {
  13326. is390 = 1
  13327. }
  13328. if i.Insutype == "310" {
  13329. is310 = 1
  13330. }
  13331. }
  13332. }
  13333. if is390 == 1 {
  13334. insutype = "390"
  13335. }
  13336. if is310 == 1 {
  13337. insutype = "310"
  13338. }
  13339. if len(insutypes) == 0 {
  13340. insutype = "310"
  13341. }
  13342. for _, item := range rf {
  13343. if item.Insutype == insutype {
  13344. insuplc_admdvs = item.InsuplcAdmdvs
  13345. }
  13346. }
  13347. psn := &models.HisPsn{
  13348. PsnNo: res.Output.Baseinfo.PsnNo,
  13349. PatientId: patient.ID,
  13350. Certno: res.Output.Baseinfo.Certno,
  13351. Gend: res.Output.Baseinfo.Gend,
  13352. Naty: res.Output.Baseinfo.Naty,
  13353. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13354. PsnName: res.Output.Baseinfo.PsnName,
  13355. Idetinfo: idetinfoStr,
  13356. Insuinfo: infoStr,
  13357. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13358. CardInfo: basStr,
  13359. VerifyNumber: "",
  13360. InsuplcAdmdvs: insuplc_admdvs,
  13361. }
  13362. service.CreateHisPsn(psn)
  13363. c.ServeSuccessJSON(map[string]interface{}{
  13364. "patient": patient,
  13365. "number": basNumber,
  13366. })
  13367. }
  13368. } else {
  13369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13370. return
  13371. }
  13372. break
  13373. }
  13374. case 2:
  13375. if miConfig.MdtrtareaAdmvs == "430800" {
  13376. if initFlag == 0 {
  13377. c.TestGetHnBasBaseInit()
  13378. }
  13379. SFZStr := c.GetSFZBaseInfo()
  13380. if len(SFZStr) == 0 {
  13381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13382. return
  13383. }
  13384. fmt.Println(SFZStr)
  13385. id_card_str := strings.Split(SFZStr, "^")
  13386. card_no := id_card_str[0]
  13387. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  13388. //name := id_card_str[1]
  13389. //name = ConvertToString(name, "gbk", "utf-8")
  13390. 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)
  13391. var dat map[string]interface{}
  13392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13393. fmt.Println(dat)
  13394. } else {
  13395. fmt.Println(err)
  13396. }
  13397. userJSONBytes, _ := json.Marshal(dat)
  13398. var res ResultTwo
  13399. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13400. utils.ErrorLog("解析失败:%v", err)
  13401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13402. return
  13403. }
  13404. if res.Infcode == 0 {
  13405. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  13406. if err == gorm.ErrRecordNotFound {
  13407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13408. return
  13409. } else if err != nil {
  13410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13411. return
  13412. } else {
  13413. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13414. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13415. infoStr := string(Iinfos)
  13416. idetinfoStr := string(Idetinfos)
  13417. var rf []*ResultFive
  13418. json.Unmarshal([]byte(infoStr), &rf)
  13419. var insutypes []*ResultFive
  13420. var insutype string
  13421. var is390 int = 0
  13422. var is310 int = 0
  13423. for _, item := range rf {
  13424. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13425. insutypes = append(insutypes, item)
  13426. }
  13427. }
  13428. if len(insutypes) == 1 {
  13429. insutype = insutypes[0].Insutype
  13430. } else {
  13431. for _, i := range insutypes {
  13432. if i.Insutype == "390" {
  13433. is390 = 1
  13434. }
  13435. if i.Insutype == "310" {
  13436. is310 = 1
  13437. }
  13438. }
  13439. }
  13440. if is390 == 1 {
  13441. insutype = "390"
  13442. }
  13443. if is310 == 1 {
  13444. insutype = "310"
  13445. }
  13446. if len(insutypes) == 0 {
  13447. insutype = "310"
  13448. }
  13449. var InsuplcAdmdvs string
  13450. for _, item := range rf {
  13451. if item.Insutype == insutype {
  13452. InsuplcAdmdvs = item.InsuplcAdmdvs
  13453. }
  13454. }
  13455. psn := &models.HisPsn{
  13456. PsnNo: res.Output.Baseinfo.PsnNo,
  13457. PatientId: patient.ID,
  13458. Certno: res.Output.Baseinfo.Certno,
  13459. Gend: res.Output.Baseinfo.Gend,
  13460. Naty: res.Output.Baseinfo.Naty,
  13461. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13462. PsnName: res.Output.Baseinfo.PsnName,
  13463. Idetinfo: idetinfoStr,
  13464. Insuinfo: infoStr,
  13465. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13466. CardInfo: SFZStr,
  13467. VerifyNumber: "",
  13468. InsuplcAdmdvs: InsuplcAdmdvs,
  13469. }
  13470. service.CreateHisPsn(psn)
  13471. c.ServeSuccessJSON(map[string]interface{}{
  13472. "patient": patient,
  13473. "number": card_no,
  13474. "insutype": insutype,
  13475. })
  13476. }
  13477. } else {
  13478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13479. return
  13480. }
  13481. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13482. var res ResultTwo
  13483. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13484. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13485. "&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)
  13486. resp, requestErr := http.Get(api)
  13487. if requestErr != nil {
  13488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13489. return
  13490. }
  13491. body, ioErr := ioutil.ReadAll(resp.Body)
  13492. if ioErr != nil {
  13493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13495. return
  13496. }
  13497. var respJSON map[string]interface{}
  13498. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13501. return
  13502. }
  13503. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13504. result, _ := json.Marshal(respJSON)
  13505. fmt.Println("log")
  13506. fmt.Println(string(result))
  13507. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13508. utils.ErrorLog("解析失败:%v", err)
  13509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13510. return
  13511. }
  13512. if res.Infcode == 0 {
  13513. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13514. if err == gorm.ErrRecordNotFound {
  13515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13516. return
  13517. } else if err != nil {
  13518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13519. return
  13520. } else {
  13521. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13522. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13523. infoStr := string(Iinfos)
  13524. idetinfoStr := string(Idetinfos)
  13525. psn := &models.HisPsn{
  13526. PsnNo: res.Output.Baseinfo.PsnNo,
  13527. PatientId: patient.ID,
  13528. Certno: res.Output.Baseinfo.Certno,
  13529. Gend: res.Output.Baseinfo.Gend,
  13530. Naty: res.Output.Baseinfo.Naty,
  13531. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13532. PsnName: res.Output.Baseinfo.PsnName,
  13533. Idetinfo: idetinfoStr,
  13534. Insuinfo: infoStr,
  13535. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13536. }
  13537. service.CreateHisPsn(psn)
  13538. c.ServeSuccessJSON(map[string]interface{}{
  13539. "patient": patient,
  13540. "number": res.Output.Baseinfo.Certno,
  13541. })
  13542. }
  13543. } else {
  13544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13545. return
  13546. }
  13547. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13548. var res ResultTwo
  13549. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13550. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13551. "&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)
  13552. resp, requestErr := http.Get(api)
  13553. if requestErr != nil {
  13554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13555. return
  13556. }
  13557. body, ioErr := ioutil.ReadAll(resp.Body)
  13558. if ioErr != nil {
  13559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13561. return
  13562. }
  13563. var respJSON map[string]interface{}
  13564. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13567. return
  13568. }
  13569. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13570. result, _ := json.Marshal(respJSON)
  13571. fmt.Println("log")
  13572. fmt.Println(string(result))
  13573. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13574. utils.ErrorLog("解析失败:%v", err)
  13575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13576. return
  13577. }
  13578. if res.Infcode == 0 {
  13579. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13580. if err == gorm.ErrRecordNotFound {
  13581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13582. return
  13583. } else if err != nil {
  13584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13585. return
  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. }
  13603. service.CreateHisPsn(psn)
  13604. c.ServeSuccessJSON(map[string]interface{}{
  13605. "patient": patient,
  13606. "number": res.Output.Baseinfo.Certno,
  13607. })
  13608. }
  13609. } else {
  13610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13611. return
  13612. }
  13613. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13614. var res ResultTwo
  13615. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13616. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13617. "&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)
  13618. resp, requestErr := http.Get(api)
  13619. if requestErr != nil {
  13620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13621. return
  13622. }
  13623. body, ioErr := ioutil.ReadAll(resp.Body)
  13624. if ioErr != nil {
  13625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13627. return
  13628. }
  13629. var respJSON map[string]interface{}
  13630. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13633. return
  13634. }
  13635. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13636. result, _ := json.Marshal(respJSON)
  13637. fmt.Println("log")
  13638. fmt.Println(string(result))
  13639. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13640. utils.ErrorLog("解析失败:%v", err)
  13641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13642. return
  13643. }
  13644. if res.Infcode == 0 {
  13645. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13646. if err == gorm.ErrRecordNotFound {
  13647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13648. return
  13649. } else if err != nil {
  13650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13651. return
  13652. } else {
  13653. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13654. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13655. infoStr := string(Iinfos)
  13656. idetinfoStr := string(Idetinfos)
  13657. var rf []*ResultFive
  13658. json.Unmarshal([]byte(infoStr), &rf)
  13659. var insutypes []*ResultFive
  13660. var insutype string
  13661. var is390 int = 0
  13662. var is310 int = 0
  13663. for _, item := range rf {
  13664. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13665. insutypes = append(insutypes, item)
  13666. }
  13667. }
  13668. if len(insutypes) == 1 {
  13669. insutype = insutypes[0].Insutype
  13670. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13671. } else {
  13672. for _, i := range insutypes {
  13673. if i.Insutype == "390" {
  13674. is390 = 1
  13675. }
  13676. if i.Insutype == "310" {
  13677. is310 = 1
  13678. }
  13679. }
  13680. }
  13681. if is390 == 1 {
  13682. insutype = "390"
  13683. }
  13684. if is310 == 1 {
  13685. insutype = "310"
  13686. }
  13687. if len(insutypes) == 0 {
  13688. insutype = "390"
  13689. }
  13690. var insuplc_admdvs string
  13691. for _, item := range rf {
  13692. if item.Insutype == insutype {
  13693. insuplc_admdvs = item.InsuplcAdmdvs
  13694. }
  13695. }
  13696. psn := &models.HisPsn{
  13697. PsnNo: res.Output.Baseinfo.PsnNo,
  13698. PatientId: patient.ID,
  13699. Certno: res.Output.Baseinfo.Certno,
  13700. Gend: res.Output.Baseinfo.Gend,
  13701. Naty: res.Output.Baseinfo.Naty,
  13702. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13703. PsnName: res.Output.Baseinfo.PsnName,
  13704. Idetinfo: idetinfoStr,
  13705. Insuinfo: infoStr,
  13706. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13707. InsuplcAdmdvs: insuplc_admdvs,
  13708. }
  13709. service.CreateHisPsn(psn)
  13710. c.ServeSuccessJSON(map[string]interface{}{
  13711. "patient": patient,
  13712. "number": res.Output.Baseinfo.Certno,
  13713. })
  13714. }
  13715. } else {
  13716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13717. return
  13718. }
  13719. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13720. res := c.GetoleInfo()
  13721. if res.Infcode == 0 {
  13722. var result string
  13723. if res.Output.MdtrtCertType == "01" {
  13724. 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)
  13725. } else if res.Output.MdtrtCertType == "02" {
  13726. 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)
  13727. } else if res.Output.MdtrtCertType == "03" {
  13728. 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)
  13729. }
  13730. var dat map[string]interface{}
  13731. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13732. fmt.Println(dat)
  13733. } else {
  13734. fmt.Println(err)
  13735. }
  13736. userJSONBytes, _ := json.Marshal(dat)
  13737. var res2 ResultTwo
  13738. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13739. utils.ErrorLog("解析失败:%v", err)
  13740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13741. return
  13742. }
  13743. if res2.Infcode == 0 {
  13744. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13745. if err == gorm.ErrRecordNotFound {
  13746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13747. return
  13748. } else if err != nil {
  13749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13750. return
  13751. } else {
  13752. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13753. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13754. infoStr := string(Iinfos)
  13755. idetinfoStr := string(Idetinfos)
  13756. var rf []*ResultFive
  13757. json.Unmarshal([]byte(infoStr), &rf)
  13758. var insutypes []*ResultFive
  13759. var insutype string
  13760. var is390 int = 0
  13761. var is310 int = 0
  13762. //var insuplc_admdvs string
  13763. for _, item := range rf {
  13764. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13765. insutypes = append(insutypes, item)
  13766. }
  13767. }
  13768. if len(insutypes) == 1 {
  13769. insutype = insutypes[0].Insutype
  13770. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13771. } else {
  13772. for _, i := range insutypes {
  13773. if i.Insutype == "390" {
  13774. is390 = 1
  13775. }
  13776. if i.Insutype == "310" {
  13777. is310 = 1
  13778. }
  13779. }
  13780. }
  13781. if is390 == 1 {
  13782. insutype = "390"
  13783. }
  13784. if is310 == 1 {
  13785. insutype = "310"
  13786. }
  13787. if len(insutypes) == 0 {
  13788. insutype = "310"
  13789. }
  13790. psn := &models.HisPsn{
  13791. PsnNo: res2.Output.Baseinfo.PsnNo,
  13792. PatientId: patient.ID,
  13793. //Brdy: res2.Output.Baseinfo.Brdy,
  13794. Certno: res2.Output.Baseinfo.Certno,
  13795. Gend: res2.Output.Baseinfo.Gend,
  13796. Naty: res2.Output.Baseinfo.Naty,
  13797. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  13798. PsnName: res2.Output.Baseinfo.PsnName,
  13799. Idetinfo: idetinfoStr,
  13800. Insuinfo: infoStr,
  13801. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13802. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  13803. VerifyNumber: res.Output.EcToken,
  13804. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  13805. }
  13806. service.CreateHisPsn(psn)
  13807. var balc float64
  13808. for _, item := range rf {
  13809. if item.Insutype == insutype {
  13810. balc = item.Balc
  13811. }
  13812. }
  13813. c.ServeSuccessJSON(map[string]interface{}{
  13814. "patient": patient,
  13815. "number": res.Output.CardNo,
  13816. "insutype": insutype,
  13817. "blac": balc,
  13818. "desc": idetinfoStr,
  13819. })
  13820. }
  13821. } else {
  13822. c.ServeSuccessJSON(map[string]interface{}{
  13823. "failed_code": -10,
  13824. "msg": res2.ErrMsg,
  13825. })
  13826. }
  13827. } else {
  13828. c.ServeSuccessJSON(map[string]interface{}{
  13829. "failed_code": -10,
  13830. "msg": res.ErrMsg,
  13831. })
  13832. }
  13833. } else {
  13834. SFZStr := c.GetSFZBaseInfo()
  13835. id_card_str := strings.Split(SFZStr, "^")
  13836. id_card_number := id_card_str[0]
  13837. card_sn := ""
  13838. 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)
  13839. var dat map[string]interface{}
  13840. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13841. fmt.Println(dat)
  13842. } else {
  13843. fmt.Println(err)
  13844. }
  13845. userJSONBytes, _ := json.Marshal(dat)
  13846. var res ResultTwo
  13847. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13848. utils.ErrorLog("解析失败:%v", err)
  13849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13850. return
  13851. }
  13852. if res.Infcode == 0 {
  13853. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  13854. if err == gorm.ErrRecordNotFound {
  13855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13856. return
  13857. } else if err != nil {
  13858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13859. return
  13860. } else {
  13861. c.ServeSuccessJSON(map[string]interface{}{
  13862. "patient": patient,
  13863. "number": id_card_number,
  13864. })
  13865. }
  13866. } else {
  13867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13868. return
  13869. }
  13870. }
  13871. break
  13872. case 3:
  13873. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13874. var api string
  13875. if miConfig.MdtrtareaAdmvs == "320921" {
  13876. 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 +
  13877. "&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
  13878. fmt.Println(api)
  13879. } else {
  13880. 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 +
  13881. "&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)
  13882. }
  13883. resp, requestErr := http.Get(api)
  13884. if requestErr != nil {
  13885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13886. return
  13887. }
  13888. body, ioErr := ioutil.ReadAll(resp.Body)
  13889. if ioErr != nil {
  13890. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13892. return
  13893. }
  13894. var respJSON map[string]interface{}
  13895. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13898. return
  13899. }
  13900. var status string
  13901. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13902. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13903. var token string
  13904. var res ResultTwo //1101结果
  13905. var res10265 ResultTwo10265 //1101结果
  13906. var card_info string //卡信息
  13907. var busi_card_info string
  13908. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13909. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13910. if status == "0" { //读卡成功
  13911. if card_type == "1" {
  13912. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13913. result, _ := json.Marshal(respJSON)
  13914. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13915. utils.ErrorLog("解析失败:%v", err)
  13916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13917. return
  13918. }
  13919. res.ErrMsg = res10265.ErrMsg
  13920. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13921. res.Infcode = infocode
  13922. res.Output = res10265.Output
  13923. res.InfRefmsgid = res10265.InfRefmsgid
  13924. } else {
  13925. //var card_info string //卡信息
  13926. //var busi_card_info string
  13927. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13928. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13929. //fmt.Println(card_info)
  13930. //fmt.Println(busi_card_info)
  13931. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13932. result, _ := json.Marshal(respJSON)
  13933. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13934. utils.ErrorLog("解析失败:%v", err)
  13935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13936. return
  13937. }
  13938. res.ErrMsg = res10265.ErrMsg
  13939. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13940. res.Infcode = infocode
  13941. res.Output = res10265.Output
  13942. res.InfRefmsgid = res10265.InfRefmsgid
  13943. }
  13944. if res.Infcode == 0 {
  13945. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13946. if err == gorm.ErrRecordNotFound {
  13947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13948. return
  13949. } else if err != nil {
  13950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13951. return
  13952. } else {
  13953. if card_type == "1" {
  13954. bas := strings.Split(card_info, "|")
  13955. basNumber := bas[2]
  13956. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13957. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13958. infoStr := string(Iinfos)
  13959. idetinfoStr := string(Idetinfos)
  13960. psn := &models.HisPsn{
  13961. PsnNo: res.Output.Baseinfo.PsnNo,
  13962. PatientId: patient.ID,
  13963. Certno: res.Output.Baseinfo.Certno,
  13964. //Brdy: res.Output.Baseinfo.Brdy,
  13965. Gend: res.Output.Baseinfo.Gend,
  13966. Naty: res.Output.Baseinfo.Naty,
  13967. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13968. PsnName: res.Output.Baseinfo.PsnName,
  13969. Idetinfo: idetinfoStr,
  13970. Insuinfo: infoStr,
  13971. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13972. CardInfo: card_info,
  13973. VerifyNumber: busi_card_info,
  13974. }
  13975. service.CreateHisPsn(psn)
  13976. c.ServeSuccessJSON(map[string]interface{}{
  13977. "patient": patient,
  13978. "number": basNumber,
  13979. })
  13980. } else {
  13981. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13982. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13983. infoStr := string(Iinfos)
  13984. idetinfoStr := string(Idetinfos)
  13985. psn := &models.HisPsn{
  13986. PsnNo: res.Output.Baseinfo.PsnNo,
  13987. PatientId: patient.ID,
  13988. Certno: res.Output.Baseinfo.Certno,
  13989. Gend: res.Output.Baseinfo.Gend,
  13990. Naty: res.Output.Baseinfo.Naty,
  13991. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13992. PsnName: res.Output.Baseinfo.PsnName,
  13993. Idetinfo: idetinfoStr,
  13994. Insuinfo: infoStr,
  13995. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13996. CardInfo: card_info,
  13997. VerifyNumber: token,
  13998. }
  13999. service.CreateHisPsn(psn)
  14000. var rf []*ResultFive
  14001. json.Unmarshal([]byte(infoStr), &rf)
  14002. var insutypes []*ResultFive
  14003. var insutype string
  14004. var is390 int = 0
  14005. var is310 int = 0
  14006. for _, item := range rf {
  14007. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14008. insutypes = append(insutypes, item)
  14009. }
  14010. }
  14011. if len(insutypes) == 1 {
  14012. insutype = insutypes[0].Insutype
  14013. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14014. } else {
  14015. for _, i := range insutypes {
  14016. if i.Insutype == "390" {
  14017. is390 = 1
  14018. }
  14019. if i.Insutype == "310" {
  14020. is310 = 1
  14021. }
  14022. }
  14023. }
  14024. if is390 == 1 {
  14025. insutype = "390"
  14026. }
  14027. if is310 == 1 {
  14028. insutype = "310"
  14029. }
  14030. if len(insutypes) == 0 {
  14031. insutype = "310"
  14032. }
  14033. c.ServeSuccessJSON(map[string]interface{}{
  14034. "patient": patient,
  14035. "number": token,
  14036. "insutype": insutype,
  14037. })
  14038. }
  14039. }
  14040. } else {
  14041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14042. return
  14043. }
  14044. } else { //读卡失败
  14045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14046. return
  14047. }
  14048. }
  14049. break
  14050. case 4:
  14051. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14052. var api string
  14053. if miConfig.MdtrtareaAdmvs == "320921" {
  14054. 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 +
  14055. "&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
  14056. fmt.Println(api)
  14057. } else {
  14058. 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 +
  14059. "&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)
  14060. }
  14061. resp, requestErr := http.Get(api)
  14062. if requestErr != nil {
  14063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14064. return
  14065. }
  14066. body, ioErr := ioutil.ReadAll(resp.Body)
  14067. if ioErr != nil {
  14068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14070. return
  14071. }
  14072. var respJSON map[string]interface{}
  14073. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14076. return
  14077. }
  14078. var status string
  14079. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14080. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14081. var token string
  14082. var res ResultTwo //1101结果
  14083. var res10265 ResultTwo10265 //1101结果
  14084. if status == "0" { //读卡成功
  14085. var card_info string //卡信息
  14086. var busi_card_info string
  14087. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14088. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14089. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14090. fmt.Println(card_info)
  14091. fmt.Println(busi_card_info)
  14092. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14093. result, _ := json.Marshal(respJSON)
  14094. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14095. utils.ErrorLog("解析失败:%v", err)
  14096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14097. return
  14098. }
  14099. res.ErrMsg = res10265.ErrMsg
  14100. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14101. res.Infcode = infocode
  14102. res.Output = res10265.Output
  14103. res.InfRefmsgid = res10265.InfRefmsgid
  14104. if res.Infcode == 0 {
  14105. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14106. if err == gorm.ErrRecordNotFound {
  14107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14108. return
  14109. } else if err != nil {
  14110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14111. return
  14112. } else {
  14113. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14114. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14115. infoStr := string(Iinfos)
  14116. idetinfoStr := string(Idetinfos)
  14117. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14118. psn := &models.HisPsn{
  14119. PsnNo: res.Output.Baseinfo.PsnNo,
  14120. PatientId: patient.ID,
  14121. Certno: res.Output.Baseinfo.Certno,
  14122. Brdy: b,
  14123. Age: float64(age),
  14124. //Brdy: res.Output.Baseinfo.Brdy,
  14125. Gend: res.Output.Baseinfo.Gend,
  14126. Naty: res.Output.Baseinfo.Naty,
  14127. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14128. PsnName: res.Output.Baseinfo.PsnName,
  14129. Idetinfo: idetinfoStr,
  14130. Insuinfo: infoStr,
  14131. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14132. CardInfo: card_info,
  14133. VerifyNumber: token,
  14134. }
  14135. var rf []*ResultFive
  14136. json.Unmarshal([]byte(infoStr), &rf)
  14137. var insutypes []*ResultFive
  14138. var insutype string
  14139. var is390 int = 0
  14140. var is310 int = 0
  14141. for _, item := range rf {
  14142. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14143. insutypes = append(insutypes, item)
  14144. }
  14145. }
  14146. if len(insutypes) == 1 {
  14147. insutype = insutypes[0].Insutype
  14148. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14149. } else {
  14150. for _, i := range insutypes {
  14151. if i.Insutype == "390" {
  14152. is390 = 1
  14153. }
  14154. if i.Insutype == "310" {
  14155. is310 = 1
  14156. }
  14157. }
  14158. }
  14159. if is390 == 1 {
  14160. insutype = "390"
  14161. }
  14162. if is310 == 1 {
  14163. insutype = "310"
  14164. }
  14165. if len(insutypes) == 0 {
  14166. insutype = "310"
  14167. }
  14168. service.CreateHisPsn(psn)
  14169. c.ServeSuccessJSON(map[string]interface{}{
  14170. "patient": patient,
  14171. "number": token,
  14172. "insutype": insutype,
  14173. })
  14174. }
  14175. } else {
  14176. c.ServeSuccessJSON(map[string]interface{}{
  14177. "failed_code": -10,
  14178. "msg": res.ErrMsg,
  14179. })
  14180. }
  14181. } else { //读卡失败
  14182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14183. return
  14184. }
  14185. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14186. var api string
  14187. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14188. "&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
  14189. resp, requestErr := http.Get(api)
  14190. if requestErr != nil {
  14191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14192. return
  14193. }
  14194. body, ioErr := ioutil.ReadAll(resp.Body)
  14195. if ioErr != nil {
  14196. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14198. return
  14199. }
  14200. var respJSON map[string]interface{}
  14201. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14204. return
  14205. }
  14206. var status string
  14207. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14208. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14209. var token string
  14210. var res ResultTwo //1101结果
  14211. if status == "1" { //读卡成功
  14212. var card_info string //卡信息
  14213. var busi_card_info string
  14214. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14215. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14216. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14217. fmt.Println(card_info)
  14218. fmt.Println(busi_card_info)
  14219. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14220. result, _ := json.Marshal(respJSON)
  14221. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14222. utils.ErrorLog("解析失败:%v", err)
  14223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14224. return
  14225. }
  14226. if res.Infcode == 0 {
  14227. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14228. if err == gorm.ErrRecordNotFound {
  14229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14230. return
  14231. } else if err != nil {
  14232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14233. return
  14234. } else {
  14235. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14236. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14237. infoStr := string(Iinfos)
  14238. idetinfoStr := string(Idetinfos)
  14239. psn := &models.HisPsn{
  14240. PsnNo: res.Output.Baseinfo.PsnNo,
  14241. PatientId: patient.ID,
  14242. Certno: res.Output.Baseinfo.Certno,
  14243. Gend: res.Output.Baseinfo.Gend,
  14244. Naty: res.Output.Baseinfo.Naty,
  14245. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14246. PsnName: res.Output.Baseinfo.PsnName,
  14247. Idetinfo: idetinfoStr,
  14248. Insuinfo: infoStr,
  14249. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14250. CardInfo: card_info,
  14251. VerifyNumber: token,
  14252. }
  14253. var rf []*ResultFive
  14254. json.Unmarshal([]byte(infoStr), &rf)
  14255. var insutypes []*ResultFive
  14256. var insutype string
  14257. var is390 int = 0
  14258. var is310 int = 0
  14259. for _, item := range rf {
  14260. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14261. insutypes = append(insutypes, item)
  14262. }
  14263. }
  14264. if len(insutypes) == 1 {
  14265. insutype = insutypes[0].Insutype
  14266. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14267. } else {
  14268. for _, i := range insutypes {
  14269. if i.Insutype == "390" {
  14270. is390 = 1
  14271. }
  14272. if i.Insutype == "310" {
  14273. is310 = 1
  14274. }
  14275. }
  14276. }
  14277. if is390 == 1 {
  14278. insutype = "390"
  14279. }
  14280. if is310 == 1 {
  14281. insutype = "310"
  14282. }
  14283. if len(insutypes) == 0 {
  14284. insutype = "310"
  14285. }
  14286. service.CreateHisPsn(psn)
  14287. c.ServeSuccessJSON(map[string]interface{}{
  14288. "patient": patient,
  14289. "number": token,
  14290. "insutype": insutype,
  14291. })
  14292. }
  14293. } else {
  14294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14295. return
  14296. }
  14297. } else { //读卡失败
  14298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14299. return
  14300. }
  14301. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14302. //idNo := c.GetString("idNo")
  14303. //userName := c.GetString("userName")
  14304. //ecToken := c.GetString("ecToken")
  14305. //insuOrg := c.GetString("insuOrg")
  14306. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  14307. utils.ErrorLog("解析失败:%v", json_result)
  14308. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  14309. type ELeData struct {
  14310. Data struct {
  14311. IdNo string `json:"idNo"`
  14312. IdType string `json:"idType"`
  14313. UserName string `json:"userName"`
  14314. EcToken string `json:"ecToken"`
  14315. InsuOrg string `json:"insuOrg"`
  14316. Gender string `json:"gender"`
  14317. Birthday string `json:"birthday"`
  14318. Nationality string `json:"nationality"`
  14319. Email string `json:"email"`
  14320. Extra string `json:"extra"`
  14321. } `json:"data"`
  14322. Code int `json:"code"`
  14323. Message string `json:"message"`
  14324. }
  14325. var ele ELeData
  14326. err := json.Unmarshal([]byte(json_result), &ele)
  14327. if err != nil {
  14328. utils.ErrorLog("解析失败:%v", err)
  14329. }
  14330. token := ele.Data.EcToken
  14331. token = Remove0000(token)
  14332. 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)
  14333. saveLog(result2, requestLog2, "1101", "获取人员信息")
  14334. var res ResultTwo
  14335. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14336. utils.ErrorLog("解析失败:%v", err)
  14337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14338. return
  14339. }
  14340. if res.Infcode == 0 {
  14341. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14342. if err == gorm.ErrRecordNotFound {
  14343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14344. return
  14345. } else if err != nil {
  14346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14347. return
  14348. } else {
  14349. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14350. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14351. infoStr := string(Iinfos)
  14352. idetinfoStr := string(Idetinfos)
  14353. psn := &models.HisPsn{
  14354. PsnNo: res.Output.Baseinfo.PsnNo,
  14355. PatientId: patient.ID,
  14356. Certno: res.Output.Baseinfo.Certno,
  14357. Gend: res.Output.Baseinfo.Gend,
  14358. Naty: res.Output.Baseinfo.Naty,
  14359. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14360. PsnName: res.Output.Baseinfo.PsnName,
  14361. Idetinfo: idetinfoStr,
  14362. Insuinfo: infoStr,
  14363. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14364. CardInfo: "",
  14365. Stage: "1",
  14366. VerifyNumber: token,
  14367. InsuplcAdmdvs: ele.Data.InsuOrg,
  14368. }
  14369. service.CreateHisPsn(psn)
  14370. var rf []*ResultFive
  14371. json.Unmarshal([]byte(infoStr), &rf)
  14372. var insutypes []*ResultFive
  14373. var insutype string
  14374. var is390 int = 0
  14375. var is310 int = 0
  14376. for _, item := range rf {
  14377. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14378. insutypes = append(insutypes, item)
  14379. }
  14380. }
  14381. if len(insutypes) == 1 {
  14382. insutype = insutypes[0].Insutype
  14383. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14384. } else {
  14385. for _, i := range insutypes {
  14386. if i.Insutype == "390" {
  14387. is390 = 1
  14388. }
  14389. if i.Insutype == "310" {
  14390. is310 = 1
  14391. }
  14392. }
  14393. }
  14394. if is390 == 1 {
  14395. insutype = "390"
  14396. }
  14397. if is310 == 1 {
  14398. insutype = "310"
  14399. }
  14400. if len(insutypes) == 0 {
  14401. insutype = "310"
  14402. }
  14403. c.ServeSuccessJSON(map[string]interface{}{
  14404. "patient": patient,
  14405. "number": token,
  14406. "insutype": insutype,
  14407. })
  14408. }
  14409. } else {
  14410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14411. return
  14412. }
  14413. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14414. //if initFlag == 0 {
  14415. //c.TestGetJiangXiBasBaseInit()
  14416. //}
  14417. //if initEleFlag == 0 {
  14418. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  14419. //}
  14420. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  14421. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  14422. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  14423. type ELeData struct {
  14424. Data struct {
  14425. IdNo string `json:"idNo"`
  14426. IdType string `json:"idType"`
  14427. UserName string `json:"userName"`
  14428. EcToken string `json:"ecToken"`
  14429. InsuOrg string `json:"insuOrg"`
  14430. Gender string `json:"gender"`
  14431. Birthday string `json:"birthday"`
  14432. Nationality string `json:"nationality"`
  14433. Email string `json:"email"`
  14434. Extra string `json:"extra"`
  14435. } `json:"data"`
  14436. Code int `json:"code"`
  14437. Message string `json:"message"`
  14438. }
  14439. var ele ELeData
  14440. err := json.Unmarshal([]byte(result), &ele)
  14441. if err != nil {
  14442. utils.ErrorLog("解析失败:%v", err)
  14443. }
  14444. token := ele.Data.EcToken
  14445. token = Remove0000(token)
  14446. 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)
  14447. saveLog(result2, requestLog2, "1101", "获取人员信息")
  14448. var res ResultTwo
  14449. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14450. utils.ErrorLog("解析失败:%v", err)
  14451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14452. return
  14453. }
  14454. if res.Infcode == 0 {
  14455. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14456. if err == gorm.ErrRecordNotFound {
  14457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14458. return
  14459. } else if err != nil {
  14460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14461. return
  14462. } else {
  14463. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14464. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14465. infoStr := string(Iinfos)
  14466. idetinfoStr := string(Idetinfos)
  14467. psn := &models.HisPsn{
  14468. PsnNo: res.Output.Baseinfo.PsnNo,
  14469. PatientId: patient.ID,
  14470. Certno: res.Output.Baseinfo.Certno,
  14471. Gend: res.Output.Baseinfo.Gend,
  14472. Naty: res.Output.Baseinfo.Naty,
  14473. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14474. PsnName: res.Output.Baseinfo.PsnName,
  14475. Idetinfo: idetinfoStr,
  14476. Insuinfo: infoStr,
  14477. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14478. CardInfo: "",
  14479. VerifyNumber: token,
  14480. InsuplcAdmdvs: ele.Data.InsuOrg,
  14481. }
  14482. service.CreateHisPsn(psn)
  14483. var rf []*ResultFive
  14484. json.Unmarshal([]byte(infoStr), &rf)
  14485. var insutypes []*ResultFive
  14486. var insutype string
  14487. var is390 int = 0
  14488. var is310 int = 0
  14489. for _, item := range rf {
  14490. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14491. insutypes = append(insutypes, item)
  14492. }
  14493. }
  14494. if len(insutypes) == 1 {
  14495. insutype = insutypes[0].Insutype
  14496. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14497. } else {
  14498. for _, i := range insutypes {
  14499. if i.Insutype == "390" {
  14500. is390 = 1
  14501. }
  14502. if i.Insutype == "310" {
  14503. is310 = 1
  14504. }
  14505. }
  14506. }
  14507. if is390 == 1 {
  14508. insutype = "390"
  14509. }
  14510. if is310 == 1 {
  14511. insutype = "310"
  14512. }
  14513. if len(insutypes) == 0 {
  14514. insutype = "310"
  14515. }
  14516. c.ServeSuccessJSON(map[string]interface{}{
  14517. "patient": patient,
  14518. "number": token,
  14519. "insutype": insutype,
  14520. })
  14521. }
  14522. } else {
  14523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14524. return
  14525. }
  14526. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14527. //if initFlag == 0 {
  14528. c.TestGetJiangXiBasBaseInit()
  14529. //}
  14530. //if initEleFlag == 0 {
  14531. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  14532. //}
  14533. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  14534. type ELeData struct {
  14535. Data struct {
  14536. IdNo string `json:"idNo"`
  14537. IdType string `json:"idType"`
  14538. UserName string `json:"userName"`
  14539. EcToken string `json:"ecToken"`
  14540. InsuOrg string `json:"insuOrg"`
  14541. Gender string `json:"gender"`
  14542. Birthday string `json:"birthday"`
  14543. Nationality string `json:"nationality"`
  14544. Email string `json:"email"`
  14545. Extra string `json:"extra"`
  14546. } `json:"data"`
  14547. Code int `json:"code"`
  14548. Message string `json:"message"`
  14549. }
  14550. var ele ELeData
  14551. err := json.Unmarshal([]byte(json_result), &ele)
  14552. if err != nil {
  14553. utils.ErrorLog("解析失败:%v", err)
  14554. }
  14555. token := ele.Data.EcToken
  14556. token = Remove0000(token)
  14557. 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)
  14558. saveLog(result2, requestLog2, "1101", "获取人员信息")
  14559. var res ResultTwo
  14560. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14561. utils.ErrorLog("解析失败:%v", err)
  14562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14563. return
  14564. }
  14565. if res.Infcode == 0 {
  14566. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14567. if err == gorm.ErrRecordNotFound {
  14568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14569. return
  14570. } else if err != nil {
  14571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14572. return
  14573. } else {
  14574. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14575. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14576. infoStr := string(Iinfos)
  14577. idetinfoStr := string(Idetinfos)
  14578. psn := &models.HisPsn{
  14579. PsnNo: res.Output.Baseinfo.PsnNo,
  14580. PatientId: patient.ID,
  14581. Certno: res.Output.Baseinfo.Certno,
  14582. Gend: res.Output.Baseinfo.Gend,
  14583. Naty: res.Output.Baseinfo.Naty,
  14584. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14585. PsnName: res.Output.Baseinfo.PsnName,
  14586. Idetinfo: idetinfoStr,
  14587. Insuinfo: infoStr,
  14588. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14589. CardInfo: "",
  14590. VerifyNumber: token,
  14591. }
  14592. service.CreateHisPsn(psn)
  14593. var rf []*ResultFive
  14594. json.Unmarshal([]byte(infoStr), &rf)
  14595. var insutypes []*ResultFive
  14596. var insutype string
  14597. var is390 int = 0
  14598. var is310 int = 0
  14599. for _, item := range rf {
  14600. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14601. insutypes = append(insutypes, item)
  14602. }
  14603. }
  14604. if len(insutypes) == 1 {
  14605. insutype = insutypes[0].Insutype
  14606. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14607. } else {
  14608. for _, i := range insutypes {
  14609. if i.Insutype == "390" {
  14610. is390 = 1
  14611. }
  14612. if i.Insutype == "310" {
  14613. is310 = 1
  14614. }
  14615. }
  14616. }
  14617. if is390 == 1 {
  14618. insutype = "390"
  14619. }
  14620. if is310 == 1 {
  14621. insutype = "310"
  14622. }
  14623. if len(insutypes) == 0 {
  14624. insutype = "310"
  14625. }
  14626. c.ServeSuccessJSON(map[string]interface{}{
  14627. "patient": patient,
  14628. "number": token,
  14629. "insutype": insutype,
  14630. })
  14631. }
  14632. } else {
  14633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14634. return
  14635. }
  14636. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14637. type ELeData struct {
  14638. Code string `json:"code"`
  14639. Data struct {
  14640. Aac002 string `json:"aac002"`
  14641. Aaz500 string `json:"aaz500"`
  14642. ActCardNo string `json:"actCardNo"`
  14643. Bab520 string `json:"bab520"`
  14644. Bkz543 string `json:"bkz543"`
  14645. BusinessType string `json:"businessType"`
  14646. CertfCodg string `json:"certfCodg"`
  14647. EcIndexNo string `json:"ecIndexNo"`
  14648. EcToken string `json:"ecToken"`
  14649. ID0000 string `json:"id0000"`
  14650. IDNo string `json:"idNo"`
  14651. IDType string `json:"idType"`
  14652. Idcode string `json:"idcode"`
  14653. IdentityToken string `json:"identity_token"`
  14654. InsuOrg string `json:"insuOrg"`
  14655. OfficeID string `json:"officeId"`
  14656. OfficeName string `json:"officeName"`
  14657. OperatorID string `json:"operatorId"`
  14658. OperatorName string `json:"operatorName"`
  14659. OrgID string `json:"orgId"`
  14660. UserName string `json:"userName"`
  14661. } `json:"data"`
  14662. Infno interface{} `json:"infno"`
  14663. Message string `json:"message"`
  14664. OrgID string `json:"orgId"`
  14665. TransType string `json:"transType"`
  14666. }
  14667. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  14668. outPutInfo = Remove0000(outPutInfo)
  14669. if len(outPutInfo) > 0 {
  14670. var ele ELeData
  14671. err := json.Unmarshal([]byte(outPutInfo), &ele)
  14672. if err != nil {
  14673. utils.ErrorLog("解析失败:%v", err)
  14674. }
  14675. token := ele.Data.EcToken
  14676. fmt.Println(inputInfo)
  14677. fmt.Println(outPutInfo)
  14678. 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)
  14679. saveLog(result, requestLog, "1101", "获取人员信息")
  14680. var dat map[string]interface{}
  14681. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14682. fmt.Println(dat)
  14683. } else {
  14684. fmt.Println(err)
  14685. }
  14686. userJSONBytes, _ := json.Marshal(dat)
  14687. var res ResultTwo
  14688. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14689. utils.ErrorLog("解析失败:%v", err)
  14690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14691. return
  14692. }
  14693. res.ErrMsg = errMsgLog
  14694. if res.Infcode == 0 {
  14695. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  14696. if err == gorm.ErrRecordNotFound {
  14697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14698. return
  14699. } else if err != nil {
  14700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14701. return
  14702. } else {
  14703. fmt.Println(res)
  14704. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14705. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14706. infoStr := string(Iinfos)
  14707. idetinfoStr := string(Idetinfos)
  14708. psn := &models.HisPsn{
  14709. PsnNo: res.Output.Baseinfo.PsnNo,
  14710. PatientId: patient.ID,
  14711. Certno: res.Output.Baseinfo.Certno,
  14712. Gend: res.Output.Baseinfo.Gend,
  14713. Naty: res.Output.Baseinfo.Naty,
  14714. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14715. PsnName: res.Output.Baseinfo.PsnName,
  14716. Idetinfo: idetinfoStr,
  14717. Insuinfo: infoStr,
  14718. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14719. CardInfo: outPutInfo,
  14720. VerifyNumber: token,
  14721. InsuplcAdmdvs: ele.Data.InsuOrg,
  14722. }
  14723. service.CreateHisPsn(psn)
  14724. var rf []*ResultFive
  14725. json.Unmarshal([]byte(infoStr), &rf)
  14726. var insutypes []*ResultFive
  14727. var insutype string
  14728. var is390 int = 0
  14729. var is310 int = 0
  14730. for _, item := range rf {
  14731. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14732. insutypes = append(insutypes, item)
  14733. }
  14734. }
  14735. if len(insutypes) == 1 {
  14736. insutype = insutypes[0].Insutype
  14737. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14738. } else {
  14739. for _, i := range insutypes {
  14740. if i.Insutype == "390" {
  14741. is390 = 1
  14742. }
  14743. if i.Insutype == "310" {
  14744. is310 = 1
  14745. }
  14746. }
  14747. }
  14748. if is390 == 1 {
  14749. insutype = "390"
  14750. }
  14751. if is310 == 1 {
  14752. insutype = "310"
  14753. }
  14754. if len(insutypes) == 0 {
  14755. insutype = "310"
  14756. }
  14757. c.ServeSuccessJSON(map[string]interface{}{
  14758. "patient": patient,
  14759. "number": token,
  14760. "insutype": insutype,
  14761. })
  14762. }
  14763. } else {
  14764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14765. return
  14766. }
  14767. }
  14768. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14769. var api string
  14770. 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 +
  14771. "&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
  14772. resp, requestErr := http.Get(api)
  14773. if requestErr != nil {
  14774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14775. return
  14776. }
  14777. body, ioErr := ioutil.ReadAll(resp.Body)
  14778. if ioErr != nil {
  14779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14781. return
  14782. }
  14783. var respJSON map[string]interface{}
  14784. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14787. return
  14788. }
  14789. var status string
  14790. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14791. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14792. var token string
  14793. var res ResultTwo //1101结果
  14794. var res10265 ResultTwo10265 //1101结果
  14795. if status == "0" { //读卡成功
  14796. var card_info string //卡信息
  14797. var busi_card_info string
  14798. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14799. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14800. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14801. fmt.Println(card_info)
  14802. fmt.Println(busi_card_info)
  14803. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14804. result, _ := json.Marshal(respJSON)
  14805. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14806. utils.ErrorLog("解析失败:%v", err)
  14807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14808. return
  14809. }
  14810. res.ErrMsg = res10265.ErrMsg
  14811. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14812. res.Infcode = infocode
  14813. res.Output = res10265.Output
  14814. res.InfRefmsgid = res10265.InfRefmsgid
  14815. if res.Infcode == 0 {
  14816. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14817. if err == gorm.ErrRecordNotFound {
  14818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14819. return
  14820. } else if err != nil {
  14821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14822. return
  14823. } else {
  14824. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14825. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14826. infoStr := string(Iinfos)
  14827. idetinfoStr := string(Idetinfos)
  14828. psn := &models.HisPsn{
  14829. PsnNo: res.Output.Baseinfo.PsnNo,
  14830. PatientId: patient.ID,
  14831. Certno: res.Output.Baseinfo.Certno,
  14832. Gend: res.Output.Baseinfo.Gend,
  14833. Naty: res.Output.Baseinfo.Naty,
  14834. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14835. PsnName: res.Output.Baseinfo.PsnName,
  14836. Idetinfo: idetinfoStr,
  14837. Insuinfo: infoStr,
  14838. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14839. CardInfo: card_info,
  14840. VerifyNumber: token,
  14841. }
  14842. var rf []*ResultFive
  14843. json.Unmarshal([]byte(infoStr), &rf)
  14844. var insutypes []*ResultFive
  14845. var insutype string
  14846. var is390 int = 0
  14847. var is310 int = 0
  14848. for _, item := range rf {
  14849. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14850. insutypes = append(insutypes, item)
  14851. }
  14852. }
  14853. if len(insutypes) == 1 {
  14854. insutype = insutypes[0].Insutype
  14855. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14856. } else {
  14857. for _, i := range insutypes {
  14858. if i.Insutype == "390" {
  14859. is390 = 1
  14860. }
  14861. if i.Insutype == "310" {
  14862. is310 = 1
  14863. }
  14864. }
  14865. }
  14866. if is390 == 1 {
  14867. insutype = "390"
  14868. }
  14869. if is310 == 1 {
  14870. insutype = "310"
  14871. }
  14872. if len(insutypes) == 0 {
  14873. insutype = "310"
  14874. }
  14875. service.CreateHisPsn(psn)
  14876. c.ServeSuccessJSON(map[string]interface{}{
  14877. "patient": patient,
  14878. "number": token,
  14879. "insutype": insutype,
  14880. })
  14881. }
  14882. } else {
  14883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14884. return
  14885. }
  14886. } else { //读卡失败
  14887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14888. return
  14889. }
  14890. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14891. res := c.GetoleInfo()
  14892. if res.Infcode == 0 {
  14893. var result string
  14894. if res.Output.MdtrtCertType == "01" {
  14895. 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)
  14896. } else if res.Output.MdtrtCertType == "02" {
  14897. 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)
  14898. } else if res.Output.MdtrtCertType == "03" {
  14899. 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)
  14900. }
  14901. var dat map[string]interface{}
  14902. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14903. fmt.Println(dat)
  14904. } else {
  14905. fmt.Println(err)
  14906. }
  14907. userJSONBytes, _ := json.Marshal(dat)
  14908. var res2 ResultTwo
  14909. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14910. utils.ErrorLog("解析失败:%v", err)
  14911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14912. return
  14913. }
  14914. if res2.Infcode == 0 {
  14915. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14916. if err == gorm.ErrRecordNotFound {
  14917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14918. return
  14919. } else if err != nil {
  14920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14921. return
  14922. } else {
  14923. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14924. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14925. infoStr := string(Iinfos)
  14926. idetinfoStr := string(Idetinfos)
  14927. var rf []*ResultFive
  14928. json.Unmarshal([]byte(infoStr), &rf)
  14929. var insutypes []*ResultFive
  14930. var insutype string
  14931. var is390 int = 0
  14932. var is310 int = 0
  14933. //var insuplc_admdvs string
  14934. for _, item := range rf {
  14935. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14936. insutypes = append(insutypes, item)
  14937. }
  14938. }
  14939. if len(insutypes) == 1 {
  14940. insutype = insutypes[0].Insutype
  14941. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14942. } else {
  14943. for _, i := range insutypes {
  14944. if i.Insutype == "390" {
  14945. is390 = 1
  14946. }
  14947. if i.Insutype == "310" {
  14948. is310 = 1
  14949. }
  14950. }
  14951. }
  14952. if is390 == 1 {
  14953. insutype = "390"
  14954. }
  14955. if is310 == 1 {
  14956. insutype = "310"
  14957. }
  14958. if len(insutypes) == 0 {
  14959. insutype = "310"
  14960. }
  14961. psn := &models.HisPsn{
  14962. PsnNo: res2.Output.Baseinfo.PsnNo,
  14963. PatientId: patient.ID,
  14964. Certno: res2.Output.Baseinfo.Certno,
  14965. Gend: res2.Output.Baseinfo.Gend,
  14966. Naty: res2.Output.Baseinfo.Naty,
  14967. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14968. PsnName: res2.Output.Baseinfo.PsnName,
  14969. Idetinfo: idetinfoStr,
  14970. Insuinfo: infoStr,
  14971. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14972. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14973. VerifyNumber: res.Output.EcToken,
  14974. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14975. }
  14976. if res.Output.MdtrtCertType == "01" {
  14977. psn.VerifyNumber = res.Output.EcToken
  14978. //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)
  14979. } else if res.Output.MdtrtCertType == "02" {
  14980. psn.VerifyNumber = res.Output.CardNo
  14981. //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)
  14982. } else if res.Output.MdtrtCertType == "03" {
  14983. psn.VerifyNumber = res.Output.MdtrtCertNo
  14984. //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)
  14985. }
  14986. service.CreateHisPsn(psn)
  14987. var balc float64
  14988. for _, item := range rf {
  14989. if item.Insutype == insutype {
  14990. balc = item.Balc
  14991. }
  14992. }
  14993. c.ServeSuccessJSON(map[string]interface{}{
  14994. "patient": patient,
  14995. "number": res.Output.CardNo,
  14996. "insutype": insutype,
  14997. "blac": balc,
  14998. "desc": idetinfoStr,
  14999. })
  15000. }
  15001. } else {
  15002. c.ServeSuccessJSON(map[string]interface{}{
  15003. "failed_code": -10,
  15004. "msg": res2.ErrMsg,
  15005. })
  15006. }
  15007. } else {
  15008. c.ServeSuccessJSON(map[string]interface{}{
  15009. "failed_code": -10,
  15010. "msg": res.ErrMsg,
  15011. })
  15012. }
  15013. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15014. var res ResultTwo
  15015. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15016. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15017. "&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)
  15018. resp, requestErr := http.Get(api)
  15019. if requestErr != nil {
  15020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15021. return
  15022. }
  15023. body, ioErr := ioutil.ReadAll(resp.Body)
  15024. if ioErr != nil {
  15025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15027. return
  15028. }
  15029. var respJSON map[string]interface{}
  15030. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15033. return
  15034. }
  15035. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15036. result, _ := json.Marshal(respJSON)
  15037. fmt.Println("log")
  15038. fmt.Println(string(result))
  15039. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15040. utils.ErrorLog("解析失败:%v", err)
  15041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15042. return
  15043. }
  15044. if res.Infcode == 0 {
  15045. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15046. if err == gorm.ErrRecordNotFound {
  15047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15048. return
  15049. } else if err != nil {
  15050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15051. return
  15052. } else {
  15053. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15054. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15055. infoStr := string(Iinfos)
  15056. idetinfoStr := string(Idetinfos)
  15057. var rf []*ResultFive
  15058. json.Unmarshal([]byte(infoStr), &rf)
  15059. var insutypes []*ResultFive
  15060. var insutype string
  15061. var is390 int = 0
  15062. var is310 int = 0
  15063. for _, item := range rf {
  15064. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15065. insutypes = append(insutypes, item)
  15066. }
  15067. }
  15068. if len(insutypes) == 1 {
  15069. insutype = insutypes[0].Insutype
  15070. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15071. } else {
  15072. for _, i := range insutypes {
  15073. if i.Insutype == "390" {
  15074. is390 = 1
  15075. }
  15076. if i.Insutype == "310" {
  15077. is310 = 1
  15078. }
  15079. }
  15080. }
  15081. if is390 == 1 {
  15082. insutype = "390"
  15083. }
  15084. if is310 == 1 {
  15085. insutype = "310"
  15086. }
  15087. if len(insutypes) == 0 {
  15088. insutype = "390"
  15089. }
  15090. var insuplc_admdvs string
  15091. for _, item := range rf {
  15092. if item.Insutype == insutype {
  15093. insuplc_admdvs = item.InsuplcAdmdvs
  15094. }
  15095. }
  15096. psn := &models.HisPsn{
  15097. PsnNo: res.Output.Baseinfo.PsnNo,
  15098. PatientId: patient.ID,
  15099. Certno: res.Output.Baseinfo.Certno,
  15100. Gend: res.Output.Baseinfo.Gend,
  15101. Naty: res.Output.Baseinfo.Naty,
  15102. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15103. PsnName: res.Output.Baseinfo.PsnName,
  15104. Idetinfo: idetinfoStr,
  15105. Insuinfo: infoStr,
  15106. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15107. InsuplcAdmdvs: insuplc_admdvs,
  15108. }
  15109. service.CreateHisPsn(psn)
  15110. c.ServeSuccessJSON(map[string]interface{}{
  15111. "patient": patient,
  15112. "number": res.Output.Baseinfo.Certno,
  15113. })
  15114. }
  15115. } else {
  15116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15117. return
  15118. }
  15119. } else {
  15120. type ELeData struct {
  15121. Code string `json:"code"`
  15122. Data struct {
  15123. Aac002 string `json:"aac002"`
  15124. Aaz500 string `json:"aaz500"`
  15125. ActCardNo string `json:"actCardNo"`
  15126. Bab520 string `json:"bab520"`
  15127. Bkz543 string `json:"bkz543"`
  15128. BusinessType string `json:"businessType"`
  15129. CertfCodg string `json:"certfCodg"`
  15130. EcIndexNo string `json:"ecIndexNo"`
  15131. EcToken string `json:"ecToken"`
  15132. ID0000 string `json:"id0000"`
  15133. IDNo string `json:"idNo"`
  15134. IDType string `json:"idType"`
  15135. Idcode string `json:"idcode"`
  15136. IdentityToken string `json:"identity_token"`
  15137. InsuOrg string `json:"insuOrg"`
  15138. OfficeID string `json:"officeId"`
  15139. OfficeName string `json:"officeName"`
  15140. OperatorID string `json:"operatorId"`
  15141. OperatorName string `json:"operatorName"`
  15142. OrgID string `json:"orgId"`
  15143. UserName string `json:"userName"`
  15144. } `json:"data"`
  15145. Infno interface{} `json:"infno"`
  15146. Message string `json:"message"`
  15147. OrgID string `json:"orgId"`
  15148. TransType string `json:"transType"`
  15149. }
  15150. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  15151. fmt.Println(result)
  15152. outPutInfo := Remove0000(result)
  15153. fmt.Println(outPutInfo)
  15154. if len(outPutInfo) > 0 {
  15155. var ele ELeData
  15156. err := json.Unmarshal([]byte(outPutInfo), &ele)
  15157. if err != nil {
  15158. utils.ErrorLog("解析失败:%v", err)
  15159. }
  15160. token := ele.Data.EcToken
  15161. fmt.Println(outPutInfo)
  15162. 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)
  15163. saveLog(result, requestLog, "1101", "获取人员信息")
  15164. var dat map[string]interface{}
  15165. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15166. fmt.Println(dat)
  15167. } else {
  15168. fmt.Println(err)
  15169. }
  15170. userJSONBytes, _ := json.Marshal(dat)
  15171. var res ResultTwo
  15172. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15173. utils.ErrorLog("解析失败:%v", err)
  15174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15175. return
  15176. }
  15177. if res.Infcode == 0 {
  15178. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  15179. if err == gorm.ErrRecordNotFound {
  15180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15181. return
  15182. } else if err != nil {
  15183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15184. return
  15185. } else {
  15186. fmt.Println(res)
  15187. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15188. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15189. infoStr := string(Iinfos)
  15190. idetinfoStr := string(Idetinfos)
  15191. psn := &models.HisPsn{
  15192. PsnNo: res.Output.Baseinfo.PsnNo,
  15193. PatientId: patient.ID,
  15194. Certno: res.Output.Baseinfo.Certno,
  15195. Gend: res.Output.Baseinfo.Gend,
  15196. Naty: res.Output.Baseinfo.Naty,
  15197. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15198. PsnName: res.Output.Baseinfo.PsnName,
  15199. Idetinfo: idetinfoStr,
  15200. Insuinfo: infoStr,
  15201. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15202. CardInfo: outPutInfo,
  15203. VerifyNumber: token,
  15204. InsuplcAdmdvs: ele.Data.InsuOrg,
  15205. }
  15206. service.CreateHisPsn(psn)
  15207. var rf []*ResultFive
  15208. json.Unmarshal([]byte(infoStr), &rf)
  15209. var insutypes []*ResultFive
  15210. var insutype string
  15211. var is390 int = 0
  15212. var is310 int = 0
  15213. for _, item := range rf {
  15214. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15215. insutypes = append(insutypes, item)
  15216. }
  15217. }
  15218. if len(insutypes) == 1 {
  15219. insutype = insutypes[0].Insutype
  15220. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15221. } else {
  15222. for _, i := range insutypes {
  15223. if i.Insutype == "390" {
  15224. is390 = 1
  15225. }
  15226. if i.Insutype == "310" {
  15227. is310 = 1
  15228. }
  15229. }
  15230. }
  15231. if is390 == 1 {
  15232. insutype = "390"
  15233. }
  15234. if is310 == 1 {
  15235. insutype = "310"
  15236. }
  15237. if len(insutypes) == 0 {
  15238. insutype = "310"
  15239. }
  15240. c.ServeSuccessJSON(map[string]interface{}{
  15241. "patient": patient,
  15242. "number": token,
  15243. "insutype": insutype,
  15244. })
  15245. }
  15246. } else {
  15247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15248. return
  15249. }
  15250. }
  15251. //fmt.Println(result)
  15252. //
  15253. //if initFlag == 0 {
  15254. // c.TestGetBasBaseInit()
  15255. //}
  15256. //token := c.GetEleBaseInfo()
  15257. //
  15258. //token = Remove0000(token)
  15259. //
  15260. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  15261. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  15262. ////
  15263. //var res ResultTwo
  15264. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15265. // utils.ErrorLog("解析失败:%v", err)
  15266. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15267. // return
  15268. //}
  15269. //
  15270. //if res.Infcode == 0 {
  15271. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15272. // if err == gorm.ErrRecordNotFound {
  15273. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15274. // return
  15275. // } else if err != nil {
  15276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15277. // return
  15278. //
  15279. // } else {
  15280. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15281. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15282. // infoStr := string(Iinfos)
  15283. // idetinfoStr := string(Idetinfos)
  15284. //
  15285. //
  15286. //
  15287. //
  15288. // var rf []*ResultFive
  15289. // json.Unmarshal([]byte(infoStr), &rf)
  15290. //
  15291. // var insutypes []*ResultFive
  15292. // var insutype string
  15293. // var is390 int = 0
  15294. // var is310 int = 0
  15295. // var insuplc_admdvs string
  15296. //
  15297. // for _, item := range rf {
  15298. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15299. // insutypes = append(insutypes, item)
  15300. // }
  15301. // }
  15302. //
  15303. // if len(insutypes) == 1 {
  15304. // insutype = insutypes[0].Insutype
  15305. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15306. // } else {
  15307. // for _, i := range insutypes {
  15308. // if i.Insutype == "390" {
  15309. // is390 = 1
  15310. // }
  15311. //
  15312. // if i.Insutype == "310" {
  15313. // is310 = 1
  15314. // }
  15315. // }
  15316. // }
  15317. // if is390 == 1 {
  15318. // insutype = "390"
  15319. // }
  15320. //
  15321. // if is310 == 1 {
  15322. // insutype = "310"
  15323. // }
  15324. // if len(insutypes) == 0 {
  15325. // insutype = "310"
  15326. // }
  15327. // for _, item := range rf {
  15328. // if item.Insutype == insutype {
  15329. // insuplc_admdvs = item.InsuplcAdmdvs
  15330. // }
  15331. // }
  15332. // psn := &models.HisPsn{
  15333. // PsnNo: res.Output.Baseinfo.PsnNo,
  15334. // Age: res.Output.Baseinfo.Age,
  15335. // PatientId: patient.ID,
  15336. // Certno: res.Output.Baseinfo.Certno,
  15337. // Brdy: res.Output.Baseinfo.Brdy,
  15338. // Gend: res.Output.Baseinfo.Gend,
  15339. // Naty: res.Output.Baseinfo.Naty,
  15340. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  15341. // PsnName: res.Output.Baseinfo.PsnName,
  15342. // Idetinfo: idetinfoStr,
  15343. // Insuinfo: infoStr,
  15344. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15345. // CardInfo: "",
  15346. // VerifyNumber: token,
  15347. // InsuplcAdmdvs: insuplc_admdvs,
  15348. // }
  15349. // service.CreateHisPsn(psn)
  15350. //
  15351. // c.ServeSuccessJSON(map[string]interface{}{
  15352. // "patient": patient,
  15353. // "number": token,
  15354. // })
  15355. // }
  15356. //} else {
  15357. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15358. // return
  15359. //}
  15360. }
  15361. break
  15362. case 5:
  15363. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15364. var api string
  15365. if miConfig.MdtrtareaAdmvs == "320921" {
  15366. 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 +
  15367. "&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
  15368. fmt.Println(api)
  15369. } else {
  15370. 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 +
  15371. "&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)
  15372. }
  15373. resp, requestErr := http.Get(api)
  15374. if requestErr != nil {
  15375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15376. return
  15377. }
  15378. body, ioErr := ioutil.ReadAll(resp.Body)
  15379. if ioErr != nil {
  15380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15382. return
  15383. }
  15384. var respJSON map[string]interface{}
  15385. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15388. return
  15389. }
  15390. var status string
  15391. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15392. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15393. var token string
  15394. var res ResultTwo //1101结果
  15395. var res10265 ResultTwo10265 //1101结果
  15396. if status == "0" { //读卡成功
  15397. var card_info string //卡信息
  15398. //var busi_card_info string
  15399. var auth_info string
  15400. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15401. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15402. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15403. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  15404. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15405. result, _ := json.Marshal(respJSON)
  15406. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15407. utils.ErrorLog("解析失败:%v", err)
  15408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15409. return
  15410. }
  15411. res.ErrMsg = res10265.ErrMsg
  15412. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15413. res.Infcode = infocode
  15414. res.Output = res10265.Output
  15415. res.InfRefmsgid = res10265.InfRefmsgid
  15416. if res.Infcode == 0 {
  15417. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15418. if err == gorm.ErrRecordNotFound {
  15419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15420. return
  15421. } else if err != nil {
  15422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15423. return
  15424. } else {
  15425. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15426. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15427. infoStr := string(Iinfos)
  15428. idetinfoStr := string(Idetinfos)
  15429. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15430. psn := &models.HisPsn{
  15431. PsnNo: res.Output.Baseinfo.PsnNo,
  15432. PatientId: patient.ID,
  15433. Certno: res.Output.Baseinfo.Certno,
  15434. Gend: res.Output.Baseinfo.Gend,
  15435. Brdy: b,
  15436. Age: float64(age),
  15437. Naty: res.Output.Baseinfo.Naty,
  15438. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15439. PsnName: res.Output.Baseinfo.PsnName,
  15440. Idetinfo: idetinfoStr,
  15441. Insuinfo: infoStr,
  15442. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15443. CardInfo: card_info,
  15444. VerifyNumber: token,
  15445. AuthInfo: auth_info,
  15446. }
  15447. var rf []*ResultFive
  15448. json.Unmarshal([]byte(infoStr), &rf)
  15449. var insutypes []*ResultFive
  15450. var insutype string
  15451. var is390 int = 0
  15452. var is310 int = 0
  15453. for _, item := range rf {
  15454. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15455. insutypes = append(insutypes, item)
  15456. }
  15457. }
  15458. if len(insutypes) == 1 {
  15459. insutype = insutypes[0].Insutype
  15460. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15461. } else {
  15462. for _, i := range insutypes {
  15463. if i.Insutype == "390" {
  15464. is390 = 1
  15465. }
  15466. if i.Insutype == "310" {
  15467. is310 = 1
  15468. }
  15469. }
  15470. }
  15471. if is390 == 1 {
  15472. insutype = "390"
  15473. }
  15474. if is310 == 1 {
  15475. insutype = "310"
  15476. }
  15477. if len(insutypes) == 0 {
  15478. insutype = "310"
  15479. }
  15480. service.CreateHisPsn(psn)
  15481. c.ServeSuccessJSON(map[string]interface{}{
  15482. "patient": patient,
  15483. "number": token,
  15484. "insutype": insutype,
  15485. })
  15486. }
  15487. } else {
  15488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15489. return
  15490. }
  15491. } else { //读卡失败
  15492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15493. return
  15494. }
  15495. }
  15496. break
  15497. }
  15498. }
  15499. var initFlag int64 = 0
  15500. var initEleFlag int64 = 0
  15501. func (c *HisApiController) TestGetBasBaseInit() {
  15502. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15503. Iinit := DllDef.MustFindProc("Init")
  15504. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15505. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  15506. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  15507. if ret != 0 {
  15508. fmt.Println("SSCard的报错原因:", err)
  15509. fmt.Println("SSCard的运算结果为:", ret)
  15510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15511. return
  15512. }
  15513. result := int(ret)
  15514. fmt.Println("SSCard的运算结果为1:", result)
  15515. initFlag = 1
  15516. return
  15517. }
  15518. func (c *HisApiController) HandleJiangXiReadCard() {
  15519. fmt.Println("~~~~~~")
  15520. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15521. admin_user_id, _ := c.GetInt64("admin_user_id")
  15522. id_card_type, _ := c.GetInt64("id_card_type")
  15523. //certificates, _ := c.GetInt64("certificates")
  15524. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  15525. if initFlag == 0 {
  15526. c.TestGetJiangXiBasBaseInit()
  15527. }
  15528. basStr := c.GetBasBaseInfo()
  15529. if len(basStr) == 0 {
  15530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15531. return
  15532. }
  15533. fmt.Println(basStr)
  15534. bas := strings.Split(basStr, "|")
  15535. basNumber := bas[1]
  15536. fmt.Println(basNumber)
  15537. card_sn := bas[3]
  15538. fmt.Println(card_sn)
  15539. 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, "")
  15540. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  15541. var dat map[string]interface{}
  15542. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15543. fmt.Println(dat)
  15544. } else {
  15545. fmt.Println(err)
  15546. }
  15547. userJSONBytes, _ := json.Marshal(dat)
  15548. var res ResultTwo
  15549. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15550. utils.ErrorLog("解析失败:%v", err)
  15551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15552. return
  15553. }
  15554. if res.Infcode == 0 {
  15555. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  15556. if err == gorm.ErrRecordNotFound {
  15557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15558. return
  15559. } else if err != nil {
  15560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15561. return
  15562. } else {
  15563. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15564. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15565. infoStr := string(Iinfos)
  15566. idetinfoStr := string(Idetinfos)
  15567. psn := &models.HisPsn{
  15568. PsnNo: res.Output.Baseinfo.PsnNo,
  15569. PatientId: patient.ID,
  15570. Certno: res.Output.Baseinfo.Certno,
  15571. Gend: res.Output.Baseinfo.Gend,
  15572. Naty: res.Output.Baseinfo.Naty,
  15573. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15574. PsnName: res.Output.Baseinfo.PsnName,
  15575. Idetinfo: idetinfoStr,
  15576. Insuinfo: infoStr,
  15577. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15578. CardInfo: basStr,
  15579. VerifyNumber: "",
  15580. }
  15581. service.CreateHisPsn(psn)
  15582. c.ServeSuccessJSON(map[string]interface{}{
  15583. "patient": patient,
  15584. "number": basNumber,
  15585. })
  15586. }
  15587. } else {
  15588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15589. return
  15590. }
  15591. }
  15592. func (c *HisApiController) TestGetHnBasBaseInit() {
  15593. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15594. Iinit := DllDef.MustFindProc("Init")
  15595. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15596. //http://10.77.211.236/CSB/hsa-fsi-1303
  15597. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  15598. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  15599. // 调用 Init 函数
  15600. 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"))))
  15601. //if ret != 0 {
  15602. fmt.Println("SSCard的报错原因:", err)
  15603. fmt.Println("SSCard的运算结果为:", ret)
  15604. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15605. // return
  15606. //}
  15607. result := int(ret)
  15608. fmt.Println("SSCard的运算结果为1:", result)
  15609. initFlag = 1
  15610. return
  15611. }
  15612. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  15613. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15614. Iinit := DllDef.MustFindProc("Init")
  15615. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15616. //http://10.77.211.236/CSB/hsa-fsi-1303
  15617. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  15618. if ret != 0 {
  15619. fmt.Println("SSCard的报错原因:", err)
  15620. fmt.Println("SSCard的运算结果为:", ret)
  15621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15622. return
  15623. }
  15624. result := int(ret)
  15625. fmt.Println("SSCard的运算结果为1:", result)
  15626. initFlag = 1
  15627. return
  15628. }
  15629. func (c *HisApiController) GetSFZBaseInfo() string {
  15630. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15631. readCard := DllDef.MustFindProc("ReadSFZ")
  15632. if readCard == nil {
  15633. fmt.Println("readcard is nil")
  15634. readCard = DllDef.MustFindProc("ReadSFZ")
  15635. }
  15636. str := make([]byte, 8096)
  15637. str1 := make([]byte, 8096)
  15638. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  15639. fmt.Println(r)
  15640. return Remove0000(string(str))
  15641. }
  15642. func (c *HisApiController) GetEleBaseInfo() string {
  15643. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15644. readCard := DllDef.MustFindProc("GetQRBase")
  15645. fmt.Println(readCard)
  15646. if readCard == nil {
  15647. fmt.Println("readcard is nil")
  15648. readCard = DllDef.MustFindProc("GetQRBase")
  15649. }
  15650. str := make([]byte, 1024)
  15651. str1 := make([]byte, 1024)
  15652. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  15653. fmt.Println(ret2)
  15654. fmt.Println(string(str1))
  15655. fmt.Println(string(str))
  15656. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15657. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  15658. if ret2 != 0 {
  15659. return ""
  15660. }
  15661. return string(str)
  15662. }
  15663. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  15664. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  15665. readCard := DllDef.MustFindProc("NationEcTrans")
  15666. fmt.Println(readCard)
  15667. fmt.Println("!!!!!")
  15668. pBusiCardInfo := make([]byte, 2048)
  15669. input := make(map[string]interface{})
  15670. inputData := make(map[string]interface{})
  15671. inputData["orgId"] = code
  15672. inputData["businessType"] = "01101"
  15673. inputData["operatorId"] = "1"
  15674. inputData["operatorName"] = "admin"
  15675. inputData["officeId"] = "001"
  15676. inputData["officeName"] = "血透室"
  15677. inputData["deviceType"] = ""
  15678. input["data"] = inputData
  15679. input["orgId"] = code
  15680. input["transType"] = "ec.query"
  15681. bytesData, _ := json.Marshal(input)
  15682. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  15683. fmt.Println(ret2)
  15684. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  15685. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  15686. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  15687. }
  15688. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  15689. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  15690. readCard := DllDef.MustFindProc("NationEcTrans")
  15691. fmt.Println(readCard)
  15692. fmt.Println("!!!!!")
  15693. pBusiCardInfo := make([]byte, 2048)
  15694. input := make(map[string]interface{})
  15695. inputData := make(map[string]interface{})
  15696. inputData["orgId"] = code
  15697. inputData["businessType"] = "01101"
  15698. inputData["operatorId"] = "9"
  15699. inputData["operatorName"] = "admin"
  15700. inputData["officeId"] = "001"
  15701. inputData["officeName"] = "血透室"
  15702. inputData["deviceType"] = ""
  15703. input["data"] = inputData
  15704. input["orgId"] = code
  15705. input["transType"] = "ec.query"
  15706. bytesData, _ := json.Marshal(input)
  15707. 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])))
  15708. fmt.Println(ret2)
  15709. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  15710. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  15711. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  15712. }
  15713. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  15714. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  15715. readCard := DllDef.MustFindProc("NationEcTrans")
  15716. fmt.Println(readCard)
  15717. fmt.Println("!!!!!")
  15718. pBusiCardInfo := make([]byte, 2048)
  15719. input := make(map[string]interface{})
  15720. inputData := make(map[string]interface{})
  15721. inputData["orgId"] = code
  15722. inputData["businessType"] = "01301"
  15723. inputData["operatorId"] = "9"
  15724. inputData["operatorName"] = "admin"
  15725. inputData["officeId"] = "001"
  15726. inputData["officeName"] = "血透室"
  15727. inputData["deviceType"] = ""
  15728. input["data"] = inputData
  15729. input["orgId"] = code
  15730. input["transType"] = "ec.query"
  15731. bytesData, _ := json.Marshal(input)
  15732. 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])))
  15733. fmt.Println(ret2)
  15734. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  15735. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  15736. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  15737. }
  15738. func GetJxEleBaseInfo(org_id int64) string {
  15739. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15740. readCard := DllDef.MustFindProc("NationEcTrans")
  15741. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  15742. if readCard == nil {
  15743. fmt.Println("readcard is nil")
  15744. readCard = DllDef.MustFindProc("NationEcTrans")
  15745. }
  15746. str1 := make([]byte, 1024)
  15747. data := make(map[string]interface{})
  15748. inputData := make(map[string]interface{})
  15749. inputData["orgId"] = miConfig.Code
  15750. inputData["businessType"] = "01101"
  15751. inputData["operatorId"] = "test001"
  15752. inputData["operatorName"] = "cn"
  15753. inputData["officeId"] = "32760"
  15754. inputData["officeName"] = "waike"
  15755. inputData["deviceType"] = ""
  15756. data["data"] = inputData
  15757. data["transType"] = "ec.query"
  15758. data["extra "] = ""
  15759. data["orgId"] = miConfig.Code
  15760. bytesData, _ := json.Marshal(data)
  15761. //bytesData, _ := json.Marshal(data)
  15762. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  15763. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  15764. fmt.Println(ret2)
  15765. fmt.Println(string(str1))
  15766. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15767. if ret2 != 0 {
  15768. return ""
  15769. }
  15770. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  15771. }
  15772. //func GetJxEleBaseInfoTWO(org_id int64) string {
  15773. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  15774. // readCard := DllDef.MustFindProc("NationEcTrans")
  15775. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  15776. //
  15777. // if readCard == nil {
  15778. // fmt.Println("readcard is nil")
  15779. // readCard = DllDef.MustFindProc("NationEcTrans")
  15780. // }
  15781. // str1 := make([]byte, 1024)
  15782. //
  15783. // data := make(map[string]interface{})
  15784. //
  15785. // inputData := make(map[string]interface{})
  15786. // inputData["orgId"] = miConfig.Code
  15787. // inputData["businessType"] = "01101"
  15788. // inputData["operatorId"] = "test001"
  15789. // inputData["operatorName"] = "cn"
  15790. // inputData["officeId"] = "32760"
  15791. // inputData["officeName"] = "waike"
  15792. // inputData["deviceType"] = ""
  15793. //
  15794. // data["data"] = inputData
  15795. // data["transType"] = "ec.query"
  15796. // data["extra "] = ""
  15797. // data["orgId"] = miConfig.Code
  15798. // bytesData, _ := json.Marshal(data)
  15799. // //bytesData, _ := json.Marshal(data)
  15800. //
  15801. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  15802. //
  15803. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  15804. // fmt.Println(ret2)
  15805. // fmt.Println(string(str1))
  15806. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15807. //
  15808. // if ret2 != 0 {
  15809. // return ""
  15810. // }
  15811. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  15812. //}
  15813. func GetJxEleBaseInitInfo(org_id int64) string {
  15814. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15815. readCard := DllDef.MustFindProc("NationEcTrans")
  15816. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  15817. if readCard == nil {
  15818. fmt.Println("readcard is nil")
  15819. readCard = DllDef.MustFindProc("NationEcTrans")
  15820. }
  15821. str1 := make([]byte, 2048)
  15822. data := make(map[string]interface{})
  15823. inputData := make(map[string]interface{})
  15824. inputData["orgId"] = miConfig.Code
  15825. inputData["businessType"] = "01101"
  15826. inputData["operatorId"] = "1"
  15827. inputData["operatorName"] = "huangchuang"
  15828. inputData["officeId"] = "101"
  15829. inputData["officeName"] = "xuetou"
  15830. inputData["deviceType"] = ""
  15831. data["data"] = inputData
  15832. data["transType"] = "ec.query"
  15833. data["orgId"] = miConfig.Code
  15834. bytesData, _ := json.Marshal(data)
  15835. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  15836. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  15837. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  15838. fmt.Println(ret2)
  15839. fmt.Println(string(str1))
  15840. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15841. if ret2 != 0 {
  15842. return ""
  15843. }
  15844. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  15845. initEleFlag = 1
  15846. }
  15847. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  15848. }
  15849. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  15850. // // 构建命令
  15851. // cmd := exec.Command("python", "b.py")
  15852. //
  15853. // // 执行命令并等待完成
  15854. // output, err := cmd.CombinedOutput()
  15855. // if err != nil {
  15856. // fmt.Println("Error executing Python script:", err)
  15857. // return
  15858. // }
  15859. //
  15860. // // 打印Python脚本的输出
  15861. // fmt.Println(string(output))
  15862. //}
  15863. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  15864. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  15865. readCard := DllDef.MustFindProc("gxyb_call")
  15866. if readCard == nil {
  15867. fmt.Println("readcard is nil")
  15868. readCard = DllDef.MustFindProc("gxyb_call")
  15869. }
  15870. str := make([]byte, 1024)
  15871. str1 := make([]byte, 1024)
  15872. //data := make(map[string]interface{})
  15873. currentTime := time.Now()
  15874. // 格式化时间为 "YYYYMMDDHH24MISS"
  15875. formattedTime := currentTime.Format("20060102150405")
  15876. inputData := make(map[string]interface{})
  15877. inputData2 := make(map[string]interface{})
  15878. inputData["transNo"] = "1401"
  15879. inputData["transType"] = "passwordCheck"
  15880. inputData["timestamp"] = formattedTime
  15881. inputData2["fixmedinsCode"] = code
  15882. inputData2["psnNo"] = ""
  15883. inputData["data"] = inputData2
  15884. jsonBytes, err := json.Marshal(inputData)
  15885. if err != nil {
  15886. fmt.Println("Error encoding map to JSON:", err)
  15887. }
  15888. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  15889. fmt.Println(string(str1))
  15890. fmt.Println(string(str))
  15891. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15892. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  15893. if ret2 != 0 {
  15894. return ""
  15895. }
  15896. return string(str)
  15897. }
  15898. func (c *HisApiController) GetoleInfo() Response {
  15899. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  15900. defer ole.CoUninitialize()
  15901. // Replace with the ProgID or CLSID of your COM object
  15902. progID := "YinHai.XJ.Actual.Interface.New"
  15903. // Create COM object
  15904. unknown, err := oleutil.CreateObject(progID)
  15905. if err != nil {
  15906. fmt.Println("Unable to create COM object:", err)
  15907. }
  15908. defer unknown.Release()
  15909. // Query for the IDispatch interface
  15910. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  15911. if err != nil {
  15912. fmt.Println("Unable to get IDispatch interface:", err)
  15913. }
  15914. defer dispatch.Release()
  15915. // Prepare parameters
  15916. transNo := "1401"
  15917. transType := "passwordCheck"
  15918. timestamp := time.Now().Unix()
  15919. fixmedinsCode := "H45072101171"
  15920. psnNo := ""
  15921. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  15922. result2 := ""
  15923. // Call COM object's method using the IDispatch interface
  15924. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  15925. fmt.Println(resulr)
  15926. fmt.Println(result2)
  15927. if err != nil {
  15928. fmt.Println("调用COM对象方法失败:", err)
  15929. }
  15930. var response Response
  15931. err2 := json.Unmarshal([]byte(result2), &response)
  15932. if err2 != nil {
  15933. fmt.Println("解析JSON失败:", err)
  15934. }
  15935. return response
  15936. }
  15937. func (c *HisApiController) GetBasBaseInfo() string {
  15938. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15939. readCard := DllDef.MustFindProc("ReadCardBas")
  15940. if readCard == nil {
  15941. fmt.Println("readcard is nil")
  15942. readCard = DllDef.MustFindProc("ReadCardBas")
  15943. }
  15944. str := make([]byte, 1024)
  15945. str1 := make([]byte, 1024)
  15946. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  15947. fmt.Println(string(str1))
  15948. fmt.Println(string(str))
  15949. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15950. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  15951. if ret2 != 0 {
  15952. return ""
  15953. }
  15954. return string(str)
  15955. }
  15956. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  15957. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  15958. readCard := DllDef.MustFindProc("read_cardinfo")
  15959. if readCard == nil {
  15960. fmt.Println("readcard is nil")
  15961. readCard = DllDef.MustFindProc("read_cardinfo")
  15962. }
  15963. str := make([]byte, 1024) //卡号
  15964. str1 := make([]byte, 1024) //卡识别码
  15965. str2 := make([]byte, 1024) //身份证号
  15966. str3 := make([]byte, 1024) //姓名
  15967. str4 := make([]byte, 1024) //错误信息
  15968. 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])))
  15969. fmt.Println(string(str1))
  15970. fmt.Println(string(str))
  15971. fmt.Println(string(str2))
  15972. fmt.Println(string(str3))
  15973. fmt.Println(string(str4))
  15974. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15975. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  15976. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  15977. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  15978. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  15979. if ret2 != 0 {
  15980. return "", "", "", "", ""
  15981. }
  15982. return string(str), string(str1), string(str2), string(str3), string(str4)
  15983. }
  15984. type CustomFundPay struct {
  15985. FundPayType string `json:"fund_pay_type"`
  15986. FundPayamt float64 `json:"fund_payamt"`
  15987. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15988. }
  15989. //func (c *HisApiController) GetBatchSettleList() {
  15990. // start_time_str := c.GetString("start_time")
  15991. // //end_time_str := c.GetString("end_time")
  15992. // admin_user_id, _ := c.GetInt64("admin_user_id")
  15993. //
  15994. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  15995. //
  15996. // for _, item := range orders {
  15997. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  15998. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  15999. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  16000. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  16001. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16002. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  16003. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16004. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  16005. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  16006. //
  16007. // if order.ID == 0 {
  16008. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  16009. // return
  16010. // }
  16011. //
  16012. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  16013. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  16014. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  16015. // //fmt.Println(count)
  16016. // //var zero string
  16017. // //number := count + 1
  16018. // //if number >= 1000 {
  16019. // // zero = "0000" + strconv.FormatInt(number, 10)
  16020. // //} else if number >= 10000 {
  16021. // // zero = "000" + strconv.FormatInt(number, 10)
  16022. // //} else if number >= 100000 {
  16023. // // zero = "00" + strconv.FormatInt(number, 10)
  16024. // //} else if number >= 1000000 {
  16025. // // zero = "0" + strconv.FormatInt(number, 10)
  16026. // //} else {
  16027. // // zero = strconv.FormatInt(number, 10)
  16028. // //}
  16029. // //fmt.Println(zero)
  16030. //
  16031. // struct4101 := service.Struct4101{
  16032. // PsnNo: order.PsnNo,
  16033. // MdtrtId: order.MdtrtId,
  16034. // SetlId: order.SetlId,
  16035. // PsnName: order.PsnName,
  16036. // Gend: order.Gend,
  16037. // Brdy: his.Brdy,
  16038. // Age: his.Age,
  16039. // Naty: order.Naty,
  16040. // PatnCertType: "01",
  16041. // Certno: order.Certno,
  16042. // Prfs: "90",
  16043. // ConerName: roles[0].UserName,
  16044. // PatnRlts: "99",
  16045. // ConerAddr: miConfig.OrgName,
  16046. // ConerTel: admin.Mobile,
  16047. // HiType: order.Insutype,
  16048. // Insuplc: miConfig.InsuplcAdmdvs,
  16049. // MaindiagFlag: "1",
  16050. // BillCode: order.SetlId,
  16051. // BillNo: order.SetlId,
  16052. // BizSn: order.Number,
  16053. // PsnSelfPay: order.PsnPartAmt,
  16054. // PsnOwnPay: order.PsnPartAmt,
  16055. // AcctPay: order.AcctPay,
  16056. // PsnCashpay: order.PsnCashPay,
  16057. // HiPaymtd: "1",
  16058. // Hsorg: miConfig.InsuplcAdmdvs,
  16059. // HsorgOpter: miConfig.InsuplcAdmdvs,
  16060. // MedinsFillPsn: curRoles.UserName,
  16061. // MedinsFillDept: miConfig.OrgName,
  16062. // IptMedType: "2",
  16063. // }
  16064. // struct4101.SetlBegnDate = order.SetlTime
  16065. // struct4101.SetlEndDate = order.SetlTime
  16066. // time_arr := strings.Split(order.SetlTime, " ")
  16067. // struct4101.AdmTime = time_arr[0]
  16068. // struct4101.AdmEndTime = time_arr[0]
  16069. //
  16070. // var rf []CustomFundPay
  16071. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  16072. //
  16073. // var tempFunPays []service.CustomStruct
  16074. // for _, item := range rf {
  16075. // var tempFunPay service.CustomStruct
  16076. // tempFunPay.FundPayamt = item.FundPayamt
  16077. // tempFunPay.FundPayType = item.FundPayType
  16078. // tempFunPays = append(tempFunPays, tempFunPay)
  16079. // }
  16080. // struct4101.CustomStruct = tempFunPays
  16081. //
  16082. // var tempDiaginfos []service.DiaginfoStructTwo
  16083. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  16084. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  16085. //
  16086. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  16087. // var config []*models.HisXtDiagnoseConfig
  16088. // for _, item := range diagnosis_ids {
  16089. // id, _ := strconv.ParseInt(item, 10, 64)
  16090. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  16091. // config = append(config, &diagnosisConfig)
  16092. // }
  16093. //
  16094. // for index, item := range config {
  16095. // if index == 0 {
  16096. // var tempDiaginfo service.DiaginfoStructTwo
  16097. // tempDiaginfo.DiagCode = item.CountryCode
  16098. // tempDiaginfo.DiagName = item.CountryContentName
  16099. // tempDiaginfo.DiagType = "1"
  16100. // tempDiaginfo.MaindiagFlag = "1"
  16101. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16102. // } else {
  16103. // var tempDiaginfo service.DiaginfoStructTwo
  16104. // tempDiaginfo.DiagCode = item.CountryCode
  16105. // tempDiaginfo.DiagName = item.CountryContentName
  16106. // tempDiaginfo.DiagType = "1"
  16107. // tempDiaginfo.MaindiagFlag = "0"
  16108. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16109. // }
  16110. // }
  16111. // struct4101.Diseinfo = tempDiaginfos
  16112. //
  16113. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  16114. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  16115. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  16116. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  16117. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  16118. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  16119. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  16120. //
  16121. // var iteminfo service.IteminfoStruct
  16122. //
  16123. // var bedCostTotal float64 = 0 //床位总费
  16124. // var bedCostSelfTotal float64 = 0 //床位自费
  16125. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  16126. //
  16127. // var operationCostTotal float64 = 0 //手术费
  16128. // var operationCostSelfTotal float64 = 0 //手术费
  16129. // var operationCostPartSelfTotal float64 = 0 //手术费
  16130. //
  16131. // var otherCostTotal float64 = 0 //其他费用
  16132. // var otherCostSelfTotal float64 = 0 //其他费用
  16133. // var otherCostPartSelfTotal float64 = 0 //其他费用
  16134. //
  16135. // var materialCostTotal float64 = 0 //材料费
  16136. // var materialCostSelfTotal float64 = 0 //材料费
  16137. // var materialCostPartSelfTotal float64 = 0 //材料费
  16138. //
  16139. // var westernMedicineCostTotal float64 = 0 //西药费
  16140. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  16141. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  16142. //
  16143. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  16144. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  16145. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  16146. //
  16147. // var checkCostTotal float64 = 0 //检查费
  16148. // var checkCostSelfTotal float64 = 0 //检查费
  16149. // var checkCostPartSelfTotal float64 = 0 //检查费
  16150. //
  16151. // var laboratoryCostTotal float64 = 0 //化验费
  16152. // var laboratoryCostSelfTotal float64 = 0 //化验费
  16153. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  16154. //
  16155. // var treatCostTotal float64 = 0 //治疗费用
  16156. // var treatCostSelfTotal float64 = 0 //治疗费用
  16157. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  16158. //
  16159. // decimal.DivisionPrecision = 2
  16160. //
  16161. // var bed_fulamt_ownpay_amt float64 = 0
  16162. // var operation_fulamt_ownpay_amt float64 = 0
  16163. // var other_fulamt_ownpay_amt float64 = 0
  16164. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  16165. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  16166. // var check_fulamt_ownpay_amt float64 = 0
  16167. // var material_fulamt_ownpay_amt float64 = 0
  16168. // var laboratory_fulamt_ownpay_amt float64 = 0
  16169. // var treat_fulamt_ownpay_amt float64 = 0
  16170. //
  16171. // var bed_claa_sunmfee float64 = 0
  16172. // var bed_clab_amt float64 = 0
  16173. // var bed_other_amt float64 = 0
  16174. //
  16175. // var operation_claa_sunmfee float64 = 0
  16176. // var operation_clab_amt float64 = 0
  16177. // var operation_other_amt float64 = 0
  16178. //
  16179. // var other_claa_sunmfee float64 = 0
  16180. // var other_clab_amt float64 = 0
  16181. // var other_other_amt float64 = 0
  16182. //
  16183. // var westernMedicine_claa_sunmfee float64 = 0
  16184. // var westernMedicine_clab_amt float64 = 0
  16185. // var westernMedicine_other_amt float64 = 0
  16186. //
  16187. // var chineseTraditional_claa_sunmfee float64 = 0
  16188. // var chineseTraditional_clab_amt float64 = 0
  16189. // var chineseTraditional_other_amt float64 = 0
  16190. //
  16191. // var check_claa_sunmfee float64 = 0
  16192. // var check_clab_amt float64 = 0
  16193. // var check_other_amt float64 = 0
  16194. //
  16195. // var material_claa_sunmfee float64 = 0
  16196. // var material_clab_amt float64 = 0
  16197. // var material_other_amt float64 = 0
  16198. //
  16199. // var laboratory_claa_sunmfee float64 = 0
  16200. // var laboratory_clab_amt float64 = 0
  16201. // var laboratory_other_amt float64 = 0
  16202. //
  16203. // var treat_claa_sunmfee float64 = 0
  16204. // var treat_clab_amt float64 = 0
  16205. // var treat_other_amt float64 = 0
  16206. //
  16207. // for _, item := range order.HisOrderInfo {
  16208. // if item.MedChrgitmType == "01" { //床位费
  16209. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16210. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16211. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16212. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16213. // if item.ChrgitmLv == "1" {
  16214. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16215. // }
  16216. // if item.ChrgitmLv == "2" {
  16217. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16218. //
  16219. // }
  16220. // if item.ChrgitmLv == "3" {
  16221. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16222. // }
  16223. //
  16224. // }
  16225. //
  16226. // if item.MedChrgitmType == "03" { //检查费
  16227. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16228. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16229. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16230. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16231. // if item.ChrgitmLv == "1" {
  16232. //
  16233. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16234. //
  16235. // }
  16236. // if item.ChrgitmLv == "2" {
  16237. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16238. //
  16239. // }
  16240. // if item.ChrgitmLv == "3" {
  16241. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16242. // }
  16243. // }
  16244. //
  16245. // if item.MedChrgitmType == "04" { //化验费
  16246. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16247. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16248. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16249. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16250. // if item.ChrgitmLv == "1" {
  16251. //
  16252. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16253. //
  16254. // }
  16255. // if item.ChrgitmLv == "2" {
  16256. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16257. //
  16258. // }
  16259. // if item.ChrgitmLv == "3" {
  16260. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16261. // }
  16262. // }
  16263. //
  16264. // if item.MedChrgitmType == "05" { //治疗费
  16265. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16266. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16267. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16268. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16269. // if item.ChrgitmLv == "1" {
  16270. //
  16271. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16272. //
  16273. // }
  16274. // if item.ChrgitmLv == "2" {
  16275. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16276. //
  16277. // }
  16278. // if item.ChrgitmLv == "3" {
  16279. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16280. // }
  16281. // }
  16282. //
  16283. // if item.MedChrgitmType == "06" { //手术费
  16284. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16285. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16286. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16287. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16288. //
  16289. // if item.ChrgitmLv == "1" {
  16290. //
  16291. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16292. //
  16293. // }
  16294. // if item.ChrgitmLv == "2" {
  16295. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16296. //
  16297. // }
  16298. // if item.ChrgitmLv == "3" {
  16299. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16300. // }
  16301. // }
  16302. //
  16303. // if item.MedChrgitmType == "08" { //材料费
  16304. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16305. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16306. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16307. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16308. // if item.ChrgitmLv == "1" {
  16309. //
  16310. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16311. //
  16312. // }
  16313. // if item.ChrgitmLv == "2" {
  16314. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16315. //
  16316. // }
  16317. // if item.ChrgitmLv == "3" {
  16318. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16319. // }
  16320. // }
  16321. //
  16322. // if item.MedChrgitmType == "09" { //西药费
  16323. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16324. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16325. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16326. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16327. // if item.ChrgitmLv == "1" {
  16328. //
  16329. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16330. //
  16331. // }
  16332. // if item.ChrgitmLv == "2" {
  16333. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16334. //
  16335. // }
  16336. // if item.ChrgitmLv == "3" {
  16337. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16338. // }
  16339. // }
  16340. //
  16341. // if item.MedChrgitmType == "11" { //中成费
  16342. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16343. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16344. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16345. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16346. // if item.ChrgitmLv == "1" {
  16347. //
  16348. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16349. //
  16350. // }
  16351. // if item.ChrgitmLv == "2" {
  16352. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16353. //
  16354. // }
  16355. // if item.ChrgitmLv == "3" {
  16356. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16357. // }
  16358. // }
  16359. //
  16360. // if item.MedChrgitmType == "14" { //其他费
  16361. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16362. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16363. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16364. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16365. // if item.ChrgitmLv == "1" {
  16366. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16367. //
  16368. // }
  16369. // if item.ChrgitmLv == "2" {
  16370. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16371. //
  16372. // }
  16373. // if item.ChrgitmLv == "3" {
  16374. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16375. // }
  16376. // }
  16377. //
  16378. // }
  16379. //
  16380. // var iteminfoStructs []service.IteminfoStruct
  16381. //
  16382. // if bedCostTotal != 0 {
  16383. // iteminfo.MedChrgitm = "01"
  16384. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  16385. // iteminfo.Amt = bedCostTotal
  16386. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  16387. // iteminfo.ClabAmt = bed_clab_amt
  16388. // iteminfo.OthAmt = bed_other_amt
  16389. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16390. // }
  16391. //
  16392. // if checkCostTotal != 0 {
  16393. // iteminfo.MedChrgitm = "03"
  16394. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  16395. // iteminfo.Amt = checkCostTotal
  16396. // iteminfo.ClaaSumfee = check_claa_sunmfee
  16397. // iteminfo.ClabAmt = check_clab_amt
  16398. // iteminfo.OthAmt = check_other_amt
  16399. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16400. //
  16401. // }
  16402. //
  16403. // if laboratoryCostTotal != 0 {
  16404. // iteminfo.MedChrgitm = "04"
  16405. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  16406. // iteminfo.Amt = laboratoryCostTotal
  16407. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  16408. // iteminfo.ClabAmt = laboratory_clab_amt
  16409. // iteminfo.OthAmt = laboratory_other_amt
  16410. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16411. //
  16412. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16413. //
  16414. // }
  16415. //
  16416. // if treatCostTotal != 0 {
  16417. // iteminfo.MedChrgitm = "05"
  16418. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  16419. // iteminfo.Amt = treatCostTotal
  16420. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  16421. // iteminfo.ClabAmt = treat_clab_amt
  16422. // iteminfo.OthAmt = treat_other_amt
  16423. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16424. // //(struct4101.IteminfoStruct, iteminfo)
  16425. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16426. // }
  16427. //
  16428. // if operationCostTotal != 0 {
  16429. // iteminfo.MedChrgitm = "06"
  16430. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  16431. // iteminfo.Amt = operationCostTotal
  16432. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  16433. // iteminfo.ClabAmt = operation_clab_amt
  16434. // iteminfo.OthAmt = operation_other_amt
  16435. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16436. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16437. // }
  16438. //
  16439. // if materialCostTotal != 0 {
  16440. // iteminfo.MedChrgitm = "08"
  16441. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  16442. // iteminfo.Amt = materialCostTotal
  16443. // iteminfo.ClaaSumfee = material_claa_sunmfee
  16444. // iteminfo.ClabAmt = material_clab_amt
  16445. // iteminfo.OthAmt = material_other_amt
  16446. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16447. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16448. // }
  16449. //
  16450. // if westernMedicineCostTotal != 0 {
  16451. // iteminfo.MedChrgitm = "09"
  16452. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  16453. // iteminfo.Amt = westernMedicineCostTotal
  16454. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  16455. // iteminfo.ClabAmt = westernMedicine_clab_amt
  16456. // iteminfo.OthAmt = westernMedicine_other_amt
  16457. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16458. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16459. //
  16460. // }
  16461. // if chineseTraditionalMedicineCostTotal != 0 {
  16462. // iteminfo.MedChrgitm = "11"
  16463. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  16464. // iteminfo.Amt = westernMedicineCostTotal
  16465. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  16466. // iteminfo.ClabAmt = westernMedicine_clab_amt
  16467. // iteminfo.OthAmt = westernMedicine_other_amt
  16468. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16469. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16470. //
  16471. // }
  16472. // if otherCostTotal != 0 {
  16473. // iteminfo.MedChrgitm = "14"
  16474. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  16475. // iteminfo.Amt = otherCostTotal
  16476. // iteminfo.ClaaSumfee = other_claa_sunmfee
  16477. // iteminfo.ClabAmt = other_clab_amt
  16478. // iteminfo.OthAmt = other_other_amt
  16479. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16480. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16481. //
  16482. // }
  16483. // struct4101.IteminfoStruct = iteminfoStructs
  16484. // struct4101.Ntly = "中国"
  16485. // struct4101.AdmCaty = "A03.06"
  16486. //
  16487. // struct4101.DoctorName = doctor.UserName
  16488. // struct4101.DoctorCode = doctor.DoctorNumber
  16489. //
  16490. // var res ResultSeventeen
  16491. //
  16492. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16493. // struct4101.BillCode = order.Number
  16494. // struct4101.BillNo = order.SetlId
  16495. // var resOther ResultSeventeenOther
  16496. // var pp models.PublicParams
  16497. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16498. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16499. // pp.FixmedinsName = miConfig.OrgName
  16500. // pp.FixmedinsCode = miConfig.Code
  16501. // pp.RequestUrl = miConfig.Url
  16502. // pp.Cainfo = miConfig.Cainfo
  16503. // pp.SecretKey = miConfig.SecretKey
  16504. // pp.AccessKey = miConfig.AccessKey
  16505. // pp.OpterName = curRoles.UserName
  16506. //
  16507. // client := &http.Client{}
  16508. // var req *http.Request
  16509. // data := make(map[string]interface{})
  16510. // data["struct4101"] = struct4101
  16511. // data["pp"] = pp
  16512. // bytesData, _ := json.Marshal(data)
  16513. // if miConfig.MdtrtareaAdmvs == "320921" {
  16514. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  16515. // } else {
  16516. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  16517. // }
  16518. // resp, _ := client.Do(req)
  16519. // defer resp.Body.Close()
  16520. // body, ioErr := ioutil.ReadAll(resp.Body)
  16521. // if ioErr != nil {
  16522. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16524. // return
  16525. // }
  16526. // var respJSON map[string]interface{}
  16527. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16528. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16529. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16530. // return
  16531. // }
  16532. //
  16533. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16534. // userJSONBytes, _ := json.Marshal(respJSON)
  16535. // fmt.Println("log")
  16536. // fmt.Println(string(userJSONBytes))
  16537. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  16538. // utils.ErrorLog("解析失败:%v", err)
  16539. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16540. // return
  16541. // }
  16542. // res.InfRefmsgid = resOther.InfRefmsgid
  16543. // res.Output = resOther.Output
  16544. // res.ErrMsg = resOther.ErrMsg
  16545. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  16546. // res.Infcode = infocode
  16547. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  16548. //
  16549. // var pp models.PublicParams
  16550. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16551. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16552. // pp.FixmedinsName = miConfig.OrgName
  16553. // pp.FixmedinsCode = miConfig.Code
  16554. // pp.RequestUrl = miConfig.Url
  16555. // pp.Cainfo = miConfig.Cainfo
  16556. // pp.SecretKey = miConfig.SecretKey
  16557. // pp.AccessKey = miConfig.AccessKey
  16558. // pp.OpterName = curRoles.UserName
  16559. // result, _ := service.Jxyb4101(struct4101, pp)
  16560. // var dat map[string]interface{}
  16561. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16562. // fmt.Println(dat)
  16563. // } else {
  16564. // fmt.Println(err)
  16565. // }
  16566. // userJSONBytes, _ := json.Marshal(dat)
  16567. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16568. // utils.ErrorLog("解析失败:%v", err)
  16569. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16570. // return
  16571. // }
  16572. //
  16573. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  16574. // var pp models.PublicParams
  16575. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16576. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16577. // pp.FixmedinsName = miConfig.OrgName
  16578. // pp.FixmedinsCode = miConfig.Code
  16579. // pp.RequestUrl = miConfig.Url
  16580. // pp.Cainfo = miConfig.Cainfo
  16581. // pp.SecretKey = miConfig.SecretKey
  16582. // pp.AccessKey = miConfig.AccessKey
  16583. // pp.OpterName = curRoles.UserName
  16584. // result, _ := service.Hnyb4101(struct4101, pp)
  16585. // var dat map[string]interface{}
  16586. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16587. // fmt.Println(dat)
  16588. // } else {
  16589. // fmt.Println(err)
  16590. // }
  16591. // userJSONBytes, _ := json.Marshal(dat)
  16592. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16593. // utils.ErrorLog("解析失败:%v", err)
  16594. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16595. // return
  16596. // }
  16597. //
  16598. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  16599. // var resOther ResultSeventeenOther
  16600. //
  16601. // var pp models.PublicParams
  16602. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16603. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16604. // pp.FixmedinsName = miConfig.OrgName
  16605. // pp.FixmedinsCode = miConfig.Code
  16606. // pp.RequestUrl = miConfig.Url
  16607. // pp.Cainfo = miConfig.Cainfo
  16608. // pp.SecretKey = miConfig.SecretKey
  16609. // pp.AccessKey = miConfig.AccessKey
  16610. // pp.OpterName = curRoles.UserName
  16611. // client := &http.Client{}
  16612. // var req *http.Request
  16613. // data := make(map[string]interface{})
  16614. // data["struct4101"] = struct4101
  16615. // data["pp"] = pp
  16616. // bytesData, _ := json.Marshal(data)
  16617. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  16618. // resp, _ := client.Do(req)
  16619. // defer resp.Body.Close()
  16620. // body, ioErr := ioutil.ReadAll(resp.Body)
  16621. // if ioErr != nil {
  16622. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16624. // return
  16625. // }
  16626. // var respJSON map[string]interface{}
  16627. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16628. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16630. // return
  16631. // }
  16632. //
  16633. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16634. // userJSONBytes, _ := json.Marshal(respJSON)
  16635. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  16636. // utils.ErrorLog("解析失败:%v", err)
  16637. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16638. // return
  16639. // }
  16640. // res.InfRefmsgid = resOther.InfRefmsgid
  16641. // res.Output = resOther.Output
  16642. // res.ErrMsg = resOther.ErrMsg
  16643. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  16644. // res.Infcode = infocode
  16645. //
  16646. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  16647. // var pp models.PublicParams
  16648. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16649. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16650. // pp.FixmedinsName = miConfig.OrgName
  16651. // pp.FixmedinsCode = miConfig.Code
  16652. // pp.RequestUrl = miConfig.Url
  16653. // pp.Cainfo = miConfig.Cainfo
  16654. // pp.SecretKey = miConfig.SecretKey
  16655. // pp.AccessKey = miConfig.AccessKey
  16656. // pp.OpterName = curRoles.UserName
  16657. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  16658. // fmt.Println(requestLog)
  16659. // fmt.Println(errMsgLog)
  16660. //
  16661. // saveLog(result, requestLog, "4101a", "上传清单")
  16662. //
  16663. // var dat map[string]interface{}
  16664. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16665. // fmt.Println(dat)
  16666. // } else {
  16667. // fmt.Println(err)
  16668. // }
  16669. // userJSONBytes, _ := json.Marshal(dat)
  16670. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16671. // utils.ErrorLog("解析失败:%v", err)
  16672. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16673. // return
  16674. // }
  16675. //
  16676. // } else {
  16677. //
  16678. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  16679. // var dat map[string]interface{}
  16680. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16681. // fmt.Println(dat)
  16682. // } else {
  16683. // fmt.Println(err)
  16684. // }
  16685. // userJSONBytes, _ := json.Marshal(dat)
  16686. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16687. // utils.ErrorLog("解析失败:%v", err)
  16688. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16689. // return
  16690. // }
  16691. // }
  16692. //
  16693. // if res.Infcode != 0 {
  16694. // adminUser := c.GetAdminUserInfo()
  16695. // errlog := &models.HisOrderError{
  16696. // UserOrgId: adminUser.CurrentOrgId,
  16697. // Ctime: time.Now().Unix(),
  16698. // Mtime: time.Now().Unix(),
  16699. // ErrMsg: res.ErrMsg,
  16700. // Status: 1,
  16701. // PatientId: order.ID,
  16702. // Stage: 10265,
  16703. // }
  16704. // service.CreateErrMsgLog(errlog)
  16705. // continue
  16706. // } else {
  16707. // //order.FaPiaoNumber = zero
  16708. // //order.FaPiaoCode = last_order.FaPiaoCode
  16709. // //service.UpdateOrder(order)
  16710. // hisFundSettleListResult := &models.HisFundSettleListResult{
  16711. // Number: res.Output.SetlListId,
  16712. // Status: 1,
  16713. // Ctime: time.Now().Unix(),
  16714. // Mtime: time.Now().Unix(),
  16715. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16716. // IsUpload: 1,
  16717. // OrderId: order.ID,
  16718. // }
  16719. // service.CreateUploadRecord(hisFundSettleListResult)
  16720. // c.ServeSuccessJSON(map[string]interface{}{
  16721. // "msg": "上传成功",
  16722. // "result": hisFundSettleListResult,
  16723. // })
  16724. // continue
  16725. // }
  16726. // }
  16727. //}
  16728. func (c *HisApiController) GetbatchSettleList() {
  16729. //order_id, _ := c.GetInt64("order_id")
  16730. admin_user_id, _ := c.GetInt64("admin_user_id")
  16731. orders, _ := service.GetAllHisOrderTwo10485()
  16732. for _, item := range orders {
  16733. order, _ := service.GetHisOrderByIDTwo(item.ID)
  16734. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  16735. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  16736. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  16737. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16738. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  16739. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16740. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  16741. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  16742. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  16743. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  16744. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  16745. //fmt.Println(count)
  16746. //var zero string
  16747. //number := count + 1
  16748. //if number >= 1000 {
  16749. // zero = "0000" + strconv.FormatInt(number, 10)
  16750. //} else if number >= 10000 {
  16751. // zero = "000" + strconv.FormatInt(number, 10)
  16752. //} else if number >= 100000 {
  16753. // zero = "00" + strconv.FormatInt(number, 10)
  16754. //} else if number >= 1000000 {
  16755. // zero = "0" + strconv.FormatInt(number, 10)
  16756. //} else {
  16757. // zero = strconv.FormatInt(number, 10)
  16758. //}
  16759. //fmt.Println(zero)
  16760. struct4101 := service.Struct4101{
  16761. PsnNo: order.PsnNo,
  16762. MdtrtId: order.MdtrtId,
  16763. SetlId: order.SetlId,
  16764. PsnName: order.PsnName,
  16765. Gend: order.Gend,
  16766. Brdy: his.Brdy,
  16767. Age: his.Age,
  16768. Naty: order.Naty,
  16769. PatnCertType: "01",
  16770. Certno: order.Certno,
  16771. Prfs: "90",
  16772. ConerName: roles[0].UserName,
  16773. PatnRlts: "99",
  16774. ConerAddr: miConfig.OrgName,
  16775. ConerTel: admin.Mobile,
  16776. HiType: order.Insutype,
  16777. Insuplc: miConfig.InsuplcAdmdvs,
  16778. MaindiagFlag: "1",
  16779. BillCode: order.SetlId,
  16780. BillNo: order.SetlId,
  16781. BizSn: order.Number,
  16782. PsnSelfPay: order.PsnPartAmt,
  16783. PsnOwnPay: order.PsnPartAmt,
  16784. AcctPay: order.AcctPay,
  16785. PsnCashpay: order.PsnCashPay,
  16786. HiPaymtd: "1",
  16787. Hsorg: miConfig.InsuplcAdmdvs,
  16788. HsorgOpter: miConfig.InsuplcAdmdvs,
  16789. MedinsFillPsn: curRoles.UserName,
  16790. MedinsFillDept: miConfig.OrgName,
  16791. IptMedType: "2",
  16792. }
  16793. struct4101.SetlBegnDate = order.SetlTime
  16794. struct4101.SetlEndDate = order.SetlTime
  16795. time_arr := strings.Split(order.SetlTime, " ")
  16796. struct4101.AdmTime = time_arr[0]
  16797. struct4101.AdmEndTime = time_arr[0]
  16798. //var rf []CustomFundPay
  16799. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  16800. //
  16801. //var tempFunPays []service.CustomStruct
  16802. //for _, item := range rf {
  16803. // var tempFunPay service.CustomStruct
  16804. // tempFunPay.FundPayamt = item.FundPayamt
  16805. // tempFunPay.FundPayType = item.FundPayType
  16806. // tempFunPays = append(tempFunPays, tempFunPay)
  16807. //}
  16808. //struct4101.CustomStruct = tempFunPays
  16809. var tempDiaginfos []service.DiaginfoStructTwo
  16810. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  16811. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  16812. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  16813. var config []*models.HisXtDiagnoseConfig
  16814. for _, item := range diagnosis_ids {
  16815. id, _ := strconv.ParseInt(item, 10, 64)
  16816. diagnosisConfig, _ := service.FindDiagnoseById(id)
  16817. config = append(config, &diagnosisConfig)
  16818. }
  16819. for index, item := range config {
  16820. if index == 0 {
  16821. var tempDiaginfo service.DiaginfoStructTwo
  16822. tempDiaginfo.DiagCode = item.CountryCode
  16823. tempDiaginfo.DiagName = item.CountryContentName
  16824. tempDiaginfo.DiagType = "1"
  16825. tempDiaginfo.MaindiagFlag = "1"
  16826. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16827. } else {
  16828. var tempDiaginfo service.DiaginfoStructTwo
  16829. tempDiaginfo.DiagCode = item.CountryCode
  16830. tempDiaginfo.DiagName = item.CountryContentName
  16831. tempDiaginfo.DiagType = "1"
  16832. tempDiaginfo.MaindiagFlag = "0"
  16833. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16834. }
  16835. }
  16836. struct4101.Diseinfo = tempDiaginfos
  16837. sickConfigTwo, _ := service.FindSickById(his.SickType)
  16838. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  16839. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  16840. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  16841. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  16842. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  16843. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  16844. var iteminfo service.IteminfoStruct
  16845. var bedCostTotal float64 = 0 //床位总费
  16846. var bedCostSelfTotal float64 = 0 //床位自费
  16847. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  16848. var operationCostTotal float64 = 0 //手术费
  16849. var operationCostSelfTotal float64 = 0 //手术费
  16850. var operationCostPartSelfTotal float64 = 0 //手术费
  16851. var otherCostTotal float64 = 0 //其他费用
  16852. var otherCostSelfTotal float64 = 0 //其他费用
  16853. var otherCostPartSelfTotal float64 = 0 //其他费用
  16854. var materialCostTotal float64 = 0 //材料费
  16855. var materialCostSelfTotal float64 = 0 //材料费
  16856. var materialCostPartSelfTotal float64 = 0 //材料费
  16857. var westernMedicineCostTotal float64 = 0 //西药费
  16858. var westernMedicineCostSelfTotal float64 = 0 //西药费
  16859. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  16860. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  16861. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  16862. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  16863. var checkCostTotal float64 = 0 //检查费
  16864. var checkCostSelfTotal float64 = 0 //检查费
  16865. var checkCostPartSelfTotal float64 = 0 //检查费
  16866. var laboratoryCostTotal float64 = 0 //化验费
  16867. var laboratoryCostSelfTotal float64 = 0 //化验费
  16868. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  16869. var treatCostTotal float64 = 0 //治疗费用
  16870. var treatCostSelfTotal float64 = 0 //治疗费用
  16871. var treatCostPartSelfTotal float64 = 0 //治疗费用
  16872. decimal.DivisionPrecision = 2
  16873. var bed_fulamt_ownpay_amt float64 = 0
  16874. var operation_fulamt_ownpay_amt float64 = 0
  16875. var other_fulamt_ownpay_amt float64 = 0
  16876. var westernMedicine_fulamt_ownpay_amt float64 = 0
  16877. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  16878. var check_fulamt_ownpay_amt float64 = 0
  16879. var material_fulamt_ownpay_amt float64 = 0
  16880. var laboratory_fulamt_ownpay_amt float64 = 0
  16881. var treat_fulamt_ownpay_amt float64 = 0
  16882. var bed_claa_sunmfee float64 = 0
  16883. var bed_clab_amt float64 = 0
  16884. var bed_other_amt float64 = 0
  16885. var operation_claa_sunmfee float64 = 0
  16886. var operation_clab_amt float64 = 0
  16887. var operation_other_amt float64 = 0
  16888. var other_claa_sunmfee float64 = 0
  16889. var other_clab_amt float64 = 0
  16890. var other_other_amt float64 = 0
  16891. var westernMedicine_claa_sunmfee float64 = 0
  16892. var westernMedicine_clab_amt float64 = 0
  16893. var westernMedicine_other_amt float64 = 0
  16894. var chineseTraditional_claa_sunmfee float64 = 0
  16895. var chineseTraditional_clab_amt float64 = 0
  16896. var chineseTraditional_other_amt float64 = 0
  16897. var check_claa_sunmfee float64 = 0
  16898. var check_clab_amt float64 = 0
  16899. var check_other_amt float64 = 0
  16900. var material_claa_sunmfee float64 = 0
  16901. var material_clab_amt float64 = 0
  16902. var material_other_amt float64 = 0
  16903. var laboratory_claa_sunmfee float64 = 0
  16904. var laboratory_clab_amt float64 = 0
  16905. var laboratory_other_amt float64 = 0
  16906. var treat_claa_sunmfee float64 = 0
  16907. var treat_clab_amt float64 = 0
  16908. var treat_other_amt float64 = 0
  16909. for _, item := range order.HisOrderInfo {
  16910. if item.MedChrgitmType == "01" { //床位费
  16911. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16912. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16913. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16914. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16915. if item.ChrgitmLv == "1" {
  16916. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16917. }
  16918. if item.ChrgitmLv == "2" {
  16919. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16920. }
  16921. if item.ChrgitmLv == "3" {
  16922. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16923. }
  16924. }
  16925. if item.MedChrgitmType == "03" { //检查费
  16926. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16927. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16928. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16929. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16930. if item.ChrgitmLv == "1" {
  16931. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16932. }
  16933. if item.ChrgitmLv == "2" {
  16934. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16935. }
  16936. if item.ChrgitmLv == "3" {
  16937. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16938. }
  16939. }
  16940. if item.MedChrgitmType == "04" { //化验费
  16941. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16942. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16943. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16944. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16945. if item.ChrgitmLv == "1" {
  16946. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16947. }
  16948. if item.ChrgitmLv == "2" {
  16949. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16950. }
  16951. if item.ChrgitmLv == "3" {
  16952. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16953. }
  16954. }
  16955. if item.MedChrgitmType == "05" { //治疗费
  16956. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16957. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16958. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16959. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16960. if item.ChrgitmLv == "1" {
  16961. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16962. }
  16963. if item.ChrgitmLv == "2" {
  16964. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16965. }
  16966. if item.ChrgitmLv == "3" {
  16967. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16968. }
  16969. }
  16970. if item.MedChrgitmType == "06" { //手术费
  16971. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16972. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16973. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16974. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16975. if item.ChrgitmLv == "1" {
  16976. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16977. }
  16978. if item.ChrgitmLv == "2" {
  16979. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16980. }
  16981. if item.ChrgitmLv == "3" {
  16982. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16983. }
  16984. }
  16985. if item.MedChrgitmType == "08" { //材料费
  16986. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16987. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16988. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16989. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16990. if item.ChrgitmLv == "1" {
  16991. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16992. }
  16993. if item.ChrgitmLv == "2" {
  16994. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16995. }
  16996. if item.ChrgitmLv == "3" {
  16997. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16998. }
  16999. }
  17000. if item.MedChrgitmType == "09" { //西药费
  17001. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17002. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17003. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17004. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17005. if item.ChrgitmLv == "1" {
  17006. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17007. }
  17008. if item.ChrgitmLv == "2" {
  17009. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17010. }
  17011. if item.ChrgitmLv == "3" {
  17012. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17013. }
  17014. }
  17015. if item.MedChrgitmType == "11" { //中成费
  17016. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17017. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17018. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17019. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17020. if item.ChrgitmLv == "1" {
  17021. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17022. }
  17023. if item.ChrgitmLv == "2" {
  17024. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17025. }
  17026. if item.ChrgitmLv == "3" {
  17027. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17028. }
  17029. }
  17030. if item.MedChrgitmType == "14" { //其他费
  17031. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17032. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17033. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17034. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17035. if item.ChrgitmLv == "1" {
  17036. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17037. }
  17038. if item.ChrgitmLv == "2" {
  17039. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17040. }
  17041. if item.ChrgitmLv == "3" {
  17042. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17043. }
  17044. }
  17045. }
  17046. var iteminfoStructs []service.IteminfoStruct
  17047. if bedCostTotal != 0 {
  17048. iteminfo.MedChrgitm = "01"
  17049. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17050. iteminfo.Amt = bedCostTotal
  17051. iteminfo.ClaaSumfee = bed_claa_sunmfee
  17052. iteminfo.ClabAmt = bed_clab_amt
  17053. iteminfo.OthAmt = bed_other_amt
  17054. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17055. }
  17056. if checkCostTotal != 0 {
  17057. iteminfo.MedChrgitm = "03"
  17058. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  17059. iteminfo.Amt = checkCostTotal
  17060. iteminfo.ClaaSumfee = check_claa_sunmfee
  17061. iteminfo.ClabAmt = check_clab_amt
  17062. iteminfo.OthAmt = check_other_amt
  17063. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17064. }
  17065. if laboratoryCostTotal != 0 {
  17066. iteminfo.MedChrgitm = "04"
  17067. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  17068. iteminfo.Amt = laboratoryCostTotal
  17069. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  17070. iteminfo.ClabAmt = laboratory_clab_amt
  17071. iteminfo.OthAmt = laboratory_other_amt
  17072. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17073. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17074. }
  17075. if treatCostTotal != 0 {
  17076. iteminfo.MedChrgitm = "05"
  17077. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  17078. iteminfo.Amt = treatCostTotal
  17079. iteminfo.ClaaSumfee = treat_claa_sunmfee
  17080. iteminfo.ClabAmt = treat_clab_amt
  17081. iteminfo.OthAmt = treat_other_amt
  17082. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17083. //(struct4101.IteminfoStruct, iteminfo)
  17084. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17085. }
  17086. if operationCostTotal != 0 {
  17087. iteminfo.MedChrgitm = "06"
  17088. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17089. iteminfo.Amt = operationCostTotal
  17090. iteminfo.ClaaSumfee = operation_claa_sunmfee
  17091. iteminfo.ClabAmt = operation_clab_amt
  17092. iteminfo.OthAmt = operation_other_amt
  17093. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17094. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17095. }
  17096. if materialCostTotal != 0 {
  17097. iteminfo.MedChrgitm = "08"
  17098. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  17099. iteminfo.Amt = materialCostTotal
  17100. iteminfo.ClaaSumfee = material_claa_sunmfee
  17101. iteminfo.ClabAmt = material_clab_amt
  17102. iteminfo.OthAmt = material_other_amt
  17103. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17104. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17105. }
  17106. if westernMedicineCostTotal != 0 {
  17107. iteminfo.MedChrgitm = "09"
  17108. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17109. iteminfo.Amt = westernMedicineCostTotal
  17110. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17111. iteminfo.ClabAmt = westernMedicine_clab_amt
  17112. iteminfo.OthAmt = westernMedicine_other_amt
  17113. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17114. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17115. }
  17116. if chineseTraditionalMedicineCostTotal != 0 {
  17117. iteminfo.MedChrgitm = "11"
  17118. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17119. iteminfo.Amt = westernMedicineCostTotal
  17120. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17121. iteminfo.ClabAmt = westernMedicine_clab_amt
  17122. iteminfo.OthAmt = westernMedicine_other_amt
  17123. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17124. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17125. }
  17126. if otherCostTotal != 0 {
  17127. iteminfo.MedChrgitm = "14"
  17128. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  17129. iteminfo.Amt = otherCostTotal
  17130. iteminfo.ClaaSumfee = other_claa_sunmfee
  17131. iteminfo.ClabAmt = other_clab_amt
  17132. iteminfo.OthAmt = other_other_amt
  17133. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17134. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17135. }
  17136. struct4101.IteminfoStruct = iteminfoStructs
  17137. struct4101.Ntly = "中国"
  17138. struct4101.AdmCaty = "A03.06"
  17139. struct4101.DoctorName = doctor.UserName
  17140. struct4101.DoctorCode = doctor.DoctorNumber
  17141. var res ResultSeventeen
  17142. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17143. struct4101.BillCode = order.Number
  17144. struct4101.BillNo = order.SetlId
  17145. var resOther ResultSeventeenOther
  17146. var pp models.PublicParams
  17147. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17148. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17149. pp.FixmedinsName = miConfig.OrgName
  17150. pp.FixmedinsCode = miConfig.Code
  17151. pp.RequestUrl = miConfig.Url
  17152. pp.Cainfo = miConfig.Cainfo
  17153. pp.SecretKey = miConfig.SecretKey
  17154. pp.AccessKey = miConfig.AccessKey
  17155. pp.OpterName = curRoles.UserName
  17156. client := &http.Client{}
  17157. var req *http.Request
  17158. data := make(map[string]interface{})
  17159. data["struct4101"] = struct4101
  17160. data["pp"] = pp
  17161. bytesData, _ := json.Marshal(data)
  17162. if miConfig.MdtrtareaAdmvs == "320921" {
  17163. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17164. } else {
  17165. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17166. }
  17167. resp, _ := client.Do(req)
  17168. defer resp.Body.Close()
  17169. body, ioErr := ioutil.ReadAll(resp.Body)
  17170. if ioErr != nil {
  17171. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17173. return
  17174. }
  17175. var respJSON map[string]interface{}
  17176. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17177. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17179. return
  17180. }
  17181. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17182. userJSONBytes, _ := json.Marshal(respJSON)
  17183. fmt.Println("log")
  17184. fmt.Println(string(userJSONBytes))
  17185. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17186. utils.ErrorLog("解析失败:%v", err)
  17187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17188. return
  17189. }
  17190. res.InfRefmsgid = resOther.InfRefmsgid
  17191. res.Output = resOther.Output
  17192. res.ErrMsg = resOther.ErrMsg
  17193. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17194. res.Infcode = infocode
  17195. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17196. var pp models.PublicParams
  17197. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  17198. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17199. pp.FixmedinsName = miConfig.OrgName
  17200. pp.FixmedinsCode = miConfig.Code
  17201. pp.RequestUrl = miConfig.Url
  17202. pp.Cainfo = miConfig.Cainfo
  17203. pp.SecretKey = miConfig.SecretKey
  17204. pp.AccessKey = miConfig.AccessKey
  17205. pp.OpterName = curRoles.UserName
  17206. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  17207. result, _ := service.Jxyb4101(struct4101, pp)
  17208. var dat map[string]interface{}
  17209. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17210. fmt.Println(dat)
  17211. } else {
  17212. fmt.Println(err)
  17213. }
  17214. userJSONBytes, _ := json.Marshal(dat)
  17215. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17216. utils.ErrorLog("解析失败:%v", err)
  17217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17218. return
  17219. }
  17220. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17221. var pp models.PublicParams
  17222. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17223. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17224. pp.FixmedinsName = miConfig.OrgName
  17225. pp.FixmedinsCode = miConfig.Code
  17226. pp.RequestUrl = miConfig.Url
  17227. pp.Cainfo = miConfig.Cainfo
  17228. pp.SecretKey = miConfig.SecretKey
  17229. pp.AccessKey = miConfig.AccessKey
  17230. pp.OpterName = curRoles.UserName
  17231. result, _ := service.Hnyb4101(struct4101, pp)
  17232. var dat map[string]interface{}
  17233. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17234. fmt.Println(dat)
  17235. } else {
  17236. fmt.Println(err)
  17237. }
  17238. userJSONBytes, _ := json.Marshal(dat)
  17239. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17240. utils.ErrorLog("解析失败:%v", err)
  17241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17242. return
  17243. }
  17244. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17245. var resOther ResultSeventeenOther
  17246. var pp models.PublicParams
  17247. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17248. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17249. pp.FixmedinsName = miConfig.OrgName
  17250. pp.FixmedinsCode = miConfig.Code
  17251. pp.RequestUrl = miConfig.Url
  17252. pp.Cainfo = miConfig.Cainfo
  17253. pp.SecretKey = miConfig.SecretKey
  17254. pp.AccessKey = miConfig.AccessKey
  17255. pp.OpterName = curRoles.UserName
  17256. client := &http.Client{}
  17257. var req *http.Request
  17258. data := make(map[string]interface{})
  17259. data["struct4101"] = struct4101
  17260. data["pp"] = pp
  17261. bytesData, _ := json.Marshal(data)
  17262. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  17263. resp, _ := client.Do(req)
  17264. defer resp.Body.Close()
  17265. body, ioErr := ioutil.ReadAll(resp.Body)
  17266. if ioErr != nil {
  17267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17269. return
  17270. }
  17271. var respJSON map[string]interface{}
  17272. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17275. return
  17276. }
  17277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17278. userJSONBytes, _ := json.Marshal(respJSON)
  17279. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17280. utils.ErrorLog("解析失败:%v", err)
  17281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17282. return
  17283. }
  17284. res.InfRefmsgid = resOther.InfRefmsgid
  17285. res.Output = resOther.Output
  17286. res.ErrMsg = resOther.ErrMsg
  17287. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17288. res.Infcode = infocode
  17289. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17290. var pp models.PublicParams
  17291. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17292. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17293. pp.FixmedinsName = miConfig.OrgName
  17294. pp.FixmedinsCode = miConfig.Code
  17295. pp.RequestUrl = miConfig.Url
  17296. pp.Cainfo = miConfig.Cainfo
  17297. pp.SecretKey = miConfig.SecretKey
  17298. pp.AccessKey = miConfig.AccessKey
  17299. pp.OpterName = curRoles.UserName
  17300. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  17301. fmt.Println(requestLog)
  17302. fmt.Println(errMsgLog)
  17303. saveLog(result, requestLog, "4101a", "上传清单")
  17304. var dat map[string]interface{}
  17305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17306. fmt.Println(dat)
  17307. } else {
  17308. fmt.Println(err)
  17309. }
  17310. userJSONBytes, _ := json.Marshal(dat)
  17311. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17312. utils.ErrorLog("解析失败:%v", err)
  17313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17314. return
  17315. }
  17316. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17317. var pp models.PublicParams
  17318. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17319. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17320. pp.FixmedinsName = miConfig.OrgName
  17321. pp.FixmedinsCode = miConfig.Code
  17322. pp.RequestUrl = miConfig.Url
  17323. pp.Cainfo = miConfig.Cainfo
  17324. pp.SecretKey = miConfig.SecretKey
  17325. pp.AccessKey = miConfig.AccessKey
  17326. pp.OpterName = curRoles.UserName
  17327. client := &http.Client{}
  17328. var req *http.Request
  17329. data := make(map[string]interface{})
  17330. data["struct4101"] = struct4101
  17331. data["pp"] = pp
  17332. bytesData, _ := json.Marshal(data)
  17333. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  17334. resp, _ := client.Do(req)
  17335. defer resp.Body.Close()
  17336. body, ioErr := ioutil.ReadAll(resp.Body)
  17337. if ioErr != nil {
  17338. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17340. return
  17341. }
  17342. var respJSON map[string]interface{}
  17343. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17344. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17346. return
  17347. }
  17348. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17349. userJSONBytes, _ := json.Marshal(respJSON)
  17350. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17351. utils.ErrorLog("解析失败:%v", err)
  17352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17353. return
  17354. }
  17355. } else {
  17356. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  17357. var dat map[string]interface{}
  17358. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17359. fmt.Println(dat)
  17360. } else {
  17361. fmt.Println(err)
  17362. }
  17363. userJSONBytes, _ := json.Marshal(dat)
  17364. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17365. utils.ErrorLog("解析失败:%v", err)
  17366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17367. return
  17368. }
  17369. }
  17370. if res.Infcode != 0 {
  17371. errlog := &models.HisOrderError{
  17372. UserOrgId: order.UserOrgId,
  17373. Ctime: time.Now().Unix(),
  17374. Mtime: time.Now().Unix(),
  17375. ErrMsg: res.ErrMsg + "解析失败",
  17376. Status: 1,
  17377. PatientId: order.ID,
  17378. Stage: 10485,
  17379. }
  17380. service.CreateErrMsgLog(errlog)
  17381. continue
  17382. //c.ServeSuccessJSON(map[string]interface{}{
  17383. // "failed_code": -10,
  17384. // "msg": res.ErrMsg,
  17385. //})
  17386. } else {
  17387. //order.FaPiaoNumber = zero
  17388. //order.FaPiaoCode = last_order.FaPiaoCode
  17389. //service.UpdateOrder(order)
  17390. hisFundSettleListResult := &models.HisFundSettleListResult{
  17391. Number: res.Output.SetlListId,
  17392. Status: 1,
  17393. Ctime: time.Now().Unix(),
  17394. Mtime: time.Now().Unix(),
  17395. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17396. IsUpload: 1,
  17397. OrderId: order.ID,
  17398. }
  17399. service.CreateUploadRecord(hisFundSettleListResult)
  17400. continue
  17401. }
  17402. }
  17403. }
  17404. func (c *HisApiController) GetSettleList() {
  17405. order_id, _ := c.GetInt64("order_id")
  17406. admin_user_id, _ := c.GetInt64("admin_user_id")
  17407. order, _ := service.GetHisOrderByIDTwo(order_id)
  17408. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17409. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17410. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17411. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17412. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17413. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17414. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17415. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17416. if order.ID == 0 {
  17417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17418. return
  17419. }
  17420. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17421. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17422. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17423. //fmt.Println(count)
  17424. //var zero string
  17425. //number := count + 1
  17426. //if number >= 1000 {
  17427. // zero = "0000" + strconv.FormatInt(number, 10)
  17428. //} else if number >= 10000 {
  17429. // zero = "000" + strconv.FormatInt(number, 10)
  17430. //} else if number >= 100000 {
  17431. // zero = "00" + strconv.FormatInt(number, 10)
  17432. //} else if number >= 1000000 {
  17433. // zero = "0" + strconv.FormatInt(number, 10)
  17434. //} else {
  17435. // zero = strconv.FormatInt(number, 10)
  17436. //}
  17437. //fmt.Println(zero)
  17438. struct4101 := service.Struct4101{
  17439. PsnNo: order.PsnNo,
  17440. MdtrtId: order.MdtrtId,
  17441. SetlId: order.SetlId,
  17442. PsnName: order.PsnName,
  17443. Gend: order.Gend,
  17444. Brdy: his.Brdy,
  17445. Age: his.Age,
  17446. Naty: order.Naty,
  17447. PatnCertType: "01",
  17448. Certno: order.Certno,
  17449. Prfs: "90",
  17450. ConerName: roles[0].UserName,
  17451. PatnRlts: "99",
  17452. ConerAddr: miConfig.OrgName,
  17453. ConerTel: admin.Mobile,
  17454. HiType: order.Insutype,
  17455. Insuplc: miConfig.InsuplcAdmdvs,
  17456. MaindiagFlag: "1",
  17457. BillCode: order.SetlId,
  17458. BillNo: order.SetlId,
  17459. BizSn: order.Number,
  17460. PsnSelfPay: order.PsnPartAmt,
  17461. PsnOwnPay: order.PsnPartAmt,
  17462. AcctPay: order.AcctPay,
  17463. PsnCashpay: order.PsnCashPay,
  17464. HiPaymtd: "1",
  17465. Hsorg: miConfig.InsuplcAdmdvs,
  17466. HsorgOpter: miConfig.InsuplcAdmdvs,
  17467. MedinsFillPsn: curRoles.UserName,
  17468. MedinsFillDept: miConfig.OrgName,
  17469. IptMedType: "2",
  17470. }
  17471. struct4101.SetlBegnDate = order.SetlTime
  17472. struct4101.SetlEndDate = order.SetlTime
  17473. time_arr := strings.Split(order.SetlTime, " ")
  17474. struct4101.AdmTime = time_arr[0]
  17475. struct4101.AdmEndTime = time_arr[0]
  17476. //
  17477. //var rf []CustomFundPay
  17478. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  17479. //
  17480. //var tempFunPays []service.CustomStruct
  17481. //for _, item := range rf {
  17482. // var tempFunPay service.CustomStruct
  17483. // tempFunPay.FundPayamt = item.FundPayamt
  17484. // tempFunPay.FundPayType = item.FundPayType
  17485. // tempFunPays = append(tempFunPays, tempFunPay)
  17486. //}
  17487. //struct4101.CustomStruct = tempFunPays
  17488. var tempDiaginfos []service.DiaginfoStructTwo
  17489. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17490. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17491. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  17492. var config []*models.HisXtDiagnoseConfig
  17493. for _, item := range diagnosis_ids {
  17494. id, _ := strconv.ParseInt(item, 10, 64)
  17495. diagnosisConfig, _ := service.FindDiagnoseById(id)
  17496. config = append(config, &diagnosisConfig)
  17497. }
  17498. if miConfig.Code == "H15049901371" {
  17499. //for _, item := range config {
  17500. // if item.ID == 138 {
  17501. diagnosisConfig, _ := service.FindDiagnoseById(138)
  17502. var tempDiaginfo service.DiaginfoStructTwo
  17503. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  17504. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  17505. tempDiaginfo.DiagType = "1"
  17506. tempDiaginfo.MaindiagFlag = "1"
  17507. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17508. //}
  17509. //}
  17510. for _, item := range config {
  17511. if item.ID != 138 {
  17512. var tempDiaginfo service.DiaginfoStructTwo
  17513. tempDiaginfo.DiagCode = item.CountryCode
  17514. tempDiaginfo.DiagName = item.CountryContentName
  17515. tempDiaginfo.DiagType = "1"
  17516. tempDiaginfo.MaindiagFlag = "0"
  17517. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17518. }
  17519. }
  17520. } else {
  17521. for index, item := range config {
  17522. if index == 0 {
  17523. var tempDiaginfo service.DiaginfoStructTwo
  17524. tempDiaginfo.DiagCode = item.CountryCode
  17525. tempDiaginfo.DiagName = item.CountryContentName
  17526. tempDiaginfo.DiagType = "1"
  17527. tempDiaginfo.MaindiagFlag = "1"
  17528. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17529. } else {
  17530. var tempDiaginfo service.DiaginfoStructTwo
  17531. tempDiaginfo.DiagCode = item.CountryCode
  17532. tempDiaginfo.DiagName = item.CountryContentName
  17533. tempDiaginfo.DiagType = "1"
  17534. tempDiaginfo.MaindiagFlag = "0"
  17535. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17536. }
  17537. }
  17538. }
  17539. struct4101.Diseinfo = tempDiaginfos
  17540. sickConfigTwo, _ := service.FindSickById(his.SickType)
  17541. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17542. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17543. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17544. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17545. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17546. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17547. var iteminfo service.IteminfoStruct
  17548. var bedCostTotal float64 = 0 //床位总费
  17549. var bedCostSelfTotal float64 = 0 //床位自费
  17550. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17551. var operationCostTotal float64 = 0 //手术费
  17552. var operationCostSelfTotal float64 = 0 //手术费
  17553. var operationCostPartSelfTotal float64 = 0 //手术费
  17554. var otherCostTotal float64 = 0 //其他费用
  17555. var otherCostSelfTotal float64 = 0 //其他费用
  17556. var otherCostPartSelfTotal float64 = 0 //其他费用
  17557. var materialCostTotal float64 = 0 //材料费
  17558. var materialCostSelfTotal float64 = 0 //材料费
  17559. var materialCostPartSelfTotal float64 = 0 //材料费
  17560. var westernMedicineCostTotal float64 = 0 //西药费
  17561. var westernMedicineCostSelfTotal float64 = 0 //西药费
  17562. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17563. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17564. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17565. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17566. var checkCostTotal float64 = 0 //检查费
  17567. var checkCostSelfTotal float64 = 0 //检查费
  17568. var checkCostPartSelfTotal float64 = 0 //检查费
  17569. var laboratoryCostTotal float64 = 0 //化验费
  17570. var laboratoryCostSelfTotal float64 = 0 //化验费
  17571. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17572. var treatCostTotal float64 = 0 //治疗费用
  17573. var treatCostSelfTotal float64 = 0 //治疗费用
  17574. var treatCostPartSelfTotal float64 = 0 //治疗费用
  17575. decimal.DivisionPrecision = 2
  17576. var bed_fulamt_ownpay_amt float64 = 0
  17577. var operation_fulamt_ownpay_amt float64 = 0
  17578. var other_fulamt_ownpay_amt float64 = 0
  17579. var westernMedicine_fulamt_ownpay_amt float64 = 0
  17580. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17581. var check_fulamt_ownpay_amt float64 = 0
  17582. var material_fulamt_ownpay_amt float64 = 0
  17583. var laboratory_fulamt_ownpay_amt float64 = 0
  17584. var treat_fulamt_ownpay_amt float64 = 0
  17585. var bed_claa_sunmfee float64 = 0
  17586. var bed_clab_amt float64 = 0
  17587. var bed_other_amt float64 = 0
  17588. var operation_claa_sunmfee float64 = 0
  17589. var operation_clab_amt float64 = 0
  17590. var operation_other_amt float64 = 0
  17591. var other_claa_sunmfee float64 = 0
  17592. var other_clab_amt float64 = 0
  17593. var other_other_amt float64 = 0
  17594. var westernMedicine_claa_sunmfee float64 = 0
  17595. var westernMedicine_clab_amt float64 = 0
  17596. var westernMedicine_other_amt float64 = 0
  17597. var chineseTraditional_claa_sunmfee float64 = 0
  17598. var chineseTraditional_clab_amt float64 = 0
  17599. var chineseTraditional_other_amt float64 = 0
  17600. var check_claa_sunmfee float64 = 0
  17601. var check_clab_amt float64 = 0
  17602. var check_other_amt float64 = 0
  17603. var material_claa_sunmfee float64 = 0
  17604. var material_clab_amt float64 = 0
  17605. var material_other_amt float64 = 0
  17606. var laboratory_claa_sunmfee float64 = 0
  17607. var laboratory_clab_amt float64 = 0
  17608. var laboratory_other_amt float64 = 0
  17609. var treat_claa_sunmfee float64 = 0
  17610. var treat_clab_amt float64 = 0
  17611. var treat_other_amt float64 = 0
  17612. for _, item := range order.HisOrderInfo {
  17613. if item.MedChrgitmType == "01" { //床位费
  17614. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17615. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17616. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17617. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17618. if item.ChrgitmLv == "1" {
  17619. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17620. }
  17621. if item.ChrgitmLv == "2" {
  17622. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17623. }
  17624. if item.ChrgitmLv == "3" {
  17625. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17626. }
  17627. }
  17628. if item.MedChrgitmType == "03" { //检查费
  17629. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17630. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17631. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17632. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17633. if item.ChrgitmLv == "1" {
  17634. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17635. }
  17636. if item.ChrgitmLv == "2" {
  17637. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17638. }
  17639. if item.ChrgitmLv == "3" {
  17640. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17641. }
  17642. }
  17643. if item.MedChrgitmType == "04" { //化验费
  17644. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17645. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17646. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17647. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17648. if item.ChrgitmLv == "1" {
  17649. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17650. }
  17651. if item.ChrgitmLv == "2" {
  17652. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17653. }
  17654. if item.ChrgitmLv == "3" {
  17655. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17656. }
  17657. }
  17658. if item.MedChrgitmType == "05" { //治疗费
  17659. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17660. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17661. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17662. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17663. if item.ChrgitmLv == "1" {
  17664. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17665. }
  17666. if item.ChrgitmLv == "2" {
  17667. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17668. }
  17669. if item.ChrgitmLv == "3" {
  17670. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17671. }
  17672. }
  17673. if item.MedChrgitmType == "06" { //手术费
  17674. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17675. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17676. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17677. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17678. if item.ChrgitmLv == "1" {
  17679. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17680. }
  17681. if item.ChrgitmLv == "2" {
  17682. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17683. }
  17684. if item.ChrgitmLv == "3" {
  17685. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17686. }
  17687. }
  17688. if item.MedChrgitmType == "08" { //材料费
  17689. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17690. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17691. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17692. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17693. if item.ChrgitmLv == "1" {
  17694. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17695. }
  17696. if item.ChrgitmLv == "2" {
  17697. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17698. }
  17699. if item.ChrgitmLv == "3" {
  17700. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17701. }
  17702. }
  17703. if item.MedChrgitmType == "09" { //西药费
  17704. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17705. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17706. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17707. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17708. if item.ChrgitmLv == "1" {
  17709. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17710. }
  17711. if item.ChrgitmLv == "2" {
  17712. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17713. }
  17714. if item.ChrgitmLv == "3" {
  17715. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17716. }
  17717. }
  17718. if item.MedChrgitmType == "11" { //中成费
  17719. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17720. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17721. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17722. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17723. if item.ChrgitmLv == "1" {
  17724. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17725. }
  17726. if item.ChrgitmLv == "2" {
  17727. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17728. }
  17729. if item.ChrgitmLv == "3" {
  17730. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17731. }
  17732. }
  17733. if item.MedChrgitmType == "14" { //其他费
  17734. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17735. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17736. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17737. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17738. if item.ChrgitmLv == "1" {
  17739. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17740. }
  17741. if item.ChrgitmLv == "2" {
  17742. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17743. }
  17744. if item.ChrgitmLv == "3" {
  17745. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17746. }
  17747. }
  17748. }
  17749. var iteminfoStructs []service.IteminfoStruct
  17750. if bedCostTotal != 0 {
  17751. iteminfo.MedChrgitm = "01"
  17752. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17753. iteminfo.Amt = bedCostTotal
  17754. iteminfo.ClaaSumfee = bed_claa_sunmfee
  17755. iteminfo.ClabAmt = bed_clab_amt
  17756. iteminfo.OthAmt = bed_other_amt
  17757. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17758. }
  17759. if checkCostTotal != 0 {
  17760. iteminfo.MedChrgitm = "03"
  17761. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  17762. iteminfo.Amt = checkCostTotal
  17763. iteminfo.ClaaSumfee = check_claa_sunmfee
  17764. iteminfo.ClabAmt = check_clab_amt
  17765. iteminfo.OthAmt = check_other_amt
  17766. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17767. }
  17768. if laboratoryCostTotal != 0 {
  17769. iteminfo.MedChrgitm = "04"
  17770. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  17771. iteminfo.Amt = laboratoryCostTotal
  17772. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  17773. iteminfo.ClabAmt = laboratory_clab_amt
  17774. iteminfo.OthAmt = laboratory_other_amt
  17775. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17776. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17777. }
  17778. if treatCostTotal != 0 {
  17779. iteminfo.MedChrgitm = "05"
  17780. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  17781. iteminfo.Amt = treatCostTotal
  17782. iteminfo.ClaaSumfee = treat_claa_sunmfee
  17783. iteminfo.ClabAmt = treat_clab_amt
  17784. iteminfo.OthAmt = treat_other_amt
  17785. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17786. //(struct4101.IteminfoStruct, iteminfo)
  17787. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17788. }
  17789. if operationCostTotal != 0 {
  17790. iteminfo.MedChrgitm = "06"
  17791. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17792. iteminfo.Amt = operationCostTotal
  17793. iteminfo.ClaaSumfee = operation_claa_sunmfee
  17794. iteminfo.ClabAmt = operation_clab_amt
  17795. iteminfo.OthAmt = operation_other_amt
  17796. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17797. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17798. }
  17799. if materialCostTotal != 0 {
  17800. iteminfo.MedChrgitm = "08"
  17801. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  17802. iteminfo.Amt = materialCostTotal
  17803. iteminfo.ClaaSumfee = material_claa_sunmfee
  17804. iteminfo.ClabAmt = material_clab_amt
  17805. iteminfo.OthAmt = material_other_amt
  17806. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17807. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17808. }
  17809. if westernMedicineCostTotal != 0 {
  17810. iteminfo.MedChrgitm = "09"
  17811. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17812. iteminfo.Amt = westernMedicineCostTotal
  17813. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17814. iteminfo.ClabAmt = westernMedicine_clab_amt
  17815. iteminfo.OthAmt = westernMedicine_other_amt
  17816. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17817. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17818. }
  17819. if chineseTraditionalMedicineCostTotal != 0 {
  17820. iteminfo.MedChrgitm = "11"
  17821. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17822. iteminfo.Amt = westernMedicineCostTotal
  17823. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17824. iteminfo.ClabAmt = westernMedicine_clab_amt
  17825. iteminfo.OthAmt = westernMedicine_other_amt
  17826. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17827. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17828. }
  17829. if otherCostTotal != 0 {
  17830. iteminfo.MedChrgitm = "14"
  17831. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  17832. iteminfo.Amt = otherCostTotal
  17833. iteminfo.ClaaSumfee = other_claa_sunmfee
  17834. iteminfo.ClabAmt = other_clab_amt
  17835. iteminfo.OthAmt = other_other_amt
  17836. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17837. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17838. }
  17839. struct4101.IteminfoStruct = iteminfoStructs
  17840. struct4101.Ntly = "中国"
  17841. struct4101.AdmCaty = "A03.06"
  17842. struct4101.DoctorName = doctor.UserName
  17843. struct4101.DoctorCode = doctor.DoctorNumber
  17844. var res ResultSeventeen
  17845. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17846. struct4101.BillCode = order.Number
  17847. struct4101.BillNo = order.SetlId
  17848. var resOther ResultSeventeenOther
  17849. var pp models.PublicParams
  17850. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17851. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17852. pp.FixmedinsName = miConfig.OrgName
  17853. pp.FixmedinsCode = miConfig.Code
  17854. pp.RequestUrl = miConfig.Url
  17855. pp.Cainfo = miConfig.Cainfo
  17856. pp.SecretKey = miConfig.SecretKey
  17857. pp.AccessKey = miConfig.AccessKey
  17858. pp.OpterName = curRoles.UserName
  17859. client := &http.Client{}
  17860. var req *http.Request
  17861. data := make(map[string]interface{})
  17862. data["struct4101"] = struct4101
  17863. data["pp"] = pp
  17864. bytesData, _ := json.Marshal(data)
  17865. if miConfig.MdtrtareaAdmvs == "320921" {
  17866. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17867. } else {
  17868. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17869. }
  17870. resp, _ := client.Do(req)
  17871. defer resp.Body.Close()
  17872. body, ioErr := ioutil.ReadAll(resp.Body)
  17873. if ioErr != nil {
  17874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17876. return
  17877. }
  17878. var respJSON map[string]interface{}
  17879. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17882. return
  17883. }
  17884. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17885. userJSONBytes, _ := json.Marshal(respJSON)
  17886. fmt.Println("log")
  17887. fmt.Println(string(userJSONBytes))
  17888. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17889. utils.ErrorLog("解析失败:%v", err)
  17890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17891. return
  17892. }
  17893. res.InfRefmsgid = resOther.InfRefmsgid
  17894. res.Output = resOther.Output
  17895. res.ErrMsg = resOther.ErrMsg
  17896. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17897. res.Infcode = infocode
  17898. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17899. var pp models.PublicParams
  17900. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  17901. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17902. pp.FixmedinsName = miConfig.OrgName
  17903. pp.FixmedinsCode = miConfig.Code
  17904. pp.RequestUrl = miConfig.Url
  17905. pp.Cainfo = miConfig.Cainfo
  17906. pp.SecretKey = miConfig.SecretKey
  17907. pp.AccessKey = miConfig.AccessKey
  17908. pp.OpterName = curRoles.UserName
  17909. result, _ := service.Jxyb4101(struct4101, pp)
  17910. var dat map[string]interface{}
  17911. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17912. fmt.Println(dat)
  17913. } else {
  17914. fmt.Println(err)
  17915. }
  17916. userJSONBytes, _ := json.Marshal(dat)
  17917. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17918. utils.ErrorLog("解析失败:%v", err)
  17919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17920. return
  17921. }
  17922. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17923. var pp models.PublicParams
  17924. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17925. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17926. pp.FixmedinsName = miConfig.OrgName
  17927. pp.FixmedinsCode = miConfig.Code
  17928. pp.RequestUrl = miConfig.Url
  17929. pp.Cainfo = miConfig.Cainfo
  17930. pp.SecretKey = miConfig.SecretKey
  17931. pp.AccessKey = miConfig.AccessKey
  17932. pp.OpterName = curRoles.UserName
  17933. result, _ := service.Hnyb4101(struct4101, pp)
  17934. var dat map[string]interface{}
  17935. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17936. fmt.Println(dat)
  17937. } else {
  17938. fmt.Println(err)
  17939. }
  17940. userJSONBytes, _ := json.Marshal(dat)
  17941. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17942. utils.ErrorLog("解析失败:%v", err)
  17943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17944. return
  17945. }
  17946. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17947. var resOther ResultSeventeenOther
  17948. var pp models.PublicParams
  17949. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17950. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17951. pp.FixmedinsName = miConfig.OrgName
  17952. pp.FixmedinsCode = miConfig.Code
  17953. pp.RequestUrl = miConfig.Url
  17954. pp.Cainfo = miConfig.Cainfo
  17955. pp.SecretKey = miConfig.SecretKey
  17956. pp.AccessKey = miConfig.AccessKey
  17957. pp.OpterName = curRoles.UserName
  17958. client := &http.Client{}
  17959. var req *http.Request
  17960. data := make(map[string]interface{})
  17961. data["struct4101"] = struct4101
  17962. data["pp"] = pp
  17963. bytesData, _ := json.Marshal(data)
  17964. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  17965. resp, _ := client.Do(req)
  17966. defer resp.Body.Close()
  17967. body, ioErr := ioutil.ReadAll(resp.Body)
  17968. if ioErr != nil {
  17969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17971. return
  17972. }
  17973. var respJSON map[string]interface{}
  17974. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17977. return
  17978. }
  17979. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17980. userJSONBytes, _ := json.Marshal(respJSON)
  17981. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17982. utils.ErrorLog("解析失败:%v", err)
  17983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17984. return
  17985. }
  17986. res.InfRefmsgid = resOther.InfRefmsgid
  17987. res.Output = resOther.Output
  17988. res.ErrMsg = resOther.ErrMsg
  17989. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17990. res.Infcode = infocode
  17991. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17992. var pp models.PublicParams
  17993. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17994. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17995. pp.FixmedinsName = miConfig.OrgName
  17996. pp.FixmedinsCode = miConfig.Code
  17997. pp.RequestUrl = miConfig.Url
  17998. pp.Cainfo = miConfig.Cainfo
  17999. pp.SecretKey = miConfig.SecretKey
  18000. pp.AccessKey = miConfig.AccessKey
  18001. pp.OpterName = curRoles.UserName
  18002. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18003. fmt.Println(requestLog)
  18004. fmt.Println(errMsgLog)
  18005. saveLog(result, requestLog, "4101a", "上传清单")
  18006. var dat map[string]interface{}
  18007. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18008. fmt.Println(dat)
  18009. } else {
  18010. fmt.Println(err)
  18011. }
  18012. userJSONBytes, _ := json.Marshal(dat)
  18013. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18014. utils.ErrorLog("解析失败:%v", err)
  18015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18016. return
  18017. }
  18018. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18019. var pp models.PublicParams
  18020. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18021. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18022. pp.FixmedinsName = miConfig.OrgName
  18023. pp.FixmedinsCode = miConfig.Code
  18024. pp.RequestUrl = miConfig.Url
  18025. pp.Cainfo = miConfig.Cainfo
  18026. pp.SecretKey = miConfig.SecretKey
  18027. pp.AccessKey = miConfig.AccessKey
  18028. pp.OpterName = curRoles.UserName
  18029. client := &http.Client{}
  18030. var req *http.Request
  18031. data := make(map[string]interface{})
  18032. data["struct4101"] = struct4101
  18033. data["pp"] = pp
  18034. bytesData, _ := json.Marshal(data)
  18035. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  18036. resp, _ := client.Do(req)
  18037. defer resp.Body.Close()
  18038. body, ioErr := ioutil.ReadAll(resp.Body)
  18039. if ioErr != nil {
  18040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18042. return
  18043. }
  18044. var respJSON map[string]interface{}
  18045. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18048. return
  18049. }
  18050. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18051. userJSONBytes, _ := json.Marshal(respJSON)
  18052. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18053. utils.ErrorLog("解析失败:%v", err)
  18054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18055. return
  18056. }
  18057. } else {
  18058. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  18059. var dat map[string]interface{}
  18060. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18061. fmt.Println(dat)
  18062. } else {
  18063. fmt.Println(err)
  18064. }
  18065. userJSONBytes, _ := json.Marshal(dat)
  18066. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18067. utils.ErrorLog("解析失败:%v", err)
  18068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18069. return
  18070. }
  18071. }
  18072. if res.Infcode != 0 {
  18073. c.ServeSuccessJSON(map[string]interface{}{
  18074. "failed_code": -10,
  18075. "msg": res.ErrMsg,
  18076. })
  18077. return
  18078. } else {
  18079. //order.FaPiaoNumber = zero
  18080. //order.FaPiaoCode = last_order.FaPiaoCode
  18081. //service.UpdateOrder(order)
  18082. hisFundSettleListResult := &models.HisFundSettleListResult{
  18083. Number: res.Output.SetlListId,
  18084. Status: 1,
  18085. Ctime: time.Now().Unix(),
  18086. Mtime: time.Now().Unix(),
  18087. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18088. IsUpload: 1,
  18089. OrderId: order_id,
  18090. }
  18091. service.CreateUploadRecord(hisFundSettleListResult)
  18092. c.ServeSuccessJSON(map[string]interface{}{
  18093. "msg": "上传成功",
  18094. "result": hisFundSettleListResult,
  18095. })
  18096. return
  18097. }
  18098. }
  18099. func (c *HisApiController) GetSettleListHospital() {
  18100. order_id, _ := c.GetInt64("order_id")
  18101. admin_user_id, _ := c.GetInt64("admin_user_id")
  18102. order, _ := service.GetHisOrderByIDTwo(order_id)
  18103. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18104. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  18105. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18106. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18107. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18108. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18109. if order.ID == 0 {
  18110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18111. return
  18112. }
  18113. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18114. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18115. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18116. fmt.Println(count)
  18117. var zero string
  18118. number := count + 1
  18119. if number >= 1000 {
  18120. zero = "0000" + strconv.FormatInt(number, 10)
  18121. } else if number >= 10000 {
  18122. zero = "000" + strconv.FormatInt(number, 10)
  18123. } else if number >= 100000 {
  18124. zero = "00" + strconv.FormatInt(number, 10)
  18125. } else if number >= 1000000 {
  18126. zero = "0" + strconv.FormatInt(number, 10)
  18127. } else {
  18128. zero = strconv.FormatInt(number, 10)
  18129. }
  18130. fmt.Println(zero)
  18131. struct4101 := service.Struct4101{
  18132. PsnNo: order.PsnNo,
  18133. MdtrtId: order.MdtrtId,
  18134. SetlId: order.SetlId,
  18135. PsnName: order.PsnName,
  18136. Gend: order.Gend,
  18137. Brdy: his.Brdy,
  18138. Age: int64(order.Age),
  18139. Naty: order.Naty,
  18140. PatnCertType: "01",
  18141. Certno: order.Certno,
  18142. Prfs: "90",
  18143. ConerName: roles[0].UserName,
  18144. PatnRlts: "99",
  18145. ConerAddr: miConfig.OrgName,
  18146. ConerTel: admin.Mobile,
  18147. HiType: order.Insutype,
  18148. Insuplc: miConfig.InsuplcAdmdvs,
  18149. MaindiagFlag: "1",
  18150. BillCode: order.SetlId,
  18151. BillNo: order.SetlId,
  18152. BizSn: order.Number,
  18153. PsnSelfPay: order.PsnPartAmt,
  18154. PsnOwnPay: order.PsnPartAmt,
  18155. AcctPay: order.AcctPay,
  18156. PsnCashpay: order.PsnCashPay,
  18157. HiPaymtd: "1",
  18158. Hsorg: miConfig.InsuplcAdmdvs,
  18159. HsorgOpter: miConfig.InsuplcAdmdvs,
  18160. MedinsFillPsn: curRoles.UserName,
  18161. MedinsFillDept: depart.Name,
  18162. IptMedType: "2",
  18163. AdmTime: his.InHosptialTime,
  18164. AdmEndTime: his.OutHosptialTime,
  18165. }
  18166. struct4101.SetlBegnDate = order.SetlTime
  18167. struct4101.SetlEndDate = order.SetlTime
  18168. //var rf []CustomFundPay
  18169. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18170. //
  18171. //var tempFunPays []service.CustomStruct
  18172. //for _, item := range rf {
  18173. // var tempFunPay service.CustomStruct
  18174. // tempFunPay.FundPayamt = item.FundPayamt
  18175. // tempFunPay.FundPayType = item.FundPayType
  18176. // tempFunPays = append(tempFunPays, tempFunPay)
  18177. //}
  18178. //struct4101.CustomStruct = tempFunPays
  18179. var tempDiaginfos []service.DiaginfoStructTwo
  18180. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18181. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18182. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  18183. //for _, item := range infos {
  18184. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  18185. //}
  18186. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  18187. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  18188. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18189. fmt.Println(diagnosis_ids_arr)
  18190. if order.UserOrgId == 10210 {
  18191. var diagnosis_ids_arr_two []int64
  18192. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  18193. var config []*models.HisXtDiagnoseConfig
  18194. for _, id := range diagnosis_ids_arr_two {
  18195. //id, _ := strconv.ParseInt(item, 10, 64)
  18196. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18197. if diagnosisConfig.ID > 0 {
  18198. config = append(config, &diagnosisConfig)
  18199. }
  18200. }
  18201. for index, item := range config {
  18202. if item.ID > 0 {
  18203. if index == 0 {
  18204. var tempDiaginfo service.DiaginfoStructTwo
  18205. tempDiaginfo.DiagCode = item.CountryCode
  18206. tempDiaginfo.DiagName = item.CountryContentName
  18207. tempDiaginfo.DiagType = "1"
  18208. tempDiaginfo.MaindiagFlag = "1"
  18209. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18210. } else {
  18211. var tempDiaginfo service.DiaginfoStructTwo
  18212. tempDiaginfo.DiagCode = item.CountryCode
  18213. tempDiaginfo.DiagName = item.CountryContentName
  18214. tempDiaginfo.DiagType = "1"
  18215. tempDiaginfo.MaindiagFlag = "0"
  18216. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18217. }
  18218. }
  18219. }
  18220. struct4101.Diseinfo = tempDiaginfos
  18221. } else {
  18222. var config []*models.HisXtDiagnoseConfig
  18223. for _, item := range diagnosis_ids_arr {
  18224. id, _ := strconv.ParseInt(item, 10, 64)
  18225. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18226. if diagnosisConfig.ID > 0 {
  18227. config = append(config, &diagnosisConfig)
  18228. }
  18229. }
  18230. for index, item := range config {
  18231. if item.ID > 0 {
  18232. if index == 0 {
  18233. var tempDiaginfo service.DiaginfoStructTwo
  18234. tempDiaginfo.DiagCode = item.CountryCode
  18235. tempDiaginfo.DiagName = item.CountryContentName
  18236. tempDiaginfo.DiagType = "1"
  18237. tempDiaginfo.MaindiagFlag = "1"
  18238. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18239. } else {
  18240. var tempDiaginfo service.DiaginfoStructTwo
  18241. tempDiaginfo.DiagCode = item.CountryCode
  18242. tempDiaginfo.DiagName = item.CountryContentName
  18243. tempDiaginfo.DiagType = "1"
  18244. tempDiaginfo.MaindiagFlag = "0"
  18245. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18246. }
  18247. }
  18248. }
  18249. struct4101.Diseinfo = tempDiaginfos
  18250. }
  18251. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18252. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18253. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18254. tempOpspdiseinfo2.OprnOprtCode = ""
  18255. tempOpspdiseinfo2.OprnOprtName = ""
  18256. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18257. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18258. var iteminfo service.IteminfoStruct
  18259. var bedCostTotal float64 = 0 //床位总费
  18260. var bedCostSelfTotal float64 = 0 //床位自费
  18261. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18262. var operationCostTotal float64 = 0 //手术费
  18263. var operationCostSelfTotal float64 = 0 //手术费
  18264. var operationCostPartSelfTotal float64 = 0 //手术费
  18265. var otherCostTotal float64 = 0 //其他费用
  18266. var otherCostSelfTotal float64 = 0 //其他费用
  18267. var otherCostPartSelfTotal float64 = 0 //其他费用
  18268. var materialCostTotal float64 = 0 //材料费
  18269. var materialCostSelfTotal float64 = 0 //材料费
  18270. var materialCostPartSelfTotal float64 = 0 //材料费
  18271. var westernMedicineCostTotal float64 = 0 //西药费
  18272. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18273. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18274. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18275. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18276. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18277. var checkCostTotal float64 = 0 //检查费
  18278. var checkCostSelfTotal float64 = 0 //检查费
  18279. var checkCostPartSelfTotal float64 = 0 //检查费
  18280. var laboratoryCostTotal float64 = 0 //化验费
  18281. var laboratoryCostSelfTotal float64 = 0 //化验费
  18282. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18283. var treatCostTotal float64 = 0 //治疗费用
  18284. var treatCostSelfTotal float64 = 0 //治疗费用
  18285. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18286. decimal.DivisionPrecision = 2
  18287. var bed_fulamt_ownpay_amt float64 = 0
  18288. var operation_fulamt_ownpay_amt float64 = 0
  18289. var other_fulamt_ownpay_amt float64 = 0
  18290. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18291. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18292. var check_fulamt_ownpay_amt float64 = 0
  18293. var material_fulamt_ownpay_amt float64 = 0
  18294. var laboratory_fulamt_ownpay_amt float64 = 0
  18295. var treat_fulamt_ownpay_amt float64 = 0
  18296. var bed_claa_sunmfee float64 = 0
  18297. var bed_clab_amt float64 = 0
  18298. var bed_other_amt float64 = 0
  18299. var operation_claa_sunmfee float64 = 0
  18300. var operation_clab_amt float64 = 0
  18301. var operation_other_amt float64 = 0
  18302. var other_claa_sunmfee float64 = 0
  18303. var other_clab_amt float64 = 0
  18304. var other_other_amt float64 = 0
  18305. var westernMedicine_claa_sunmfee float64 = 0
  18306. var westernMedicine_clab_amt float64 = 0
  18307. var westernMedicine_other_amt float64 = 0
  18308. var chineseTraditional_claa_sunmfee float64 = 0
  18309. var chineseTraditional_clab_amt float64 = 0
  18310. var chineseTraditional_other_amt float64 = 0
  18311. var check_claa_sunmfee float64 = 0
  18312. var check_clab_amt float64 = 0
  18313. var check_other_amt float64 = 0
  18314. var material_claa_sunmfee float64 = 0
  18315. var material_clab_amt float64 = 0
  18316. var material_other_amt float64 = 0
  18317. var laboratory_claa_sunmfee float64 = 0
  18318. var laboratory_clab_amt float64 = 0
  18319. var laboratory_other_amt float64 = 0
  18320. var treat_claa_sunmfee float64 = 0
  18321. var treat_clab_amt float64 = 0
  18322. var treat_other_amt float64 = 0
  18323. for _, item := range order.HisOrderInfo {
  18324. if item.MedChrgitmType == "01" { //床位费
  18325. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18326. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18327. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18328. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18329. if item.ChrgitmLv == "1" {
  18330. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18331. }
  18332. if item.ChrgitmLv == "2" {
  18333. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18334. }
  18335. if item.ChrgitmLv == "3" {
  18336. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18337. }
  18338. }
  18339. if item.MedChrgitmType == "03" { //检查费
  18340. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18341. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18342. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18343. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18344. if item.ChrgitmLv == "1" {
  18345. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18346. }
  18347. if item.ChrgitmLv == "2" {
  18348. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18349. }
  18350. if item.ChrgitmLv == "3" {
  18351. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18352. }
  18353. }
  18354. if item.MedChrgitmType == "04" { //化验费
  18355. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18356. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18357. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18358. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18359. if item.ChrgitmLv == "1" {
  18360. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18361. }
  18362. if item.ChrgitmLv == "2" {
  18363. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18364. }
  18365. if item.ChrgitmLv == "3" {
  18366. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18367. }
  18368. }
  18369. if item.MedChrgitmType == "05" { //治疗费
  18370. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18371. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18372. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18373. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18374. if item.ChrgitmLv == "1" {
  18375. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18376. }
  18377. if item.ChrgitmLv == "2" {
  18378. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18379. }
  18380. if item.ChrgitmLv == "3" {
  18381. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18382. }
  18383. }
  18384. if item.MedChrgitmType == "06" { //手术费
  18385. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18386. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18387. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18388. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18389. if item.ChrgitmLv == "1" {
  18390. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18391. }
  18392. if item.ChrgitmLv == "2" {
  18393. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18394. }
  18395. if item.ChrgitmLv == "3" {
  18396. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18397. }
  18398. }
  18399. if item.MedChrgitmType == "08" { //材料费
  18400. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18401. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18402. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18403. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18404. if item.ChrgitmLv == "1" {
  18405. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18406. }
  18407. if item.ChrgitmLv == "2" {
  18408. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18409. }
  18410. if item.ChrgitmLv == "3" {
  18411. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18412. }
  18413. }
  18414. if item.MedChrgitmType == "09" { //西药费
  18415. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18416. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18417. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18418. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18419. if item.ChrgitmLv == "1" {
  18420. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18421. }
  18422. if item.ChrgitmLv == "2" {
  18423. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18424. }
  18425. if item.ChrgitmLv == "3" {
  18426. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18427. }
  18428. }
  18429. if item.MedChrgitmType == "11" { //中成费
  18430. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18431. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18432. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18433. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18434. if item.ChrgitmLv == "1" {
  18435. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18436. }
  18437. if item.ChrgitmLv == "2" {
  18438. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18439. }
  18440. if item.ChrgitmLv == "3" {
  18441. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18442. }
  18443. }
  18444. if item.MedChrgitmType == "14" { //其他费
  18445. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18446. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18447. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18448. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18449. if item.ChrgitmLv == "1" {
  18450. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18451. }
  18452. if item.ChrgitmLv == "2" {
  18453. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18454. }
  18455. if item.ChrgitmLv == "3" {
  18456. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18457. }
  18458. }
  18459. }
  18460. var iteminfoStructs []service.IteminfoStruct
  18461. if bedCostTotal != 0 {
  18462. iteminfo.MedChrgitm = "01"
  18463. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18464. iteminfo.Amt = bedCostTotal
  18465. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18466. iteminfo.ClabAmt = bed_clab_amt
  18467. iteminfo.OthAmt = bed_other_amt
  18468. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18469. }
  18470. if checkCostTotal != 0 {
  18471. iteminfo.MedChrgitm = "03"
  18472. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18473. iteminfo.Amt = checkCostTotal
  18474. iteminfo.ClaaSumfee = check_claa_sunmfee
  18475. iteminfo.ClabAmt = check_clab_amt
  18476. iteminfo.OthAmt = check_other_amt
  18477. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18478. }
  18479. if laboratoryCostTotal != 0 {
  18480. iteminfo.MedChrgitm = "04"
  18481. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18482. iteminfo.Amt = laboratoryCostTotal
  18483. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18484. iteminfo.ClabAmt = laboratory_clab_amt
  18485. iteminfo.OthAmt = laboratory_other_amt
  18486. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18487. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18488. }
  18489. if treatCostTotal != 0 {
  18490. iteminfo.MedChrgitm = "05"
  18491. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18492. iteminfo.Amt = treatCostTotal
  18493. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18494. iteminfo.ClabAmt = treat_clab_amt
  18495. iteminfo.OthAmt = treat_other_amt
  18496. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18497. //(struct4101.IteminfoStruct, iteminfo)
  18498. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18499. }
  18500. if operationCostTotal != 0 {
  18501. iteminfo.MedChrgitm = "06"
  18502. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18503. iteminfo.Amt = operationCostTotal
  18504. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18505. iteminfo.ClabAmt = operation_clab_amt
  18506. iteminfo.OthAmt = operation_other_amt
  18507. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18508. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18509. }
  18510. if materialCostTotal != 0 {
  18511. iteminfo.MedChrgitm = "08"
  18512. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18513. iteminfo.Amt = materialCostTotal
  18514. iteminfo.ClaaSumfee = material_claa_sunmfee
  18515. iteminfo.ClabAmt = material_clab_amt
  18516. iteminfo.OthAmt = material_other_amt
  18517. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18518. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18519. }
  18520. if westernMedicineCostTotal != 0 {
  18521. iteminfo.MedChrgitm = "09"
  18522. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18523. iteminfo.Amt = westernMedicineCostTotal
  18524. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18525. iteminfo.ClabAmt = westernMedicine_clab_amt
  18526. iteminfo.OthAmt = westernMedicine_other_amt
  18527. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18528. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18529. }
  18530. if chineseTraditionalMedicineCostTotal != 0 {
  18531. iteminfo.MedChrgitm = "11"
  18532. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18533. iteminfo.Amt = westernMedicineCostTotal
  18534. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18535. iteminfo.ClabAmt = westernMedicine_clab_amt
  18536. iteminfo.OthAmt = westernMedicine_other_amt
  18537. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18538. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18539. }
  18540. if otherCostTotal != 0 {
  18541. iteminfo.MedChrgitm = "14"
  18542. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18543. iteminfo.Amt = otherCostTotal
  18544. iteminfo.ClaaSumfee = other_claa_sunmfee
  18545. iteminfo.ClabAmt = other_clab_amt
  18546. iteminfo.OthAmt = other_other_amt
  18547. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18548. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18549. }
  18550. struct4101.IteminfoStruct = iteminfoStructs
  18551. struct4101.Ntly = "中国"
  18552. struct4101.AdmCaty = "A03.06"
  18553. var resOther ResultSeventeenOther
  18554. var res ResultSeventeen
  18555. if miConfig.MdtrtareaAdmvs == "150499" {
  18556. var pp models.PublicParams
  18557. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18558. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18559. pp.FixmedinsName = miConfig.OrgName
  18560. pp.FixmedinsCode = miConfig.Code
  18561. pp.RequestUrl = miConfig.Url
  18562. pp.Cainfo = miConfig.Cainfo
  18563. pp.SecretKey = miConfig.SecretKey
  18564. pp.AccessKey = miConfig.AccessKey
  18565. pp.OpterName = curRoles.UserName
  18566. client := &http.Client{}
  18567. var req *http.Request
  18568. data := make(map[string]interface{})
  18569. data["struct4101"] = struct4101
  18570. data["pp"] = pp
  18571. bytesData, _ := json.Marshal(data)
  18572. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18573. resp, _ := client.Do(req)
  18574. defer resp.Body.Close()
  18575. body, ioErr := ioutil.ReadAll(resp.Body)
  18576. if ioErr != nil {
  18577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18579. return
  18580. }
  18581. var respJSON map[string]interface{}
  18582. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18585. return
  18586. }
  18587. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18588. userJSONBytes, _ := json.Marshal(respJSON)
  18589. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18590. utils.ErrorLog("解析失败:%v", err)
  18591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18592. return
  18593. }
  18594. res.InfRefmsgid = resOther.InfRefmsgid
  18595. res.Output = resOther.Output
  18596. res.ErrMsg = resOther.ErrMsg
  18597. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18598. res.Infcode = infocode
  18599. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18600. var pp models.PublicParams
  18601. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18602. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18603. pp.FixmedinsName = miConfig.OrgName
  18604. pp.FixmedinsCode = miConfig.Code
  18605. pp.RequestUrl = miConfig.Url
  18606. pp.Cainfo = miConfig.Cainfo
  18607. pp.SecretKey = miConfig.SecretKey
  18608. pp.AccessKey = miConfig.AccessKey
  18609. pp.OpterName = curRoles.UserName
  18610. result, _ := service.Jxyb4101(struct4101, pp)
  18611. var dat map[string]interface{}
  18612. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18613. fmt.Println(dat)
  18614. } else {
  18615. fmt.Println(err)
  18616. }
  18617. userJSONBytes, _ := json.Marshal(dat)
  18618. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18619. utils.ErrorLog("解析失败:%v", err)
  18620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18621. return
  18622. }
  18623. } else {
  18624. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  18625. var dat map[string]interface{}
  18626. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18627. fmt.Println(dat)
  18628. } else {
  18629. fmt.Println(err)
  18630. }
  18631. userJSONBytes, _ := json.Marshal(dat)
  18632. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18633. utils.ErrorLog("解析失败:%v", err)
  18634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18635. return
  18636. }
  18637. }
  18638. if res.Infcode != 0 {
  18639. c.ServeSuccessJSON(map[string]interface{}{
  18640. "failed_code": -10,
  18641. "msg": res.ErrMsg,
  18642. })
  18643. return
  18644. } else {
  18645. if miConfig.MdtrtareaAdmvs != "150499" {
  18646. order.FaPiaoNumber = zero
  18647. order.FaPiaoCode = last_order.FaPiaoCode
  18648. service.UpdateOrder(order)
  18649. }
  18650. hisFundSettleListResult := &models.HisFundSettleListResult{
  18651. Number: res.Output.SetlListId,
  18652. Status: 1,
  18653. Ctime: time.Now().Unix(),
  18654. Mtime: time.Now().Unix(),
  18655. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18656. IsUpload: 1,
  18657. OrderId: order_id,
  18658. }
  18659. service.CreateUploadRecord(hisFundSettleListResult)
  18660. c.ServeSuccessJSON(map[string]interface{}{
  18661. "msg": "上传成功",
  18662. "result": hisFundSettleListResult,
  18663. })
  18664. return
  18665. }
  18666. }
  18667. //func (c *HisApiController) GetBatchSettleList() {
  18668. // orders, _ := service.GetAllHisOrder(10106)
  18669. // for _, item := range orders {
  18670. // order_id := item.ID
  18671. // order, _ := service.GetHisOrderByIDTwo(order_id)
  18672. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18673. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18674. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18675. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  18676. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18677. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18678. //
  18679. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18680. //
  18681. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18682. //
  18683. // if order.ID == 0 {
  18684. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18685. // return
  18686. // }
  18687. // if his.BalanceAccountsType == 2 {
  18688. // continue
  18689. // }
  18690. // struct4101 := service.Struct4101{
  18691. // PsnNo: order.PsnNo,
  18692. // MdtrtId: order.MdtrtId,
  18693. // SetlId: order.SetlId,
  18694. // PsnName: order.PsnName,
  18695. // Gend: order.Gend,
  18696. // Brdy: his.Brdy,
  18697. // Age: his.Age,
  18698. // Naty: order.Naty,
  18699. // PatnCertType: "01",
  18700. // Certno: order.Certno,
  18701. // Prfs: "90",
  18702. // ConerName: roles[0].UserName,
  18703. // PatnRlts: "99",
  18704. // ConerAddr: miConfig.OrgName,
  18705. // ConerTel: admin.Mobile,
  18706. // HiType: order.Insutype,
  18707. // Insuplc: his.InsuplcAdmdvs,
  18708. // MaindiagFlag: "1",
  18709. // BillCode: order.SetlId,
  18710. // BillNo: order.SetlId,
  18711. // BizSn: order.Number,
  18712. // PsnSelfPay: order.PsnPartAmt,
  18713. // PsnOwnPay: order.PsnPartAmt,
  18714. // AcctPay: order.AcctPay,
  18715. // PsnCashpay: order.PsnCashPay,
  18716. // HiPaymtd: "1",
  18717. // Hsorg: his.InsuplcAdmdvs,
  18718. // HsorgOpter: his.InsuplcAdmdvs,
  18719. // MedinsFillPsn: curRoles.UserName,
  18720. // MedinsFillDept: depart.Name,
  18721. // IptMedType: "2",
  18722. // }
  18723. // struct4101.SetlBegnDate = order.SetlTime
  18724. // struct4101.SetlEndDate = order.SetlTime
  18725. // //if order.SettleType == 1 {
  18726. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  18727. // // dateStr := t.Format("2006-01-02")
  18728. // // struct4101.SetlBegnDate = dateStr
  18729. // // struct4101.SetlEndDate = dateStr
  18730. // //} else {
  18731. // // t := time.Unix(int64(order.SettleStartTime), 0)
  18732. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  18733. // // dateStartStr := t.Format("2006-01-02")
  18734. // // dateEndStr := t2.Format("2006-01-02")
  18735. // // struct4101.SetlBegnDate = dateStartStr
  18736. // // struct4101.SetlEndDate = dateEndStr
  18737. // //}
  18738. //
  18739. // var rf []CustomFundPay
  18740. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18741. //
  18742. // var tempFunPays []service.CustomStruct
  18743. // var tempFunPay610100 service.CustomStruct
  18744. //
  18745. // for _, item := range rf {
  18746. // if item.FundPayType == "610100" {
  18747. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  18748. // tempFunPay610100.FundPayType = item.FundPayType
  18749. // } else {
  18750. // var tempFunPay service.CustomStruct
  18751. // tempFunPay.FundPayamt = item.FundPayamt
  18752. // tempFunPay.FundPayType = item.FundPayType
  18753. // tempFunPays = append(tempFunPays, tempFunPay)
  18754. // }
  18755. // }
  18756. // tempFunPays = append(tempFunPays, tempFunPay610100)
  18757. // struct4101.CustomStruct = tempFunPays
  18758. //
  18759. // var tempDiaginfos []service.DiaginfoStructTwo
  18760. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18761. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18762. //
  18763. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18764. // var config []*models.HisXtDiagnoseConfig
  18765. // for _, item := range diagnosis_ids {
  18766. // id, _ := strconv.ParseInt(item, 10, 64)
  18767. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18768. // config = append(config, &diagnosisConfig)
  18769. // }
  18770. //
  18771. // for index, item := range config {
  18772. // if index == 0 {
  18773. // var tempDiaginfo service.DiaginfoStructTwo
  18774. // tempDiaginfo.DiagCode = item.CountryCode
  18775. // tempDiaginfo.DiagName = item.CountryContentName
  18776. // tempDiaginfo.DiagType = "1"
  18777. // tempDiaginfo.MaindiagFlag = "1"
  18778. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18779. // } else {
  18780. //
  18781. // var tempDiaginfo service.DiaginfoStructTwo
  18782. // tempDiaginfo.DiagCode = item.CountryCode
  18783. // tempDiaginfo.DiagName = item.CountryContentName
  18784. // tempDiaginfo.DiagType = "2"
  18785. // tempDiaginfo.MaindiagFlag = "0"
  18786. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18787. // }
  18788. // }
  18789. // struct4101.Diseinfo = tempDiaginfos
  18790. //
  18791. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18792. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18793. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18794. // tempOpspdiseinfo2.OprnOprtCode = ""
  18795. // tempOpspdiseinfo2.OprnOprtName = ""
  18796. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18797. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18798. //
  18799. // var iteminfo service.IteminfoStruct
  18800. //
  18801. // var bedCostTotal float64 = 0 //床位总费
  18802. // var bedCostSelfTotal float64 = 0 //床位自费
  18803. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18804. //
  18805. // var examineCostTotal float64 = 0 //诊查总费
  18806. // var examineCostSelfTotal float64 = 0 //诊查自费
  18807. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  18808. //
  18809. // var nursingCostTotal float64 = 0 //护理总费
  18810. // var nursingCostSelfTotal float64 = 0 //护理自费
  18811. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  18812. //
  18813. // var chineseMedicineCostTotal float64 = 0 //中成药
  18814. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  18815. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  18816. //
  18817. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  18818. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  18819. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  18820. //
  18821. // var registerCostTotal float64 = 0 //一般诊疗费
  18822. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  18823. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  18824. //
  18825. // var operationCostTotal float64 = 0 //手术费
  18826. // var operationCostSelfTotal float64 = 0 //手术费
  18827. // var operationCostPartSelfTotal float64 = 0 //手术费
  18828. //
  18829. // var otherCostTotal float64 = 0 //其他费用
  18830. // var otherCostSelfTotal float64 = 0 //其他费用
  18831. // var otherCostPartSelfTotal float64 = 0 //其他费用
  18832. //
  18833. // var materialCostTotal float64 = 0 //材料费
  18834. // var materialCostSelfTotal float64 = 0 //材料费
  18835. // var materialCostPartSelfTotal float64 = 0 //材料费
  18836. //
  18837. // var westernMedicineCostTotal float64 = 0 //西药费
  18838. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  18839. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18840. //
  18841. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18842. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18843. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18844. //
  18845. // var checkCostTotal float64 = 0 //检查费
  18846. // var checkCostSelfTotal float64 = 0 //检查费
  18847. // var checkCostPartSelfTotal float64 = 0 //检查费
  18848. //
  18849. // var laboratoryCostTotal float64 = 0 //化验费
  18850. // var laboratoryCostSelfTotal float64 = 0 //化验费
  18851. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18852. //
  18853. // var treatCostTotal float64 = 0 //治疗费用
  18854. // var treatCostSelfTotal float64 = 0 //治疗费用
  18855. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  18856. //
  18857. // decimal.DivisionPrecision = 2
  18858. //
  18859. // var bed_fulamt_ownpay_amt float64 = 0
  18860. //
  18861. // var examine_fulamt_ownpay_amt float64 = 0
  18862. //
  18863. // var nursing_fulamt_ownpay_amt float64 = 0
  18864. //
  18865. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  18866. //
  18867. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  18868. //
  18869. // var register_fulamt_ownpay_amt float64 = 0
  18870. //
  18871. // var operation_fulamt_ownpay_amt float64 = 0
  18872. // var other_fulamt_ownpay_amt float64 = 0
  18873. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  18874. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18875. // var check_fulamt_ownpay_amt float64 = 0
  18876. // var material_fulamt_ownpay_amt float64 = 0
  18877. // var laboratory_fulamt_ownpay_amt float64 = 0
  18878. // var treat_fulamt_ownpay_amt float64 = 0
  18879. //
  18880. // var bed_claa_sunmfee float64 = 0
  18881. // var bed_clab_amt float64 = 0
  18882. // var bed_other_amt float64 = 0
  18883. //
  18884. // var examine_claa_sunmfee float64 = 0
  18885. // var examine_clab_amt float64 = 0
  18886. // var examine_other_amt float64 = 0
  18887. //
  18888. // var nursing_claa_sunmfee float64 = 0
  18889. // var nursing_clab_amt float64 = 0
  18890. // var nursing_other_amt float64 = 0
  18891. //
  18892. // var chinese_medicine_claa_sunmfee float64 = 0
  18893. // var chinese_medicine_clab_amt float64 = 0
  18894. // var chinese_medicine_other_amt float64 = 0
  18895. //
  18896. // var commonly_treatment_claa_sunmfee float64 = 0
  18897. // var commonly_treatment_clab_amt float64 = 0
  18898. // var commonly_treatment_other_amt float64 = 0
  18899. //
  18900. // var operation_claa_sunmfee float64 = 0
  18901. // var operation_clab_amt float64 = 0
  18902. // var operation_other_amt float64 = 0
  18903. //
  18904. // var other_claa_sunmfee float64 = 0
  18905. // var other_clab_amt float64 = 0
  18906. // var other_other_amt float64 = 0
  18907. //
  18908. // var westernMedicine_claa_sunmfee float64 = 0
  18909. // var westernMedicine_clab_amt float64 = 0
  18910. // var westernMedicine_other_amt float64 = 0
  18911. //
  18912. // var chineseTraditional_claa_sunmfee float64 = 0
  18913. // var chineseTraditional_clab_amt float64 = 0
  18914. // var chineseTraditional_other_amt float64 = 0
  18915. //
  18916. // var check_claa_sunmfee float64 = 0
  18917. // var check_clab_amt float64 = 0
  18918. // var check_other_amt float64 = 0
  18919. //
  18920. // var material_claa_sunmfee float64 = 0
  18921. // var material_clab_amt float64 = 0
  18922. // var material_other_amt float64 = 0
  18923. //
  18924. // var laboratory_claa_sunmfee float64 = 0
  18925. // var laboratory_clab_amt float64 = 0
  18926. // var laboratory_other_amt float64 = 0
  18927. //
  18928. // var treat_claa_sunmfee float64 = 0
  18929. // var treat_clab_amt float64 = 0
  18930. // var treat_other_amt float64 = 0
  18931. //
  18932. // var register_claa_sunmfee float64 = 0
  18933. // var register_clab_amt float64 = 0
  18934. // var register_other_amt float64 = 0
  18935. //
  18936. // for _, item := range order.HisOrderInfo {
  18937. // if item.MedChrgitmType == "01" { //床位费
  18938. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18939. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18940. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18941. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18942. // if item.ChrgitmLv == "1" {
  18943. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18944. // }
  18945. // if item.ChrgitmLv == "2" {
  18946. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18947. //
  18948. // }
  18949. // if item.ChrgitmLv == "3" {
  18950. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18951. // }
  18952. //
  18953. // }
  18954. //
  18955. // if item.MedChrgitmType == "02" { //诊查
  18956. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18957. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18958. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18959. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18960. // if item.ChrgitmLv == "1" {
  18961. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18962. // }
  18963. // if item.ChrgitmLv == "2" {
  18964. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18965. //
  18966. // }
  18967. // if item.ChrgitmLv == "3" {
  18968. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18969. // }
  18970. //
  18971. // }
  18972. //
  18973. // if item.MedChrgitmType == "03" { //检查费
  18974. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18975. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18976. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18977. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18978. // if item.ChrgitmLv == "1" {
  18979. //
  18980. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18981. //
  18982. // }
  18983. // if item.ChrgitmLv == "2" {
  18984. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18985. //
  18986. // }
  18987. // if item.ChrgitmLv == "3" {
  18988. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18989. // }
  18990. // }
  18991. //
  18992. // if item.MedChrgitmType == "04" { //化验费
  18993. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18994. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18995. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18996. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18997. // if item.ChrgitmLv == "1" {
  18998. //
  18999. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19000. //
  19001. // }
  19002. // if item.ChrgitmLv == "2" {
  19003. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19004. //
  19005. // }
  19006. // if item.ChrgitmLv == "3" {
  19007. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19008. // }
  19009. // }
  19010. //
  19011. // if item.MedChrgitmType == "05" { //治疗费
  19012. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19013. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19014. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19015. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19016. // if item.ChrgitmLv == "1" {
  19017. //
  19018. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19019. //
  19020. // }
  19021. // if item.ChrgitmLv == "2" {
  19022. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19023. //
  19024. // }
  19025. // if item.ChrgitmLv == "3" {
  19026. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19027. // }
  19028. // }
  19029. //
  19030. // if item.MedChrgitmType == "06" { //手术费
  19031. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19032. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19033. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19034. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19035. //
  19036. // if item.ChrgitmLv == "1" {
  19037. //
  19038. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19039. //
  19040. // }
  19041. // if item.ChrgitmLv == "2" {
  19042. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19043. //
  19044. // }
  19045. // if item.ChrgitmLv == "3" {
  19046. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19047. // }
  19048. // }
  19049. //
  19050. // if item.MedChrgitmType == "07" { //手术费
  19051. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19052. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19053. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19054. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19055. //
  19056. // if item.ChrgitmLv == "1" {
  19057. //
  19058. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19059. //
  19060. // }
  19061. // if item.ChrgitmLv == "2" {
  19062. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19063. //
  19064. // }
  19065. // if item.ChrgitmLv == "3" {
  19066. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19067. // }
  19068. // }
  19069. //
  19070. // if item.MedChrgitmType == "08" { //材料费
  19071. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19072. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19073. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19074. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19075. // if item.ChrgitmLv == "1" {
  19076. //
  19077. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19078. //
  19079. // }
  19080. // if item.ChrgitmLv == "2" {
  19081. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19082. //
  19083. // }
  19084. // if item.ChrgitmLv == "3" {
  19085. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19086. // }
  19087. // }
  19088. // if item.MedChrgitmType == "09" { //西药费
  19089. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19090. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19091. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19092. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19093. // if item.ChrgitmLv == "1" {
  19094. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19095. // }
  19096. // if item.ChrgitmLv == "2" {
  19097. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19098. // }
  19099. // if item.ChrgitmLv == "3" {
  19100. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19101. // }
  19102. // }
  19103. // if item.MedChrgitmType == "10" { //中药饮片
  19104. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19105. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19106. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19107. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19108. // if item.ChrgitmLv == "1" {
  19109. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19110. // }
  19111. // if item.ChrgitmLv == "2" {
  19112. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19113. // }
  19114. // if item.ChrgitmLv == "3" {
  19115. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19116. // }
  19117. // }
  19118. //
  19119. // if item.MedChrgitmType == "11" { //中成费
  19120. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19121. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19122. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19123. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19124. // if item.ChrgitmLv == "1" {
  19125. //
  19126. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19127. //
  19128. // }
  19129. // if item.ChrgitmLv == "2" {
  19130. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19131. //
  19132. // }
  19133. // if item.ChrgitmLv == "3" {
  19134. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19135. // }
  19136. // }
  19137. //
  19138. // if item.MedChrgitmType == "12" { //中成费
  19139. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19140. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19141. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19142. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19143. // if item.ChrgitmLv == "1" {
  19144. //
  19145. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19146. //
  19147. // }
  19148. // if item.ChrgitmLv == "2" {
  19149. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19150. //
  19151. // }
  19152. // if item.ChrgitmLv == "3" {
  19153. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19154. // }
  19155. // }
  19156. //
  19157. // if item.MedChrgitmType == "13" { //中成费
  19158. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19159. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19160. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19161. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19162. // if item.ChrgitmLv == "1" {
  19163. //
  19164. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19165. //
  19166. // }
  19167. // if item.ChrgitmLv == "2" {
  19168. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19169. //
  19170. // }
  19171. // if item.ChrgitmLv == "3" {
  19172. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19173. // }
  19174. // }
  19175. //
  19176. // if item.MedChrgitmType == "14" { //其他费
  19177. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19178. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19179. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19180. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19181. // if item.ChrgitmLv == "1" {
  19182. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19183. //
  19184. // }
  19185. // if item.ChrgitmLv == "2" {
  19186. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19187. //
  19188. // }
  19189. // if item.ChrgitmLv == "3" {
  19190. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19191. // }
  19192. // }
  19193. //
  19194. // }
  19195. //
  19196. // var iteminfoStructs []service.IteminfoStruct
  19197. //
  19198. // if bedCostTotal != 0 {
  19199. // iteminfo.MedChrgitm = "01"
  19200. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19201. // iteminfo.Amt = bedCostTotal
  19202. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  19203. // iteminfo.ClabAmt = bed_clab_amt
  19204. // iteminfo.OthAmt = bed_other_amt
  19205. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19206. // }
  19207. //
  19208. // if examineCostTotal != 0 {
  19209. // iteminfo.MedChrgitm = "02"
  19210. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  19211. // iteminfo.Amt = examineCostTotal
  19212. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  19213. // iteminfo.ClabAmt = examine_clab_amt
  19214. // iteminfo.OthAmt = examine_other_amt
  19215. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19216. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19217. // }
  19218. //
  19219. // if checkCostTotal != 0 {
  19220. // iteminfo.MedChrgitm = "03"
  19221. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19222. // iteminfo.Amt = checkCostTotal
  19223. // iteminfo.ClaaSumfee = check_claa_sunmfee
  19224. // iteminfo.ClabAmt = check_clab_amt
  19225. // iteminfo.OthAmt = check_other_amt
  19226. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19227. //
  19228. // }
  19229. //
  19230. // if laboratoryCostTotal != 0 {
  19231. // iteminfo.MedChrgitm = "04"
  19232. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19233. // iteminfo.Amt = laboratoryCostTotal
  19234. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19235. // iteminfo.ClabAmt = laboratory_clab_amt
  19236. // iteminfo.OthAmt = laboratory_other_amt
  19237. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19238. //
  19239. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19240. //
  19241. // }
  19242. //
  19243. // if treatCostTotal != 0 {
  19244. // iteminfo.MedChrgitm = "05"
  19245. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19246. // iteminfo.Amt = treatCostTotal
  19247. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  19248. // iteminfo.ClabAmt = treat_clab_amt
  19249. // iteminfo.OthAmt = treat_other_amt
  19250. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19251. // //(struct4101.IteminfoStruct, iteminfo)
  19252. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19253. // }
  19254. //
  19255. // if operationCostTotal != 0 {
  19256. // iteminfo.MedChrgitm = "06"
  19257. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19258. // iteminfo.Amt = operationCostTotal
  19259. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  19260. // iteminfo.ClabAmt = operation_clab_amt
  19261. // iteminfo.OthAmt = operation_other_amt
  19262. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19263. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19264. // }
  19265. //
  19266. // if nursingCostTotal != 0 {
  19267. // iteminfo.MedChrgitm = "07"
  19268. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  19269. // iteminfo.Amt = nursingCostTotal
  19270. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  19271. // iteminfo.ClabAmt = nursing_clab_amt
  19272. // iteminfo.OthAmt = nursing_other_amt
  19273. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19274. // }
  19275. //
  19276. // if materialCostTotal != 0 {
  19277. // iteminfo.MedChrgitm = "08"
  19278. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19279. // iteminfo.Amt = materialCostTotal
  19280. // iteminfo.ClaaSumfee = material_claa_sunmfee
  19281. // iteminfo.ClabAmt = material_clab_amt
  19282. // iteminfo.OthAmt = material_other_amt
  19283. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19284. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19285. // }
  19286. //
  19287. // if westernMedicineCostTotal != 0 {
  19288. // iteminfo.MedChrgitm = "09"
  19289. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19290. // iteminfo.Amt = westernMedicineCostTotal
  19291. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19292. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19293. // iteminfo.OthAmt = westernMedicine_other_amt
  19294. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19295. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19296. //
  19297. // }
  19298. //
  19299. // if chineseMedicineCostTotal != 0 {
  19300. // iteminfo.MedChrgitm = "10"
  19301. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  19302. // iteminfo.Amt = chineseMedicineCostTotal
  19303. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  19304. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  19305. // iteminfo.OthAmt = chinese_medicine_other_amt
  19306. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19307. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19308. //
  19309. // }
  19310. //
  19311. // if chineseTraditionalMedicineCostTotal != 0 {
  19312. // iteminfo.MedChrgitm = "11"
  19313. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19314. // iteminfo.Amt = westernMedicineCostTotal
  19315. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19316. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19317. // iteminfo.OthAmt = westernMedicine_other_amt
  19318. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19319. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19320. //
  19321. // }
  19322. //
  19323. // if commonlyTreatmentCostTotal != 0 {
  19324. // iteminfo.MedChrgitm = "12"
  19325. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  19326. // iteminfo.Amt = commonlyTreatmentCostTotal
  19327. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  19328. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  19329. // iteminfo.OthAmt = commonly_treatment_other_amt
  19330. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19331. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19332. //
  19333. // }
  19334. //
  19335. // if registerCostTotal != 0 {
  19336. // iteminfo.MedChrgitm = "13"
  19337. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  19338. // iteminfo.Amt = registerCostTotal
  19339. // iteminfo.ClaaSumfee = register_claa_sunmfee
  19340. // iteminfo.ClabAmt = register_clab_amt
  19341. // iteminfo.OthAmt = register_other_amt
  19342. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19343. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19344. //
  19345. // }
  19346. //
  19347. // if otherCostTotal != 0 {
  19348. // iteminfo.MedChrgitm = "14"
  19349. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19350. // iteminfo.Amt = otherCostTotal
  19351. // iteminfo.ClaaSumfee = other_claa_sunmfee
  19352. // iteminfo.ClabAmt = other_clab_amt
  19353. // iteminfo.OthAmt = other_other_amt
  19354. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19355. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19356. //
  19357. // }
  19358. // struct4101.IteminfoStruct = iteminfoStructs
  19359. // time_arr := strings.Split(order.SetlTime, " ")
  19360. // struct4101.AdmTime = time_arr[0]
  19361. // struct4101.AdmEndTime = time_arr[0]
  19362. //
  19363. // struct4101.DoctorName = doctor.UserName
  19364. // struct4101.DoctorCode = doctor.DoctorNumber
  19365. //
  19366. // struct4101.Ntly = "中国"
  19367. // struct4101.AdmCaty = "A03.06"
  19368. // var res ResultSeventeen
  19369. // if miConfig.MdtrtareaAdmvs == "421300" {
  19370. // data := make(map[string]interface{})
  19371. // data["struct4101"] = struct4101
  19372. // data["secret_key"] = miConfig.SecretKey
  19373. // data["org_name"] = miConfig.OrgName
  19374. // data["opera"] = curRoles.UserName
  19375. // data["code"] = miConfig.Code
  19376. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  19377. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19378. //
  19379. // client := &http.Client{}
  19380. // bytesData, _ := json.Marshal(data)
  19381. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  19382. // resp, _ := client.Do(req)
  19383. // defer resp.Body.Close()
  19384. // body, ioErr := ioutil.ReadAll(resp.Body)
  19385. // if ioErr != nil {
  19386. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19387. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19388. // return
  19389. // }
  19390. // var respJSON map[string]interface{}
  19391. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19392. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19394. // return
  19395. // }
  19396. //
  19397. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19398. // userJSONBytes, _ := json.Marshal(respJSON)
  19399. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19400. // utils.ErrorLog("解析失败:%v", err)
  19401. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19402. // adminUser := c.GetAdminUserInfo()
  19403. // errlog := &models.HisOrderError{
  19404. // UserOrgId: adminUser.CurrentOrgId,
  19405. // Ctime: time.Now().Unix(),
  19406. // Mtime: time.Now().Unix(),
  19407. // ErrMsg: res.ErrMsg + "解析失败",
  19408. // Status: 1,
  19409. // PatientId: order_id,
  19410. // Stage: 10088,
  19411. // }
  19412. // service.CreateErrMsgLog(errlog)
  19413. // continue
  19414. // }
  19415. //
  19416. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  19417. // data := make(map[string]interface{})
  19418. // data["struct4101"] = struct4101
  19419. // data["secret_key"] = miConfig.SecretKey
  19420. // data["org_name"] = miConfig.OrgName
  19421. // data["opera"] = curRoles.UserName
  19422. // data["code"] = miConfig.Code
  19423. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  19424. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19425. //
  19426. // client := &http.Client{}
  19427. // bytesData, _ := json.Marshal(data)
  19428. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  19429. // resp, _ := client.Do(req)
  19430. // defer resp.Body.Close()
  19431. // body, ioErr := ioutil.ReadAll(resp.Body)
  19432. // if ioErr != nil {
  19433. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19435. // return
  19436. // }
  19437. // var respJSON map[string]interface{}
  19438. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19439. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19440. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19441. // return
  19442. // }
  19443. //
  19444. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19445. // userJSONBytes, _ := json.Marshal(respJSON)
  19446. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19447. // utils.ErrorLog("解析失败:%v", err)
  19448. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19449. // adminUser := c.GetAdminUserInfo()
  19450. // errlog := &models.HisOrderError{
  19451. // UserOrgId: adminUser.CurrentOrgId,
  19452. // Ctime: time.Now().Unix(),
  19453. // Mtime: time.Now().Unix(),
  19454. // ErrMsg: res.ErrMsg + "解析失败",
  19455. // Status: 1,
  19456. // PatientId: order_id,
  19457. // Stage: 10088,
  19458. // }
  19459. // service.CreateErrMsgLog(errlog)
  19460. // continue
  19461. // }
  19462. //
  19463. // } else {
  19464. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  19465. // fmt.Println(result)
  19466. //
  19467. // var dat map[string]interface{}
  19468. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19469. // fmt.Println(dat)
  19470. // } else {
  19471. // fmt.Println(err)
  19472. // }
  19473. // userJSONBytes, _ := json.Marshal(dat)
  19474. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19475. // utils.ErrorLog("解析失败:%v", err)
  19476. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19477. // adminUser := c.GetAdminUserInfo()
  19478. // errlog := &models.HisOrderError{
  19479. // UserOrgId: adminUser.CurrentOrgId,
  19480. // Ctime: time.Now().Unix(),
  19481. // Mtime: time.Now().Unix(),
  19482. // ErrMsg: res.ErrMsg + "解析失败",
  19483. // Status: 1,
  19484. // PatientId: order_id,
  19485. // Stage: 10106,
  19486. // }
  19487. // service.CreateErrMsgLog(errlog)
  19488. // continue
  19489. // }
  19490. // }
  19491. //
  19492. // if res.Infcode != 0 {
  19493. // adminUser := c.GetAdminUserInfo()
  19494. // errlog := &models.HisOrderError{
  19495. // UserOrgId: adminUser.CurrentOrgId,
  19496. // Ctime: time.Now().Unix(),
  19497. // Mtime: time.Now().Unix(),
  19498. // ErrMsg: res.ErrMsg,
  19499. // Status: 1,
  19500. // PatientId: order_id,
  19501. // Stage: 10106,
  19502. // }
  19503. // service.CreateErrMsgLog(errlog)
  19504. // continue
  19505. // } else {
  19506. // hisFundSettleListResult := &models.HisFundSettleListResult{
  19507. // Number: res.Output.SetlListId,
  19508. // Status: 1,
  19509. // Ctime: time.Now().Unix(),
  19510. // Mtime: time.Now().Unix(),
  19511. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19512. // IsUpload: 1,
  19513. // OrderId: order_id,
  19514. // }
  19515. // service.CreateUploadRecord(hisFundSettleListResult)
  19516. // continue
  19517. // }
  19518. // }
  19519. //}
  19520. func (c *HisApiController) GetOrgInfo() {
  19521. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  19522. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  19523. }
  19524. func (c *HisApiController) GetHisPatientInfo() {
  19525. medical_insurance_card := c.GetString("medical_insurance_card")
  19526. id_card_type, _ := c.GetInt64("id_card_type")
  19527. id_card := c.GetString("id_card")
  19528. adminInfo := c.GetAdminUserInfo()
  19529. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  19530. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  19531. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  19532. IdCardNo := ""
  19533. if id_card_type == 1 {
  19534. IdCardNo = medical_insurance_card
  19535. } else if id_card_type == 2 {
  19536. IdCardNo = id_card
  19537. }
  19538. if config.IsOpen == 1 {
  19539. 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
  19540. resp, requestErr := http.Get(api)
  19541. if requestErr != nil {
  19542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19543. return
  19544. }
  19545. defer resp.Body.Close()
  19546. body, ioErr := ioutil.ReadAll(resp.Body)
  19547. if ioErr != nil {
  19548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19550. return
  19551. }
  19552. var respJSON map[string]interface{}
  19553. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19556. return
  19557. }
  19558. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19559. userJSONBytes, _ := json.Marshal(userJSON)
  19560. var res ResultTwo
  19561. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19562. utils.ErrorLog("解析失败:%v", err)
  19563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19564. return
  19565. }
  19566. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  19567. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  19568. infoStr := string(Iinfos)
  19569. idetinfoStr := string(Idetinfos)
  19570. if res.Infcode == 0 {
  19571. his := models.VMHisPatient{
  19572. Status: 1,
  19573. Ctime: time.Now().Unix(),
  19574. Mtime: time.Now().Unix(),
  19575. PsnNo: res.Output.Baseinfo.PsnNo,
  19576. PsnCertType: res.Output.Baseinfo.PsnCertType,
  19577. Certno: res.Output.Baseinfo.Certno,
  19578. PsnName: res.Output.Baseinfo.PsnName,
  19579. Gend: res.Output.Baseinfo.Gend,
  19580. Naty: res.Output.Baseinfo.Naty,
  19581. Iinfo: infoStr,
  19582. Idetinfo: idetinfoStr,
  19583. UserOrgId: adminInfo.CurrentOrgId,
  19584. IsReturn: 1,
  19585. IdCardType: id_card_type,
  19586. }
  19587. c.ServeSuccessJSON(map[string]interface{}{
  19588. "info": his,
  19589. })
  19590. } else {
  19591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  19592. return
  19593. }
  19594. }
  19595. }
  19596. //func GetBasBaseInfo() (jsonStr string, err error) {
  19597. //
  19598. // handle := syscall.NewLazyDLL("SSCard.dll")
  19599. // add := handle.NewProc("ReadCardBas")
  19600. // str := make([]byte, 1024)
  19601. // str1 := make([]byte, 1024)
  19602. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  19603. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  19604. //
  19605. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  19606. //
  19607. // fmt.Println("> Add(4,5)的结果为:", ret)
  19608. // handle.Release()
  19609. //
  19610. // return "", nil
  19611. //
  19612. //}
  19613. //func GetQRBaseInfo() (jsonStr string, err error) {
  19614. // handle := syscall.LoadDLL("SSCard.dll")
  19615. // ReadCardBas := handle.FindProc("GetQRBase")
  19616. //
  19617. // str := make([]byte, 256)
  19618. // str1 := make([]byte, 256)
  19619. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  19620. //
  19621. // fmt.Println(string(str))
  19622. // fmt.Println(r)
  19623. // return string(str), nil
  19624. //}
  19625. //func CardInit() int {
  19626. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  19627. // add := DllTestDef.MustFindProc("Init")
  19628. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  19629. // if err != nil {
  19630. // fmt.Println("SSCard的运算结果为:", ret)
  19631. // }
  19632. // result := int(ret)
  19633. // return result
  19634. //}
  19635. //func CardInit() int {
  19636. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  19637. // if err != nil {
  19638. // fmt.Println("SSCard的运算结果为:", ret)
  19639. // }
  19640. // fmt.Println(err)
  19641. // result := int(ret)
  19642. // return result
  19643. //}
  19644. func IntPtr(n int) uintptr {
  19645. return uintptr(n)
  19646. }
  19647. func StrPtr(s string) uintptr {
  19648. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  19649. }
  19650. type Result2001 struct {
  19651. Cainfo interface{} `json:"cainfo"`
  19652. ErrMsg string `json:"err_msg"`
  19653. InfRefmsgid string `json:"inf_refmsgid"`
  19654. Infcode int64 `json:"infcode"`
  19655. Output struct {
  19656. Trtinfo struct {
  19657. PsnNo string `json:"psn_no"`
  19658. TrtChkType string `json:"trt_chk_type"`
  19659. FundPayType string `json:"fund_pay_type"`
  19660. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  19661. Begndate string `json:"begndate"`
  19662. Enddate string `json:"enddate"`
  19663. TrtChkRslt string `json:"trt_chk_rslt"`
  19664. } `json:"trtinfo"`
  19665. } `json:"output"`
  19666. RefmsgTime string `json:"refmsg_time"`
  19667. RespondTime string `json:"respond_time"`
  19668. Signtype interface{} `json:"signtype"`
  19669. WarnMsg interface{} `json:"warn_msg"`
  19670. }
  19671. type Result2001Org10265 struct {
  19672. Cainfo interface{} `json:"cainfo"`
  19673. ErrMsg string `json:"err_msg"`
  19674. InfRefmsgid string `json:"inf_refmsgid"`
  19675. Infcode string `json:"infcode"`
  19676. Output struct {
  19677. Trtinfo struct {
  19678. PsnNo string `json:"psn_no"`
  19679. TrtChkType string `json:"trt_chk_type"`
  19680. FundPayType string `json:"fund_pay_type"`
  19681. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  19682. Begndate string `json:"begndate"`
  19683. Enddate string `json:"enddate"`
  19684. TrtChkRslt string `json:"trt_chk_rslt"`
  19685. } `json:"trtinfo"`
  19686. } `json:"output"`
  19687. RefmsgTime string `json:"refmsg_time"`
  19688. RespondTime string `json:"respond_time"`
  19689. Signtype interface{} `json:"signtype"`
  19690. WarnMsg interface{} `json:"warn_msg"`
  19691. }
  19692. type ResultTwo struct {
  19693. ErrMsg string `json:"err_msg"`
  19694. InfRefmsgid string `json:"inf_refmsgid"`
  19695. Infcode int64 `json:"infcode"`
  19696. Output struct {
  19697. Baseinfo struct {
  19698. //Brdy string `json:"brdy"`
  19699. Certno string `json:"certno"`
  19700. Gend string `json:"gend"`
  19701. Naty string `json:"naty"`
  19702. PsnCertType string `json:"psn_cert_type"`
  19703. PsnName string `json:"psn_name"`
  19704. PsnNo string `json:"psn_no"`
  19705. } `json:"baseinfo"`
  19706. Idetinfo []interface{} `json:"idetinfo"`
  19707. Iinfo []struct {
  19708. Balc float64 `json:"balc"`
  19709. CvlservFlag string `json:"cvlserv_flag"`
  19710. EmpName string `json:"emp_name"`
  19711. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  19712. Insutype string `json:"insutype"`
  19713. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  19714. //PausInsuDate string `json:"paus_insu_date"`
  19715. //PsnInsuDate string `json:"psn_insu_date"`
  19716. PsnInsuStas string `json:"psn_insu_stas"`
  19717. PsnType string `json:"psn_type"`
  19718. } `json:"insuinfo"`
  19719. } `json:"output"`
  19720. RefmsgTime string `json:"refmsg_time"`
  19721. RespondTime string `json:"respond_time"`
  19722. Signtype interface{} `json:"signtype"`
  19723. WarnInfo interface{} `json:"warn_info"`
  19724. }
  19725. type ResultTwo10265 struct {
  19726. ErrMsg string `json:"err_msg"`
  19727. InfRefmsgid string `json:"inf_refmsgid"`
  19728. Infcode string `json:"infcode"`
  19729. Output struct {
  19730. Baseinfo struct {
  19731. //Brdy string `json:"brdy"`
  19732. Certno string `json:"certno"`
  19733. Gend string `json:"gend"`
  19734. Naty string `json:"naty"`
  19735. PsnCertType string `json:"psn_cert_type"`
  19736. PsnName string `json:"psn_name"`
  19737. PsnNo string `json:"psn_no"`
  19738. } `json:"baseinfo"`
  19739. Idetinfo []interface{} `json:"idetinfo"`
  19740. Iinfo []struct {
  19741. Balc float64 `json:"balc"`
  19742. CvlservFlag string `json:"cvlserv_flag"`
  19743. EmpName string `json:"emp_name"`
  19744. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  19745. Insutype string `json:"insutype"`
  19746. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  19747. PsnInsuStas string `json:"psn_insu_stas"`
  19748. PsnType string `json:"psn_type"`
  19749. } `json:"insuinfo"`
  19750. } `json:"output"`
  19751. RefmsgTime string `json:"refmsg_time"`
  19752. RespondTime string `json:"respond_time"`
  19753. Signtype interface{} `json:"signtype"`
  19754. WarnInfo interface{} `json:"warn_info"`
  19755. }
  19756. type ResultThree struct {
  19757. Cainfo interface{} `json:"cainfo"`
  19758. ErrMsg string `json:"err_msg"`
  19759. InfRefmsgid string `json:"inf_refmsgid"`
  19760. Infcode int64 `json:"infcode"`
  19761. Output struct {
  19762. Data struct {
  19763. IptOtpNo string `json:"ipt_otp_no"`
  19764. MdtrtID string `json:"mdtrt_id"`
  19765. PsnNo string `json:"psn_no"`
  19766. } `json:"data"`
  19767. } `json:"output"`
  19768. RefmsgTime string `json:"refmsg_time"`
  19769. RespondTime string `json:"respond_time"`
  19770. Signtype interface{} `json:"signtype"`
  19771. WarnMsg interface{} `json:"warn_msg"`
  19772. }
  19773. type ResultThree10265 struct {
  19774. Cainfo interface{} `json:"cainfo"`
  19775. ErrMsg string `json:"err_msg"`
  19776. InfRefmsgid string `json:"inf_refmsgid"`
  19777. Infcode string `json:"infcode"`
  19778. Output struct {
  19779. Data struct {
  19780. IptOtpNo string `json:"ipt_otp_no"`
  19781. MdtrtID string `json:"mdtrt_id"`
  19782. PsnNo string `json:"psn_no"`
  19783. } `json:"data"`
  19784. } `json:"output"`
  19785. RefmsgTime string `json:"refmsg_time"`
  19786. RespondTime string `json:"respond_time"`
  19787. Signtype interface{} `json:"signtype"`
  19788. WarnMsg interface{} `json:"warn_msg"`
  19789. }
  19790. type ResultFour struct {
  19791. Cainfo string `json:"cainfo"`
  19792. ErrMsg string `json:"err_msg"`
  19793. InfRefmsgid string `json:"inf_refmsgid"`
  19794. Infcode int64 `json:"infcode"`
  19795. Output struct {
  19796. Result []struct {
  19797. BasMednFlag string `json:"bas_medn_flag"`
  19798. ChldMedcFlag string `json:"chld_medc_flag"`
  19799. ChrgitmLv string `json:"chrgitm_lv"`
  19800. Cnt float64 `json:"cnt"`
  19801. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  19802. DrtReimFlag string `json:"drt_reim_flag"`
  19803. FeedetlSn string `json:"feedetl_sn"`
  19804. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19805. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  19806. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19807. ListSpItemFlag string `json:"list_sp_item_flag"`
  19808. LmtUsedFlag string `json:"lmt_used_flag"`
  19809. MedChrgitmType string `json:"med_chrgitm_type"`
  19810. Memo string `json:"memo"`
  19811. OverlmtAmt float64 `json:"overlmt_amt"`
  19812. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19813. Pric float64 `json:"pric"`
  19814. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  19815. SelfpayProp float64 `json:"selfpay_prop"`
  19816. } `json:"result"`
  19817. } `json:"output"`
  19818. RefmsgTime string `json:"refmsg_time"`
  19819. RespondTime string `json:"respond_time"`
  19820. Signtype string `json:"signtype"`
  19821. WarnMsg string `json:"warn_msg"`
  19822. }
  19823. type ResultFour10265 struct {
  19824. Cainfo string `json:"cainfo"`
  19825. ErrMsg string `json:"err_msg"`
  19826. InfRefmsgid string `json:"inf_refmsgid"`
  19827. Infcode string `json:"infcode"`
  19828. Output struct {
  19829. Result []struct {
  19830. BasMednFlag string `json:"bas_medn_flag"`
  19831. ChldMedcFlag string `json:"chld_medc_flag"`
  19832. ChrgitmLv string `json:"chrgitm_lv"`
  19833. Cnt float64 `json:"cnt"`
  19834. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  19835. DrtReimFlag string `json:"drt_reim_flag"`
  19836. FeedetlSn string `json:"feedetl_sn"`
  19837. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19838. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  19839. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19840. ListSpItemFlag string `json:"list_sp_item_flag"`
  19841. LmtUsedFlag string `json:"lmt_used_flag"`
  19842. MedChrgitmType string `json:"med_chrgitm_type"`
  19843. Memo string `json:"memo"`
  19844. OverlmtAmt float64 `json:"overlmt_amt"`
  19845. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19846. Pric float64 `json:"pric"`
  19847. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  19848. SelfpayProp float64 `json:"selfpay_prop"`
  19849. } `json:"result"`
  19850. } `json:"output"`
  19851. RefmsgTime string `json:"refmsg_time"`
  19852. RespondTime string `json:"respond_time"`
  19853. Signtype string `json:"signtype"`
  19854. WarnMsg string `json:"warn_msg"`
  19855. }
  19856. type ResultMemo struct {
  19857. InsuAdmdvs string `json:"insuAdmdvs"`
  19858. }
  19859. // [{"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}]
  19860. type ResultIDInfo struct {
  19861. Begntime string `json:"begntime"`
  19862. Endtime string `json:"endtime"`
  19863. Memo string `json:"memo"`
  19864. }
  19865. type ResultFive struct {
  19866. Balc float64 `json:"balc"`
  19867. CvlservFlag string `json:"cvlserv_flag"`
  19868. EmpName string `json:"emp_name"`
  19869. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  19870. Insutype string `json:"insutype"`
  19871. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  19872. PausInsuDate string `json:"paus_insu_date"`
  19873. PsnInsuDate string `json:"psn_insu_date"`
  19874. PsnInsuStas string `json:"psn_insu_stas"`
  19875. PsnType string `json:"psn_type"`
  19876. }
  19877. type ResultSix struct {
  19878. Cainfo interface{} `json:"cainfo"`
  19879. ErrMsg string `json:"err_msg"`
  19880. InfRefmsgid string `json:"inf_refmsgid"`
  19881. Infcode int64 `json:"infcode"`
  19882. Output struct {
  19883. } `json:"output"`
  19884. RefmsgTime string `json:"refmsg_time"`
  19885. RespondTime string `json:"respond_time"`
  19886. Signtype interface{} `json:"signtype"`
  19887. WarnMsg interface{} `json:"warn_msg"`
  19888. }
  19889. type FJ3507Result struct {
  19890. Cainfo interface{} `json:"cainfo"`
  19891. ErrMsg string `json:"err_msg"`
  19892. InfRefmsgid string `json:"inf_refmsgid"`
  19893. Infcode int64 `json:"infcode"`
  19894. Output struct {
  19895. retRslt string `json:"retRslt"`
  19896. msgRslt string `json:"msgRslt"`
  19897. } `json:"output"`
  19898. RefmsgTime string `json:"refmsg_time"`
  19899. RespondTime string `json:"respond_time"`
  19900. Signtype interface{} `json:"signtype"`
  19901. WarnMsg interface{} `json:"warn_msg"`
  19902. }
  19903. type FJ3507ResultFor10188 struct {
  19904. Cainfo interface{} `json:"cainfo"`
  19905. ErrMsg string `json:"err_msg"`
  19906. InfRefmsgid string `json:"inf_refmsgid"`
  19907. Infcode string `json:"infcode"`
  19908. RefmsgTime string `json:"refmsg_time"`
  19909. RespondTime string `json:"respond_time"`
  19910. Signtype interface{} `json:"signtype"`
  19911. WarnMsg interface{} `json:"warn_msg"`
  19912. }
  19913. type Result2406 struct {
  19914. Cainfo interface{} `json:"cainfo"`
  19915. ErrMsg string `json:"err_msg"`
  19916. InfRefmsgid string `json:"inf_refmsgid"`
  19917. Infcode int64 `json:"infcode"`
  19918. Output struct {
  19919. Result struct {
  19920. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  19921. } `json:"result"`
  19922. } `json:"output"`
  19923. RefmsgTime string `json:"refmsg_time"`
  19924. RespondTime string `json:"respond_time"`
  19925. Signtype interface{} `json:"signtype"`
  19926. WarnMsg interface{} `json:"warn_msg"`
  19927. }
  19928. type GZResultSix struct {
  19929. Cainfo interface{} `json:"cainfo"`
  19930. ErrMsg string `json:"err_msg"`
  19931. InfRefmsgid string `json:"inf_refmsgid"`
  19932. Infcode int64 `json:"infcode"`
  19933. Output string `json:"output"`
  19934. RefmsgTime string `json:"refmsg_time"`
  19935. RespondTime string `json:"respond_time"`
  19936. Signtype interface{} `json:"signtype"`
  19937. WarnMsg interface{} `json:"warn_msg"`
  19938. }
  19939. type ResultSix10265 struct {
  19940. Cainfo interface{} `json:"cainfo"`
  19941. ErrMsg string `json:"err_msg"`
  19942. InfRefmsgid string `json:"inf_refmsgid"`
  19943. Infcode string `json:"infcode"`
  19944. Output struct {
  19945. } `json:"output"`
  19946. RefmsgTime string `json:"refmsg_time"`
  19947. RespondTime string `json:"respond_time"`
  19948. Signtype interface{} `json:"signtype"`
  19949. WarnMsg interface{} `json:"warn_msg"`
  19950. }
  19951. type ResultSeven struct {
  19952. Cainfo string `json:"cainfo"`
  19953. ErrMsg string `json:"err_msg"`
  19954. InfRefmsgid string `json:"inf_refmsgid"`
  19955. Infcode int64 `json:"infcode"`
  19956. Output struct {
  19957. Setlinfo struct {
  19958. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  19959. AcctPay float64 `json:"acct_pay"`
  19960. ActPayDedc float64 `json:"act_pay_dedc"`
  19961. Age float64 `json:"age"`
  19962. Balc float64 `json:"balc"`
  19963. Certno string `json:"certno"`
  19964. ClrOptins string `json:"clr_optins"`
  19965. ClrType string `json:"clr_type"`
  19966. ClrWay string `json:"clr_way"`
  19967. CvlservFlag string `json:"cvlserv_flag"`
  19968. CvlservPay float64 `json:"cvlserv_pay"`
  19969. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19970. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  19971. Gend string `json:"gend"`
  19972. HifesPay float64 `json:"hifes_pay"`
  19973. HifmiPay float64 `json:"hifmi_pay"`
  19974. HifpPay float64 `json:"hifp_pay"`
  19975. HospPartAmt float64 `json:"hosp_part_amt"`
  19976. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19977. Insutype string `json:"insutype"`
  19978. MafPay float64 `json:"maf_pay"`
  19979. MdtrtCertType string `json:"mdtrt_cert_type"`
  19980. HifobPay float64 `json:"hifob_pay"`
  19981. MdtrtID string `json:"mdtrt_id"`
  19982. MedType string `json:"med_type"`
  19983. MedfeeSumamt float64 `json:"medfee_sumamt"`
  19984. MedinsSetlID string `json:"medins_setl_id"`
  19985. Naty string `json:"naty"`
  19986. OthPay float64 `json:"oth_pay"`
  19987. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  19988. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  19989. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19990. PsnCashPay float64 `json:"psn_cash_pay"`
  19991. PsnCertType string `json:"psn_cert_type"`
  19992. PsnName string `json:"psn_name"`
  19993. PsnNo string `json:"psn_no"`
  19994. PsnPartAmt float64 `json:"psn_part_amt"`
  19995. PsnType string `json:"psn_type"`
  19996. SetlID string `json:"setl_id"`
  19997. SetlTime string `json:"setl_time"`
  19998. } `json:"setlinfo"`
  19999. Setldetail interface{} `json:"setldetail"`
  20000. } `json:"output"`
  20001. RefmsgTime string `json:"refmsg_time"`
  20002. RespondTime string `json:"respond_time"`
  20003. Signtype interface{} `json:"signtype"`
  20004. WarnMsg interface{} `json:"warn_msg"`
  20005. }
  20006. type ResultSevenAH struct {
  20007. Cainfo string `json:"cainfo"`
  20008. ErrMsg string `json:"err_msg"`
  20009. InfRefmsgid string `json:"inf_refmsgid"`
  20010. Infcode int64 `json:"infcode"`
  20011. Output struct {
  20012. Setlinfo struct {
  20013. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  20014. AcctPay float64 `json:"acct_pay"`
  20015. ActPayDedc float64 `json:"act_pay_dedc"`
  20016. Age float64 `json:"age"`
  20017. Balc float64 `json:"balc"`
  20018. Certno string `json:"certno"`
  20019. ClrOptins string `json:"clr_optins"`
  20020. ClrType string `json:"clr_type"`
  20021. ClrWay string `json:"clr_way"`
  20022. CvlservFlag string `json:"cvlserv_flag"`
  20023. CvlservPay float64 `json:"cvlserv_pay"`
  20024. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20025. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20026. Gend string `json:"gend"`
  20027. HifesPay float64 `json:"hifes_pay"`
  20028. HifmiPay float64 `json:"hifmi_pay"`
  20029. HifpPay float64 `json:"hifp_pay"`
  20030. HospPartAmt float64 `json:"hosp_part_amt"`
  20031. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20032. Insutype string `json:"insutype"`
  20033. MafPay float64 `json:"maf_pay"`
  20034. MdtrtCertType string `json:"mdtrt_cert_type"`
  20035. HifobPay float64 `json:"hifob_pay"`
  20036. MdtrtID string `json:"mdtrt_id"`
  20037. MedType string `json:"med_type"`
  20038. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20039. MedinsSetlID string `json:"medins_setl_id"`
  20040. Naty string `json:"naty"`
  20041. OthPay float64 `json:"oth_pay"`
  20042. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20043. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20044. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20045. PsnCashPay float64 `json:"psn_cash_pay"`
  20046. PsnCertType string `json:"psn_cert_type"`
  20047. PsnName string `json:"psn_name"`
  20048. PsnNo string `json:"psn_no"`
  20049. PsnPartAmt float64 `json:"psn_part_amt"`
  20050. PsnType string `json:"psn_type"`
  20051. SetlID string `json:"setl_id"`
  20052. SetlTime int64 `json:"setl_time"`
  20053. } `json:"setlinfo"`
  20054. Setldetail interface{} `json:"setldetail"`
  20055. } `json:"output"`
  20056. RefmsgTime string `json:"refmsg_time"`
  20057. RespondTime string `json:"respond_time"`
  20058. Signtype interface{} `json:"signtype"`
  20059. WarnMsg interface{} `json:"warn_msg"`
  20060. }
  20061. type ResultSeven10265 struct {
  20062. Cainfo string `json:"cainfo"`
  20063. ErrMsg string `json:"err_msg"`
  20064. InfRefmsgid string `json:"inf_refmsgid"`
  20065. Infcode string `json:"infcode"`
  20066. Output struct {
  20067. Setlinfo struct {
  20068. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  20069. AcctPay float64 `json:"acct_pay"`
  20070. ActPayDedc float64 `json:"act_pay_dedc"`
  20071. Age float64 `json:"age"`
  20072. Balc float64 `json:"balc"`
  20073. Certno string `json:"certno"`
  20074. ClrOptins string `json:"clr_optins"`
  20075. ClrType string `json:"clr_type"`
  20076. ClrWay string `json:"clr_way"`
  20077. CvlservFlag string `json:"cvlserv_flag"`
  20078. CvlservPay float64 `json:"cvlserv_pay"`
  20079. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20080. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20081. Gend string `json:"gend"`
  20082. HifesPay float64 `json:"hifes_pay"`
  20083. HifmiPay float64 `json:"hifmi_pay"`
  20084. HifpPay float64 `json:"hifp_pay"`
  20085. HospPartAmt float64 `json:"hosp_part_amt"`
  20086. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20087. Insutype string `json:"insutype"`
  20088. MafPay float64 `json:"maf_pay"`
  20089. MdtrtCertType string `json:"mdtrt_cert_type"`
  20090. HifobPay float64 `json:"hifob_pay"`
  20091. MdtrtID string `json:"mdtrt_id"`
  20092. MedType string `json:"med_type"`
  20093. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20094. MedinsSetlID string `json:"medins_setl_id"`
  20095. Naty string `json:"naty"`
  20096. OthPay float64 `json:"oth_pay"`
  20097. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20098. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20099. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20100. PsnCashPay float64 `json:"psn_cash_pay"`
  20101. PsnCertType string `json:"psn_cert_type"`
  20102. PsnName string `json:"psn_name"`
  20103. PsnNo string `json:"psn_no"`
  20104. PsnPartAmt float64 `json:"psn_part_amt"`
  20105. PsnType string `json:"psn_type"`
  20106. SetlID string `json:"setl_id"`
  20107. SetlTime string `json:"setl_time"`
  20108. } `json:"setlinfo"`
  20109. Setldetail interface{} `json:"setldetail"`
  20110. } `json:"output"`
  20111. RefmsgTime string `json:"refmsg_time"`
  20112. RespondTime string `json:"respond_time"`
  20113. Signtype interface{} `json:"signtype"`
  20114. WarnMsg interface{} `json:"warn_msg"`
  20115. }
  20116. type ResultSeven10265Two struct {
  20117. Cainfo string `json:"cainfo"`
  20118. ErrMsg string `json:"err_msg"`
  20119. InfRefmsgid string `json:"inf_refmsgid"`
  20120. Infcode string `json:"infcode"`
  20121. Output struct {
  20122. Setlinfo struct {
  20123. AcctMulaidPay string `json:"acct_mulaid_pay"`
  20124. AcctPay float64 `json:"acct_pay"`
  20125. ActPayDedc float64 `json:"act_pay_dedc"`
  20126. Age float64 `json:"age"`
  20127. Balc float64 `json:"balc"`
  20128. Certno string `json:"certno"`
  20129. ClrOptins string `json:"clr_optins"`
  20130. ClrType string `json:"clr_type"`
  20131. ClrWay string `json:"clr_way"`
  20132. CvlservFlag string `json:"cvlserv_flag"`
  20133. CvlservPay float64 `json:"cvlserv_pay"`
  20134. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20135. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20136. Gend string `json:"gend"`
  20137. HifesPay float64 `json:"hifes_pay"`
  20138. HifmiPay float64 `json:"hifmi_pay"`
  20139. HifpPay float64 `json:"hifp_pay"`
  20140. HospPartAmt string `json:"hosp_part_amt"`
  20141. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20142. Insutype string `json:"insutype"`
  20143. MafPay float64 `json:"maf_pay"`
  20144. MdtrtCertType string `json:"mdtrt_cert_type"`
  20145. HifobPay float64 `json:"hifob_pay"`
  20146. MdtrtID string `json:"mdtrt_id"`
  20147. MedType string `json:"med_type"`
  20148. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20149. MedinsSetlID string `json:"medins_setl_id"`
  20150. Naty string `json:"naty"`
  20151. OthPay float64 `json:"oth_pay"`
  20152. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20153. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  20154. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20155. PsnCashPay float64 `json:"psn_cash_pay"`
  20156. PsnCertType string `json:"psn_cert_type"`
  20157. PsnName string `json:"psn_name"`
  20158. PsnNo string `json:"psn_no"`
  20159. PsnPartAmt float64 `json:"psn_part_amt"`
  20160. PsnType string `json:"psn_type"`
  20161. SetlID string `json:"setl_id"`
  20162. SetlTime string `json:"setl_time"`
  20163. } `json:"setlinfo"`
  20164. Setldetail interface{} `json:"setldetail"`
  20165. } `json:"output"`
  20166. RefmsgTime string `json:"refmsg_time"`
  20167. RespondTime string `json:"respond_time"`
  20168. Signtype interface{} `json:"signtype"`
  20169. WarnMsg interface{} `json:"warn_msg"`
  20170. }
  20171. type GZResultSeven10265Two struct {
  20172. Cainfo string `json:"cainfo"`
  20173. ErrMsg string `json:"err_msg"`
  20174. InfRefmsgid string `json:"inf_refmsgid"`
  20175. Infcode int64 `json:"infcode"`
  20176. Output struct {
  20177. Setlinfo struct {
  20178. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  20179. AcctPay float64 `json:"acct_pay"`
  20180. ActPayDedc float64 `json:"act_pay_dedc"`
  20181. Age float64 `json:"age"`
  20182. Balc float64 `json:"balc"`
  20183. Certno string `json:"certno"`
  20184. ClrOptins string `json:"clr_optins"`
  20185. ClrType string `json:"clr_type"`
  20186. ClrWay string `json:"clr_way"`
  20187. CvlservFlag string `json:"cvlserv_flag"`
  20188. CvlservPay float64 `json:"cvlserv_pay"`
  20189. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20190. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20191. Gend string `json:"gend"`
  20192. HifesPay float64 `json:"hifes_pay"`
  20193. HifmiPay float64 `json:"hifmi_pay"`
  20194. HifpPay float64 `json:"hifp_pay"`
  20195. HospPartAmt float64 `json:"hosp_part_amt"`
  20196. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20197. Insutype string `json:"insutype"`
  20198. MafPay float64 `json:"maf_pay"`
  20199. MdtrtCertType string `json:"mdtrt_cert_type"`
  20200. HifobPay float64 `json:"hifob_pay"`
  20201. MdtrtID string `json:"mdtrt_id"`
  20202. MedType string `json:"med_type"`
  20203. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20204. MedinsSetlID string `json:"medins_setl_id"`
  20205. Naty string `json:"naty"`
  20206. OthPay float64 `json:"oth_pay"`
  20207. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20208. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  20209. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20210. PsnCashPay float64 `json:"psn_cash_pay"`
  20211. PsnCertType string `json:"psn_cert_type"`
  20212. PsnName string `json:"psn_name"`
  20213. PsnNo string `json:"psn_no"`
  20214. PsnPartAmt float64 `json:"psn_part_amt"`
  20215. PsnType string `json:"psn_type"`
  20216. SetlID string `json:"setl_id"`
  20217. SetlTime string `json:"setl_time"`
  20218. } `json:"setlinfo"`
  20219. Setldetail interface{} `json:"setldetail"`
  20220. } `json:"output"`
  20221. RefmsgTime string `json:"refmsg_time"`
  20222. RespondTime string `json:"respond_time"`
  20223. Signtype interface{} `json:"signtype"`
  20224. WarnMsg interface{} `json:"warn_msg"`
  20225. }
  20226. type ResultEight struct {
  20227. Cainfo string `json:"cainfo"`
  20228. ErrMsg string `json:"err_msg"`
  20229. InfRefmsgid string `json:"inf_refmsgid"`
  20230. Infcode int64 `json:"infcode"`
  20231. Output struct {
  20232. Stmtinfo struct {
  20233. SetlOptins string `json:"setl_optins"`
  20234. StmtRslt string `json:"stmt_rslt"`
  20235. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  20236. } `json:"stmtinfo"`
  20237. } `json:"output"`
  20238. RefmsgTime string `json:"refmsg_time"`
  20239. RespondTime string `json:"respond_time"`
  20240. Signtype interface{} `json:"signtype"`
  20241. WarnMsg interface{} `json:"warn_msg"`
  20242. }
  20243. type ResultEightFor10188 struct {
  20244. Cainfo string `json:"cainfo"`
  20245. ErrMsg string `json:"err_msg"`
  20246. InfRefmsgid string `json:"inf_refmsgid"`
  20247. Infcode string `json:"infcode"`
  20248. Output struct {
  20249. Stmtinfo struct {
  20250. SetlOptins string `json:"setl_optins"`
  20251. StmtRslt string `json:"stmt_rslt"`
  20252. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  20253. } `json:"stmtinfo"`
  20254. } `json:"output"`
  20255. RefmsgTime string `json:"refmsg_time"`
  20256. RespondTime string `json:"respond_time"`
  20257. Signtype interface{} `json:"signtype"`
  20258. WarnMsg interface{} `json:"warn_msg"`
  20259. }
  20260. type ResultNine struct {
  20261. Cainfo string `json:"cainfo"`
  20262. ErrMsg string `json:"err_msg"`
  20263. InfRefmsgid string `json:"inf_refmsgid"`
  20264. Infcode int64 `json:"infcode"`
  20265. Output struct {
  20266. FileQuryNo string `json:"file_qury_no"`
  20267. } `json:"output"`
  20268. RefmsgTime string `json:"refmsg_time"`
  20269. RespondTime string `json:"respond_time"`
  20270. Signtype interface{} `json:"signtype"`
  20271. WarnMsg interface{} `json:"warn_msg"`
  20272. }
  20273. type ResultTen struct {
  20274. Cainfo string `json:"cainfo"`
  20275. ErrMsg string `json:"err_msg"`
  20276. InfRefmsgid string `json:"inf_refmsgid"`
  20277. Infcode int64 `json:"infcode"`
  20278. Output struct {
  20279. Fileinfo struct {
  20280. DldEndtime string `json:"dld_endtime"`
  20281. FileQuryNo string `json:"file_qury_no"`
  20282. Filename string `json:"filename"`
  20283. } `json:"fileinfo"`
  20284. } `json:"output"`
  20285. RefmsgTime string `json:"refmsg_time"`
  20286. RespondTime string `json:"respond_time"`
  20287. Signtype interface{} `json:"signtype"`
  20288. WarnMsg interface{} `json:"warn_msg"`
  20289. }
  20290. type Result5262 struct {
  20291. ErrMsg string `json:"err_msg"`
  20292. InfRefmsgid string `json:"inf_refmsgid"`
  20293. Infcode int64 `json:"infcode"`
  20294. Output struct {
  20295. PageInfo struct {
  20296. Size int `json:"size"`
  20297. RecordCounts int `json:"record_counts"`
  20298. } `json:"page_info"`
  20299. Idetinfo []interface{} `json:"idetinfo"`
  20300. Result []struct {
  20301. SetlID string `json:"setl_id"`
  20302. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  20303. MdtrtID string `json:"mdtrt_id"`
  20304. InitSetlID string `json:"init_setl_id,omitempty"`
  20305. PsnNo string `json:"psn_no"`
  20306. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  20307. PsnName string `json:"psn_name"`
  20308. PsnCertType string `json:"psn_cert_type"`
  20309. Certno string `json:"certno"`
  20310. Gend string `json:"gend,omitempty"`
  20311. Naty string `json:"naty,omitempty"`
  20312. Brdy string `json:"brdy,omitempty"`
  20313. Age float64 `json:"age,omitempty"`
  20314. Insutype string `json:"insutype,omitempty"`
  20315. PsnType string `json:"psn_type"`
  20316. CvlservFlag string `json:"cvlserv_flag"`
  20317. CvlservLv string `json:"cvlserv_lv,omitempty"`
  20318. SpPsnType string `json:"sp_psn_type,omitempty"`
  20319. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  20320. ClctGrde string `json:"clct_grde,omitempty"`
  20321. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  20322. NwbFlag string `json:"nwb_flag,omitempty"`
  20323. InsuAdmdvs string `json:"insu_admdvs"`
  20324. EmpNo string `json:"emp_no,omitempty"`
  20325. EmpName string `json:"emp_name,omitempty"`
  20326. EmpType string `json:"emp_type,omitempty"`
  20327. EconType string `json:"econ_type,omitempty"`
  20328. AfilIndu string `json:"afil_indu,omitempty"`
  20329. AfilRlts string `json:"afil_rlts,omitempty"`
  20330. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  20331. PayLoc string `json:"pay_loc,omitempty"`
  20332. FixmedinsCode string `json:"fixmedins_code"`
  20333. FixmedinsName string `json:"fixmedins_name"`
  20334. HospLv string `json:"hosp_lv,omitempty"`
  20335. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  20336. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  20337. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  20338. Begndate string `json:"begndate"`
  20339. Enddate string `json:"enddate"`
  20340. SetlTime string `json:"setl_time"`
  20341. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  20342. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  20343. MedType string `json:"med_type"`
  20344. SetlType string `json:"setl_type,omitempty"`
  20345. ClrType string `json:"clr_type,omitempty"`
  20346. ClrWay string `json:"clr_way,omitempty"`
  20347. PsnSetlway string `json:"psn_setlway,omitempty"`
  20348. ClrOptins string `json:"clr_optins,omitempty"`
  20349. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  20350. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  20351. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  20352. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  20353. InscpAmt float64 `json:"inscp_amt,omitempty"`
  20354. DedcStd float64 `json:"dedc_std,omitempty"`
  20355. CrtDedc float64 `json:"crt_dedc,omitempty"`
  20356. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  20357. HifpPay float64 `json:"hifp_pay,omitempty"`
  20358. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  20359. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  20360. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  20361. HifesPay float64 `json:"hifes_pay,omitempty"`
  20362. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  20363. HifobPay float64 `json:"hifob_pay,omitempty"`
  20364. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  20365. MafPay float64 `json:"maf_pay,omitempty"`
  20366. OthfundPay float64 `json:"othfund_pay,omitempty"`
  20367. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  20368. PsnPay float64 `json:"psn_pay,omitempty"`
  20369. AcctPay float64 `json:"acct_pay,omitempty"`
  20370. CashPayamt float64 `json:"cash_payamt,omitempty"`
  20371. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  20372. Balc float64 `json:"balc,omitempty"`
  20373. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  20374. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  20375. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  20376. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  20377. Year string `json:"year,omitempty"`
  20378. DiseNo string `json:"dise_no,omitempty"`
  20379. DiseName string `json:"dise_name,omitempty"`
  20380. Invono string `json:"invono,omitempty"`
  20381. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  20382. ValiFlag string `json:"vali_flag,omitempty"`
  20383. Memo string `json:"memo,omitempty"`
  20384. Rid string `json:"rid"`
  20385. UpdtTime string `json:"updt_time,omitempty"`
  20386. CrterID string `json:"crter_id,omitempty"`
  20387. CrterName string `json:"crter_name,omitempty"`
  20388. CrteTime string `json:"crte_time,omitempty"`
  20389. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  20390. OpterID string `json:"opter_id,omitempty"`
  20391. OpterName string `json:"opter_name,omitempty"`
  20392. OptTime string `json:"opt_time,omitempty"`
  20393. OptinsNo string `json:"optins_no,omitempty"`
  20394. PoolareaNo string `json:"poolarea_no,omitempty"`
  20395. } `json:"result"`
  20396. } `json:"output"`
  20397. RefmsgTime string `json:"refmsg_time"`
  20398. RespondTime string `json:"respond_time"`
  20399. Signtype interface{} `json:"signtype"`
  20400. WarnInfo interface{} `json:"warn_info"`
  20401. }
  20402. type Result5267 struct {
  20403. ErrMsg string `json:"err_msg"`
  20404. InfRefmsgid string `json:"inf_refmsgid"`
  20405. Infcode int64 `json:"infcode"`
  20406. Output struct {
  20407. PageInfo struct {
  20408. Size int `json:"size"`
  20409. RecordCounts int `json:"record_counts"`
  20410. } `json:"pageinfo"`
  20411. Result []struct {
  20412. SetlID string `json:"setl_id"`
  20413. ClrOptins string `json:"clr_optins"`
  20414. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  20415. MdtrtID string `json:"mdtrt_id"`
  20416. InitSetlID string `json:"init_setl_id,omitempty"`
  20417. PsnNo string `json:"psn_no"`
  20418. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  20419. PsnName string `json:"psn_name"`
  20420. PsnCertType string `json:"psn_cert_type"`
  20421. Certno string `json:"certno"`
  20422. Gend string `json:"gend,omitempty"`
  20423. Naty string `json:"naty,omitempty"`
  20424. Brdy string `json:"brdy,omitempty"`
  20425. Age float64 `json:"age,omitempty"`
  20426. Insutype string `json:"insutype,omitempty"`
  20427. PsnType string `json:"psn_type"`
  20428. CvlservFlag string `json:"cvlserv_flag"`
  20429. CvlservLv string `json:"cvlserv_lv,omitempty"`
  20430. SpPsnType string `json:"sp_psn_type,omitempty"`
  20431. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  20432. ClctGrde string `json:"clct_grde,omitempty"`
  20433. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  20434. NwbFlag string `json:"nwb_flag,omitempty"`
  20435. InsuAdmdvs string `json:"insu_admdvs"`
  20436. EmpNo string `json:"emp_no,omitempty"`
  20437. EmpName string `json:"emp_name,omitempty"`
  20438. EmpType string `json:"emp_type,omitempty"`
  20439. EconType string `json:"econ_type,omitempty"`
  20440. AfilIndu string `json:"afil_indu,omitempty"`
  20441. AfilRlts string `json:"afil_rlts,omitempty"`
  20442. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  20443. PayLoc string `json:"pay_loc,omitempty"`
  20444. FixmedinsCode string `json:"fixmedins_code"`
  20445. FixmedinsName string `json:"fixmedins_name"`
  20446. HospLv string `json:"hosp_lv,omitempty"`
  20447. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  20448. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  20449. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  20450. Begndate string `json:"begndate,omitempty"`
  20451. Enddate string `json:"enddate,omitempty"`
  20452. SetlTime string `json:"setl_time,omitempty"`
  20453. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  20454. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  20455. MedType string `json:"med_type"`
  20456. SetlType string `json:"setl_type,omitempty"`
  20457. ClrType string `json:"clr_type,omitempty"`
  20458. ClrWay string `json:"clr_way,omitempty"`
  20459. PsnSetlway string `json:"psn_setlway,omitempty"`
  20460. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  20461. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  20462. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  20463. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  20464. InscpAmt float64 `json:"inscp_amt,omitempty"`
  20465. DedcStd float64 `json:"dedc_std,omitempty"`
  20466. CrtDedc float64 `json:"crt_dedc,omitempty"`
  20467. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  20468. HifpPay float64 `json:"hifp_pay,omitempty"`
  20469. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  20470. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  20471. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  20472. HifesPay float64 `json:"hifes_pay,omitempty"`
  20473. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  20474. HifobPay float64 `json:"hifob_pay,omitempty"`
  20475. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  20476. MafPay float64 `json:"maf_pay,omitempty"`
  20477. OthfundPay float64 `json:"othfund_pay,omitempty"`
  20478. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  20479. PsnPay float64 `json:"psn_pay,omitempty"`
  20480. AcctPay float64 `json:"acct_pay,omitempty"`
  20481. CashPayamt float64 `json:"cash_payamt,omitempty"`
  20482. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  20483. Balc float64 `json:"balc,omitempty"`
  20484. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  20485. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  20486. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  20487. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  20488. Year string `json:"year,omitempty"`
  20489. DiseNo string `json:"dise_no,omitempty"`
  20490. DiseName string `json:"dise_name,omitempty"`
  20491. Invono string `json:"invono,omitempty"`
  20492. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  20493. Memo string `json:"memo,omitempty"`
  20494. UpdtTime string `json:"updt_time,omitempty"`
  20495. OpterID string `json:"opter_id,omitempty"`
  20496. OpterName string `json:"opter_name,omitempty"`
  20497. OptTime string `json:"opt_time,omitempty"`
  20498. OptinsNo string `json:"optins_no,omitempty"`
  20499. PoolareaNo string `json:"poolarea_no,omitempty"`
  20500. } `json:"result"`
  20501. } `json:"output"`
  20502. RefmsgTime string `json:"refmsg_time"`
  20503. RespondTime string `json:"respond_time"`
  20504. Signtype interface{} `json:"signtype"`
  20505. WarnInfo interface{} `json:"warn_info"`
  20506. }
  20507. // type Autogenerated struct {
  20508. // Output struct {
  20509. // Setlinfo struct {
  20510. // SetlTime string `json:"setl_time"`
  20511. // CvlservPay float64 `json:"cvlserv_pay"`
  20512. // Year string `json:"year"`
  20513. // MedType string `json:"med_type"`
  20514. // PsnPay float64 `json:"psn_pay"`
  20515. // OpterID string `json:"opter_id"`
  20516. // Begndate string `json:"begndate"`
  20517. // FlxempeFlag string `json:"flxempe_flag"`
  20518. // HifmiPay float64 `json:"hifmi_pay"`
  20519. // PsnNo string `json:"psn_no"`
  20520. // ActPayDedc float64 `json:"act_pay_dedc"`
  20521. // MedinsSetlID interface{} `json:"medins_setl_id"`
  20522. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  20523. // ClrWay string `json:"clr_way"`
  20524. // OthPay float64 `json:"oth_pay"`
  20525. // Gend string `json:"gend"`
  20526. // MdtrtID string `json:"mdtrt_id"`
  20527. // AcctPay float64 `json:"acct_pay"`
  20528. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  20529. // Insutype string `json:"insutype"`
  20530. // Invono interface{} `json:"invono"`
  20531. // Enddate string `json:"enddate"`
  20532. // CashPayamt float64 `json:"cash_payamt"`
  20533. // PsnType string `json:"psn_type"`
  20534. // FixmedinsName string `json:"fixmedins_name"`
  20535. // HifpPay float64 `json:"hifp_pay"`
  20536. // NewFlag interface{} `json:"new_flag"`
  20537. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20538. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  20539. // PayLoc string `json:"pay_loc"`
  20540. // ClrType string `json:"clr_type"`
  20541. // RefdSetlFlag string `json:"refd_setl_flag"`
  20542. // CvlservFlag string `json:"cvlserv_flag"`
  20543. // EmpName string `json:"emp_name"`
  20544. // Brdy string `json:"brdy"`
  20545. // Naty string `json:"naty"`
  20546. // Certno string `json:"certno"`
  20547. // DiseCode string `json:"dise_code"`
  20548. // FixmedinsCode string `json:"fixmedins_code"`
  20549. // DedcHospLv string `json:"dedc_hosp_lv"`
  20550. // OpterName string `json:"opter_name"`
  20551. // Balc float64 `json:"balc"`
  20552. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  20553. // PsnCertType string `json:"psn_cert_type"`
  20554. // HifobPay float64 `json:"hifob_pay"`
  20555. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  20556. // HifesPay float64 `json:"hifes_pay"`
  20557. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20558. // OptTime string `json:"opt_time"`
  20559. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20560. // SetlID string `json:"setl_id"`
  20561. // MafPay float64 `json:"maf_pay"`
  20562. // PsnName string `json:"psn_name"`
  20563. // InsuOptins interface{} `json:"insu_optins"`
  20564. // PrefFundPay interface{} `json:"pref_fund_pay"`
  20565. // ClrOptins string `json:"clr_optins"`
  20566. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20567. // DiseName string `json:"dise_name"`
  20568. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  20569. // Age float64 `json:"age"`
  20570. // DtrtCertType string `json:"dtrt_cert_type"`
  20571. // HospLv string `json:"hosp_lv"`
  20572. // } `json:"setlinfo"`
  20573. // Setldetail []struct {
  20574. // FundPayType string `json:"fund_pay_type"`
  20575. // FundPayamt float64 `json:"fund_payamt"`
  20576. // SetlProcInfo interface{} `json:"setl_proc_info"`
  20577. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  20578. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  20579. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  20580. // PrefFundPay interface{} `json:"pref_fund_pay"`
  20581. // } `json:"setldetail"`
  20582. // } `json:"output"`
  20583. // Infcode int `json:"infcode"`
  20584. // WarnMsg interface{} `json:"warn_msg"`
  20585. // Cainfo interface{} `json:"cainfo"`
  20586. // ErrMsg interface{} `json:"err_msg"`
  20587. // RefmsgTime string `json:"refmsg_time"`
  20588. // Signtype interface{} `json:"signtype"`
  20589. // RespondTime string `json:"respond_time"`
  20590. // InfRefmsgid string `json:"inf_refmsgid"`
  20591. // }
  20592. type Result002 struct {
  20593. Cainfo interface{} `json:"cainfo"`
  20594. ErrMsg string `json:"err_msg"`
  20595. InfRefmsgid string `json:"inf_refmsgid"`
  20596. Infcode int64 `json:"infcode"`
  20597. Output struct {
  20598. RxFile string `json:"rx_file"`
  20599. SignDigest string `json:"sign_digest"`
  20600. SignCertSn string `json:"sign_cert_sn"`
  20601. SignCertDn string `json:"sign_cert_dn"`
  20602. } `json:"output"`
  20603. RefmsgTime string `json:"refmsg_time"`
  20604. RespondTime string `json:"respond_time"`
  20605. Signtype interface{} `json:"signtype"`
  20606. WarnMsg interface{} `json:"warn_msg"`
  20607. }
  20608. type Result003 struct {
  20609. Cainfo interface{} `json:"cainfo"`
  20610. ErrMsg string `json:"err_msg"`
  20611. InfRefmsgid string `json:"inf_refmsgid"`
  20612. Infcode int64 `json:"infcode"`
  20613. Output struct {
  20614. HiRxno string `json:"hi_rxno"`
  20615. RxStasCodg string `json:"rx_stas_codg"`
  20616. RxStasName string `json:"rx_stas_name"`
  20617. } `json:"output"`
  20618. RefmsgTime string `json:"refmsg_time"`
  20619. RespondTime string `json:"respond_time"`
  20620. Signtype interface{} `json:"signtype"`
  20621. WarnMsg interface{} `json:"warn_msg"`
  20622. }
  20623. type ResultEleven struct {
  20624. Cainfo string `json:"cainfo"`
  20625. ErrMsg string `json:"err_msg"`
  20626. InfRefmsgid string `json:"inf_refmsgid"`
  20627. Infcode int64 `json:"infcode"`
  20628. Output struct {
  20629. Setlinfo struct {
  20630. SetlTime string `json:"setl_time"`
  20631. CvlservPay float64 `json:"cvlserv_pay"`
  20632. Year string `json:"year"`
  20633. MedType string `json:"med_type"`
  20634. PsnPay float64 `json:"psn_pay"`
  20635. OpterID string `json:"opter_id"`
  20636. Begndate string `json:"begndate"`
  20637. FlxempeFlag string `json:"flxempe_flag"`
  20638. HifmiPay float64 `json:"hifmi_pay"`
  20639. PsnNo string `json:"psn_no"`
  20640. ActPayDedc float64 `json:"act_pay_dedc"`
  20641. MedinsSetlID interface{} `json:"medins_setl_id"`
  20642. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  20643. ClrWay string `json:"clr_way"`
  20644. OthPay float64 `json:"oth_pay"`
  20645. Gend string `json:"gend"`
  20646. MdtrtID string `json:"mdtrt_id"`
  20647. AcctPay float64 `json:"acct_pay"`
  20648. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20649. Insutype string `json:"insutype"`
  20650. Invono interface{} `json:"invono"`
  20651. Enddate string `json:"enddate"`
  20652. CashPayamt float64 `json:"cash_payamt"`
  20653. PsnType string `json:"psn_type"`
  20654. FixmedinsName string `json:"fixmedins_name"`
  20655. HifpPay float64 `json:"hifp_pay"`
  20656. NewFlag interface{} `json:"new_flag"`
  20657. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20658. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20659. PayLoc string `json:"pay_loc"`
  20660. ClrType string `json:"clr_type"`
  20661. RefdSetlFlag string `json:"refd_setl_flag"`
  20662. CvlservFlag string `json:"cvlserv_flag"`
  20663. EmpName string `json:"emp_name"`
  20664. Brdy string `json:"brdy"`
  20665. Naty string `json:"naty"`
  20666. Certno string `json:"certno"`
  20667. DiseCode string `json:"dise_code"`
  20668. FixmedinsCode string `json:"fixmedins_code"`
  20669. DedcHospLv string `json:"dedc_hosp_lv"`
  20670. OpterName string `json:"opter_name"`
  20671. Balc float64 `json:"balc"`
  20672. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  20673. PsnCertType string `json:"psn_cert_type"`
  20674. HifobPay float64 `json:"hifob_pay"`
  20675. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20676. HifesPay float64 `json:"hifes_pay"`
  20677. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20678. OptTime string `json:"opt_time"`
  20679. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20680. SetlID string `json:"setl_id"`
  20681. MafPay float64 `json:"maf_pay"`
  20682. PsnName string `json:"psn_name"`
  20683. InsuOptins interface{} `json:"insu_optins"`
  20684. PrefFundPay interface{} `json:"pref_fund_pay"`
  20685. ClrOptins string `json:"clr_optins"`
  20686. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20687. DiseName string `json:"dise_name"`
  20688. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  20689. Age float64 `json:"age"`
  20690. DtrtCertType string `json:"dtrt_cert_type"`
  20691. HospLv string `json:"hosp_lv"`
  20692. PsnCashPay float64 `json:"psn_cash_pay"`
  20693. } `json:"setlinfo"`
  20694. } `json:"output"`
  20695. RefmsgTime string `json:"refmsg_time"`
  20696. RespondTime string `json:"respond_time"`
  20697. Signtype interface{} `json:"signtype"`
  20698. WarnMsg interface{} `json:"warn_msg"`
  20699. }
  20700. type ResultElevenah struct {
  20701. Cainfo string `json:"cainfo"`
  20702. ErrMsg string `json:"err_msg"`
  20703. InfRefmsgid string `json:"inf_refmsgid"`
  20704. Infcode int64 `json:"infcode"`
  20705. Output struct {
  20706. Setlinfo struct {
  20707. SetlTime int64 `json:"setl_time"`
  20708. CvlservPay float64 `json:"cvlserv_pay"`
  20709. Year string `json:"year"`
  20710. MedType string `json:"med_type"`
  20711. PsnPay float64 `json:"psn_pay"`
  20712. OpterID string `json:"opter_id"`
  20713. Begndate int64 `json:"begndate"`
  20714. FlxempeFlag string `json:"flxempe_flag"`
  20715. HifmiPay float64 `json:"hifmi_pay"`
  20716. PsnNo string `json:"psn_no"`
  20717. ActPayDedc float64 `json:"act_pay_dedc"`
  20718. MedinsSetlID interface{} `json:"medins_setl_id"`
  20719. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  20720. ClrWay string `json:"clr_way"`
  20721. OthPay float64 `json:"oth_pay"`
  20722. Gend string `json:"gend"`
  20723. MdtrtID string `json:"mdtrt_id"`
  20724. AcctPay float64 `json:"acct_pay"`
  20725. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20726. Insutype string `json:"insutype"`
  20727. Invono interface{} `json:"invono"`
  20728. Enddate int64 `json:"enddate"`
  20729. CashPayamt float64 `json:"cash_payamt"`
  20730. PsnType string `json:"psn_type"`
  20731. FixmedinsName string `json:"fixmedins_name"`
  20732. HifpPay float64 `json:"hifp_pay"`
  20733. NewFlag interface{} `json:"new_flag"`
  20734. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20735. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20736. PayLoc string `json:"pay_loc"`
  20737. ClrType string `json:"clr_type"`
  20738. RefdSetlFlag string `json:"refd_setl_flag"`
  20739. CvlservFlag string `json:"cvlserv_flag"`
  20740. EmpName string `json:"emp_name"`
  20741. Brdy int64 `json:"brdy"`
  20742. Naty string `json:"naty"`
  20743. Certno string `json:"certno"`
  20744. DiseCode string `json:"dise_code"`
  20745. FixmedinsCode string `json:"fixmedins_code"`
  20746. DedcHospLv string `json:"dedc_hosp_lv"`
  20747. OpterName string `json:"opter_name"`
  20748. Balc float64 `json:"balc"`
  20749. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  20750. PsnCertType string `json:"psn_cert_type"`
  20751. HifobPay float64 `json:"hifob_pay"`
  20752. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20753. HifesPay float64 `json:"hifes_pay"`
  20754. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20755. OptTime int64 `json:"opt_time"`
  20756. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20757. SetlID string `json:"setl_id"`
  20758. MafPay float64 `json:"maf_pay"`
  20759. PsnName string `json:"psn_name"`
  20760. InsuOptins interface{} `json:"insu_optins"`
  20761. PrefFundPay interface{} `json:"pref_fund_pay"`
  20762. ClrOptins string `json:"clr_optins"`
  20763. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20764. DiseName string `json:"dise_name"`
  20765. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  20766. Age float64 `json:"age"`
  20767. DtrtCertType string `json:"dtrt_cert_type"`
  20768. HospLv string `json:"hosp_lv"`
  20769. PsnCashPay float64 `json:"psn_cash_pay"`
  20770. } `json:"setlinfo"`
  20771. } `json:"output"`
  20772. RefmsgTime string `json:"refmsg_time"`
  20773. RespondTime string `json:"respond_time"`
  20774. Signtype interface{} `json:"signtype"`
  20775. WarnMsg interface{} `json:"warn_msg"`
  20776. }
  20777. type ResultEleven10265 struct {
  20778. Cainfo string `json:"cainfo"`
  20779. ErrMsg string `json:"err_msg"`
  20780. InfRefmsgid string `json:"inf_refmsgid"`
  20781. Infcode string `json:"infcode"`
  20782. Output struct {
  20783. Setlinfo struct {
  20784. SetlTime string `json:"setl_time"`
  20785. CvlservPay float64 `json:"cvlserv_pay"`
  20786. Year string `json:"year"`
  20787. MedType string `json:"med_type"`
  20788. PsnPay float64 `json:"psn_pay"`
  20789. OpterID string `json:"opter_id"`
  20790. Begndate string `json:"begndate"`
  20791. FlxempeFlag string `json:"flxempe_flag"`
  20792. HifmiPay float64 `json:"hifmi_pay"`
  20793. PsnNo string `json:"psn_no"`
  20794. ActPayDedc float64 `json:"act_pay_dedc"`
  20795. MedinsSetlID interface{} `json:"medins_setl_id"`
  20796. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  20797. ClrWay string `json:"clr_way"`
  20798. OthPay float64 `json:"oth_pay"`
  20799. Gend string `json:"gend"`
  20800. MdtrtID string `json:"mdtrt_id"`
  20801. AcctPay float64 `json:"acct_pay"`
  20802. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20803. Insutype string `json:"insutype"`
  20804. Invono interface{} `json:"invono"`
  20805. Enddate string `json:"enddate"`
  20806. CashPayamt float64 `json:"cash_payamt"`
  20807. PsnType string `json:"psn_type"`
  20808. FixmedinsName string `json:"fixmedins_name"`
  20809. HifpPay float64 `json:"hifp_pay"`
  20810. NewFlag interface{} `json:"new_flag"`
  20811. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20812. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20813. PayLoc string `json:"pay_loc"`
  20814. ClrType string `json:"clr_type"`
  20815. RefdSetlFlag string `json:"refd_setl_flag"`
  20816. CvlservFlag string `json:"cvlserv_flag"`
  20817. EmpName string `json:"emp_name"`
  20818. Brdy string `json:"brdy"`
  20819. Naty string `json:"naty"`
  20820. Certno string `json:"certno"`
  20821. DiseCode string `json:"dise_code"`
  20822. FixmedinsCode string `json:"fixmedins_code"`
  20823. DedcHospLv string `json:"dedc_hosp_lv"`
  20824. OpterName string `json:"opter_name"`
  20825. Balc float64 `json:"balc"`
  20826. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  20827. PsnCertType string `json:"psn_cert_type"`
  20828. HifobPay float64 `json:"hifob_pay"`
  20829. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20830. HifesPay float64 `json:"hifes_pay"`
  20831. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20832. OptTime string `json:"opt_time"`
  20833. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20834. SetlID string `json:"setl_id"`
  20835. MafPay float64 `json:"maf_pay"`
  20836. PsnName string `json:"psn_name"`
  20837. InsuOptins interface{} `json:"insu_optins"`
  20838. PrefFundPay interface{} `json:"pref_fund_pay"`
  20839. ClrOptins string `json:"clr_optins"`
  20840. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20841. DiseName string `json:"dise_name"`
  20842. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  20843. Age float64 `json:"age"`
  20844. DtrtCertType string `json:"dtrt_cert_type"`
  20845. HospLv string `json:"hosp_lv"`
  20846. PsnCashPay float64 `json:"psn_cash_pay"`
  20847. } `json:"setlinfo"`
  20848. } `json:"output"`
  20849. RefmsgTime string `json:"refmsg_time"`
  20850. RespondTime string `json:"respond_time"`
  20851. Signtype interface{} `json:"signtype"`
  20852. WarnMsg interface{} `json:"warn_msg"`
  20853. }
  20854. type ResultTwelve struct {
  20855. Cainfo string `json:"cainfo"`
  20856. ErrMsg string `json:"err_msg"`
  20857. InfRefmsgid string `json:"inf_refmsgid"`
  20858. Infcode int64 `json:"infcode"`
  20859. Output struct {
  20860. MdtrtId string `json:"mdtrt_id"`
  20861. ChrgBchno string `json:"chrg_bchno"`
  20862. PsnNo string `json:"psn_no"`
  20863. } `json:"output"`
  20864. RefmsgTime string `json:"refmsg_time"`
  20865. RespondTime string `json:"respond_time"`
  20866. Signtype interface{} `json:"signtype"`
  20867. WarnMsg interface{} `json:"warn_msg"`
  20868. }
  20869. type ResultThirteen struct {
  20870. ErrMsg string `json:"err_msg"`
  20871. InfRefmsgid string `json:"inf_refmsgid"`
  20872. Infcode int64 `json:"infcode"`
  20873. Output struct {
  20874. Result struct {
  20875. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  20876. } `json:"result"`
  20877. } `json:"output"`
  20878. RefmsgTime string `json:"refmsg_time"`
  20879. RespondTime string `json:"respond_time"`
  20880. Signtype interface{} `json:"signtype"`
  20881. WarnInfo interface{} `json:"warn_info"`
  20882. }
  20883. type ResultThirteen10265 struct {
  20884. ErrMsg string `json:"err_msg"`
  20885. InfRefmsgid string `json:"inf_refmsgid"`
  20886. Infcode string `json:"infcode"`
  20887. Output struct {
  20888. Result struct {
  20889. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  20890. } `json:"result"`
  20891. } `json:"output"`
  20892. RefmsgTime string `json:"refmsg_time"`
  20893. RespondTime string `json:"respond_time"`
  20894. Signtype interface{} `json:"signtype"`
  20895. WarnInfo interface{} `json:"warn_info"`
  20896. }
  20897. type ResultFourteen struct {
  20898. ErrMsg string `json:"err_msg"`
  20899. InfRefmsgid string `json:"inf_refmsgid"`
  20900. Infcode int64 `json:"infcode"`
  20901. Output struct {
  20902. } `json:"output"`
  20903. RefmsgTime string `json:"refmsg_time"`
  20904. RespondTime string `json:"respond_time"`
  20905. Signtype interface{} `json:"signtype"`
  20906. WarnInfo interface{} `json:"warn_info"`
  20907. }
  20908. type ResultCFYLJG001 struct {
  20909. ErrMsg string `json:"err_msg"`
  20910. InfRefmsgid string `json:"inf_refmsgid"`
  20911. Infcode int64 `json:"infcode"`
  20912. Output struct {
  20913. RxTraceCode string `json:"rx_trace_code"`
  20914. HiRxno string `json:"hi_rxno"`
  20915. } `json:"output"`
  20916. RefmsgTime string `json:"refmsg_time"`
  20917. RespondTime string `json:"respond_time"`
  20918. Signtype interface{} `json:"signtype"`
  20919. WarnInfo interface{} `json:"warn_info"`
  20920. }
  20921. type ResultCFYLJG007 struct {
  20922. ErrMsg string `json:"err_msg"`
  20923. InfRefmsgid string `json:"inf_refmsgid"`
  20924. Infcode int64 `json:"infcode"`
  20925. Output struct {
  20926. HiRxno string `json:"hi_rxno"`
  20927. RxStasName string `json:"rx_stas_name"`
  20928. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  20929. Seltdelts []interface{} `json:"seltdelts"`
  20930. RxUsedStasName string `json:"rx_used_stas_name"`
  20931. RxStasCodg string `json:"rx_stas_codg"`
  20932. } `json:"output"`
  20933. RefmsgTime string `json:"refmsg_time"`
  20934. RespondTime string `json:"respond_time"`
  20935. Signtype interface{} `json:"signtype"`
  20936. WarnInfo interface{} `json:"warn_info"`
  20937. }
  20938. type ResultCFYLJG002 struct {
  20939. ErrMsg string `json:"err_msg"`
  20940. InfRefmsgid string `json:"inf_refmsgid"`
  20941. Infcode int64 `json:"infcode"`
  20942. Output struct {
  20943. RxFile string `json:"rx_file"`
  20944. SignDigest string `json:"sign_digest"`
  20945. SignCertSn string `json:"sign_cert_sn"`
  20946. SignCertDn string `json:"sign_cert_dn"`
  20947. } `json:"output"`
  20948. RefmsgTime string `json:"refmsg_time"`
  20949. RespondTime string `json:"respond_time"`
  20950. Signtype interface{} `json:"signtype"`
  20951. WarnInfo interface{} `json:"warn_info"`
  20952. }
  20953. type ResultCFYLJG003 struct {
  20954. ErrMsg string `json:"err_msg"`
  20955. InfRefmsgid string `json:"inf_refmsgid"`
  20956. Infcode int64 `json:"infcode"`
  20957. Output struct {
  20958. HiRxno string `json:"hi_rxno"`
  20959. RxStasCodg string `json:"rx_stas_codg"`
  20960. RxStasName string `json:"rx_stas_name"`
  20961. } `json:"output"`
  20962. RefmsgTime string `json:"refmsg_time"`
  20963. RespondTime string `json:"respond_time"`
  20964. Signtype interface{} `json:"signtype"`
  20965. WarnInfo interface{} `json:"warn_info"`
  20966. }
  20967. type ResultCFYLJG004 struct {
  20968. ErrMsg string `json:"err_msg"`
  20969. InfRefmsgid string `json:"inf_refmsgid"`
  20970. Infcode int64 `json:"infcode"`
  20971. Output struct {
  20972. HiRxno string `json:"hi_rxno"`
  20973. RxStasCodg string `json:"rx_stas_codg"`
  20974. RxStasName string `json:"rx_stas_name"`
  20975. } `json:"output"`
  20976. RefmsgTime string `json:"refmsg_time"`
  20977. RespondTime string `json:"respond_time"`
  20978. Signtype interface{} `json:"signtype"`
  20979. WarnInfo interface{} `json:"warn_info"`
  20980. }
  20981. type ResultCFYLJG008 struct {
  20982. ErrMsg string `json:"err_msg"`
  20983. InfRefmsgid string `json:"inf_refmsgid"`
  20984. Infcode int64 `json:"infcode"`
  20985. Output struct {
  20986. PoolareaNo string `json:"poolareaNo"`
  20987. AdmdvsName string `json:"admdvsName"`
  20988. Count string `json:"count"`
  20989. } `json:"output"`
  20990. RefmsgTime string `json:"refmsg_time"`
  20991. RespondTime string `json:"respond_time"`
  20992. Signtype interface{} `json:"signtype"`
  20993. WarnInfo interface{} `json:"warn_info"`
  20994. }
  20995. type ResultCFYLJG005 struct {
  20996. ErrMsg string `json:"err_msg"`
  20997. InfRefmsgid string `json:"inf_refmsgid"`
  20998. Infcode int64 `json:"infcode"`
  20999. Output struct {
  21000. HiRxNo string `json:"hi_rxno"`
  21001. FixMedinsCode string `json:"fixmedins_code"`
  21002. FixMedinsName string `json:"fixmedins_name"`
  21003. RxStasCodg string `json:"rx_stas_codg"`
  21004. RxStasName string `json:"rx_stas_name"`
  21005. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  21006. RxUserdStasName string `json:"rx_userd_stas_name"`
  21007. PrscTime string `json:"prsc_time"`
  21008. RxDrugCnt float64 `json:"rx_drug_cnt"`
  21009. RxUsedWayCodg string `json:"rx_used_way_codg"`
  21010. RxUsedWayName string `json:"rx_used_way_name"`
  21011. RxFrquCodg string `json:"rx_frqu_codg"`
  21012. RxFrquName string `json:"rx_frqu_name"`
  21013. RxDosunt string `json:"rx_dosunt"`
  21014. RxDoscnt float64 `json:"rx_doscnt"`
  21015. RxDrordDscr string `json:"rx_drord_dscr"`
  21016. ValiDays int64 `json:"vali_days"`
  21017. ValiEndTime string `json:"vali_end_time"`
  21018. ReptFlag string `json:"rept_flag"`
  21019. MaxReptCnt int64 `json:"max_rept_cnt"`
  21020. ReptdCnt int64 `json:"reptd_cnt"`
  21021. MinInrvDays int64 `json:"min_inrv_days"`
  21022. RxTypeCode string `json:"rx_type_code"`
  21023. RxTypeName string `json:"rx_type_name"`
  21024. LongRxFlag string `json:"long_rx_flag"`
  21025. RxDetlList []struct {
  21026. MedListCodg string `json:"med_list_codg"`
  21027. MedinsListCodg string `json:"medins_list_codg"`
  21028. HospPrepFlag string `json:"hosp_prep_flag"`
  21029. RxItemTypeCode string `json:"rx_item_type_code"`
  21030. RxItemTypeName string `json:"rx_item_type_name"`
  21031. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  21032. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  21033. TcmHerbFoote string `json:"tcmherb_foote"`
  21034. MednTypeCode string `json:"medn_type_code"`
  21035. MednTypeName string `json:"medn_type_name"`
  21036. MainMedcFlag string `json:"main_medc_flag"`
  21037. UrgtFlag string `json:"urgt_flag"`
  21038. BasMednFlag string `json:"bas_medn_flag"`
  21039. ImpDrugFlag string `json:"imp_drug_flag"`
  21040. ProdBarc string `json:"prod_barc"`
  21041. DrugProdname string `json:"drug_prodname"`
  21042. GennameCodg string `json:"genname_codg"`
  21043. DrugGenname string `json:"drug_genname"`
  21044. DrugDosform string `json:"drug_dosform"`
  21045. DrugSpec string `json:"drug_spec"`
  21046. PrdrName string `json:"prdr_name"`
  21047. MedcWayCodg string `json:"medc_way_codg"`
  21048. MedcWayDscr string `json:"medc_way_dscr"`
  21049. MedcBegntime string `json:"medc_begntime"`
  21050. MedcEndtime string `json:"medc_endtime"`
  21051. MedcDays float64 `json:"medc_days"`
  21052. DrugPric float64 `json:"drug_pric"`
  21053. DrugSumamt float64 `json:"drug_sumamt"`
  21054. DrugCnt float64 `json:"drug_cnt"`
  21055. DrugDosunt string `json:"drug_dosunt"`
  21056. SinDoscnt float64 `json:"sin_doscnt"`
  21057. SinDosunt string `json:"sin_dosunt"`
  21058. UsedFrquCodg string `json:"used_frqu_codg"`
  21059. UsedFrquName string `json:"used_frqu_name"`
  21060. DrugTotlcnt string `json:"drug_totlcnt"`
  21061. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  21062. DiseCodg string `json:"dise_codg"`
  21063. HospApprFlag string `json:"hosp_appr_flag"`
  21064. } `json:"rx_detl_list"`
  21065. RxOtpinfo struct {
  21066. MedType string `json:"med_type"`
  21067. IptOtpNo string `json:"ipt_otp_no"`
  21068. OtpIptFlag string `json:"otp_ipt_flag"`
  21069. PatnName string `json:"patn_name"`
  21070. PatnAge float64 `json:"patn_age"`
  21071. PatnHgt float64 `json:"patn_hgt"`
  21072. PatnWt float64 `json:"patn_wt"`
  21073. Gend string `json:"gend"`
  21074. GesoVal float64 `json:"geso_val"`
  21075. NwbFlag string `json:"nwb_flag"`
  21076. NwbAge string `json:"nwb_age"`
  21077. SuckPrdFlag string `json:"suck_prd_flag"`
  21078. AlgsHis string `json:"algs_his"`
  21079. Insutype string `json:"insutype"`
  21080. PrscDeptName string `json:"prsc_dept_name"`
  21081. PrscDrName string `json:"prsc_dr_name"`
  21082. PharName string `json:"phar_name"`
  21083. PharChkTime string `json:"phar_chk_time"`
  21084. MdtrtTime string `json:"mdtrt_time"`
  21085. DiseCodg string `json:"dise_codg"`
  21086. DiseName string `json:"dise_name"`
  21087. SpDiseFlag string `json:"sp_dise_flag"`
  21088. MaindiagCode string `json:"maindiag_code"`
  21089. MaindiagName string `json:"maindiag_name"`
  21090. DiseCondDscr string `json:"dise_cond_dscr"`
  21091. FstdiagFlag string `json:"fstdiag_flag"`
  21092. } `json:"rx_otpinfo"`
  21093. RxDiseList []struct {
  21094. DiagType string `json:"diag_type"`
  21095. MaindiagFlag string `json:"maindiag_flag"`
  21096. DiagSrtNo string `json:"diag_srt_no"`
  21097. DiagCode string `json:"diag_code"`
  21098. DiagName string `json:"diag_name"`
  21099. DiagDept string `json:"diag_dept"`
  21100. DiagDrNo string `json:"diag_dr_no"`
  21101. DiagDrName string `json:"diag_dr_name"`
  21102. DiagTime string `json:"diag_time"`
  21103. TcmDiseCode string `json:"tcm_dise_code"`
  21104. TcmDiseName string `json:"tcm_dise_name"`
  21105. TcmSympCode string `json:"tcmsymp_code"`
  21106. TcmSymp string `json:"tcmsymp"`
  21107. } `json:"rx_dise_list"`
  21108. } `json:"output"`
  21109. RefmsgTime string `json:"refmsg_time"`
  21110. RespondTime string `json:"respond_time"`
  21111. Signtype interface{} `json:"signtype"`
  21112. WarnInfo interface{} `json:"warn_info"`
  21113. }
  21114. type ResultCFYLJG006 struct {
  21115. ErrMsg string `json:"err_msg"`
  21116. InfRefmsgid string `json:"inf_refmsgid"`
  21117. Infcode int64 `json:"infcode"`
  21118. Output struct {
  21119. HiRxNo string `json:"hi_rxno"`
  21120. PharCode string `json:"phar_code"`
  21121. PharName string `json:"phar_name"`
  21122. RxChkOpnn string `json:"rx_chk_opnn"`
  21123. RxChkTime string `json:"rx_chk_time"`
  21124. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  21125. RxChkStasName string `json:"rx_chk_stas_name"`
  21126. RxStasCodg string `json:"rx_stas_codg"`
  21127. RxStasName string `json:"rx_stas_name"`
  21128. } `json:"output"`
  21129. RefmsgTime string `json:"refmsg_time"`
  21130. RespondTime string `json:"respond_time"`
  21131. Signtype interface{} `json:"signtype"`
  21132. WarnInfo interface{} `json:"warn_info"`
  21133. }
  21134. type ResultFourteen10265 struct {
  21135. ErrMsg string `json:"err_msg"`
  21136. InfRefmsgid string `json:"inf_refmsgid"`
  21137. Infcode string `json:"infcode"`
  21138. Output struct {
  21139. } `json:"output"`
  21140. RefmsgTime string `json:"refmsg_time"`
  21141. RespondTime string `json:"respond_time"`
  21142. Signtype interface{} `json:"signtype"`
  21143. WarnInfo interface{} `json:"warn_info"`
  21144. }
  21145. type ResultSixteen struct {
  21146. Cainfo string `json:"cainfo"`
  21147. ErrMsg string `json:"err_msg"`
  21148. InfRefmsgid string `json:"inf_refmsgid"`
  21149. Infcode int64 `json:"infcode"`
  21150. Output struct {
  21151. Setlinfo struct {
  21152. MdtrtID string `json:"mdtrt_id"`
  21153. SetlID string `json:"setl_id"`
  21154. ClrOptins string `json:"clr_optins"`
  21155. SetlTime string `json:"setl_time"`
  21156. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21157. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21158. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21159. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21160. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21161. ActPayDedc float64 `json:"act_pay_dedc"`
  21162. HifpPay float64 `json:"hifp_pay"`
  21163. PoolPropSe float64 `json:"pool_prop_selfpay"`
  21164. Lfpay float64 `json:"selfpay"`
  21165. CvlservPay float64 `json:"cvlserv_pay"`
  21166. HifesPay float64 `json:"hifes_pay"`
  21167. HifmiPay float64 `json:"hifmi_pay"`
  21168. HifobPay float64 `json:"hifob_pay"`
  21169. MafPay float64 `json:"maf_pay"`
  21170. OthPay float64 `json:"oth_pay"`
  21171. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21172. PsnPartAmt float64 `json:"psn_part_amt"`
  21173. AcctPay float64 `json:"acct_pay"`
  21174. Balc float64 `json:"balc"`
  21175. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21176. HospPartAmt float64 `json:"hosp_part_amt"`
  21177. MedinsSetlID string `json:"medins_setl_id"`
  21178. PdnCashPay string `json:"pdn_cash_pay"`
  21179. } `json:"setlinfo"`
  21180. } `json:"output"`
  21181. RefmsgTime string `json:"refmsg_time"`
  21182. RespondTime string `json:"respond_time"`
  21183. Signtype interface{} `json:"signtype"`
  21184. WarnMsg interface{} `json:"warn_msg"`
  21185. }
  21186. type ResultSixteen10265 struct {
  21187. Cainfo string `json:"cainfo"`
  21188. ErrMsg string `json:"err_msg"`
  21189. InfRefmsgid string `json:"inf_refmsgid"`
  21190. Infcode string `json:"infcode"`
  21191. Output struct {
  21192. Setlinfo struct {
  21193. MdtrtID string `json:"mdtrt_id"`
  21194. SetlID string `json:"setl_id"`
  21195. ClrOptins string `json:"clr_optins"`
  21196. SetlTime string `json:"setl_time"`
  21197. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21198. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21199. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21200. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21201. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21202. ActPayDedc float64 `json:"act_pay_dedc"`
  21203. HifpPay float64 `json:"hifp_pay"`
  21204. PoolPropSe float64 `json:"pool_prop_selfpay"`
  21205. Lfpay float64 `json:"selfpay"`
  21206. CvlservPay float64 `json:"cvlserv_pay"`
  21207. HifesPay float64 `json:"hifes_pay"`
  21208. HifmiPay float64 `json:"hifmi_pay"`
  21209. HifobPay float64 `json:"hifob_pay"`
  21210. MafPay float64 `json:"maf_pay"`
  21211. OthPay float64 `json:"oth_pay"`
  21212. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21213. PsnPartAmt float64 `json:"psn_part_amt"`
  21214. AcctPay float64 `json:"acct_pay"`
  21215. Balc float64 `json:"balc"`
  21216. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21217. HospPartAmt float64 `json:"hosp_part_amt"`
  21218. MedinsSetlID string `json:"medins_setl_id"`
  21219. PdnCashPay string `json:"pdn_cash_pay"`
  21220. } `json:"setlinfo"`
  21221. } `json:"output"`
  21222. RefmsgTime string `json:"refmsg_time"`
  21223. RespondTime string `json:"respond_time"`
  21224. Signtype interface{} `json:"signtype"`
  21225. WarnMsg interface{} `json:"warn_msg"`
  21226. }
  21227. type ResultSixteen10265Two struct {
  21228. Cainfo string `json:"cainfo"`
  21229. ErrMsg string `json:"err_msg"`
  21230. InfRefmsgid string `json:"inf_refmsgid"`
  21231. Infcode string `json:"infcode"`
  21232. Output struct {
  21233. Setlinfo interface{} `json:"setlinfo"`
  21234. } `json:"output"`
  21235. RefmsgTime string `json:"refmsg_time"`
  21236. RespondTime string `json:"respond_time"`
  21237. Signtype interface{} `json:"signtype"`
  21238. WarnMsg interface{} `json:"warn_msg"`
  21239. }
  21240. type ResultgzSixteen10265Two struct {
  21241. Cainfo string `json:"cainfo"`
  21242. ErrMsg string `json:"err_msg"`
  21243. InfRefmsgid string `json:"inf_refmsgid"`
  21244. Infcode int64 `json:"infcode"`
  21245. Output struct {
  21246. Setlinfo interface{} `json:"setlinfo"`
  21247. } `json:"output"`
  21248. RefmsgTime string `json:"refmsg_time"`
  21249. RespondTime string `json:"respond_time"`
  21250. Signtype interface{} `json:"signtype"`
  21251. WarnMsg interface{} `json:"warn_msg"`
  21252. }
  21253. type ResultSeventeen struct {
  21254. ErrMsg string `json:"err_msg"`
  21255. InfRefmsgid string `json:"inf_refmsgid"`
  21256. Infcode int64 `json:"infcode"`
  21257. Output struct {
  21258. SetlListId string `json:"setl_list_id"`
  21259. } `json:"output"`
  21260. RefmsgTime string `json:"refmsg_time"`
  21261. RespondTime string `json:"respond_time"`
  21262. Signtype string `json:"signtype"`
  21263. WarnInfo string `json:"warn_info"`
  21264. }
  21265. type ResultSeventeenOther struct {
  21266. ErrMsg string `json:"err_msg"`
  21267. InfRefmsgid string `json:"inf_refmsgid"`
  21268. Infcode string `json:"infcode"`
  21269. Output struct {
  21270. SetlListId string `json:"setl_list_id"`
  21271. } `json:"output"`
  21272. RefmsgTime string `json:"refmsg_time"`
  21273. RespondTime string `json:"respond_time"`
  21274. Signtype string `json:"signtype"`
  21275. WarnInfo string `json:"warn_info"`
  21276. }
  21277. type Result90991 struct {
  21278. ErrMsg string `json:"err_msg"`
  21279. InfRefmsgid string `json:"inf_refmsgid"`
  21280. Infcode int64 `json:"infcode"`
  21281. Output struct {
  21282. Result struct {
  21283. PsnNo string `json:"psn_no"`
  21284. CardStat string `json:"card_stat"`
  21285. Certno string `json:"certno"`
  21286. PsnName string `json:"psn_name"`
  21287. CheckStat string `json:"check_stat"`
  21288. SscnoCheckStat string `json:"sscno_check_stat"`
  21289. } `json:"result"`
  21290. } `json:"output"`
  21291. RefmsgTime string `json:"refmsg_time"`
  21292. RespondTime string `json:"respond_time"`
  21293. Signtype interface{} `json:"signtype"`
  21294. WarnInfo interface{} `json:"warn_info"`
  21295. }
  21296. type Result90100 struct {
  21297. ErrMsg string `json:"err_msg"`
  21298. InfRefmsgid string `json:"inf_refmsgid"`
  21299. Infcode int64 `json:"infcode"`
  21300. Output struct {
  21301. PoolareaNo string `json:"poolarea_no"`
  21302. PoolareaNoName string `json:"poolarea_no_name"`
  21303. Insutype string `json:"insutype"`
  21304. InsutypeName string `json:"insutype_name"`
  21305. ClctType string `json:"clct_type"`
  21306. ClctTypeName string `json:"clct_type_name"`
  21307. ClctFlag string `json:"clct_flag"`
  21308. ClctFlagName string `json:"clct_flag_name"`
  21309. AccrymBegn string `json:"accrym_begn"`
  21310. AccrymEnd string `json:"accrym_end"`
  21311. ClctTime string `json:"clct_time"`
  21312. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  21313. } `json:"output"`
  21314. RefmsgTime string `json:"refmsg_time"`
  21315. RespondTime string `json:"respond_time"`
  21316. Signtype interface{} `json:"signtype"`
  21317. WarnInfo interface{} `json:"warn_info"`
  21318. }
  21319. type Custom struct {
  21320. DetItemFeeSumamt string
  21321. Cut string
  21322. FeedetlSn string
  21323. Price string
  21324. MedListCodg string
  21325. Type int64
  21326. AdviceId int64
  21327. ProjectId int64
  21328. ItemId int64
  21329. }
  21330. type Result5301 struct {
  21331. ErrMsg string `json:"err_msg"`
  21332. InfRefmsgid string `json:"inf_refmsgid"`
  21333. Infcode int64 `json:"infcode"`
  21334. Output struct {
  21335. Result []struct {
  21336. OpspDiseCode string `json:"opsp_dise_code"`
  21337. OpspDiseName string `json:"opsp_dise_name"`
  21338. Begndate string `json:"begndate"`
  21339. Enddate string `json:"enddate"`
  21340. } `json:"feedetail"`
  21341. } `json:"output"`
  21342. RefmsgTime string `json:"refmsg_time"`
  21343. RespondTime string `json:"respond_time"`
  21344. Signtype interface{} `json:"signtype"`
  21345. WarnInfo interface{} `json:"warn_info"`
  21346. }
  21347. type Result5301For10265 struct {
  21348. ErrMsg string `json:"err_msg"`
  21349. InfRefmsgid string `json:"inf_refmsgid"`
  21350. Infcode string `json:"infcode"`
  21351. Output struct {
  21352. Result []struct {
  21353. OpspDiseCode string `json:"opsp_dise_code"`
  21354. OpspDiseName string `json:"opsp_dise_name"`
  21355. Begndate string `json:"begndate"`
  21356. Enddate string `json:"enddate"`
  21357. } `json:"feedetail"`
  21358. } `json:"output"`
  21359. RefmsgTime string `json:"refmsg_time"`
  21360. RespondTime string `json:"respond_time"`
  21361. Signtype interface{} `json:"signtype"`
  21362. WarnInfo interface{} `json:"warn_info"`
  21363. }
  21364. //获取个人信息----挂号-----上传就诊信息
  21365. func (c *HisApiController) GetRegisterInfo() {
  21366. id, _ := c.GetInt64("id")
  21367. record_time := c.GetString("record_time")
  21368. settlementValue, _ := c.GetInt64("settlement_value")
  21369. medical_insurance_card := c.GetString("medical_insurance_card")
  21370. name := c.GetString("name")
  21371. id_card_type, _ := c.GetInt64("id_card_type")
  21372. certificates, _ := c.GetInt64("certificates")
  21373. medical_care, _ := c.GetInt64("medical_care")
  21374. birthday := c.GetString("birthday")
  21375. id_card := c.GetString("id_card")
  21376. register_type, _ := c.GetInt64("register")
  21377. doctor, _ := c.GetInt64("doctor")
  21378. department, _ := c.GetInt64("department")
  21379. gender, _ := c.GetInt64("sex")
  21380. registration_fee, _ := c.GetFloat("registration_fee")
  21381. medical_expenses, _ := c.GetFloat("medical_expenses")
  21382. social_type, _ := c.GetInt64("social_type")
  21383. admin_user_id, _ := c.GetInt64("admin_user_id")
  21384. insuplc_admdvs := c.GetString("insuplc_admdvs")
  21385. mdtrt_type := c.GetString("mdtrt_type")
  21386. if id_card_type == 5 {
  21387. id_card_type = 4
  21388. }
  21389. timeLayout := "2006-01-02"
  21390. loc, _ := time.LoadLocation("Local")
  21391. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  21392. birthUnix := birthdays.Unix()
  21393. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  21394. if err != nil {
  21395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21396. return
  21397. }
  21398. recordDateTime := theTime.Unix()
  21399. adminInfo := c.GetAdminUserInfo()
  21400. var patient service.Patients
  21401. if id == 0 {
  21402. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  21403. } else {
  21404. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  21405. }
  21406. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  21407. if patientPrescription.ID == 0 {
  21408. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  21409. }
  21410. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21411. if patient.ID == 0 {
  21412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  21413. return
  21414. }
  21415. if len(patient.IdCardNo) == 0 {
  21416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  21417. return
  21418. }
  21419. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21420. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  21421. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  21422. //就诊结算未完成,不能进行二次挂号
  21423. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  21424. if len(his) >= 1 {
  21425. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  21426. if len(his) >= 1 && order.ID == 0 {
  21427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  21428. return
  21429. }
  21430. }
  21431. //var register_log string
  21432. if config.IsOpen == 1 {
  21433. var res ResultTwo
  21434. var res10265 ResultTwo10265
  21435. var PsnNo string
  21436. var PsnCertType string
  21437. var Certno string
  21438. var PsnName string
  21439. var Gend string
  21440. var Naty string
  21441. var Brdy string
  21442. var Age float64
  21443. var infoStr string
  21444. var idetinfoStr string
  21445. var infocode int64
  21446. var verify_number string
  21447. fmt.Println(verify_number)
  21448. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  21449. psn_info, _ := service.GetPsnByPatientId(id)
  21450. PsnNo = psn_info.PsnNo
  21451. PsnCertType = psn_info.PsnCertType
  21452. Certno = psn_info.Certno
  21453. PsnName = psn_info.PsnName
  21454. Gend = psn_info.Gend
  21455. Naty = psn_info.Naty
  21456. Brdy = psn_info.Brdy
  21457. Age = psn_info.Age
  21458. infoStr = psn_info.Insuinfo
  21459. idetinfoStr = psn_info.Idetinfo
  21460. infocode = 0
  21461. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21462. psn_info, _ := service.GetPsnByPatientId(id)
  21463. PsnNo = psn_info.PsnNo
  21464. PsnCertType = psn_info.PsnCertType
  21465. Certno = psn_info.Certno
  21466. PsnName = psn_info.PsnName
  21467. Gend = psn_info.Gend
  21468. Naty = psn_info.Naty
  21469. Brdy = psn_info.Brdy
  21470. Age = psn_info.Age
  21471. infoStr = psn_info.Insuinfo
  21472. idetinfoStr = psn_info.Idetinfo
  21473. infocode = 0
  21474. verify_number = psn_info.VerifyNumber
  21475. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21476. if id_card_type == 2 {
  21477. //请求内网数据
  21478. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  21479. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21480. "&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
  21481. resp, requestErr := http.Get(api)
  21482. if requestErr != nil {
  21483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21484. return
  21485. }
  21486. body, ioErr := ioutil.ReadAll(resp.Body)
  21487. if ioErr != nil {
  21488. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21490. return
  21491. }
  21492. var respJSON map[string]interface{}
  21493. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21494. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21496. return
  21497. }
  21498. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21499. result_byte, _ := json.Marshal(respJSON)
  21500. result := string(result_byte)
  21501. var dat map[string]interface{}
  21502. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21503. fmt.Println(dat)
  21504. } else {
  21505. fmt.Println(err)
  21506. }
  21507. userJSONBytes, _ := json.Marshal(dat)
  21508. var res ResultTwo
  21509. var resTwo10265 ResultTwo10265
  21510. if miConfig.Code == "H15049901371" {
  21511. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  21512. utils.ErrorLog("解析失败:%v", err)
  21513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21514. return
  21515. }
  21516. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  21517. res.Infcode = Infcode
  21518. res.ErrMsg = resTwo10265.ErrMsg
  21519. res.Output = resTwo10265.Output
  21520. res.InfRefmsgid = resTwo10265.InfRefmsgid
  21521. res.RespondTime = resTwo10265.RespondTime
  21522. res.WarnInfo = resTwo10265.WarnInfo
  21523. } else {
  21524. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21525. utils.ErrorLog("解析失败:%v", err)
  21526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21527. return
  21528. }
  21529. }
  21530. //var insutypes []string
  21531. //var insutype string
  21532. //var is390 int = 0
  21533. //var is310 int = 0
  21534. //for _, item := range res.Output.Iinfo {
  21535. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21536. // insutypes = append(insutypes, item.Insutype)
  21537. // }
  21538. //}
  21539. //if len(insutypes) == 1 {
  21540. // insutype = insutypes[0]
  21541. //} else {
  21542. // for _, i := range insutypes {
  21543. // if i == "390" {
  21544. // is390 = 1
  21545. // }
  21546. //
  21547. // if i == "310" {
  21548. // is310 = 1
  21549. // }
  21550. // }
  21551. //}
  21552. //if is390 == 1 {
  21553. // insutype = "390"
  21554. //}
  21555. //if is310 == 1 {
  21556. // insutype = "310"
  21557. //}
  21558. //if len(insutypes) == 0 {
  21559. // insutype = "310"
  21560. //}
  21561. PsnNo = res.Output.Baseinfo.PsnNo
  21562. PsnCertType = res.Output.Baseinfo.PsnCertType
  21563. Certno = res.Output.Baseinfo.Certno
  21564. PsnName = res.Output.Baseinfo.PsnName
  21565. Gend = res.Output.Baseinfo.Gend
  21566. Naty = res.Output.Baseinfo.Naty
  21567. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21568. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21569. infoStr = string(Iinfos)
  21570. idetinfoStr = string(Idetinfos)
  21571. infocode = res.Infcode
  21572. //infocode = 0
  21573. //verify_number = psn_info.VerifyNumber
  21574. } else {
  21575. psn_info, _ := service.GetPsnByPatientId(id)
  21576. PsnNo = psn_info.PsnNo
  21577. PsnCertType = psn_info.PsnCertType
  21578. Certno = psn_info.Certno
  21579. PsnName = psn_info.PsnName
  21580. Gend = psn_info.Gend
  21581. Naty = psn_info.Naty
  21582. Brdy = psn_info.Brdy
  21583. Age = psn_info.Age
  21584. infoStr = psn_info.Insuinfo
  21585. idetinfoStr = psn_info.Idetinfo
  21586. infocode = 0
  21587. verify_number = psn_info.VerifyNumber
  21588. }
  21589. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21590. if id_card_type == 1 {
  21591. psn_info, _ := service.GetPsnByPatientId(id)
  21592. PsnNo = psn_info.PsnNo
  21593. PsnCertType = psn_info.PsnCertType
  21594. Certno = psn_info.Certno
  21595. PsnName = psn_info.PsnName
  21596. Gend = psn_info.Gend
  21597. Naty = psn_info.Naty
  21598. Brdy = psn_info.Brdy
  21599. Age = psn_info.Age
  21600. infoStr = psn_info.Insuinfo
  21601. idetinfoStr = psn_info.Idetinfo
  21602. infocode = 0
  21603. verify_number = psn_info.VerifyNumber
  21604. } else if id_card_type == 2 {
  21605. 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)
  21606. fmt.Println(errMsgLog)
  21607. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21608. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21609. utils.ErrorLog("解析失败:%v", err)
  21610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21611. return
  21612. }
  21613. PsnNo = res.Output.Baseinfo.PsnNo
  21614. PsnCertType = res.Output.Baseinfo.PsnCertType
  21615. Certno = res.Output.Baseinfo.Certno
  21616. PsnName = res.Output.Baseinfo.PsnName
  21617. Gend = res.Output.Baseinfo.Gend
  21618. Naty = res.Output.Baseinfo.Naty
  21619. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21620. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21621. infoStr = string(Iinfos)
  21622. idetinfoStr = string(Idetinfos)
  21623. infocode = res.Infcode
  21624. }
  21625. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21626. if id_card_type == 1 {
  21627. psn_info, _ := service.GetPsnByPatientId(id)
  21628. PsnNo = psn_info.PsnNo
  21629. PsnCertType = psn_info.PsnCertType
  21630. Certno = psn_info.Certno
  21631. PsnName = psn_info.PsnName
  21632. Gend = psn_info.Gend
  21633. Naty = psn_info.Naty
  21634. Brdy = psn_info.Brdy
  21635. Age = psn_info.Age
  21636. infoStr = psn_info.Insuinfo
  21637. idetinfoStr = psn_info.Idetinfo
  21638. infocode = 0
  21639. verify_number = psn_info.VerifyNumber
  21640. } else if id_card_type == 2 {
  21641. 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, "")
  21642. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21643. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21644. utils.ErrorLog("解析失败:%v", err)
  21645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21646. return
  21647. }
  21648. PsnNo = res.Output.Baseinfo.PsnNo
  21649. PsnCertType = res.Output.Baseinfo.PsnCertType
  21650. Certno = res.Output.Baseinfo.Certno
  21651. PsnName = res.Output.Baseinfo.PsnName
  21652. Gend = res.Output.Baseinfo.Gend
  21653. Naty = res.Output.Baseinfo.Naty
  21654. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21655. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21656. infoStr = string(Iinfos)
  21657. idetinfoStr = string(Idetinfos)
  21658. infocode = res.Infcode
  21659. } else {
  21660. psn_info, _ := service.GetPsnByPatientId(id)
  21661. PsnNo = psn_info.PsnNo
  21662. PsnCertType = psn_info.PsnCertType
  21663. Certno = psn_info.Certno
  21664. PsnName = psn_info.PsnName
  21665. Gend = psn_info.Gend
  21666. Naty = psn_info.Naty
  21667. Brdy = psn_info.Brdy
  21668. Age = psn_info.Age
  21669. infoStr = psn_info.Insuinfo
  21670. idetinfoStr = psn_info.Idetinfo
  21671. infocode = 0
  21672. verify_number = psn_info.VerifyNumber
  21673. }
  21674. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21675. psn_info, _ := service.GetPsnByPatientId(id)
  21676. PsnNo = psn_info.PsnNo
  21677. PsnCertType = psn_info.PsnCertType
  21678. Certno = psn_info.Certno
  21679. PsnName = psn_info.PsnName
  21680. Gend = psn_info.Gend
  21681. Naty = psn_info.Naty
  21682. Brdy = psn_info.Brdy
  21683. Age = psn_info.Age
  21684. infoStr = psn_info.Insuinfo
  21685. idetinfoStr = psn_info.Idetinfo
  21686. infocode = 0
  21687. verify_number = psn_info.VerifyNumber
  21688. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21689. if id_card_type == 1 {
  21690. psn_info, _ := service.GetPsnByPatientId(id)
  21691. PsnNo = psn_info.PsnNo
  21692. PsnCertType = psn_info.PsnCertType
  21693. Certno = psn_info.Certno
  21694. PsnName = psn_info.PsnName
  21695. Gend = psn_info.Gend
  21696. Naty = psn_info.Naty
  21697. Brdy = psn_info.Brdy
  21698. Age = psn_info.Age
  21699. infoStr = psn_info.Insuinfo
  21700. idetinfoStr = psn_info.Idetinfo
  21701. infocode = 0
  21702. verify_number = psn_info.VerifyNumber
  21703. } else if id_card_type == 2 {
  21704. 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)
  21705. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21706. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21707. utils.ErrorLog("解析失败:%v", err)
  21708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21709. return
  21710. }
  21711. PsnNo = res.Output.Baseinfo.PsnNo
  21712. PsnCertType = res.Output.Baseinfo.PsnCertType
  21713. Certno = res.Output.Baseinfo.Certno
  21714. PsnName = res.Output.Baseinfo.PsnName
  21715. Gend = res.Output.Baseinfo.Gend
  21716. Naty = res.Output.Baseinfo.Naty
  21717. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21718. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21719. infoStr = string(Iinfos)
  21720. idetinfoStr = string(Idetinfos)
  21721. infocode = res.Infcode
  21722. } else if id_card_type == 4 {
  21723. psn_info, _ := service.GetPsnByPatientId(id)
  21724. PsnNo = psn_info.PsnNo
  21725. PsnCertType = psn_info.PsnCertType
  21726. Certno = psn_info.Certno
  21727. PsnName = psn_info.PsnName
  21728. Gend = psn_info.Gend
  21729. Naty = psn_info.Naty
  21730. Brdy = psn_info.Brdy
  21731. Age = psn_info.Age
  21732. infoStr = psn_info.Insuinfo
  21733. idetinfoStr = psn_info.Idetinfo
  21734. infocode = 0
  21735. verify_number = psn_info.VerifyNumber
  21736. }
  21737. } else if miConfig.MdtrtareaAdmvs == "131023" {
  21738. var result string
  21739. var requestLog string
  21740. 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), "")
  21741. if id_card_type == 4 {
  21742. psn_info, _ := service.GetPsnByPatientId(id)
  21743. PsnNo = psn_info.PsnNo
  21744. PsnCertType = psn_info.PsnCertType
  21745. Certno = psn_info.Certno
  21746. PsnName = psn_info.PsnName
  21747. Gend = psn_info.Gend
  21748. Naty = psn_info.Naty
  21749. Brdy = psn_info.Brdy
  21750. Age = psn_info.Age
  21751. infoStr = psn_info.Insuinfo
  21752. idetinfoStr = psn_info.Idetinfo
  21753. infocode = 0
  21754. verify_number = psn_info.VerifyNumber
  21755. } else {
  21756. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21757. if miConfig.Code == "H15049901371" {
  21758. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  21759. utils.ErrorLog("解析失败:%v", err)
  21760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21761. return
  21762. }
  21763. res.ErrMsg = res10265.ErrMsg
  21764. res.Output = res10265.Output
  21765. res.InfRefmsgid = res10265.InfRefmsgid
  21766. } else {
  21767. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21768. utils.ErrorLog("解析失败:%v", err)
  21769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21770. return
  21771. }
  21772. }
  21773. PsnNo = res.Output.Baseinfo.PsnNo
  21774. PsnCertType = res.Output.Baseinfo.PsnCertType
  21775. Certno = res.Output.Baseinfo.Certno
  21776. PsnName = res.Output.Baseinfo.PsnName
  21777. Gend = res.Output.Baseinfo.Gend
  21778. Naty = res.Output.Baseinfo.Naty
  21779. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21780. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21781. infoStr = string(Iinfos)
  21782. idetinfoStr = string(Idetinfos)
  21783. if miConfig.Code == "H15049901371" {
  21784. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  21785. } else {
  21786. infocode = res.Infcode
  21787. }
  21788. }
  21789. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21790. psn_info, _ := service.GetPsnByPatientId(id)
  21791. PsnNo = psn_info.PsnNo
  21792. PsnCertType = psn_info.PsnCertType
  21793. Certno = psn_info.Certno
  21794. PsnName = psn_info.PsnName
  21795. Gend = psn_info.Gend
  21796. Naty = psn_info.Naty
  21797. Brdy = psn_info.Brdy
  21798. Age = psn_info.Age
  21799. infoStr = psn_info.Insuinfo
  21800. idetinfoStr = psn_info.Idetinfo
  21801. infocode = 0
  21802. verify_number = psn_info.VerifyNumber
  21803. } else if miConfig.MdtrtareaAdmvs == "450721" {
  21804. psn_info, _ := service.GetPsnByPatientId(id)
  21805. PsnNo = psn_info.PsnNo
  21806. PsnCertType = psn_info.PsnCertType
  21807. Certno = psn_info.Certno
  21808. PsnName = psn_info.PsnName
  21809. Gend = psn_info.Gend
  21810. Naty = psn_info.Naty
  21811. Brdy = psn_info.Brdy
  21812. Age = psn_info.Age
  21813. infoStr = psn_info.Insuinfo
  21814. idetinfoStr = psn_info.Idetinfo
  21815. infocode = 0
  21816. verify_number = psn_info.VerifyNumber
  21817. } else {
  21818. var result string
  21819. var requestLog string
  21820. //if miConfig.UserOrgId == 10138 {
  21821. if id_card_type != 4 || id_card_type != 1 {
  21822. var insa string
  21823. if len(patient.InsuplcAdmdvs) > 0 {
  21824. insa = patient.InsuplcAdmdvs
  21825. } else {
  21826. insa = miConfig.InsuplcAdmdvs
  21827. }
  21828. //psn_info, _ := service.GetPsnByPatientId(id)
  21829. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  21830. 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)
  21831. }
  21832. //}
  21833. //else {
  21834. // var insa string
  21835. // if len(patient.InsuplcAdmdvs) > 0 {
  21836. // insa = patient.InsuplcAdmdvs
  21837. // } else {
  21838. // insa = miConfig.InsuplcAdmdvs
  21839. // }
  21840. // 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)
  21841. //}
  21842. if id_card_type == 4 || id_card_type == 1 {
  21843. psn_info, _ := service.GetPsnByPatientId(id)
  21844. PsnNo = psn_info.PsnNo
  21845. PsnCertType = psn_info.PsnCertType
  21846. Certno = psn_info.Certno
  21847. PsnName = psn_info.PsnName
  21848. Gend = psn_info.Gend
  21849. Naty = psn_info.Naty
  21850. Brdy = psn_info.Brdy
  21851. Age = psn_info.Age
  21852. infoStr = psn_info.Insuinfo
  21853. idetinfoStr = psn_info.Idetinfo
  21854. infocode = 0
  21855. verify_number = psn_info.VerifyNumber
  21856. } else {
  21857. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21858. if miConfig.Code == "H15049901371" {
  21859. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  21860. utils.ErrorLog("解析失败:%v", err)
  21861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21862. return
  21863. }
  21864. res.ErrMsg = res10265.ErrMsg
  21865. res.Output = res10265.Output
  21866. res.InfRefmsgid = res10265.InfRefmsgid
  21867. } else {
  21868. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21869. utils.ErrorLog("解析失败:%v", err)
  21870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21871. return
  21872. }
  21873. }
  21874. PsnNo = res.Output.Baseinfo.PsnNo
  21875. PsnCertType = res.Output.Baseinfo.PsnCertType
  21876. Certno = res.Output.Baseinfo.Certno
  21877. PsnName = res.Output.Baseinfo.PsnName
  21878. Gend = res.Output.Baseinfo.Gend
  21879. Naty = res.Output.Baseinfo.Naty
  21880. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21881. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21882. infoStr = string(Iinfos)
  21883. idetinfoStr = string(Idetinfos)
  21884. if miConfig.Code == "H15049901371" {
  21885. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  21886. } else {
  21887. infocode = res.Infcode
  21888. }
  21889. }
  21890. }
  21891. if infocode == 0 {
  21892. his := models.VMHisPatient{
  21893. Name: name,
  21894. Gender: gender,
  21895. Birthday: birthUnix,
  21896. MedicalTreatmentType: medical_care,
  21897. IdType: certificates,
  21898. IdCardNo: id_card,
  21899. BalanceAccountsType: settlementValue,
  21900. SocialType: social_type,
  21901. MedicalInsuranceNumber: medical_insurance_card,
  21902. RegisterType: register_type,
  21903. RegisterCost: registration_fee,
  21904. TreatmentCost: medical_expenses,
  21905. Status: 1,
  21906. Ctime: time.Now().Unix(),
  21907. Mtime: time.Now().Unix(),
  21908. PsnNo: PsnNo,
  21909. PsnCertType: PsnCertType,
  21910. Certno: Certno,
  21911. PsnName: PsnName,
  21912. Gend: Gend,
  21913. Naty: Naty,
  21914. Brdy: Brdy,
  21915. Age: Age,
  21916. Iinfo: infoStr,
  21917. Idetinfo: idetinfoStr,
  21918. PatientId: patient.ID,
  21919. RecordDate: theTime.Unix(),
  21920. UserOrgId: adminInfo.CurrentOrgId,
  21921. AdminUserId: admin_user_id,
  21922. IsReturn: 1,
  21923. IdCardType: id_card_type,
  21924. Doctor: doctor,
  21925. Departments: department,
  21926. MdtrtGrpType: mdtrt_type,
  21927. }
  21928. timestamp := time.Now().Unix()
  21929. tempTime := time.Unix(timestamp, 0)
  21930. timeFormat := tempTime.Format("20060102150405")
  21931. chrgBchno := rand.Intn(100000) + 10000
  21932. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  21933. his.Number = ipt_otp_no
  21934. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  21935. department, _ := service.GetDepartMentDetail(department)
  21936. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  21937. IdCardNo := ""
  21938. if id_card_type == 1 {
  21939. // IdCardNo = medical_insurance_card
  21940. IdCardNo = patient.IdCardNo
  21941. } else {
  21942. IdCardNo = patient.IdCardNo
  21943. }
  21944. var rf []*ResultFive
  21945. json.Unmarshal([]byte(his.Iinfo), &rf)
  21946. var insutypes []*ResultFive
  21947. var insutype string
  21948. var insuplc_admdvs_temp string
  21949. var is390 int = 0
  21950. var is310 int = 0
  21951. for _, item := range rf {
  21952. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21953. insutypes = append(insutypes, item)
  21954. }
  21955. }
  21956. if len(insutypes) == 1 {
  21957. insutype = insutypes[0].Insutype
  21958. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  21959. if insutype == "390" {
  21960. is390 = 1
  21961. }
  21962. if insutype == "310" {
  21963. is310 = 1
  21964. }
  21965. } else {
  21966. for _, i := range insutypes {
  21967. if i.Insutype == "390" {
  21968. is390 = 1
  21969. }
  21970. if i.Insutype == "310" {
  21971. is310 = 1
  21972. }
  21973. }
  21974. }
  21975. if is390 == 1 {
  21976. insutype = "390"
  21977. }
  21978. if is310 == 1 {
  21979. insutype = "310"
  21980. }
  21981. fmt.Println(social_type)
  21982. if social_type > 0 {
  21983. insutype = strconv.FormatInt(social_type, 10)
  21984. }
  21985. var infocode int64
  21986. var resThree ResultThree
  21987. var resThree10265 ResultThree10265
  21988. if len(insuplc_admdvs) == 0 {
  21989. psn_info, _ := service.GetPsnByPatientId(id)
  21990. //if len(psn_info.InsuplcAdmdvs) > 0 {
  21991. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  21992. //}
  21993. } else {
  21994. insuplc_admdvs_temp = insuplc_admdvs
  21995. }
  21996. if miConfig.MdtrtareaAdmvs == "421300" {
  21997. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  21998. psn_info, _ := service.GetPsnByPatientId(id)
  21999. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22000. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22001. "&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
  22002. resp, requestErr := http.Get(api)
  22003. if requestErr != nil {
  22004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22005. return
  22006. }
  22007. body, ioErr := ioutil.ReadAll(resp.Body)
  22008. if ioErr != nil {
  22009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22011. return
  22012. }
  22013. var respJSON map[string]interface{}
  22014. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22017. return
  22018. }
  22019. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22020. result, _ := json.Marshal(respJSON)
  22021. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22022. utils.ErrorLog("解析失败:%v", err)
  22023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22024. return
  22025. }
  22026. infocode = resThree.Infcode
  22027. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22028. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22029. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  22030. // insuplc_admdvs_temp =
  22031. //}
  22032. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  22033. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22034. //}
  22035. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22036. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22037. "&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
  22038. resp, requestErr := http.Get(api)
  22039. if requestErr != nil {
  22040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22041. return
  22042. }
  22043. body, ioErr := ioutil.ReadAll(resp.Body)
  22044. if ioErr != nil {
  22045. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22047. return
  22048. }
  22049. var respJSON map[string]interface{}
  22050. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22053. return
  22054. }
  22055. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22056. result, _ := json.Marshal(respJSON)
  22057. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22058. utils.ErrorLog("解析失败:%v", err)
  22059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22060. return
  22061. }
  22062. infocode = resThree.Infcode
  22063. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22064. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22065. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  22066. // insuplc_admdvs_temp =
  22067. //}
  22068. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  22069. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22070. //}
  22071. utils.ErrorLog("解析失败:%v", insutype)
  22072. utils.ErrorLog("解析失败:%v", PsnNo)
  22073. utils.ErrorLog("解析失败:%v", Certno)
  22074. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  22075. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  22076. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  22077. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  22078. utils.ErrorLog("解析失败:%v", PsnNo)
  22079. utils.ErrorLog("解析失败:%v", department.Number)
  22080. utils.ErrorLog("解析失败:%v", department.Name)
  22081. utils.ErrorLog("解析失败:%v", roles.UserName)
  22082. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22083. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22084. "&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
  22085. resp, requestErr := http.Get(api)
  22086. if requestErr != nil {
  22087. utils.ErrorLog("解析失败:%v", requestErr)
  22088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22089. return
  22090. }
  22091. body, ioErr := ioutil.ReadAll(resp.Body)
  22092. if ioErr != nil {
  22093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22095. return
  22096. }
  22097. var respJSON map[string]interface{}
  22098. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22101. return
  22102. }
  22103. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22104. result, _ := json.Marshal(respJSON)
  22105. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22106. utils.ErrorLog("解析失败:%v", err)
  22107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22108. return
  22109. }
  22110. infocode = resThree.Infcode
  22111. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22112. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22113. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  22114. // insuplc_admdvs_temp =
  22115. //}
  22116. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  22117. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22118. //}
  22119. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22120. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22121. "&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
  22122. resp, requestErr := http.Get(api)
  22123. if requestErr != nil {
  22124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22125. return
  22126. }
  22127. body, ioErr := ioutil.ReadAll(resp.Body)
  22128. if ioErr != nil {
  22129. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22131. return
  22132. }
  22133. var respJSON map[string]interface{}
  22134. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22135. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22137. return
  22138. }
  22139. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22140. result, _ := json.Marshal(respJSON)
  22141. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22142. utils.ErrorLog("解析失败:%v", err)
  22143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22144. return
  22145. }
  22146. infocode = resThree.Infcode
  22147. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22148. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22149. psn_info, _ := service.GetPsnByPatientId(id)
  22150. var verify_number string
  22151. if id_card_type == 4 {
  22152. verify_number = psn_info.VerifyNumber
  22153. } else if id_card_type == 1 {
  22154. bas := strings.Split(psn_info.CardInfo, "|")
  22155. cardNumber := bas[2]
  22156. verify_number = cardNumber
  22157. }
  22158. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22159. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22160. "&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
  22161. resp, requestErr := http.Get(api)
  22162. if requestErr != nil {
  22163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22164. return
  22165. }
  22166. body, ioErr := ioutil.ReadAll(resp.Body)
  22167. if ioErr != nil {
  22168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22170. return
  22171. }
  22172. var respJSON map[string]interface{}
  22173. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22176. return
  22177. }
  22178. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22179. result, _ := json.Marshal(respJSON)
  22180. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22181. // utils.ErrorLog("解析失败:%v", err)
  22182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22183. // return
  22184. //}
  22185. //infocode = resThree.Infcode
  22186. //result, _ := json.Marshal(respJSON)
  22187. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22188. utils.ErrorLog("解析失败:%v", err)
  22189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22190. return
  22191. }
  22192. resThree.ErrMsg = resThree10265.ErrMsg
  22193. resThree.Output = resThree10265.Output
  22194. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22195. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22196. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22197. psn_info, _ := service.GetPsnByPatientId(id)
  22198. his.PsnNo = psn_info.PsnNo
  22199. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22200. var cert_no string
  22201. if id_card_type == 3 {
  22202. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  22203. cert_no = IdCardNo
  22204. } else if id_card_type == 4 {
  22205. cert_no = IdCardNo
  22206. psn_info.VerifyNumber = psn_info.VerifyNumber
  22207. } else {
  22208. bas := strings.Split(psn_info.CardInfo, "|")
  22209. cert_no = bas[2]
  22210. }
  22211. var hisPrescription []*models.HisPrescription
  22212. for _, item := range rf {
  22213. if item.Insutype == insutype {
  22214. //insuplc_admdvs = item.InsuplcAdmdvs
  22215. his.InsuplcAdmdvs = insuplc_admdvs
  22216. }
  22217. }
  22218. his.Insutype = insutype
  22219. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  22220. fmt.Println(res3101)
  22221. fmt.Println(res3101.Infcode)
  22222. if res3101.Infcode == "0" {
  22223. fmt.Println("33333333")
  22224. if len(res3101.Output.Result) > 0 {
  22225. fmt.Println("222222")
  22226. for _, item := range res3101.Output.Result {
  22227. if len(res3101.ErrMsg) == 0 {
  22228. res3101.ErrMsg = item.VolaCont
  22229. } else {
  22230. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  22231. }
  22232. }
  22233. c.ServeSuccessJSON(map[string]interface{}{
  22234. "failed_code": -10,
  22235. "msg": res3101.ErrMsg,
  22236. })
  22237. return
  22238. } else {
  22239. fmt.Println("11111")
  22240. var api string
  22241. if miConfig.MdtrtareaAdmvs == "320921" {
  22242. ipt_otp_no = timeFormat
  22243. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  22244. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22245. "&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
  22246. } else {
  22247. ipt_otp_no = timeFormat
  22248. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  22249. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22250. "&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
  22251. }
  22252. resp, requestErr := http.Get(api)
  22253. if requestErr != nil {
  22254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22255. return
  22256. }
  22257. body, ioErr := ioutil.ReadAll(resp.Body)
  22258. if ioErr != nil {
  22259. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22261. return
  22262. }
  22263. var respJSON map[string]interface{}
  22264. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22267. return
  22268. }
  22269. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22270. result, _ := json.Marshal(respJSON)
  22271. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22272. utils.ErrorLog("解析失败:%v", err)
  22273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22274. return
  22275. }
  22276. resThree.ErrMsg = resThree10265.ErrMsg
  22277. resThree.Output = resThree10265.Output
  22278. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22279. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22280. }
  22281. } else if res3101.Infcode != "0" {
  22282. c.ServeSuccessJSON(map[string]interface{}{
  22283. "failed_code": -10,
  22284. "msg": res3101.ErrMsg,
  22285. })
  22286. return
  22287. }
  22288. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22289. psn_info, _ := service.GetPsnByPatientId(id)
  22290. var cert_no string
  22291. if id_card_type == 1 {
  22292. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  22293. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22294. } else if id_card_type == 4 {
  22295. cert_no = psn_info.VerifyNumber
  22296. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22297. } else {
  22298. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22299. cert_no = psn_info.VerifyNumber
  22300. }
  22301. 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)
  22302. saveLog(result, requestLog, "2201", "挂号")
  22303. if miConfig.Code == "H15049901371" {
  22304. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22305. utils.ErrorLog("解析失败:%v", err)
  22306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22307. return
  22308. }
  22309. resThree.ErrMsg = resThree10265.ErrMsg
  22310. resThree.Output = resThree10265.Output
  22311. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22312. } else {
  22313. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22314. utils.ErrorLog("解析失败:%v", err)
  22315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22316. return
  22317. }
  22318. }
  22319. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22320. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  22321. psn_info, _ := service.GetPsnByPatientId(id)
  22322. var result string
  22323. var requestLog string
  22324. if id_card_type == 1 {
  22325. bas := strings.Split(psn_info.CardInfo, "|")
  22326. basNumber := bas[2]
  22327. card_sn := bas[3]
  22328. 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)
  22329. saveLog(result, requestLog, "2201A", "挂号")
  22330. } else if id_card_type == 2 {
  22331. 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, "", "", "", "", "", "")
  22332. saveLog(result, requestLog, "2201A", "挂号")
  22333. } else {
  22334. 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)
  22335. saveLog(result, requestLog, "2201A", "挂号")
  22336. }
  22337. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22338. utils.ErrorLog("解析失败:%v", err)
  22339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22340. return
  22341. }
  22342. infocode = resThree.Infcode
  22343. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22344. psn_info, _ := service.GetPsnByPatientId(id)
  22345. his.PsnNo = psn_info.PsnNo
  22346. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22347. var cert_no string
  22348. if id_card_type == 1 {
  22349. bas := strings.Split(psn_info.CardInfo, "|")
  22350. cert_no = bas[2]
  22351. } else if id_card_type == 4 {
  22352. cert_no = IdCardNo
  22353. psn_info.VerifyNumber = psn_info.VerifyNumber
  22354. } else {
  22355. cert_no = IdCardNo
  22356. psn_info.VerifyNumber = cert_no
  22357. }
  22358. for _, item := range rf {
  22359. if item.Insutype == insutype {
  22360. his.InsuplcAdmdvs = insuplc_admdvs
  22361. }
  22362. }
  22363. his.Insutype = insutype
  22364. var api string
  22365. ipt_otp_no = timeFormat
  22366. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  22367. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22368. "&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
  22369. resp, requestErr := http.Get(api)
  22370. if requestErr != nil {
  22371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22372. return
  22373. }
  22374. body, ioErr := ioutil.ReadAll(resp.Body)
  22375. if ioErr != nil {
  22376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22378. return
  22379. }
  22380. var respJSON map[string]interface{}
  22381. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22384. return
  22385. }
  22386. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22387. if status == "0" {
  22388. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22389. c.ServeSuccessJSON(map[string]interface{}{
  22390. "failed_code": -10,
  22391. "msg": err_msg,
  22392. })
  22393. return
  22394. }
  22395. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22396. result, _ := json.Marshal(respJSON)
  22397. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22398. utils.ErrorLog("解析失败:%v", err)
  22399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22400. return
  22401. }
  22402. infocode = resThree.Infcode
  22403. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22404. psn_info, _ := service.GetPsnByPatientId(id)
  22405. var result string
  22406. var requestLog string
  22407. if id_card_type == 1 {
  22408. bas := strings.Split(psn_info.CardInfo, "|")
  22409. basNumber := bas[2]
  22410. card_sn := bas[3]
  22411. 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)
  22412. saveLog(result, requestLog, "2201A", "挂号")
  22413. } else if id_card_type == 2 {
  22414. 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, "", "")
  22415. saveLog(result, requestLog, "2201A", "挂号")
  22416. } else {
  22417. 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, "", "")
  22418. saveLog(result, requestLog, "2201A", "挂号")
  22419. }
  22420. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22421. utils.ErrorLog("解析失败:%v", err)
  22422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22423. return
  22424. }
  22425. infocode = resThree.Infcode
  22426. } else if miConfig.MdtrtareaAdmvs == "131023" {
  22427. psn_info, _ := service.GetPsnByPatientId(id)
  22428. 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)
  22429. saveLog(result, requestLog, "2201A", "挂号")
  22430. if miConfig.Code == "H15049901371" {
  22431. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22432. utils.ErrorLog("解析失败:%v", err)
  22433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22434. return
  22435. }
  22436. resThree.ErrMsg = resThree10265.ErrMsg
  22437. resThree.Output = resThree10265.Output
  22438. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22439. } else {
  22440. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22441. utils.ErrorLog("解析失败:%v", err)
  22442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22443. return
  22444. }
  22445. }
  22446. if miConfig.Code == "H15049901371" {
  22447. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22448. } else {
  22449. infocode = resThree.Infcode
  22450. }
  22451. } else {
  22452. psn_info, _ := service.GetPsnByPatientId(id)
  22453. if id_card_type == 4 || id_card_type == 1 {
  22454. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22455. }
  22456. var rf []*ResultFive
  22457. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  22458. var insutypes []*ResultFive
  22459. var insutype string
  22460. var is390 int = 0
  22461. var is310 int = 0
  22462. for _, item := range rf {
  22463. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22464. insutypes = append(insutypes, item)
  22465. }
  22466. }
  22467. if len(insutypes) == 1 {
  22468. insutype = insutypes[0].Insutype
  22469. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  22470. } else {
  22471. for _, i := range insutypes {
  22472. if i.Insutype == "390" {
  22473. is390 = 1
  22474. }
  22475. if i.Insutype == "310" {
  22476. is310 = 1
  22477. }
  22478. }
  22479. }
  22480. if is390 == 1 {
  22481. insutype = "390"
  22482. }
  22483. if is310 == 1 {
  22484. insutype = "310"
  22485. }
  22486. fmt.Println(len(insutypes))
  22487. if len(insutypes) == 0 {
  22488. for index, item := range rf {
  22489. if index == 0 {
  22490. insutype = item.Insutype
  22491. insuplc_admdvs = item.InsuplcAdmdvs
  22492. }
  22493. }
  22494. fmt.Println(insutype)
  22495. fmt.Println(insuplc_admdvs)
  22496. }
  22497. if social_type > 0 {
  22498. insutype = strconv.FormatInt(social_type, 10)
  22499. }
  22500. fmt.Println("--------")
  22501. fmt.Println(psn_info)
  22502. fmt.Println(psn_info.PsnNo)
  22503. if miConfig.MdtrtareaAdmvs == "441202" {
  22504. var hisPrescription []*models.HisPrescription
  22505. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  22506. if res3101.Infcode == 0 {
  22507. fmt.Println("33333333")
  22508. if len(res3101.Output.Result) > 0 {
  22509. fmt.Println("222222")
  22510. for _, item := range res3101.Output.Result {
  22511. if len(res3101.ErrMsg) == 0 {
  22512. res3101.ErrMsg = item.VolaCont
  22513. } else {
  22514. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  22515. }
  22516. }
  22517. c.ServeSuccessJSON(map[string]interface{}{
  22518. "failed_code": -10,
  22519. "msg": res3101.ErrMsg,
  22520. })
  22521. return
  22522. } else {
  22523. hour := time.Now().Format("15")
  22524. min := time.Now().Format("04")
  22525. sec := time.Now().Format("05")
  22526. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  22527. fmt.Println(record_time_two)
  22528. 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)
  22529. saveLog(result, requestLog, "2201A", "挂号")
  22530. if miConfig.Code == "H15049901371" {
  22531. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22532. utils.ErrorLog("解析失败:%v", err)
  22533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22534. return
  22535. }
  22536. resThree.ErrMsg = resThree10265.ErrMsg
  22537. resThree.Output = resThree10265.Output
  22538. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22539. } else {
  22540. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22541. utils.ErrorLog("解析失败:%v", err)
  22542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22543. return
  22544. }
  22545. }
  22546. if miConfig.Code == "H15049901371" {
  22547. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22548. } else {
  22549. infocode = resThree.Infcode
  22550. }
  22551. }
  22552. } else if res3101.Infcode != 0 {
  22553. c.ServeSuccessJSON(map[string]interface{}{
  22554. "failed_code": -10,
  22555. "msg": res3101.ErrMsg,
  22556. })
  22557. return
  22558. }
  22559. } else if miConfig.MdtrtareaAdmvs == "440205" {
  22560. var hisPrescription []*models.HisPrescription
  22561. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  22562. if res3101.Infcode == 0 {
  22563. fmt.Println("33333333")
  22564. if len(res3101.Output.Result) > 0 {
  22565. fmt.Println("222222")
  22566. for _, item := range res3101.Output.Result {
  22567. if len(res3101.ErrMsg) == 0 {
  22568. res3101.ErrMsg = item.VolaCont
  22569. } else {
  22570. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  22571. }
  22572. }
  22573. c.ServeSuccessJSON(map[string]interface{}{
  22574. "failed_code": -10,
  22575. "msg": res3101.ErrMsg,
  22576. })
  22577. return
  22578. } else {
  22579. hour := time.Now().Format("15")
  22580. min := time.Now().Format("04")
  22581. sec := time.Now().Format("05")
  22582. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  22583. fmt.Println(record_time_two)
  22584. 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)
  22585. saveLog(result, requestLog, "2201A", "挂号")
  22586. if miConfig.Code == "H15049901371" {
  22587. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22588. utils.ErrorLog("解析失败:%v", err)
  22589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22590. return
  22591. }
  22592. resThree.ErrMsg = resThree10265.ErrMsg
  22593. resThree.Output = resThree10265.Output
  22594. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22595. } else {
  22596. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22597. utils.ErrorLog("解析失败:%v", err)
  22598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22599. return
  22600. }
  22601. }
  22602. if miConfig.Code == "H15049901371" {
  22603. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22604. } else {
  22605. infocode = resThree.Infcode
  22606. }
  22607. }
  22608. } else if res3101.Infcode != 0 {
  22609. c.ServeSuccessJSON(map[string]interface{}{
  22610. "failed_code": -10,
  22611. "msg": res3101.ErrMsg,
  22612. })
  22613. return
  22614. }
  22615. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22616. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22617. psn_info, _ := service.GetPsnByPatientId(id)
  22618. var verify_number string
  22619. if id_card_type == 4 {
  22620. verify_number = psn_info.VerifyNumber
  22621. } else if id_card_type == 1 {
  22622. bas := strings.Split(psn_info.CardInfo, "|")
  22623. cardNumber := bas[2]
  22624. verify_number = cardNumber
  22625. } else {
  22626. verify_number = psn_info.Certno
  22627. }
  22628. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22629. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22630. "&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
  22631. resp, requestErr := http.Get(api)
  22632. if requestErr != nil {
  22633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22634. return
  22635. }
  22636. body, ioErr := ioutil.ReadAll(resp.Body)
  22637. if ioErr != nil {
  22638. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22640. return
  22641. }
  22642. var respJSON map[string]interface{}
  22643. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22644. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22646. return
  22647. }
  22648. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22649. result, _ := json.Marshal(respJSON)
  22650. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22651. utils.ErrorLog("解析失败:%v", err)
  22652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22653. return
  22654. }
  22655. infocode = resThree.Infcode
  22656. } else {
  22657. hour := time.Now().Format("15")
  22658. min := time.Now().Format("04")
  22659. sec := time.Now().Format("05")
  22660. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  22661. if id_card_type == 1 {
  22662. for _, item := range rf {
  22663. if item.Insutype == strconv.FormatInt(social_type, 10) {
  22664. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  22665. insuplc_admdvs_temp = item.InsuplcAdmdvs
  22666. } else if strconv.FormatInt(social_type, 10) == "390" {
  22667. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22668. } else {
  22669. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22670. }
  22671. }
  22672. }
  22673. }
  22674. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  22675. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22676. }
  22677. if id_card_type == 1 {
  22678. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  22679. bas := strings.Split(psn_info.CardInfo, "|")
  22680. basNumber := bas[1]
  22681. IdCardNo = basNumber
  22682. }
  22683. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  22684. IdCardNo = psn_info.VerifyNumber
  22685. }
  22686. if len(insuplc_admdvs_temp) == 0 {
  22687. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22688. }
  22689. 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)
  22690. saveLog(result, requestLog, "2201A", "挂号")
  22691. if miConfig.Code == "H15049901371" {
  22692. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22693. utils.ErrorLog("解析失败:%v", err)
  22694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22695. return
  22696. }
  22697. resThree.ErrMsg = resThree10265.ErrMsg
  22698. resThree.Output = resThree10265.Output
  22699. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22700. } else {
  22701. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22702. utils.ErrorLog("解析失败:%v", err)
  22703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22704. return
  22705. }
  22706. }
  22707. if miConfig.Code == "H15049901371" {
  22708. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22709. } else {
  22710. infocode = resThree.Infcode
  22711. }
  22712. }
  22713. }
  22714. if infocode == -1 {
  22715. adminUser := c.GetAdminUserInfo()
  22716. errlog := &models.HisOrderError{
  22717. UserOrgId: adminUser.CurrentOrgId,
  22718. Ctime: time.Now().Unix(),
  22719. Mtime: time.Now().Unix(),
  22720. ErrMsg: resThree.ErrMsg,
  22721. Status: 1,
  22722. PatientId: id,
  22723. RecordTime: recordDateTime,
  22724. Stage: 2,
  22725. }
  22726. service.CreateErrMsgLog(errlog)
  22727. c.ServeSuccessJSON(map[string]interface{}{
  22728. "failed_code": -10,
  22729. "msg": resThree.ErrMsg,
  22730. })
  22731. return
  22732. }
  22733. his.Number = resThree.Output.Data.MdtrtID
  22734. his.PsnNo = resThree.Output.Data.PsnNo
  22735. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  22736. his.IdCardNo = patient.IdCardNo
  22737. his.PhoneNumber = patient.Phone
  22738. his.UserOrgId = adminInfo.CurrentOrgId
  22739. his.Insutype = insutype
  22740. his.Ctime = time.Now().Unix()
  22741. his.Mtime = time.Now().Unix()
  22742. his.InsuplcAdmdvs = insuplc_admdvs_temp
  22743. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  22744. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  22745. }
  22746. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  22747. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  22748. }
  22749. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  22750. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  22751. }
  22752. his.Status = 1
  22753. his.MdtrtGrpType = mdtrt_type
  22754. service.UpdateHisPatientStatus(&his)
  22755. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  22756. c.ServeSuccessJSON(map[string]interface{}{
  22757. "his_info": his,
  22758. })
  22759. } else {
  22760. adminUser := c.GetAdminUserInfo()
  22761. errlog := &models.HisOrderError{
  22762. UserOrgId: adminUser.CurrentOrgId,
  22763. Ctime: time.Now().Unix(),
  22764. Mtime: time.Now().Unix(),
  22765. ErrMsg: res.ErrMsg,
  22766. Status: 1,
  22767. PatientId: id,
  22768. RecordTime: recordDateTime,
  22769. Stage: 1,
  22770. }
  22771. service.CreateErrMsgLog(errlog)
  22772. c.ServeSuccessJSON(map[string]interface{}{
  22773. "failed_code": -10,
  22774. "msg": res.ErrMsg,
  22775. })
  22776. return
  22777. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  22778. }
  22779. }
  22780. }
  22781. func (c *HisApiController) GetUploadInfo() {
  22782. id, _ := c.GetInt64("id")
  22783. record_time := c.GetString("record_time")
  22784. his_patient_id, _ := c.GetInt64("his_patient_id")
  22785. order_id, _ := c.GetInt64("order_id")
  22786. pay_way, _ := c.GetInt64("pay_way")
  22787. pay_ways := c.GetString("pay_ways")
  22788. oth_desc := c.GetString("oth_desc")
  22789. pay_price, _ := c.GetFloat("pay_price")
  22790. pay_card_no := c.GetString("pay_card_no")
  22791. discount_price, _ := c.GetFloat("discount_price")
  22792. preferential_price, _ := c.GetFloat("preferential_price")
  22793. reality_price, _ := c.GetFloat("reality_price")
  22794. found_price, _ := c.GetFloat("found_price")
  22795. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  22796. private_price, _ := c.GetFloat("private_price")
  22797. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  22798. admin_user_id, _ := c.GetInt64("admin_user_id")
  22799. fapiao_code := c.GetString("fapiao_code")
  22800. fapiao_number := c.GetString("fapiao_number")
  22801. diagnosis_id := c.GetString("diagnosis")
  22802. sick_type, _ := c.GetInt64("sick_type")
  22803. reg_type, _ := c.GetInt64("p_type")
  22804. begin_time := c.GetString("begin_time")
  22805. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  22806. cash_pay := c.GetString("cash_pay")
  22807. band_card_pay := c.GetString("band_card_pay")
  22808. wechat_pay := c.GetString("wechat_pay")
  22809. ali_pay := c.GetString("ali_pay")
  22810. jifen_pay := c.GetString("jifen_pay")
  22811. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  22812. fmt.Println(acct_used_flag)
  22813. id_str := c.GetString("ids")
  22814. ids_arr := strings.Split(id_str, ",")
  22815. timeLayout := "2006-01-02"
  22816. loc, _ := time.LoadLocation("Local")
  22817. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  22818. if err != nil {
  22819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22820. return
  22821. }
  22822. recordDateTime := theTime.Unix()
  22823. adminUser := c.GetAdminUserInfo()
  22824. var tempOrder models.HisOrder
  22825. tempOrder, _ = service.GetHisOrderByID(order_id)
  22826. var prescriptions []*models.HisPrescription
  22827. var start_time int64
  22828. var end_time int64
  22829. //押金模块
  22830. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  22831. tmp_decimal := c.GetString("tmp_decimal")
  22832. var decimal float64 //本次使用的押金
  22833. var errmsg error
  22834. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  22835. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  22836. return
  22837. }
  22838. if len(tmp_decimal) > 0 {
  22839. if tmp_decimal[0] == 45 {
  22840. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  22841. return
  22842. }
  22843. }
  22844. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  22845. fmt.Println(errs)
  22846. decimal = tt
  22847. //if adminUser.CurrentOrgId == 10106{
  22848. // if len(fapiao_code) == 0{
  22849. // fapiao_code = "144072080589"
  22850. // }
  22851. // if len(fapiao_number) == 0{
  22852. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  22853. // if order.ID == 0{
  22854. // fapiao_number = "00001520"
  22855. // }else{
  22856. // //fapiao_code = "00001520"
  22857. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  22858. // var zero string
  22859. // if fpNumber >= 1000{
  22860. // zero = "0000" + strconv.Itoa(fpNumber)
  22861. // }else if fpNumber >= 10000{
  22862. // zero = "000" + strconv.Itoa(fpNumber)
  22863. // } else if fpNumber >= 100000{
  22864. // zero = "00" + strconv.Itoa(fpNumber)
  22865. // } else if fpNumber >= 1000000{
  22866. // zero = "0" + strconv.Itoa(fpNumber)
  22867. // }else {
  22868. // zero = strconv.Itoa(fpNumber)
  22869. // }
  22870. // fapiao_number = zero
  22871. // }
  22872. // }
  22873. //}
  22874. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  22875. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  22876. var patientPrescription models.HisPrescriptionInfo
  22877. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  22878. if patientPrescription.ID == 0 {
  22879. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  22880. }
  22881. //if patientPrescription.Do
  22882. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  22883. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  22884. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  22885. diagnosis_ids := strings.Split(diagnosis_id, ",")
  22886. var config []*models.HisXtDiagnoseConfig
  22887. for _, item := range diagnosis_ids {
  22888. id, _ := strconv.ParseInt(item, 10, 64)
  22889. diagnosisConfig, _ := service.FindDiagnoseById(id)
  22890. config = append(config, &diagnosisConfig)
  22891. }
  22892. sickConfig, _ := service.FindSickById(sick_type)
  22893. //if tempOrder.ID == 0 {
  22894. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  22895. //}
  22896. if tempOrder.ID == 0 {
  22897. var result string
  22898. var requestLog string
  22899. var res2 ResultSix
  22900. var res3 GZResultSix
  22901. var ressix10265 ResultSix10265
  22902. if miConfig.MdtrtareaAdmvs == "421300" {
  22903. data := make(map[string]interface{})
  22904. client := &http.Client{}
  22905. data["psn_no"] = his.PsnNo
  22906. data["mdtrt_id"] = his.Number
  22907. data["opter"] = roles.UserName
  22908. data["org_name"] = miConfig.OrgName
  22909. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22910. data["doctor_id"] = doctor_info.DoctorNumber
  22911. data["doctor_name"] = doctor_info.UserName
  22912. data["department"] = department.Name
  22913. data["fixmedins_code"] = miConfig.Code
  22914. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22915. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22916. data["secret_key"] = miConfig.SecretKey
  22917. data["sick_code"] = sickConfig.CountryCode
  22918. data["sick_name"] = sickConfig.ClassName
  22919. data["dept"] = strconv.FormatInt(department.ID, 10)
  22920. data["config"] = config
  22921. data["begin_time"] = begin_time
  22922. bytesData, _ := json.Marshal(data)
  22923. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  22924. resp, _ := client.Do(req)
  22925. defer resp.Body.Close()
  22926. body, ioErr := ioutil.ReadAll(resp.Body)
  22927. if ioErr != nil {
  22928. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22930. return
  22931. }
  22932. var respJSON map[string]interface{}
  22933. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22936. return
  22937. }
  22938. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22939. userJSONBytes, _ := json.Marshal(respJSON)
  22940. fmt.Println("log")
  22941. fmt.Println(string(userJSONBytes))
  22942. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22943. utils.ErrorLog("解析失败:%v", err)
  22944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22945. return
  22946. }
  22947. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22948. data := make(map[string]interface{})
  22949. client := &http.Client{}
  22950. data["psn_no"] = his.PsnNo
  22951. data["mdtrt_id"] = his.Number
  22952. data["opter"] = roles.UserName
  22953. data["org_name"] = miConfig.OrgName
  22954. if reg_type == 11 && his.Insutype == "390" {
  22955. data["med_type"] = "110104"
  22956. } else {
  22957. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22958. }
  22959. data["doctor_id"] = doctor_info.DoctorNumber
  22960. data["doctor_name"] = doctor_info.UserName
  22961. data["department"] = department.Name
  22962. data["fixmedins_code"] = miConfig.Code
  22963. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22964. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22965. data["secret_key"] = miConfig.SecretKey
  22966. data["sick_code"] = sickConfig.CountryCode
  22967. data["sick_name"] = sickConfig.ClassName
  22968. data["dept"] = strconv.FormatInt(department.ID, 10)
  22969. data["config"] = config
  22970. data["begin_time"] = begin_time
  22971. bytesData, _ := json.Marshal(data)
  22972. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  22973. resp, _ := client.Do(req)
  22974. defer resp.Body.Close()
  22975. body, ioErr := ioutil.ReadAll(resp.Body)
  22976. if ioErr != nil {
  22977. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22979. return
  22980. }
  22981. var respJSON map[string]interface{}
  22982. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22985. return
  22986. }
  22987. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22988. userJSONBytes, _ := json.Marshal(respJSON)
  22989. fmt.Println("log")
  22990. fmt.Println(string(userJSONBytes))
  22991. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22992. utils.ErrorLog("解析失败:%v", err)
  22993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22994. return
  22995. }
  22996. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22997. data := make(map[string]interface{})
  22998. client := &http.Client{}
  22999. data["psn_no"] = his.PsnNo
  23000. data["mdtrt_id"] = his.Number
  23001. data["opter"] = roles.UserName
  23002. data["org_name"] = miConfig.OrgName
  23003. if reg_type == 11 && his.Insutype == "390" {
  23004. data["med_type"] = "110104"
  23005. } else {
  23006. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23007. }
  23008. data["doctor_id"] = doctor_info.DoctorNumber
  23009. data["doctor_name"] = doctor_info.UserName
  23010. data["department"] = department.Name
  23011. data["fixmedins_code"] = miConfig.Code
  23012. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23013. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23014. data["secret_key"] = miConfig.SecretKey
  23015. data["sick_code"] = sickConfig.CountryCode
  23016. data["sick_name"] = sickConfig.ClassName
  23017. data["dept"] = strconv.FormatInt(department.ID, 10)
  23018. data["config"] = config
  23019. data["begin_time"] = begin_time
  23020. bytesData, _ := json.Marshal(data)
  23021. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  23022. resp, _ := client.Do(req)
  23023. defer resp.Body.Close()
  23024. body, ioErr := ioutil.ReadAll(resp.Body)
  23025. if ioErr != nil {
  23026. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23028. return
  23029. }
  23030. var respJSON map[string]interface{}
  23031. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23032. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23034. return
  23035. }
  23036. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23037. userJSONBytes, _ := json.Marshal(respJSON)
  23038. fmt.Println("log")
  23039. fmt.Println(string(userJSONBytes))
  23040. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23041. utils.ErrorLog("解析失败:%v", err)
  23042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23043. return
  23044. }
  23045. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23046. data := make(map[string]interface{})
  23047. client := &http.Client{}
  23048. data["psn_no"] = his.PsnNo
  23049. data["mdtrt_id"] = his.Number
  23050. data["opter"] = roles.UserName
  23051. data["org_name"] = miConfig.OrgName
  23052. if reg_type == 11 && his.Insutype == "390" {
  23053. data["med_type"] = "110104"
  23054. } else {
  23055. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23056. }
  23057. data["doctor_id"] = doctor_info.DoctorNumber
  23058. data["doctor_name"] = doctor_info.UserName
  23059. data["department"] = department.Name
  23060. data["fixmedins_code"] = miConfig.Code
  23061. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23062. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23063. data["secret_key"] = miConfig.SecretKey
  23064. data["sick_code"] = sickConfig.CountryCode
  23065. data["sick_name"] = sickConfig.ClassName
  23066. data["dept"] = strconv.FormatInt(department.ID, 10)
  23067. data["config"] = config
  23068. data["begin_time"] = begin_time
  23069. bytesData, _ := json.Marshal(data)
  23070. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  23071. resp, _ := client.Do(req)
  23072. defer resp.Body.Close()
  23073. body, ioErr := ioutil.ReadAll(resp.Body)
  23074. if ioErr != nil {
  23075. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23077. return
  23078. }
  23079. var respJSON map[string]interface{}
  23080. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23081. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23083. return
  23084. }
  23085. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23086. userJSONBytes, _ := json.Marshal(respJSON)
  23087. fmt.Println("log")
  23088. fmt.Println(string(userJSONBytes))
  23089. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23090. utils.ErrorLog("解析失败:%v", err)
  23091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23092. return
  23093. }
  23094. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23095. data := make(map[string]interface{})
  23096. client := &http.Client{}
  23097. data["psn_no"] = his.PsnNo
  23098. data["mdtrt_id"] = his.Number
  23099. data["doctor"] = roles.UserName
  23100. data["department"] = department.Name
  23101. data["org_name"] = miConfig.OrgName
  23102. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23103. data["doctor_id"] = doctor_info.DoctorNumber
  23104. data["new_doctor_name"] = doctor_info.UserName
  23105. data["fixmedins_code"] = miConfig.Code
  23106. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23107. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23108. data["secret_key"] = miConfig.SecretKey
  23109. data["sick_code"] = sickConfig.CountryCode
  23110. data["sick_name"] = sickConfig.ClassName
  23111. data["url"] = miConfig.Url
  23112. data["ak"] = miConfig.AccessKey
  23113. data["begin_time"] = begin_time
  23114. data["cainfo"] = miConfig.Cainfo
  23115. data["dept"] = strconv.FormatInt(department.ID, 10)
  23116. data["config"] = config
  23117. bytesData, _ := json.Marshal(data)
  23118. var req *http.Request
  23119. if miConfig.MdtrtareaAdmvs == "320921" {
  23120. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  23121. //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 +
  23122. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  23123. } else {
  23124. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  23125. }
  23126. resp, _ := client.Do(req)
  23127. defer resp.Body.Close()
  23128. body, ioErr := ioutil.ReadAll(resp.Body)
  23129. if ioErr != nil {
  23130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23132. return
  23133. }
  23134. var respJSON map[string]interface{}
  23135. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23136. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23138. return
  23139. }
  23140. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23141. userJSONBytes, _ := json.Marshal(respJSON)
  23142. fmt.Println("log")
  23143. fmt.Println(string(userJSONBytes))
  23144. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  23145. utils.ErrorLog("解析失败:%v", err)
  23146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23147. return
  23148. }
  23149. res2.InfRefmsgid = ressix10265.InfRefmsgid
  23150. res2.Output = ressix10265.Output
  23151. res2.ErrMsg = ressix10265.ErrMsg
  23152. res2.Cainfo = ressix10265.Cainfo
  23153. res2.WarnMsg = ressix10265.WarnMsg
  23154. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  23155. res2.Infcode = infocode
  23156. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23157. data := make(map[string]interface{})
  23158. client := &http.Client{}
  23159. data["psn_no"] = his.PsnNo
  23160. data["mdtrt_id"] = his.Number
  23161. data["doctor"] = roles.UserName
  23162. data["department"] = department.Name
  23163. data["org_name"] = miConfig.OrgName
  23164. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23165. data["doctor_id"] = doctor_info.DoctorNumber
  23166. data["new_doctor_name"] = doctor_info.UserName
  23167. data["fixmedins_code"] = miConfig.Code
  23168. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23169. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23170. data["secret_key"] = miConfig.SecretKey
  23171. data["sick_code"] = sickConfig.CountryCode
  23172. data["sick_name"] = sickConfig.ClassName
  23173. data["url"] = miConfig.Url
  23174. data["ak"] = miConfig.AccessKey
  23175. data["begin_time"] = begin_time
  23176. data["cainfo"] = miConfig.Cainfo
  23177. data["dept"] = strconv.FormatInt(department.ID, 10)
  23178. data["config"] = config
  23179. bytesData, _ := json.Marshal(data)
  23180. var req *http.Request
  23181. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  23182. resp, _ := client.Do(req)
  23183. defer resp.Body.Close()
  23184. body, ioErr := ioutil.ReadAll(resp.Body)
  23185. if ioErr != nil {
  23186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23188. return
  23189. }
  23190. var respJSON map[string]interface{}
  23191. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23194. return
  23195. }
  23196. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23197. userJSONBytes, _ := json.Marshal(respJSON)
  23198. fmt.Println("log")
  23199. fmt.Println(string(userJSONBytes))
  23200. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  23201. utils.ErrorLog("解析失败:%v", err)
  23202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23203. return
  23204. }
  23205. res2.InfRefmsgid = ressix10265.InfRefmsgid
  23206. res2.Output = ressix10265.Output
  23207. res2.ErrMsg = ressix10265.ErrMsg
  23208. res2.Cainfo = ressix10265.Cainfo
  23209. res2.WarnMsg = ressix10265.WarnMsg
  23210. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  23211. res2.Infcode = infocode
  23212. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23213. 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)
  23214. saveLog(result, requestLog, "2203", "上传就诊信息")
  23215. var respJSON2 map[string]interface{}
  23216. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  23217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23219. return
  23220. }
  23221. userJSONBytes2, _ := json.Marshal(respJSON2)
  23222. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  23223. utils.ErrorLog("解析失败:%v", err)
  23224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23225. return
  23226. }
  23227. 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)
  23228. fmt.Println(result2)
  23229. fmt.Println(src_request)
  23230. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23231. data := make(map[string]interface{})
  23232. client := &http.Client{}
  23233. data["psn_no"] = his.PsnNo
  23234. data["mdtrt_id"] = his.Number
  23235. data["doctor"] = roles.UserName
  23236. data["department"] = department.Name
  23237. data["org_name"] = miConfig.OrgName
  23238. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23239. data["doctor_id"] = doctor_info.DoctorNumber
  23240. data["new_doctor_name"] = doctor_info.UserName
  23241. data["fixmedins_code"] = miConfig.Code
  23242. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23243. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23244. data["secret_key"] = miConfig.SecretKey
  23245. data["sick_code"] = sickConfig.CountryCode
  23246. data["sick_name"] = sickConfig.ClassName
  23247. data["url"] = miConfig.Url
  23248. data["ak"] = miConfig.AccessKey
  23249. data["begin_time"] = begin_time
  23250. data["cainfo"] = miConfig.Cainfo
  23251. data["dept"] = strconv.FormatInt(department.ID, 10)
  23252. data["config"] = config
  23253. bytesData, _ := json.Marshal(data)
  23254. var req *http.Request
  23255. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  23256. resp, _ := client.Do(req)
  23257. defer resp.Body.Close()
  23258. body, ioErr := ioutil.ReadAll(resp.Body)
  23259. if ioErr != nil {
  23260. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23262. return
  23263. }
  23264. var respJSON map[string]interface{}
  23265. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23268. return
  23269. }
  23270. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23271. userJSONBytes, _ := json.Marshal(respJSON)
  23272. fmt.Println("log")
  23273. fmt.Println(string(userJSONBytes))
  23274. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23275. utils.ErrorLog("解析失败:%v", err)
  23276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23277. return
  23278. }
  23279. } else {
  23280. if miConfig.MdtrtareaAdmvs == "440781" { //
  23281. 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)
  23282. } else {
  23283. if miConfig.Code == "H15049901371" {
  23284. //赤峰地区国家医保医疗类别
  23285. //职工透析:医疗类别选特殊情况门诊990502
  23286. //居民定额血透门慢: 医疗类别选门诊慢病140104
  23287. var med_type string
  23288. if his.Insutype == "390" {
  23289. if reg_type == 14 {
  23290. med_type = "9933"
  23291. } else if reg_type == 11 {
  23292. med_type = "11"
  23293. }
  23294. } else if his.Insutype == "310" {
  23295. if reg_type == 14 {
  23296. med_type = "990502"
  23297. } else if reg_type == 11 {
  23298. med_type = "11"
  23299. }
  23300. }
  23301. 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)
  23302. } else {
  23303. 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)
  23304. }
  23305. }
  23306. saveLog(result, requestLog, "2203", "上传就诊信息")
  23307. var respJSON2 map[string]interface{}
  23308. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  23309. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23311. return
  23312. }
  23313. userJSONBytes2, _ := json.Marshal(respJSON2)
  23314. if miConfig.Code == "H15049901371" {
  23315. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  23316. utils.ErrorLog("解析失败:%v", err)
  23317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23318. return
  23319. }
  23320. res2.InfRefmsgid = ressix10265.InfRefmsgid
  23321. res2.Output = ressix10265.Output
  23322. res2.ErrMsg = ressix10265.ErrMsg
  23323. res2.Cainfo = ressix10265.Cainfo
  23324. res2.WarnMsg = ressix10265.WarnMsg
  23325. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  23326. res2.Infcode = infocode
  23327. } else {
  23328. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23329. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  23330. utils.ErrorLog("解析失败:%v", err)
  23331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23332. return
  23333. }
  23334. res2.Infcode = res3.Infcode
  23335. } else {
  23336. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  23337. utils.ErrorLog("解析失败:%v", err)
  23338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23339. return
  23340. }
  23341. }
  23342. }
  23343. }
  23344. if res2.Infcode == -1 {
  23345. adminUser := c.GetAdminUserInfo()
  23346. errlog := &models.HisOrderError{
  23347. UserOrgId: adminUser.CurrentOrgId,
  23348. Ctime: time.Now().Unix(),
  23349. Mtime: time.Now().Unix(),
  23350. ErrMsg: res2.ErrMsg,
  23351. Status: 1,
  23352. PatientId: id,
  23353. RecordTime: recordDateTime,
  23354. Stage: 3,
  23355. }
  23356. service.CreateErrMsgLog(errlog)
  23357. c.ServeSuccessJSON(map[string]interface{}{
  23358. "failed_code": -10,
  23359. "msg": res2.ErrMsg,
  23360. })
  23361. return
  23362. } else {
  23363. his.Diagnosis = diagnosis_id
  23364. his.SickType = sickConfig.ID
  23365. //var p_type int64
  23366. //if reg_type == 1111 || reg_type == 1112 {
  23367. // p_type = 11
  23368. //
  23369. //}
  23370. his.PType = fmt.Sprintf("%d", reg_type)
  23371. service.UpdateHisPatientThree(&his)
  23372. data := make(map[string]interface{})
  23373. if settle_accounts_type == 1 { //日结
  23374. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  23375. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  23376. } else {
  23377. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  23378. }
  23379. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  23380. data["pre"] = prescriptions
  23381. } else { //月结
  23382. start_time_str := c.GetString("start_time")
  23383. end_time_str := c.GetString("end_time")
  23384. timeLayout := "2006-01-02"
  23385. loc, _ := time.LoadLocation("Local")
  23386. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  23387. if err != nil {
  23388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23389. return
  23390. }
  23391. recordStartTime := theStartTime.Unix()
  23392. start_time = recordStartTime
  23393. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  23394. if err != nil {
  23395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23396. return
  23397. }
  23398. recordEndTime := theEndTime.Unix()
  23399. end_time = recordEndTime
  23400. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  23401. data["pre"] = prescriptions
  23402. }
  23403. timestamp := time.Now().Unix()
  23404. tempTime := time.Unix(timestamp, 0)
  23405. timeFormat := tempTime.Format("20060102150405")
  23406. chrgBchno := rand.Intn(100000) + 10000
  23407. new_chrg_bchno := ""
  23408. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23409. new_chrg_bchno = chrg_bchno
  23410. strconv.FormatInt(his.PatientId, 10)
  23411. client := &http.Client{}
  23412. if adminUser.CurrentOrgId == 10265 {
  23413. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  23414. new_chrg_bchno = "0000"
  23415. }
  23416. }
  23417. data["psn_no"] = his.PsnNo
  23418. data["mdtrt_id"] = his.Number
  23419. data["chrg_bchno"] = new_chrg_bchno
  23420. data["org_name"] = miConfig.OrgName
  23421. data["doctor"] = doctor_info.UserName
  23422. data["doctor_id"] = doctor_info.DoctorNumber
  23423. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  23424. data["fixmedins_code"] = miConfig.Code
  23425. data["dept_code"] = department.Number
  23426. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23427. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23428. data["secret_key"] = miConfig.SecretKey
  23429. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  23430. data["url"] = miConfig.Url
  23431. data["ak"] = miConfig.AccessKey
  23432. data["new_doctor_name"] = patientPrescription.Doctor
  23433. data["diag_code"] = sickConfig.CountryCode
  23434. data["cainfo"] = miConfig.Cainfo
  23435. data["opter"] = roles.UserName
  23436. var ids []int64
  23437. for _, item := range prescriptions {
  23438. ids = append(ids, item.ID)
  23439. }
  23440. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23441. if config.IsOpen == 1 { //对接了医保,走医保流程
  23442. var res ResultFour
  23443. var resFour10265 ResultFour10265
  23444. if miConfig.MdtrtareaAdmvs == "421300" {
  23445. bytesData, _ := json.Marshal(data)
  23446. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  23447. resp, _ := client.Do(req)
  23448. defer resp.Body.Close()
  23449. body, ioErr := ioutil.ReadAll(resp.Body)
  23450. if ioErr != nil {
  23451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23453. return
  23454. }
  23455. var respJSON map[string]interface{}
  23456. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23459. return
  23460. }
  23461. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23462. userJSONBytes, _ := json.Marshal(respJSON)
  23463. fmt.Println("log")
  23464. fmt.Println(string(userJSONBytes))
  23465. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23466. utils.ErrorLog("解析失败:%v", err)
  23467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23468. return
  23469. }
  23470. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23471. bytesData, _ := json.Marshal(data)
  23472. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  23473. resp, _ := client.Do(req)
  23474. defer resp.Body.Close()
  23475. body, ioErr := ioutil.ReadAll(resp.Body)
  23476. if ioErr != nil {
  23477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23479. return
  23480. }
  23481. var respJSON map[string]interface{}
  23482. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23485. return
  23486. }
  23487. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23488. userJSONBytes, _ := json.Marshal(respJSON)
  23489. fmt.Println("log")
  23490. fmt.Println(string(userJSONBytes))
  23491. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23492. utils.ErrorLog("解析失败:%v", err)
  23493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23494. return
  23495. }
  23496. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23497. bytesData, _ := json.Marshal(data)
  23498. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  23499. resp, _ := client.Do(req)
  23500. defer resp.Body.Close()
  23501. body, ioErr := ioutil.ReadAll(resp.Body)
  23502. if ioErr != nil {
  23503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23505. return
  23506. }
  23507. var respJSON map[string]interface{}
  23508. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23511. return
  23512. }
  23513. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23514. userJSONBytes, _ := json.Marshal(respJSON)
  23515. fmt.Println("log")
  23516. fmt.Println(string(userJSONBytes))
  23517. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23518. utils.ErrorLog("解析失败:%v", err)
  23519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23520. return
  23521. }
  23522. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23523. bytesData, _ := json.Marshal(data)
  23524. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  23525. resp, _ := client.Do(req)
  23526. defer resp.Body.Close()
  23527. body, ioErr := ioutil.ReadAll(resp.Body)
  23528. if ioErr != nil {
  23529. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23531. return
  23532. }
  23533. var respJSON map[string]interface{}
  23534. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23535. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23537. return
  23538. }
  23539. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23540. userJSONBytes, _ := json.Marshal(respJSON)
  23541. fmt.Println("log")
  23542. fmt.Println(string(userJSONBytes))
  23543. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23544. utils.ErrorLog("解析失败:%v", err)
  23545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23546. return
  23547. }
  23548. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23549. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  23550. if result3101.Infcode == "0" {
  23551. if len(result3101.Output.Result) > 0 {
  23552. var errMsgs []string
  23553. for _, item := range result3101.Output.Result {
  23554. errMsgs = append(errMsgs, item.VolaCont)
  23555. }
  23556. c.ServeSuccessJSON(map[string]interface{}{
  23557. "failed_code": -10,
  23558. "msg": errMsgs,
  23559. })
  23560. return
  23561. }
  23562. }
  23563. bytesData, _ := json.Marshal(data)
  23564. var req *http.Request
  23565. if miConfig.MdtrtareaAdmvs == "320921" {
  23566. data["diag_code"] = sickConfig.CountryCode
  23567. fmt.Println(data)
  23568. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23569. } else {
  23570. data["diag_code"] = sickConfig.CountryCode
  23571. fmt.Println(data)
  23572. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23573. }
  23574. resp, _ := client.Do(req)
  23575. defer resp.Body.Close()
  23576. body, ioErr := ioutil.ReadAll(resp.Body)
  23577. if ioErr != nil {
  23578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23580. return
  23581. }
  23582. var respJSON map[string]interface{}
  23583. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23586. return
  23587. }
  23588. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23589. userJSONBytes, _ := json.Marshal(respJSON)
  23590. fmt.Println("log")
  23591. fmt.Println(string(userJSONBytes))
  23592. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23593. utils.ErrorLog("解析失败:%v", err)
  23594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23595. return
  23596. }
  23597. res.InfRefmsgid = resFour10265.InfRefmsgid
  23598. res.Output = resFour10265.Output
  23599. res.ErrMsg = resFour10265.ErrMsg
  23600. res.Cainfo = resFour10265.Cainfo
  23601. res.WarnMsg = resFour10265.WarnMsg
  23602. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23603. res.Infcode = infocode
  23604. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23605. var pagesize int = 2
  23606. var start int = 1
  23607. var stop int
  23608. var pagecount int
  23609. var curpage int
  23610. var isSuccess bool = true
  23611. data["doctor_id"] = doctor_info.DoctorNumber
  23612. //总页数,向上取整,注意除之前要先转换类型为float64
  23613. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  23614. for curpage = 1; curpage <= pagecount; curpage++ {
  23615. if curpage == 1 {
  23616. start = 1
  23617. } else {
  23618. start = (curpage-1)*pagesize + 1
  23619. }
  23620. stop = curpage * pagesize
  23621. if stop > len(prescriptions) {
  23622. stop = len(prescriptions)
  23623. }
  23624. //var requestLog string
  23625. data["pre"] = prescriptions[start-1 : stop]
  23626. fmt.Println(data["pre"])
  23627. bytesData, _ := json.Marshal(data)
  23628. var req *http.Request
  23629. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  23630. resp, _ := client.Do(req)
  23631. defer resp.Body.Close()
  23632. body, ioErr := ioutil.ReadAll(resp.Body)
  23633. if ioErr != nil {
  23634. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23636. return
  23637. }
  23638. var respJSON map[string]interface{}
  23639. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23642. return
  23643. }
  23644. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23645. userJSONBytes, _ := json.Marshal(respJSON)
  23646. fmt.Println("log")
  23647. fmt.Println(string(userJSONBytes))
  23648. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23649. utils.ErrorLog("解析失败:%v", err)
  23650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23651. return
  23652. }
  23653. res.InfRefmsgid = resFour10265.InfRefmsgid
  23654. res.Output = resFour10265.Output
  23655. res.ErrMsg = resFour10265.ErrMsg
  23656. res.Cainfo = resFour10265.Cainfo
  23657. res.WarnMsg = resFour10265.WarnMsg
  23658. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23659. res.Infcode = infocode
  23660. if infocode == 0 {
  23661. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  23662. } else {
  23663. isSuccess = false
  23664. errlog := &models.HisOrderError{
  23665. UserOrgId: adminUser.CurrentOrgId,
  23666. Ctime: time.Now().Unix(),
  23667. Mtime: time.Now().Unix(),
  23668. Number: chrg_bchno,
  23669. ErrMsg: "",
  23670. Status: 1,
  23671. PatientId: id,
  23672. RecordTime: recordDateTime,
  23673. Stage: 4,
  23674. }
  23675. service.CreateErrMsgLog(errlog)
  23676. c.ServeSuccessJSON(map[string]interface{}{
  23677. "failed_code": -10,
  23678. "msg": res.ErrMsg,
  23679. })
  23680. return
  23681. }
  23682. }
  23683. if isSuccess {
  23684. res.Infcode = 0
  23685. }
  23686. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23687. 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)
  23688. var dat map[string]interface{}
  23689. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23690. fmt.Println(dat)
  23691. } else {
  23692. fmt.Println(err)
  23693. }
  23694. saveLog(result, request_log, "2204", "上传费用明细")
  23695. userJSONBytes, _ := json.Marshal(dat)
  23696. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23697. utils.ErrorLog("解析失败:%v", err)
  23698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23699. return
  23700. }
  23701. res.InfRefmsgid = resFour10265.InfRefmsgid
  23702. res.Output = resFour10265.Output
  23703. res.ErrMsg = resFour10265.ErrMsg
  23704. res.Cainfo = resFour10265.Cainfo
  23705. res.WarnMsg = resFour10265.WarnMsg
  23706. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23707. res.Infcode = infocode
  23708. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23709. bytesData, _ := json.Marshal(data)
  23710. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  23711. resp, _ := client.Do(req)
  23712. defer resp.Body.Close()
  23713. body, ioErr := ioutil.ReadAll(resp.Body)
  23714. if ioErr != nil {
  23715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23717. return
  23718. }
  23719. var respJSON map[string]interface{}
  23720. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23723. return
  23724. }
  23725. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23726. userJSONBytes, _ := json.Marshal(respJSON)
  23727. fmt.Println("log")
  23728. fmt.Println(string(userJSONBytes))
  23729. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23730. utils.ErrorLog("解析失败:%v", err)
  23731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23732. return
  23733. }
  23734. } else {
  23735. if miConfig.Code == "H15049901371" {
  23736. 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)
  23737. var dat map[string]interface{}
  23738. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23739. fmt.Println(dat)
  23740. } else {
  23741. fmt.Println(err)
  23742. }
  23743. saveLog(result, request_log, "2204", "上传费用明细")
  23744. userJSONBytes, _ := json.Marshal(dat)
  23745. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23746. utils.ErrorLog("解析失败:%v", err)
  23747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23748. return
  23749. }
  23750. res.InfRefmsgid = resFour10265.InfRefmsgid
  23751. res.Output = resFour10265.Output
  23752. res.ErrMsg = resFour10265.ErrMsg
  23753. res.Cainfo = resFour10265.Cainfo
  23754. res.WarnMsg = resFour10265.WarnMsg
  23755. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23756. res.Infcode = infocode
  23757. } else {
  23758. 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)
  23759. var dat map[string]interface{}
  23760. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23761. fmt.Println(dat)
  23762. } else {
  23763. fmt.Println(err)
  23764. }
  23765. saveLog(result, request_log, "2204", "上传费用明细")
  23766. userJSONBytes, _ := json.Marshal(dat)
  23767. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23768. utils.ErrorLog("解析失败:%v", err)
  23769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23770. return
  23771. }
  23772. }
  23773. }
  23774. if res.Infcode == 0 {
  23775. order := &models.HisOrder{
  23776. UserOrgId: adminUser.CurrentOrgId,
  23777. HisPatientId: his.ID,
  23778. PatientId: his.PatientId,
  23779. SettleAccountsDate: recordDateTime,
  23780. MdtrtId: his.Number,
  23781. PsnNo: his.PsnNo,
  23782. MedType: strconv.FormatInt(reg_type, 10),
  23783. Ctime: time.Now().Unix(),
  23784. Mtime: time.Now().Unix(),
  23785. Status: 1,
  23786. Number: chrg_bchno,
  23787. Infcode: res.Infcode,
  23788. WarnMsg: res.WarnMsg,
  23789. Cainfo: res.Cainfo,
  23790. ErrMsg: res.ErrMsg,
  23791. RespondTime: res.RefmsgTime,
  23792. InfRefmsgid: res.InfRefmsgid,
  23793. OrderStatus: 1,
  23794. PayWay: pay_way,
  23795. PayWays: pay_ways,
  23796. OthDesc: oth_desc,
  23797. PayPrice: pay_price,
  23798. PayCardNo: pay_card_no,
  23799. DiscountPrice: discount_price,
  23800. PreferentialPrice: preferential_price,
  23801. RealityPrice: reality_price,
  23802. FoundPrice: found_price,
  23803. MedicalInsurancePrice: medical_insurance_price,
  23804. PrivatePrice: private_price,
  23805. IsMedicineInsurance: 1,
  23806. SettleType: settle_accounts_type,
  23807. SettleStartTime: start_time,
  23808. SettleEndTime: end_time,
  23809. Creator: roles.AdminUserId,
  23810. Modify: roles.AdminUserId,
  23811. FaPiaoNumber: fapiao_number,
  23812. FaPiaoCode: fapiao_code,
  23813. PType: 2,
  23814. Diagnosis: diagnosis_id,
  23815. CashPay: cash_pay,
  23816. WechatPay: wechat_pay,
  23817. AliPay: ali_pay,
  23818. JifenPay: jifen_pay,
  23819. BandCardPay: band_card_pay,
  23820. }
  23821. err = service.CreateOrder(order)
  23822. if err != nil {
  23823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  23824. return
  23825. }
  23826. for _, item := range res.Output.Result {
  23827. temp := strings.Split(item.FeedetlSn, "-")
  23828. var advice_id int64 = 0
  23829. var project_id int64 = 0
  23830. var types int64 = 0
  23831. id, _ := strconv.ParseInt(temp[2], 10, 64)
  23832. types, _ = strconv.ParseInt(temp[1], 10, 64)
  23833. if temp[1] == "1" {
  23834. advice_id = id
  23835. project_id = 0
  23836. } else if temp[1] == "2" {
  23837. advice_id = 0
  23838. project_id = id
  23839. }
  23840. if item.MedChrgitmType == "9" {
  23841. item.MedChrgitmType = "09"
  23842. }
  23843. info := &models.HisOrderInfo{
  23844. OrderNumber: order.Number,
  23845. FeedetlSn: item.FeedetlSn,
  23846. UploadDate: time.Now().Unix(),
  23847. AdviceId: advice_id,
  23848. DetItemFeeSumamt: item.DetItemFeeSumamt,
  23849. Cnt: item.Cnt,
  23850. Pric: float64(item.Pric),
  23851. PatientId: his.PatientId,
  23852. PricUplmtAmt: item.PricUplmtAmt,
  23853. SelfpayProp: item.SelfpayProp,
  23854. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  23855. OverlmtAmt: item.OverlmtAmt,
  23856. PreselfpayAmt: item.PreselfpayAmt,
  23857. BasMednFlag: item.BasMednFlag,
  23858. MedChrgitmType: item.MedChrgitmType,
  23859. HiNegoDrugFlag: item.HiNegoDrugFlag,
  23860. Status: 1,
  23861. Memo: item.Memo,
  23862. Mtime: time.Now().Unix(),
  23863. InscpScpAmt: item.InscpScpAmt,
  23864. DrtReimFlag: item.DrtReimFlag,
  23865. Ctime: time.Now().Unix(),
  23866. ListSpItemFlag: item.ListSpItemFlag,
  23867. ChldMedcFlag: item.ChldMedcFlag,
  23868. LmtUsedFlag: item.LmtUsedFlag,
  23869. ChrgitmLv: item.ChrgitmLv,
  23870. UserOrgId: adminUser.CurrentOrgId,
  23871. HisPatientId: his.ID,
  23872. OrderId: order.ID,
  23873. ProjectId: project_id,
  23874. Type: types,
  23875. }
  23876. service.CreateOrderInfo(info)
  23877. }
  23878. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  23879. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  23880. var total float64
  23881. for _, item := range prescriptions {
  23882. if item.Type == 1 { //药品
  23883. for _, subItem := range item.HisDoctorAdviceInfo {
  23884. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  23885. total_one := price * subItem.PrescribingNumber
  23886. total = total + total_one
  23887. }
  23888. }
  23889. if item.Type == 2 { //项目
  23890. for _, subItem := range item.HisPrescriptionProject {
  23891. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  23892. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  23893. total_one := price * cnt
  23894. total = total + total_one
  23895. }
  23896. }
  23897. }
  23898. allTotal := fmt.Sprintf("%.2f", total)
  23899. //if adminUser.CurrentOrgId == 9919 {
  23900. //
  23901. // allTotal = fmt.Sprintf("%.2f", total)
  23902. //
  23903. //} else {
  23904. //
  23905. // allTotal = fmt.Sprintf("%.2f", total)
  23906. //
  23907. //}
  23908. if res.Infcode == 0 {
  23909. var rf []*ResultFive
  23910. json.Unmarshal([]byte(his.Iinfo), &rf)
  23911. chrg_bchno := chrg_bchno
  23912. cert_no := his.Certno
  23913. var insutypes []string
  23914. var insutype string
  23915. var is390 int = 0
  23916. var is310 int = 0
  23917. for _, item := range rf {
  23918. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23919. insutypes = append(insutypes, item.Insutype)
  23920. }
  23921. }
  23922. if len(insutypes) == 1 {
  23923. insutype = insutypes[0]
  23924. } else {
  23925. for _, i := range insutypes {
  23926. if i == "390" {
  23927. is390 = 1
  23928. }
  23929. if i == "310" {
  23930. is310 = 1
  23931. }
  23932. }
  23933. }
  23934. if is390 == 1 {
  23935. insutype = "390"
  23936. }
  23937. if is310 == 1 {
  23938. insutype = "310"
  23939. }
  23940. if len(insutypes) == 0 {
  23941. insutype = "310"
  23942. }
  23943. if len(insutypes) == 2 {
  23944. insutype = strconv.FormatInt(his.SocialType, 10)
  23945. }
  23946. insutype = strconv.FormatInt(his.SocialType, 10)
  23947. //insutype = "390"
  23948. if his.IdCardType == 1 {
  23949. // cert_no = his.MedicalInsuranceNumber
  23950. cert_no = his.Certno
  23951. } else {
  23952. cert_no = his.Certno
  23953. }
  23954. var res ResultSeven
  23955. var resSeven10265 ResultSeven10265
  23956. var gzresSeven10265Two GZResultSeven10265Two
  23957. var src_resquest string
  23958. var result2 string
  23959. if miConfig.MdtrtareaAdmvs == "421300" {
  23960. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23961. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23962. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23963. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23964. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23965. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23966. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  23967. resp, requestErr := http.Get(api)
  23968. if requestErr != nil {
  23969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23970. return
  23971. }
  23972. body, ioErr := ioutil.ReadAll(resp.Body)
  23973. if ioErr != nil {
  23974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23976. return
  23977. }
  23978. var respJSON map[string]interface{}
  23979. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23982. return
  23983. }
  23984. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23985. result, _ := json.Marshal(respJSON)
  23986. if miConfig.Code == "H15049901371" {
  23987. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23988. utils.ErrorLog("解析失败:%v", err)
  23989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23990. return
  23991. }
  23992. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23993. res.Output = resSeven10265.Output
  23994. res.ErrMsg = resSeven10265.ErrMsg
  23995. res.Cainfo = resSeven10265.Cainfo
  23996. res.WarnMsg = resSeven10265.WarnMsg
  23997. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23998. res.Infcode = infocode
  23999. } else {
  24000. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24001. utils.ErrorLog("解析失败:%v", err)
  24002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24003. return
  24004. }
  24005. }
  24006. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24007. if reg_type == 11 && his.Insutype == "390" {
  24008. reg_type = 110104
  24009. }
  24010. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24011. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24012. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24013. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24014. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24015. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24016. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24017. resp, requestErr := http.Get(api)
  24018. if requestErr != nil {
  24019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24020. return
  24021. }
  24022. body, ioErr := ioutil.ReadAll(resp.Body)
  24023. if ioErr != nil {
  24024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24026. return
  24027. }
  24028. var respJSON map[string]interface{}
  24029. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24032. return
  24033. }
  24034. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24035. result, _ := json.Marshal(respJSON)
  24036. if miConfig.Code == "H15049901371" {
  24037. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24038. utils.ErrorLog("解析失败:%v", err)
  24039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24040. return
  24041. }
  24042. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24043. res.Output = resSeven10265.Output
  24044. res.ErrMsg = resSeven10265.ErrMsg
  24045. res.Cainfo = resSeven10265.Cainfo
  24046. res.WarnMsg = resSeven10265.WarnMsg
  24047. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24048. res.Infcode = infocode
  24049. } else {
  24050. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24051. utils.ErrorLog("解析失败:%v", err)
  24052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24053. return
  24054. }
  24055. }
  24056. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24057. if reg_type == 11 && his.Insutype == "390" {
  24058. reg_type = 110104
  24059. }
  24060. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24061. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24062. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24063. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24064. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24065. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24066. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24067. resp, requestErr := http.Get(api)
  24068. if requestErr != nil {
  24069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24070. return
  24071. }
  24072. body, ioErr := ioutil.ReadAll(resp.Body)
  24073. if ioErr != nil {
  24074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24076. return
  24077. }
  24078. var respJSON map[string]interface{}
  24079. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24082. return
  24083. }
  24084. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24085. result, _ := json.Marshal(respJSON)
  24086. if miConfig.Code == "H15049901371" {
  24087. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24088. utils.ErrorLog("解析失败:%v", err)
  24089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24090. return
  24091. }
  24092. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24093. res.Output = resSeven10265.Output
  24094. res.ErrMsg = resSeven10265.ErrMsg
  24095. res.Cainfo = resSeven10265.Cainfo
  24096. res.WarnMsg = resSeven10265.WarnMsg
  24097. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24098. res.Infcode = infocode
  24099. } else {
  24100. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24101. utils.ErrorLog("解析失败:%v", err)
  24102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24103. return
  24104. }
  24105. }
  24106. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24107. if reg_type == 11 && his.Insutype == "390" {
  24108. reg_type = 110104
  24109. }
  24110. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24111. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24112. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24113. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24114. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24115. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24116. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24117. resp, requestErr := http.Get(api)
  24118. if requestErr != nil {
  24119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24120. return
  24121. }
  24122. body, ioErr := ioutil.ReadAll(resp.Body)
  24123. if ioErr != nil {
  24124. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24126. return
  24127. }
  24128. var respJSON map[string]interface{}
  24129. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24132. return
  24133. }
  24134. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24135. result, _ := json.Marshal(respJSON)
  24136. if miConfig.Code == "H15049901371" {
  24137. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24138. utils.ErrorLog("解析失败:%v", err)
  24139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24140. return
  24141. }
  24142. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24143. res.Output = resSeven10265.Output
  24144. res.ErrMsg = resSeven10265.ErrMsg
  24145. res.Cainfo = resSeven10265.Cainfo
  24146. res.WarnMsg = resSeven10265.WarnMsg
  24147. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24148. res.Infcode = infocode
  24149. } else {
  24150. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24151. utils.ErrorLog("解析失败:%v", err)
  24152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24153. return
  24154. }
  24155. }
  24156. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24157. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  24158. if result3101.Infcode == "0" {
  24159. if len(result3101.Output.Result) > 0 {
  24160. var errMsgs []string
  24161. for _, item := range result3101.Output.Result {
  24162. errMsgs = append(errMsgs, item.VolaCont)
  24163. }
  24164. c.ServeSuccessJSON(map[string]interface{}{
  24165. "failed_code": -10,
  24166. "msg": errMsgs,
  24167. })
  24168. return
  24169. } else {
  24170. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24171. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24172. bas := strings.Split(psn_info.CardInfo, "|")
  24173. if his.IdCardType == 1 {
  24174. cert_no = bas[2]
  24175. } else if his.IdCardType == 3 {
  24176. cert_no = his.Certno
  24177. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  24178. } else if his.IdCardType == 4 {
  24179. cert_no = his.Certno
  24180. psn_info.VerifyNumber = psn_info.VerifyNumber
  24181. }
  24182. var api string
  24183. if miConfig.MdtrtareaAdmvs == "320921" {
  24184. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24185. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24186. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24187. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24188. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24189. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24190. "&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
  24191. } else {
  24192. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24193. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24194. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24195. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24196. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24197. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24198. "&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
  24199. }
  24200. resp, requestErr := http.Get(api)
  24201. if requestErr != nil {
  24202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24203. return
  24204. }
  24205. body, ioErr := ioutil.ReadAll(resp.Body)
  24206. if ioErr != nil {
  24207. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24209. return
  24210. }
  24211. var respJSON map[string]interface{}
  24212. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24215. return
  24216. }
  24217. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24218. result, _ := json.Marshal(respJSON)
  24219. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24220. utils.ErrorLog("解析失败:%v", err)
  24221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24222. return
  24223. }
  24224. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24225. res.Output = resSeven10265.Output
  24226. res.ErrMsg = resSeven10265.ErrMsg
  24227. res.Cainfo = resSeven10265.Cainfo
  24228. res.WarnMsg = resSeven10265.WarnMsg
  24229. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24230. res.Infcode = infocode
  24231. }
  24232. }
  24233. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24234. psn_info, _ := service.GetPsnByPatientId(id)
  24235. var verify_number string
  24236. if psn_info.IdCardType == 4 {
  24237. verify_number = psn_info.VerifyNumber
  24238. } else if psn_info.IdCardType == 1 {
  24239. bas := strings.Split(psn_info.CardInfo, "|")
  24240. cardNumber := bas[2]
  24241. verify_number = cardNumber
  24242. } else {
  24243. psn_info.IdCardType = 2
  24244. verify_number = psn_info.Certno
  24245. }
  24246. var api string
  24247. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24248. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24249. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24250. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24251. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24252. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24253. "&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
  24254. resp, requestErr := http.Get(api)
  24255. if requestErr != nil {
  24256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24257. return
  24258. }
  24259. body, ioErr := ioutil.ReadAll(resp.Body)
  24260. if ioErr != nil {
  24261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24263. return
  24264. }
  24265. var respJSON map[string]interface{}
  24266. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24269. return
  24270. }
  24271. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24272. result, _ := json.Marshal(respJSON)
  24273. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24274. utils.ErrorLog("解析失败:%v", err)
  24275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24276. return
  24277. }
  24278. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24279. res.Output = resSeven10265.Output
  24280. res.ErrMsg = resSeven10265.ErrMsg
  24281. res.Cainfo = resSeven10265.Cainfo
  24282. res.WarnMsg = resSeven10265.WarnMsg
  24283. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24284. res.Infcode = infocode
  24285. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24286. var cert_no string
  24287. if his.IdCardType == 4 {
  24288. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24289. cert_no = psn_info.VerifyNumber
  24290. 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)
  24291. } else if his.IdCardType == 1 {
  24292. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24293. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24294. 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)
  24295. }
  24296. //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)
  24297. var dat map[string]interface{}
  24298. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24299. fmt.Println(dat)
  24300. } else {
  24301. fmt.Println(err)
  24302. }
  24303. saveLog(result2, src_resquest, "2207", "结算")
  24304. userJSONBytes, _ := json.Marshal(dat)
  24305. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  24306. utils.ErrorLog("解析失败:%v", err)
  24307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24308. return
  24309. }
  24310. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24311. res.Output = resSeven10265.Output
  24312. res.ErrMsg = resSeven10265.ErrMsg
  24313. res.Cainfo = resSeven10265.Cainfo
  24314. res.WarnMsg = resSeven10265.WarnMsg
  24315. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24316. res.Infcode = infocode
  24317. } else if miConfig.MdtrtareaAdmvs == "450721" {
  24318. res2 := c.GetoleInfo()
  24319. if res2.Infcode == 0 {
  24320. var result string
  24321. var request_log string
  24322. var result_log string
  24323. if res2.Output.MdtrtCertType == "02" {
  24324. 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)
  24325. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24326. } else if res2.Output.MdtrtCertType == "01" {
  24327. 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)
  24328. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24329. } else {
  24330. 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)
  24331. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24332. }
  24333. var dat map[string]interface{}
  24334. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24335. fmt.Println(dat)
  24336. } else {
  24337. fmt.Println(err)
  24338. }
  24339. userJSONBytes, _ := json.Marshal(dat)
  24340. var res5 ResultTwo
  24341. //var resTwo10265 ResultTwo10265
  24342. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  24343. utils.ErrorLog("解析失败:%v", err)
  24344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24345. return
  24346. }
  24347. if res5.Infcode == -1 {
  24348. c.ServeSuccessJSON(map[string]interface{}{
  24349. "failed_code": -10,
  24350. "msg": res5.ErrMsg,
  24351. })
  24352. return
  24353. }
  24354. var insutypes []string
  24355. var insutype string
  24356. var is390 int = 0
  24357. var is310 int = 0
  24358. for _, item := range res5.Output.Iinfo {
  24359. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24360. insutypes = append(insutypes, item.Insutype)
  24361. }
  24362. }
  24363. if len(insutypes) == 1 {
  24364. insutype = insutypes[0]
  24365. } else {
  24366. for _, i := range insutypes {
  24367. if i == "390" {
  24368. is390 = 1
  24369. }
  24370. if i == "310" {
  24371. is310 = 1
  24372. }
  24373. }
  24374. }
  24375. if is390 == 1 {
  24376. insutype = "390"
  24377. }
  24378. if is310 == 1 {
  24379. insutype = "310"
  24380. }
  24381. if len(insutypes) == 0 {
  24382. insutype = "310"
  24383. }
  24384. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  24385. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  24386. infoStr := string(Iinfos)
  24387. idetinfoStr := string(Idetinfos)
  24388. psn := &models.HisPsn{
  24389. PsnNo: res5.Output.Baseinfo.PsnNo,
  24390. PatientId: id,
  24391. Certno: res5.Output.Baseinfo.Certno,
  24392. Gend: res5.Output.Baseinfo.Gend,
  24393. Naty: res5.Output.Baseinfo.Naty,
  24394. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  24395. PsnName: res5.Output.Baseinfo.PsnName,
  24396. Idetinfo: idetinfoStr,
  24397. Insuinfo: infoStr,
  24398. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  24399. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  24400. VerifyNumber: res2.Output.EcToken,
  24401. }
  24402. if res2.Output.MdtrtCertType == "01" {
  24403. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24404. psn.VerifyNumber = res2.Output.EcToken
  24405. } else if res2.Output.MdtrtCertType == "02" {
  24406. psn.VerifyNumber = res2.Output.CardNo
  24407. } else {
  24408. psn.VerifyNumber = res2.Output.MdtrtCertNo
  24409. }
  24410. service.CreateHisPsn(psn)
  24411. if res2.Output.MdtrtCertType == "01" {
  24412. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24413. token := res2.Output.EcToken
  24414. 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)
  24415. } else if res2.Output.MdtrtCertType == "02" {
  24416. 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)
  24417. } else {
  24418. 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)
  24419. }
  24420. var dat2 map[string]interface{}
  24421. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  24422. fmt.Println(dat2)
  24423. } else {
  24424. fmt.Println(err)
  24425. }
  24426. userJSONBytes3, _ := json.Marshal(dat2)
  24427. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24428. utils.ErrorLog("解析失败:%v", err)
  24429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24430. return
  24431. }
  24432. saveLog(result2, src_resquest, "2207", "结算")
  24433. } else {
  24434. c.ServeSuccessJSON(map[string]interface{}{
  24435. "failed_code": -10,
  24436. "msg": res2.ErrMsg,
  24437. })
  24438. return
  24439. }
  24440. } else {
  24441. if miConfig.Code == "H15049901371" {
  24442. //赤峰地区国家医保医疗类别
  24443. //职工透析:医疗类别选特殊情况门诊990502
  24444. //居民定额血透门慢: 医疗类别选门诊慢病140104
  24445. var med_type string
  24446. if his.Insutype == "390" {
  24447. if reg_type == 14 {
  24448. med_type = "9933"
  24449. } else if reg_type == 11 {
  24450. med_type = "11"
  24451. }
  24452. } else if his.Insutype == "310" {
  24453. if reg_type == 14 {
  24454. med_type = "990502"
  24455. } else if reg_type == 11 {
  24456. med_type = "11"
  24457. }
  24458. }
  24459. 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)
  24460. } else {
  24461. if his.IdCardType == 4 {
  24462. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24463. var token string
  24464. token = psn_info.VerifyNumber
  24465. 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)
  24466. } else {
  24467. if his.IdCardType == 1 {
  24468. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24469. bas := strings.Split(psn_info.CardInfo, "|")
  24470. basNumber := bas[2]
  24471. cert_no = basNumber
  24472. }
  24473. 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)
  24474. }
  24475. }
  24476. //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)
  24477. var dat map[string]interface{}
  24478. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24479. fmt.Println(dat)
  24480. } else {
  24481. fmt.Println(err)
  24482. }
  24483. saveLog(result2, src_resquest, "2207", "结算")
  24484. userJSONBytes, _ := json.Marshal(dat)
  24485. if miConfig.Code == "H15049901371" {
  24486. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  24487. utils.ErrorLog("解析失败:%v", err)
  24488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24489. return
  24490. }
  24491. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24492. res.Output = resSeven10265.Output
  24493. res.ErrMsg = resSeven10265.ErrMsg
  24494. res.Cainfo = resSeven10265.Cainfo
  24495. res.WarnMsg = resSeven10265.WarnMsg
  24496. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24497. res.Infcode = infocode
  24498. } else {
  24499. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24500. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  24501. utils.ErrorLog("解析失败:%v", err)
  24502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24503. return
  24504. }
  24505. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  24506. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  24507. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  24508. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  24509. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  24510. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  24511. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  24512. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  24513. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  24514. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24515. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24516. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24517. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24518. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  24519. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  24520. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  24521. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  24522. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  24523. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  24524. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  24525. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  24526. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  24527. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  24528. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  24529. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  24530. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  24531. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  24532. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  24533. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  24534. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  24535. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  24536. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  24537. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  24538. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  24539. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  24540. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  24541. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  24542. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  24543. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24544. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  24545. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  24546. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  24547. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  24548. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  24549. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  24550. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  24551. res.ErrMsg = gzresSeven10265Two.ErrMsg
  24552. res.Cainfo = gzresSeven10265Two.Cainfo
  24553. res.WarnMsg = gzresSeven10265Two.WarnMsg
  24554. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  24555. //res.Infcode = infocode
  24556. } else {
  24557. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24558. utils.ErrorLog("解析失败:%v", err)
  24559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24560. return
  24561. }
  24562. }
  24563. }
  24564. }
  24565. if res.Infcode == -1 {
  24566. errlog := &models.HisOrderError{
  24567. UserOrgId: adminUser.CurrentOrgId,
  24568. Ctime: time.Now().Unix(),
  24569. Mtime: time.Now().Unix(),
  24570. Number: chrg_bchno,
  24571. ErrMsg: res.ErrMsg,
  24572. Status: 1,
  24573. PatientId: id,
  24574. RecordTime: recordDateTime,
  24575. Stage: 6,
  24576. }
  24577. service.CreateErrMsgLog(errlog)
  24578. c.ServeSuccessJSON(map[string]interface{}{
  24579. "failed_code": -10,
  24580. "msg": res.ErrMsg,
  24581. })
  24582. return
  24583. } else {
  24584. sickConfig, _ := service.FindSickById(his.SickType)
  24585. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  24586. order.OrderStatus = 2
  24587. order.Status = 1
  24588. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  24589. order.SetlId = res.Output.Setlinfo.SetlID
  24590. order.PsnNo = res.Output.Setlinfo.PsnNo
  24591. order.PsnName = res.Output.Setlinfo.PsnName
  24592. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  24593. order.Certno = res.Output.Setlinfo.Certno
  24594. order.Gend = res.Output.Setlinfo.Gend
  24595. order.Naty = res.Output.Setlinfo.Naty
  24596. order.Age = res.Output.Setlinfo.Age
  24597. order.Insutype = res.Output.Setlinfo.Insutype
  24598. order.PsnType = res.Output.Setlinfo.PsnType
  24599. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  24600. order.SetlTime = res.Output.Setlinfo.SetlTime
  24601. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  24602. if res.Output.Setlinfo.MedType == "140101" {
  24603. order.MedType = "14"
  24604. } else {
  24605. if res.Output.Setlinfo.MedType == "110104" {
  24606. order.MedType = "11"
  24607. } else {
  24608. order.MedType = res.Output.Setlinfo.MedType
  24609. }
  24610. }
  24611. if reg_type == 1112 {
  24612. order.MedType = "1112"
  24613. }
  24614. if reg_type == 1111 {
  24615. order.MedType = "1111"
  24616. }
  24617. order.ClrType = res.Output.Setlinfo.ClrType
  24618. if adminUser.CurrentOrgId == 10480 {
  24619. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  24620. order.ClrType = "11"
  24621. } else {
  24622. order.ClrType = "9903"
  24623. }
  24624. }
  24625. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  24626. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  24627. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  24628. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  24629. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  24630. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  24631. order.HifpPay = res.Output.Setlinfo.HifpPay
  24632. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  24633. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  24634. order.HifesPay = res.Output.Setlinfo.HifesPay
  24635. order.HifobPay = res.Output.Setlinfo.HifobPay
  24636. order.MafPay = res.Output.Setlinfo.MafPay
  24637. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  24638. order.OthPay = res.Output.Setlinfo.OthPay
  24639. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  24640. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  24641. order.AcctPay = res.Output.Setlinfo.AcctPay
  24642. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  24643. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  24644. order.Balc = res.Output.Setlinfo.Balc
  24645. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  24646. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  24647. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  24648. //order.ClrType = res.Output.Setlinfo.ClrType
  24649. order.ClrWay = res.Output.Setlinfo.ClrWay
  24650. order.Creator = order.Creator
  24651. order.Modify = roles.AdminUserId
  24652. order.RequestLog = src_resquest
  24653. order.FaPiaoNumber = fapiao_number
  24654. order.FaPiaoCode = fapiao_code
  24655. order.SickName = sickConfig.ClassName
  24656. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  24657. //detailStr := string(setlDetail)
  24658. //order.SetlDetail = detailStr
  24659. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  24660. err = service.UpDateOrder(order)
  24661. if err == nil {
  24662. //判断是否使用了押金
  24663. if dec_way == "true" {
  24664. tmpstring := strconv.FormatInt(order.ID, 10)
  24665. order.Decimal = decimal
  24666. service.UpDateOrder(order)
  24667. //扣押金
  24668. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  24669. if errmsg != nil {
  24670. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  24671. return
  24672. }
  24673. }
  24674. c.ServeSuccessJSON(map[string]interface{}{
  24675. "msg": "结算成功",
  24676. })
  24677. } else {
  24678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  24679. return
  24680. }
  24681. }
  24682. } else {
  24683. adminUser := c.GetAdminUserInfo()
  24684. errlog := &models.HisOrderError{
  24685. UserOrgId: adminUser.CurrentOrgId,
  24686. Ctime: time.Now().Unix(),
  24687. Mtime: time.Now().Unix(),
  24688. ErrMsg: res.ErrMsg,
  24689. Status: 1,
  24690. PatientId: id,
  24691. RecordTime: recordDateTime,
  24692. Stage: 4,
  24693. }
  24694. service.CreateErrMsgLog(errlog)
  24695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  24696. return
  24697. }
  24698. } else {
  24699. adminUser := c.GetAdminUserInfo()
  24700. errlog := &models.HisOrderError{
  24701. UserOrgId: adminUser.CurrentOrgId,
  24702. Ctime: time.Now().Unix(),
  24703. Mtime: time.Now().Unix(),
  24704. ErrMsg: res.ErrMsg,
  24705. Status: 1,
  24706. PatientId: id,
  24707. RecordTime: recordDateTime,
  24708. Stage: 4,
  24709. }
  24710. service.CreateErrMsgLog(errlog)
  24711. c.ServeSuccessJSON(map[string]interface{}{
  24712. "failed_code": -10,
  24713. "msg": res.ErrMsg,
  24714. })
  24715. return
  24716. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  24717. //return
  24718. }
  24719. }
  24720. }
  24721. } else if tempOrder.ID > 0 {
  24722. if tempOrder.IsPre == 1 {
  24723. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  24724. var rf []*ResultFive
  24725. json.Unmarshal([]byte(his.Iinfo), &rf)
  24726. chrg_bchno := tempOrder.Number
  24727. cert_no := his.Certno
  24728. var insutypes []string
  24729. var insutype string
  24730. var is390 int = 0
  24731. var is310 int = 0
  24732. for _, item := range rf {
  24733. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24734. insutypes = append(insutypes, item.Insutype)
  24735. }
  24736. }
  24737. if len(insutypes) == 1 {
  24738. insutype = insutypes[0]
  24739. } else {
  24740. for _, i := range insutypes {
  24741. if i == "390" {
  24742. is390 = 1
  24743. }
  24744. if i == "310" {
  24745. is310 = 1
  24746. }
  24747. }
  24748. }
  24749. if is390 == 1 {
  24750. insutype = "390"
  24751. }
  24752. if is310 == 1 {
  24753. insutype = "310"
  24754. }
  24755. if len(insutypes) == 0 {
  24756. insutype = "310"
  24757. }
  24758. if len(insutypes) == 2 {
  24759. insutype = strconv.FormatInt(his.SocialType, 10)
  24760. }
  24761. //insutype = "390"
  24762. if his.IdCardType == 1 {
  24763. // cert_no = his.MedicalInsuranceNumber
  24764. cert_no = his.Certno
  24765. } else {
  24766. cert_no = his.Certno
  24767. }
  24768. var res ResultSeven
  24769. var ahres ResultSevenAH
  24770. var resSeven10265 ResultSeven10265
  24771. var gzresSeven10265Two GZResultSeven10265Two
  24772. var src_resquest string
  24773. var result2 string
  24774. if miConfig.MdtrtareaAdmvs == "450721" {
  24775. res2 := c.GetoleInfo()
  24776. if res2.Infcode == 0 {
  24777. var result string
  24778. var request_log string
  24779. var result_log string
  24780. if res2.Output.MdtrtCertType == "02" {
  24781. 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)
  24782. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24783. } else if res2.Output.MdtrtCertType == "01" {
  24784. 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)
  24785. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24786. } else {
  24787. 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)
  24788. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24789. }
  24790. var dat map[string]interface{}
  24791. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24792. fmt.Println(dat)
  24793. } else {
  24794. fmt.Println(err)
  24795. }
  24796. userJSONBytes, _ := json.Marshal(dat)
  24797. var res5 ResultTwo
  24798. //var resTwo10265 ResultTwo10265
  24799. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  24800. utils.ErrorLog("解析失败:%v", err)
  24801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24802. return
  24803. }
  24804. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  24805. if res5.Infcode == -1 {
  24806. c.ServeSuccessJSON(map[string]interface{}{
  24807. "failed_code": -10,
  24808. "msg": res5.ErrMsg,
  24809. })
  24810. return
  24811. }
  24812. var insutypes []string
  24813. var insutype string
  24814. var is390 int = 0
  24815. var is310 int = 0
  24816. for _, item := range res5.Output.Iinfo {
  24817. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24818. insutypes = append(insutypes, item.Insutype)
  24819. }
  24820. }
  24821. if len(insutypes) == 1 {
  24822. insutype = insutypes[0]
  24823. } else {
  24824. for _, i := range insutypes {
  24825. if i == "390" {
  24826. is390 = 1
  24827. }
  24828. if i == "310" {
  24829. is310 = 1
  24830. }
  24831. }
  24832. }
  24833. if is390 == 1 {
  24834. insutype = "390"
  24835. }
  24836. if is310 == 1 {
  24837. insutype = "310"
  24838. }
  24839. if len(insutypes) == 0 {
  24840. insutype = "310"
  24841. }
  24842. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  24843. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  24844. infoStr := string(Iinfos)
  24845. idetinfoStr := string(Idetinfos)
  24846. psn := &models.HisPsn{
  24847. PsnNo: res5.Output.Baseinfo.PsnNo,
  24848. PatientId: id,
  24849. Certno: res5.Output.Baseinfo.Certno,
  24850. Gend: res5.Output.Baseinfo.Gend,
  24851. Naty: res5.Output.Baseinfo.Naty,
  24852. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  24853. PsnName: res5.Output.Baseinfo.PsnName,
  24854. Idetinfo: idetinfoStr,
  24855. Insuinfo: infoStr,
  24856. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  24857. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  24858. VerifyNumber: res2.Output.EcToken,
  24859. }
  24860. service.CreateHisPsn(psn)
  24861. if res2.Output.MdtrtCertType == "01" {
  24862. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24863. token := res2.Output.EcToken
  24864. 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)
  24865. } else if res2.Output.MdtrtCertType == "02" {
  24866. 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)
  24867. } else {
  24868. 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)
  24869. }
  24870. var dat2 map[string]interface{}
  24871. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  24872. fmt.Println(dat2)
  24873. } else {
  24874. fmt.Println(err)
  24875. }
  24876. userJSONBytes3, _ := json.Marshal(dat2)
  24877. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24878. utils.ErrorLog("解析失败:%v", err)
  24879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24880. return
  24881. }
  24882. saveLog(result2, src_resquest, "2207", "结算")
  24883. } else {
  24884. c.ServeSuccessJSON(map[string]interface{}{
  24885. "failed_code": -10,
  24886. "msg": res2.ErrMsg,
  24887. })
  24888. return
  24889. }
  24890. } else if miConfig.MdtrtareaAdmvs == "421300" {
  24891. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24892. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24893. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24894. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24895. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24896. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24897. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24898. resp, requestErr := http.Get(api)
  24899. if requestErr != nil {
  24900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24901. return
  24902. }
  24903. body, ioErr := ioutil.ReadAll(resp.Body)
  24904. if ioErr != nil {
  24905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24907. return
  24908. }
  24909. var respJSON map[string]interface{}
  24910. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24913. return
  24914. }
  24915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24916. result, _ := json.Marshal(respJSON)
  24917. fmt.Println("log")
  24918. fmt.Println(string(result))
  24919. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24920. utils.ErrorLog("解析失败:%v", err)
  24921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24922. return
  24923. }
  24924. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24925. if reg_type == 11 && his.Insutype == "390" {
  24926. reg_type = 110104
  24927. }
  24928. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24929. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24930. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24931. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24932. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24933. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24934. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24935. resp, requestErr := http.Get(api)
  24936. if requestErr != nil {
  24937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24938. return
  24939. }
  24940. body, ioErr := ioutil.ReadAll(resp.Body)
  24941. if ioErr != nil {
  24942. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24944. return
  24945. }
  24946. var respJSON map[string]interface{}
  24947. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24948. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24950. return
  24951. }
  24952. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24953. result, _ := json.Marshal(respJSON)
  24954. fmt.Println("log")
  24955. fmt.Println(string(result))
  24956. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24957. utils.ErrorLog("解析失败:%v", err)
  24958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24959. return
  24960. }
  24961. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24962. if reg_type == 11 && his.Insutype == "390" {
  24963. reg_type = 110104
  24964. }
  24965. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24966. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24967. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24968. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24969. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24970. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24971. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24972. resp, requestErr := http.Get(api)
  24973. if requestErr != nil {
  24974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24975. return
  24976. }
  24977. body, ioErr := ioutil.ReadAll(resp.Body)
  24978. if ioErr != nil {
  24979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24981. return
  24982. }
  24983. var respJSON map[string]interface{}
  24984. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24987. return
  24988. }
  24989. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24990. result, _ := json.Marshal(respJSON)
  24991. fmt.Println("log")
  24992. fmt.Println(string(result))
  24993. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24994. utils.ErrorLog("解析失败:%v", err)
  24995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24996. return
  24997. }
  24998. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24999. if reg_type == 11 && his.Insutype == "390" {
  25000. reg_type = 110104
  25001. }
  25002. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25003. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25004. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25005. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25006. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25007. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25008. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25009. resp, requestErr := http.Get(api)
  25010. if requestErr != nil {
  25011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25012. return
  25013. }
  25014. body, ioErr := ioutil.ReadAll(resp.Body)
  25015. if ioErr != nil {
  25016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25018. return
  25019. }
  25020. var respJSON map[string]interface{}
  25021. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25024. return
  25025. }
  25026. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25027. result, _ := json.Marshal(respJSON)
  25028. fmt.Println("log")
  25029. fmt.Println(string(result))
  25030. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25031. utils.ErrorLog("解析失败:%v", err)
  25032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25033. return
  25034. }
  25035. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25036. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  25037. if result3101.Infcode == "0" {
  25038. if len(result3101.Output.Result) > 0 {
  25039. var errMsgs []string
  25040. for _, item := range result3101.Output.Result {
  25041. errMsgs = append(errMsgs, item.VolaCont)
  25042. }
  25043. c.ServeSuccessJSON(map[string]interface{}{
  25044. "failed_code": -10,
  25045. "msg": errMsgs,
  25046. })
  25047. return
  25048. } else {
  25049. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25050. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25051. bas := strings.Split(psn_info.CardInfo, "|")
  25052. if his.IdCardType == 1 {
  25053. cert_no = bas[2]
  25054. } else if his.IdCardType == 3 {
  25055. cert_no = his.Certno
  25056. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  25057. } else if his.IdCardType == 4 {
  25058. cert_no = his.Certno
  25059. psn_info.VerifyNumber = psn_info.VerifyNumber
  25060. }
  25061. //江苏地区国家医保医疗类别
  25062. //职工透析:医疗类别选特殊情况门诊9933
  25063. //居民血透门慢: 医疗类别选门诊慢病1402
  25064. //var med_type string
  25065. //if his.Insutype == "310" {
  25066. // if reg_type == 14 {
  25067. // med_type = "9933"
  25068. // } else if reg_type == 11 {
  25069. // med_type = "11"
  25070. //
  25071. // }
  25072. //} else if his.Insutype == "390" {
  25073. // if reg_type == 14 {
  25074. // med_type = "1402"
  25075. // } else if reg_type == 11 {
  25076. // med_type = "11"
  25077. // }
  25078. //}
  25079. var api string
  25080. if miConfig.MdtrtareaAdmvs == "320921" {
  25081. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25082. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25083. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25084. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25085. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25086. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25087. "&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
  25088. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25089. } else {
  25090. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25091. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25092. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25093. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25094. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25095. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25096. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25097. "&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
  25098. }
  25099. resp, requestErr := http.Get(api)
  25100. if requestErr != nil {
  25101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25102. return
  25103. }
  25104. body, ioErr := ioutil.ReadAll(resp.Body)
  25105. if ioErr != nil {
  25106. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25108. return
  25109. }
  25110. var respJSON map[string]interface{}
  25111. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25114. return
  25115. }
  25116. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25117. result, _ := json.Marshal(respJSON)
  25118. fmt.Println("log")
  25119. fmt.Println(string(result))
  25120. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25121. utils.ErrorLog("解析失败:%v", err)
  25122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25123. return
  25124. }
  25125. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25126. res.Output = resSeven10265.Output
  25127. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25128. res.ErrMsg = resSeven10265.ErrMsg
  25129. res.Cainfo = resSeven10265.Cainfo
  25130. res.WarnMsg = resSeven10265.WarnMsg
  25131. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25132. res.Infcode = infocode
  25133. }
  25134. }
  25135. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25136. psn_info, _ := service.GetPsnByPatientId(id)
  25137. var verify_number string
  25138. if psn_info.IdCardType == 4 {
  25139. verify_number = psn_info.VerifyNumber
  25140. } else if psn_info.IdCardType == 1 {
  25141. bas := strings.Split(psn_info.CardInfo, "|")
  25142. cardNumber := bas[2]
  25143. verify_number = cardNumber
  25144. } else {
  25145. verify_number = psn_info.Certno
  25146. psn_info.IdCardType = 2
  25147. }
  25148. var api string
  25149. new_chrg_bchno := chrg_bchno
  25150. if adminUser.CurrentOrgId == 10265 {
  25151. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25152. new_chrg_bchno = "0000"
  25153. }
  25154. }
  25155. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25156. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  25157. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25158. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25159. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  25160. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25161. "&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
  25162. resp, requestErr := http.Get(api)
  25163. if requestErr != nil {
  25164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25165. return
  25166. }
  25167. body, ioErr := ioutil.ReadAll(resp.Body)
  25168. if ioErr != nil {
  25169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25171. return
  25172. }
  25173. var respJSON map[string]interface{}
  25174. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25177. return
  25178. }
  25179. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25180. result, _ := json.Marshal(respJSON)
  25181. fmt.Println("log")
  25182. fmt.Println(string(result))
  25183. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25184. utils.ErrorLog("解析失败:%v", err)
  25185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25186. return
  25187. }
  25188. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25189. res.Output = resSeven10265.Output
  25190. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25191. res.ErrMsg = resSeven10265.ErrMsg
  25192. res.Cainfo = resSeven10265.Cainfo
  25193. res.WarnMsg = resSeven10265.WarnMsg
  25194. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25195. res.Infcode = infocode
  25196. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25197. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25198. var cert_no string
  25199. if his.IdCardType == 1 {
  25200. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25201. } else {
  25202. cert_no = psn_info.VerifyNumber
  25203. }
  25204. 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)
  25205. var dat map[string]interface{}
  25206. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25207. fmt.Println(dat)
  25208. } else {
  25209. fmt.Println(err)
  25210. }
  25211. saveLog(result2, src_resquest, "2207", "结算")
  25212. userJSONBytes, _ := json.Marshal(dat)
  25213. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25214. utils.ErrorLog("解析失败:%v", err)
  25215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25216. return
  25217. }
  25218. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25219. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25220. var cert_no string
  25221. var card_sn string
  25222. if his.IdCardType == 1 {
  25223. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25224. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25225. bas := strings.Split(psn_info.CardInfo, "|")
  25226. card_sn = bas[3]
  25227. } else if his.IdCardType == 2 {
  25228. cert_no = his.IdCardNo
  25229. } else {
  25230. cert_no = psn_info.VerifyNumber
  25231. }
  25232. var rf []*ResultFive
  25233. json.Unmarshal([]byte(his.Iinfo), &rf)
  25234. var psn_type string
  25235. for _, item := range rf {
  25236. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  25237. psn_type = item.PsnType
  25238. }
  25239. }
  25240. 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)
  25241. var dat map[string]interface{}
  25242. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25243. fmt.Println(dat)
  25244. } else {
  25245. fmt.Println(err)
  25246. }
  25247. saveLog(result2, src_resquest, "2207", "结算")
  25248. userJSONBytes, _ := json.Marshal(dat)
  25249. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25250. utils.ErrorLog("解析失败:%v", err)
  25251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25252. return
  25253. }
  25254. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25255. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25256. if his.IdCardType == 1 {
  25257. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25258. bas := strings.Split(psn_info.CardInfo, "|")
  25259. cert_no = bas[2]
  25260. } else if his.IdCardType == 3 {
  25261. cert_no = his.Certno
  25262. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  25263. } else if his.IdCardType == 4 {
  25264. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25265. cert_no = his.Certno
  25266. psn_info.VerifyNumber = psn_info.VerifyNumber
  25267. } else {
  25268. cert_no = his.Certno
  25269. psn_info.VerifyNumber = his.Certno
  25270. }
  25271. var api string
  25272. var med_type string
  25273. if his.Insutype == "390" {
  25274. if reg_type == 992102 {
  25275. med_type = "992102"
  25276. }
  25277. if reg_type == 140104 {
  25278. med_type = "140104"
  25279. }
  25280. if reg_type == 14 {
  25281. med_type = "14"
  25282. }
  25283. } else if his.Insutype == "310" {
  25284. if reg_type == 992102 {
  25285. med_type = "992102"
  25286. }
  25287. if reg_type == 14 {
  25288. med_type = "14"
  25289. }
  25290. }
  25291. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25292. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25293. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25294. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25295. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25296. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25297. "&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
  25298. resp, requestErr := http.Get(api)
  25299. if requestErr != nil {
  25300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25301. return
  25302. }
  25303. body, ioErr := ioutil.ReadAll(resp.Body)
  25304. if ioErr != nil {
  25305. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25307. return
  25308. }
  25309. var respJSON map[string]interface{}
  25310. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25313. return
  25314. }
  25315. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25316. if status == "0" {
  25317. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25318. c.ServeSuccessJSON(map[string]interface{}{
  25319. "failed_code": -10,
  25320. "msg": err_msg,
  25321. })
  25322. return
  25323. }
  25324. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25325. result, _ := json.Marshal(respJSON)
  25326. fmt.Println("log")
  25327. fmt.Println(string(result))
  25328. if err := json.Unmarshal(result, &ahres); err != nil {
  25329. utils.ErrorLog("解析失败:%v", err)
  25330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25331. return
  25332. }
  25333. res.InfRefmsgid = ahres.InfRefmsgid
  25334. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  25335. // 创建对应的Time类型
  25336. t := time.UnixMilli(timestamp)
  25337. // 格式化成指定的日期字符串
  25338. str := t.Format("2006-01-02 15:04:05")
  25339. res.Output.Setlinfo.SetlTime = str
  25340. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  25341. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  25342. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  25343. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  25344. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  25345. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  25346. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  25347. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  25348. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  25349. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  25350. res.Output.Setlinfo.ClrType = "11"
  25351. } else {
  25352. res.Output.Setlinfo.ClrType = "9903"
  25353. }
  25354. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  25355. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  25356. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  25357. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  25358. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  25359. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  25360. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  25361. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  25362. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  25363. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  25364. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  25365. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  25366. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  25367. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  25368. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  25369. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  25370. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  25371. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  25372. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  25373. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  25374. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  25375. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  25376. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  25377. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  25378. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  25379. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  25380. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  25381. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  25382. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  25383. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  25384. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  25385. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  25386. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  25387. res.Output.Setldetail = ahres.Output.Setldetail
  25388. res.ErrMsg = ahres.ErrMsg
  25389. res.Cainfo = ahres.Cainfo
  25390. res.WarnMsg = ahres.WarnMsg
  25391. res.Infcode = ahres.Infcode
  25392. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25393. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25394. var cert_no string
  25395. if his.IdCardType == 1 {
  25396. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25397. } else if his.IdCardType == 2 {
  25398. cert_no = his.IdCardNo
  25399. } else {
  25400. cert_no = psn_info.VerifyNumber
  25401. }
  25402. 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, "")
  25403. var dat map[string]interface{}
  25404. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25405. fmt.Println(dat)
  25406. } else {
  25407. fmt.Println(err)
  25408. }
  25409. saveLog(result2, src_resquest, "2207", "结算")
  25410. userJSONBytes, _ := json.Marshal(dat)
  25411. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25412. utils.ErrorLog("解析失败:%v", err)
  25413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25414. return
  25415. }
  25416. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25417. psn_info, _ := service.GetPsnByPatientId(id)
  25418. var verify_number string
  25419. if psn_info.IdCardType == 4 {
  25420. verify_number = psn_info.VerifyNumber
  25421. } else if psn_info.IdCardType == 1 {
  25422. bas := strings.Split(psn_info.CardInfo, "|")
  25423. cardNumber := bas[2]
  25424. verify_number = cardNumber
  25425. } else {
  25426. verify_number = psn_info.Certno
  25427. psn_info.IdCardType = 2
  25428. }
  25429. var api string
  25430. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25431. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25432. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25433. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25434. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  25435. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25436. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  25437. resp, requestErr := http.Get(api)
  25438. if requestErr != nil {
  25439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25440. return
  25441. }
  25442. body, ioErr := ioutil.ReadAll(resp.Body)
  25443. if ioErr != nil {
  25444. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25446. return
  25447. }
  25448. var respJSON map[string]interface{}
  25449. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25452. return
  25453. }
  25454. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25455. result, _ := json.Marshal(respJSON)
  25456. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25457. utils.ErrorLog("解析失败:%v", err)
  25458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25459. return
  25460. }
  25461. } else {
  25462. var src_resquest string
  25463. if miConfig.Code == "H15049901371" {
  25464. //赤峰地区国家医保医疗类别
  25465. //职工透析:医疗类别选特殊情况门诊990502
  25466. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25467. var med_type string
  25468. if his.Insutype == "390" {
  25469. if reg_type == 14 {
  25470. med_type = "9933"
  25471. } else if reg_type == 11 {
  25472. med_type = "11"
  25473. }
  25474. } else if his.Insutype == "310" {
  25475. if reg_type == 14 {
  25476. med_type = "990502"
  25477. } else if reg_type == 11 {
  25478. med_type = "11"
  25479. }
  25480. }
  25481. 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)
  25482. } else {
  25483. if his.IdCardType == 4 {
  25484. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25485. token := psn_info.VerifyNumber
  25486. 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)
  25487. } else {
  25488. 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)
  25489. }
  25490. }
  25491. var dat map[string]interface{}
  25492. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25493. fmt.Println(dat)
  25494. } else {
  25495. fmt.Println(err)
  25496. }
  25497. saveLog(result2, src_resquest, "2207", "结算")
  25498. userJSONBytes, _ := json.Marshal(dat)
  25499. if miConfig.Code == "H15049901371" {
  25500. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  25501. utils.ErrorLog("解析失败:%v", err)
  25502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25503. return
  25504. }
  25505. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25506. res.Output = resSeven10265.Output
  25507. res.ErrMsg = resSeven10265.ErrMsg
  25508. res.Cainfo = resSeven10265.Cainfo
  25509. res.WarnMsg = resSeven10265.WarnMsg
  25510. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25511. res.Infcode = infocode
  25512. } else {
  25513. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25514. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  25515. utils.ErrorLog("解析失败:%v", err)
  25516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25517. return
  25518. }
  25519. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  25520. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  25521. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  25522. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  25523. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  25524. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  25525. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  25526. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  25527. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  25528. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25529. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25530. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25531. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25532. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  25533. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  25534. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  25535. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  25536. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  25537. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  25538. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  25539. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  25540. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  25541. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  25542. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  25543. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  25544. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  25545. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  25546. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  25547. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  25548. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  25549. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  25550. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  25551. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  25552. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  25553. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  25554. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  25555. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  25556. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  25557. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25558. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  25559. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  25560. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  25561. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  25562. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  25563. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  25564. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  25565. res.ErrMsg = gzresSeven10265Two.ErrMsg
  25566. res.Cainfo = gzresSeven10265Two.Cainfo
  25567. res.WarnMsg = gzresSeven10265Two.WarnMsg
  25568. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  25569. //res.Infcode = infocode
  25570. } else {
  25571. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25572. utils.ErrorLog("解析失败:%v", err)
  25573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25574. return
  25575. }
  25576. }
  25577. }
  25578. }
  25579. if res.Infcode == -1 {
  25580. errlog := &models.HisOrderError{
  25581. UserOrgId: adminUser.CurrentOrgId,
  25582. Ctime: time.Now().Unix(),
  25583. Mtime: time.Now().Unix(),
  25584. Number: chrg_bchno,
  25585. ErrMsg: res.ErrMsg,
  25586. Status: 1,
  25587. PatientId: id,
  25588. RecordTime: recordDateTime,
  25589. Stage: 6,
  25590. }
  25591. service.CreateErrMsgLog(errlog)
  25592. c.ServeSuccessJSON(map[string]interface{}{
  25593. "failed_code": -10,
  25594. "msg": res.ErrMsg,
  25595. })
  25596. return
  25597. } else {
  25598. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  25599. order.OrderStatus = 2
  25600. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  25601. order.SetlId = res.Output.Setlinfo.SetlID
  25602. order.PsnNo = res.Output.Setlinfo.PsnNo
  25603. order.PsnName = res.Output.Setlinfo.PsnName
  25604. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  25605. order.Certno = res.Output.Setlinfo.Certno
  25606. order.Gend = res.Output.Setlinfo.Gend
  25607. order.Naty = res.Output.Setlinfo.Naty
  25608. order.Age = res.Output.Setlinfo.Age
  25609. order.Insutype = res.Output.Setlinfo.Insutype
  25610. order.PsnType = res.Output.Setlinfo.PsnType
  25611. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  25612. order.SetlTime = res.Output.Setlinfo.SetlTime
  25613. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  25614. order.PayWays = pay_ways
  25615. order.AcctUsedFlag = acct_used_flag
  25616. order.WechatPay = wechat_pay
  25617. order.AliPay = ali_pay
  25618. order.JifenPay = jifen_pay
  25619. order.BandCardPay = band_card_pay
  25620. order.CashPay = cash_pay
  25621. order.OthDesc = oth_desc
  25622. //order.MedType = res.Output.Setlinfo.MedType
  25623. if reg_type == 1112 {
  25624. order.MedType = "1112"
  25625. }
  25626. if reg_type == 1111 {
  25627. order.MedType = "1111"
  25628. }
  25629. order.ClrType = res.Output.Setlinfo.ClrType
  25630. if adminUser.CurrentOrgId == 10480 {
  25631. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  25632. order.ClrType = "11"
  25633. } else {
  25634. order.ClrType = "9903"
  25635. }
  25636. }
  25637. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  25638. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  25639. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  25640. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  25641. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  25642. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  25643. order.HifpPay = res.Output.Setlinfo.HifpPay
  25644. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  25645. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  25646. order.HifesPay = res.Output.Setlinfo.HifesPay
  25647. order.HifobPay = res.Output.Setlinfo.HifobPay
  25648. order.MafPay = res.Output.Setlinfo.MafPay
  25649. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  25650. order.OthPay = res.Output.Setlinfo.OthPay
  25651. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  25652. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  25653. order.AcctPay = res.Output.Setlinfo.AcctPay
  25654. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  25655. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  25656. order.Balc = res.Output.Setlinfo.Balc
  25657. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  25658. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  25659. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  25660. order.ClrWay = res.Output.Setlinfo.ClrWay
  25661. order.Creator = order.Creator
  25662. order.Modify = roles.AdminUserId
  25663. order.RequestLog = src_resquest
  25664. order.Diagnosis = diagnosis_id
  25665. order.FaPiaoNumber = fapiao_number
  25666. order.FaPiaoCode = fapiao_code
  25667. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  25668. detailStr := string(setlDetail)
  25669. order.SetlDetail = detailStr
  25670. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  25671. err = service.UpDateOrder(order)
  25672. if err == nil {
  25673. //判断是否使用了押金
  25674. if dec_way == "true" {
  25675. tmpstring := strconv.FormatInt(order.ID, 10)
  25676. //扣押金
  25677. order.Decimal = decimal
  25678. service.UpDateOrder(order)
  25679. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  25680. if errmsg != nil {
  25681. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  25682. return
  25683. }
  25684. }
  25685. c.ServeSuccessJSON(map[string]interface{}{
  25686. "msg": "结算成功",
  25687. })
  25688. } else {
  25689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  25690. return
  25691. }
  25692. }
  25693. }
  25694. }
  25695. }
  25696. // 上传明细-预结算-
  25697. func (c *HisApiController) GetPreUploadInfo() {
  25698. id, _ := c.GetInt64("id")
  25699. record_time := c.GetString("record_time")
  25700. his_patient_id, _ := c.GetInt64("his_patient_id")
  25701. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  25702. admin_user_id, _ := c.GetInt64("admin_user_id")
  25703. diagnosis_id := c.GetString("diagnosis")
  25704. sick_type, _ := c.GetInt64("sick_type")
  25705. reg_type, _ := c.GetInt64("p_type")
  25706. begin_time := c.GetString("begin_time")
  25707. acct_used_flag := c.GetString("acct_used_flag")
  25708. id_str := c.GetString("ids")
  25709. ids_arr := strings.Split(id_str, ",")
  25710. timeLayout := "2006-01-02"
  25711. loc, _ := time.LoadLocation("Local")
  25712. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25713. if err != nil {
  25714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25715. return
  25716. }
  25717. recordDateTime := theTime.Unix()
  25718. adminUser := c.GetAdminUserInfo()
  25719. diagnosis_ids := strings.Split(diagnosis_id, ",")
  25720. var config []*models.HisXtDiagnoseConfig
  25721. for _, item := range diagnosis_ids {
  25722. id, _ := strconv.ParseInt(item, 10, 64)
  25723. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25724. config = append(config, &diagnosisConfig)
  25725. }
  25726. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  25727. sickConfig, _ := service.FindSickById(sick_type)
  25728. var prescriptions []*models.HisPrescription
  25729. var start_time int64
  25730. var end_time int64
  25731. var isSuccess bool = true
  25732. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25733. fmt.Println(his_patient_id)
  25734. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25735. timestamp := time.Now().Unix()
  25736. tempTime := time.Unix(timestamp, 0)
  25737. timeFormat := tempTime.Format("20060102150405")
  25738. chrgBchno := rand.Intn(100000) + 10000
  25739. new_chrg_bchno := ""
  25740. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  25741. new_chrg_bchno = chrg_bchno
  25742. if adminUser.CurrentOrgId == 10265 {
  25743. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25744. new_chrg_bchno = "0000"
  25745. }
  25746. }
  25747. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25748. var patientPrescription models.HisPrescriptionInfo
  25749. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25750. if patientPrescription.ID == 0 {
  25751. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  25752. }
  25753. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25754. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  25755. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  25756. strconv.FormatInt(his.PatientId, 10)
  25757. var res2406 Result2406
  25758. //安徽单病种处理
  25759. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  25760. data := make(map[string]interface{})
  25761. client := &http.Client{}
  25762. data["psn_no"] = his.PsnNo
  25763. data["mdtrt_id"] = his.Number
  25764. data["operator"] = roles.UserName
  25765. data["cert_no"] = his.IdCardNo
  25766. data["org_name"] = miConfig.OrgName
  25767. data["psn_name"] = his.Name
  25768. data["ipt_otp_no"] = his.IptOtpNo
  25769. data["ipt_psn_sp_flag_type"] = "0901"
  25770. data["ipt_psn_sp_flag"] = "1"
  25771. data["fixmedins_code"] = miConfig.Code
  25772. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25773. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25774. data["url"] = miConfig.Url
  25775. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  25776. bytesData, _ := json.Marshal(data)
  25777. var req *http.Request
  25778. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  25779. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  25780. resp, _ := client.Do(req)
  25781. defer resp.Body.Close()
  25782. body, ioErr := ioutil.ReadAll(resp.Body)
  25783. if ioErr != nil {
  25784. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25786. return
  25787. }
  25788. var respJSON map[string]interface{}
  25789. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25792. return
  25793. }
  25794. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25795. if status == "0" {
  25796. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25797. c.ServeSuccessJSON(map[string]interface{}{
  25798. "failed_code": -10,
  25799. "msg": err_msg,
  25800. })
  25801. return
  25802. }
  25803. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25804. userJSONBytes, _ := json.Marshal(respJSON)
  25805. fmt.Println("log")
  25806. fmt.Println(string(userJSONBytes))
  25807. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  25808. utils.ErrorLog("解析失败:%v", err)
  25809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25810. return
  25811. }
  25812. }
  25813. if res2406.Infcode != 0 {
  25814. adminUser := c.GetAdminUserInfo()
  25815. errlog := &models.HisOrderError{
  25816. UserOrgId: adminUser.CurrentOrgId,
  25817. Ctime: time.Now().Unix(),
  25818. Mtime: time.Now().Unix(),
  25819. ErrMsg: res2406.ErrMsg,
  25820. Status: 1,
  25821. PatientId: id,
  25822. RecordTime: recordDateTime,
  25823. Stage: 3,
  25824. }
  25825. service.CreateErrMsgLog(errlog)
  25826. c.ServeSuccessJSON(map[string]interface{}{
  25827. "failed_code": -10,
  25828. "msg": res2406.ErrMsg,
  25829. })
  25830. return
  25831. }
  25832. var res2 ResultSix
  25833. var res3 GZResultSix
  25834. var resSix10265 ResultSix10265
  25835. //var time_stamp string
  25836. if miConfig.MdtrtareaAdmvs == "421300" {
  25837. data := make(map[string]interface{})
  25838. client := &http.Client{}
  25839. data["psn_no"] = his.PsnNo
  25840. data["mdtrt_id"] = his.Number
  25841. data["department"] = department.Name
  25842. data["org_name"] = miConfig.OrgName
  25843. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25844. data["doctor_id"] = doctor_info.DoctorNumber
  25845. data["doctor_name"] = roles.UserName
  25846. data["fixmedins_code"] = miConfig.Code
  25847. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25848. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25849. data["secret_key"] = miConfig.SecretKey
  25850. data["sick_code"] = sickConfig.CountryCode
  25851. data["sick_name"] = sickConfig.ClassName
  25852. data["begin_time"] = begin_time
  25853. data["dept"] = strconv.FormatInt(department.ID, 10)
  25854. data["config"] = config
  25855. data["opter"] = roles.UserName
  25856. fmt.Println(data)
  25857. bytesData, _ := json.Marshal(data)
  25858. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25859. resp, _ := client.Do(req)
  25860. defer resp.Body.Close()
  25861. body, ioErr := ioutil.ReadAll(resp.Body)
  25862. if ioErr != nil {
  25863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25865. return
  25866. }
  25867. var respJSON map[string]interface{}
  25868. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25871. return
  25872. }
  25873. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25874. userJSONBytes, _ := json.Marshal(respJSON)
  25875. fmt.Println("log")
  25876. fmt.Println(string(userJSONBytes))
  25877. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25878. utils.ErrorLog("解析失败:%v", err)
  25879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25880. return
  25881. }
  25882. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25883. data := make(map[string]interface{})
  25884. client := &http.Client{}
  25885. data["psn_no"] = his.PsnNo
  25886. data["mdtrt_id"] = his.Number
  25887. data["department"] = department.Name
  25888. data["org_name"] = miConfig.OrgName
  25889. if reg_type == 11 && his.Insutype == "390" {
  25890. data["med_type"] = "110104"
  25891. } else {
  25892. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25893. }
  25894. data["doctor_id"] = doctor_info.DoctorNumber
  25895. data["doctor_name"] = roles.UserName
  25896. data["fixmedins_code"] = miConfig.Code
  25897. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25898. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25899. data["secret_key"] = miConfig.SecretKey
  25900. data["sick_code"] = sickConfig.CountryCode
  25901. data["sick_name"] = sickConfig.ClassName
  25902. data["begin_time"] = begin_time
  25903. data["dept"] = strconv.FormatInt(department.ID, 10)
  25904. data["config"] = config
  25905. data["opter"] = roles.UserName
  25906. fmt.Println(data)
  25907. bytesData, _ := json.Marshal(data)
  25908. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25909. resp, _ := client.Do(req)
  25910. defer resp.Body.Close()
  25911. body, ioErr := ioutil.ReadAll(resp.Body)
  25912. if ioErr != nil {
  25913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25915. return
  25916. }
  25917. var respJSON map[string]interface{}
  25918. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25921. return
  25922. }
  25923. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25924. userJSONBytes, _ := json.Marshal(respJSON)
  25925. fmt.Println("log")
  25926. fmt.Println(string(userJSONBytes))
  25927. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25928. utils.ErrorLog("解析失败:%v", err)
  25929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25930. return
  25931. }
  25932. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25933. data := make(map[string]interface{})
  25934. client := &http.Client{}
  25935. data["psn_no"] = his.PsnNo
  25936. data["mdtrt_id"] = his.Number
  25937. data["department"] = department.Name
  25938. data["org_name"] = miConfig.OrgName
  25939. if reg_type == 11 && his.Insutype == "390" {
  25940. data["med_type"] = "110104"
  25941. } else {
  25942. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25943. }
  25944. data["doctor_id"] = doctor_info.DoctorNumber
  25945. data["doctor_name"] = roles.UserName
  25946. data["fixmedins_code"] = miConfig.Code
  25947. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25948. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25949. data["secret_key"] = miConfig.SecretKey
  25950. data["sick_code"] = sickConfig.CountryCode
  25951. data["sick_name"] = sickConfig.ClassName
  25952. data["begin_time"] = begin_time
  25953. data["dept"] = strconv.FormatInt(department.ID, 10)
  25954. data["config"] = config
  25955. data["opter"] = roles.UserName
  25956. fmt.Println(data)
  25957. bytesData, _ := json.Marshal(data)
  25958. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25959. resp, _ := client.Do(req)
  25960. defer resp.Body.Close()
  25961. body, ioErr := ioutil.ReadAll(resp.Body)
  25962. if ioErr != nil {
  25963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25965. return
  25966. }
  25967. var respJSON map[string]interface{}
  25968. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25971. return
  25972. }
  25973. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25974. userJSONBytes, _ := json.Marshal(respJSON)
  25975. fmt.Println("log")
  25976. fmt.Println(string(userJSONBytes))
  25977. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25978. utils.ErrorLog("解析失败:%v", err)
  25979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25980. return
  25981. }
  25982. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25983. data := make(map[string]interface{})
  25984. client := &http.Client{}
  25985. data["psn_no"] = his.PsnNo
  25986. data["mdtrt_id"] = his.Number
  25987. data["department"] = department.Name
  25988. data["org_name"] = miConfig.OrgName
  25989. if reg_type == 11 && his.Insutype == "390" {
  25990. data["med_type"] = "110104"
  25991. } else {
  25992. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25993. }
  25994. data["doctor_id"] = doctor_info.DoctorNumber
  25995. data["doctor_name"] = roles.UserName
  25996. data["fixmedins_code"] = miConfig.Code
  25997. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25998. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25999. data["secret_key"] = miConfig.SecretKey
  26000. data["sick_code"] = sickConfig.CountryCode
  26001. data["sick_name"] = sickConfig.ClassName
  26002. data["begin_time"] = begin_time
  26003. data["dept"] = strconv.FormatInt(department.ID, 10)
  26004. data["config"] = config
  26005. data["opter"] = roles.UserName
  26006. fmt.Println(data)
  26007. bytesData, _ := json.Marshal(data)
  26008. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26009. resp, _ := client.Do(req)
  26010. defer resp.Body.Close()
  26011. body, ioErr := ioutil.ReadAll(resp.Body)
  26012. if ioErr != nil {
  26013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26015. return
  26016. }
  26017. var respJSON map[string]interface{}
  26018. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26021. return
  26022. }
  26023. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26024. userJSONBytes, _ := json.Marshal(respJSON)
  26025. fmt.Println("log")
  26026. fmt.Println(string(userJSONBytes))
  26027. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26028. utils.ErrorLog("解析失败:%v", err)
  26029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26030. return
  26031. }
  26032. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26033. data := make(map[string]interface{})
  26034. client := &http.Client{}
  26035. data["psn_no"] = his.PsnNo
  26036. data["mdtrt_id"] = his.Number
  26037. data["doctor"] = roles.UserName
  26038. data["department"] = department.Name
  26039. data["org_name"] = miConfig.OrgName
  26040. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26041. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  26042. data["fixmedins_code"] = miConfig.Code
  26043. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26044. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26045. data["secret_key"] = miConfig.SecretKey
  26046. data["sick_code"] = sickConfig.CountryCode
  26047. data["sick_name"] = sickConfig.ClassName
  26048. data["begin_time"] = begin_time
  26049. data["dept"] = strconv.FormatInt(department.ID, 10)
  26050. data["config"] = config
  26051. data["url"] = miConfig.Url
  26052. data["ak"] = miConfig.AccessKey
  26053. data["cainfo"] = miConfig.Cainfo
  26054. bytesData, _ := json.Marshal(data)
  26055. var req *http.Request
  26056. if miConfig.MdtrtareaAdmvs == "320921" {
  26057. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26058. } else {
  26059. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26060. }
  26061. resp, _ := client.Do(req)
  26062. defer resp.Body.Close()
  26063. body, ioErr := ioutil.ReadAll(resp.Body)
  26064. if ioErr != nil {
  26065. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26067. return
  26068. }
  26069. var respJSON map[string]interface{}
  26070. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26071. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26073. return
  26074. }
  26075. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  26076. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  26077. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  26078. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26079. userJSONBytes, _ := json.Marshal(respJSON)
  26080. fmt.Println("log")
  26081. fmt.Println(string(userJSONBytes))
  26082. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  26083. utils.ErrorLog("解析失败:%v", err)
  26084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26085. return
  26086. }
  26087. res2.InfRefmsgid = resSix10265.InfRefmsgid
  26088. res2.Output = resSix10265.Output
  26089. res2.ErrMsg = resSix10265.ErrMsg
  26090. res2.Cainfo = resSix10265.Cainfo
  26091. res2.WarnMsg = resSix10265.WarnMsg
  26092. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  26093. res2.Infcode = infocode
  26094. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26095. data := make(map[string]interface{})
  26096. client := &http.Client{}
  26097. data["psn_no"] = his.PsnNo
  26098. data["mdtrt_id"] = his.Number
  26099. data["doctor"] = roles.UserName
  26100. data["department"] = department.Name
  26101. data["org_name"] = miConfig.OrgName
  26102. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26103. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  26104. data["fixmedins_code"] = miConfig.Code
  26105. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26106. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26107. data["secret_key"] = miConfig.SecretKey
  26108. data["sick_code"] = sickConfig.CountryCode
  26109. data["sick_name"] = sickConfig.ClassName
  26110. data["begin_time"] = begin_time
  26111. data["dept"] = strconv.FormatInt(department.ID, 10)
  26112. data["config"] = config
  26113. //data["url"] = miConfig.Url
  26114. //data["ak"] = miConfig.AccessKey
  26115. data["cainfo"] = miConfig.Cainfo
  26116. fmt.Println(data)
  26117. bytesData, _ := json.Marshal(data)
  26118. var req *http.Request
  26119. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  26120. resp, _ := client.Do(req)
  26121. defer resp.Body.Close()
  26122. body, ioErr := ioutil.ReadAll(resp.Body)
  26123. if ioErr != nil {
  26124. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26126. return
  26127. }
  26128. var respJSON map[string]interface{}
  26129. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26132. return
  26133. }
  26134. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  26135. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  26136. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  26137. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26138. userJSONBytes, _ := json.Marshal(respJSON)
  26139. fmt.Println("log")
  26140. fmt.Println(string(userJSONBytes))
  26141. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  26142. utils.ErrorLog("解析失败:%v", err)
  26143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26144. return
  26145. }
  26146. res2.InfRefmsgid = resSix10265.InfRefmsgid
  26147. res2.Output = resSix10265.Output
  26148. res2.ErrMsg = resSix10265.ErrMsg
  26149. res2.Cainfo = resSix10265.Cainfo
  26150. res2.WarnMsg = resSix10265.WarnMsg
  26151. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  26152. res2.Infcode = infocode
  26153. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26154. 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)
  26155. saveLog(result, requestLog, "2203", "上传就诊信息")
  26156. var respJSON2 map[string]interface{}
  26157. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26160. return
  26161. }
  26162. userJSONBytes2, _ := json.Marshal(respJSON2)
  26163. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26164. utils.ErrorLog("解析失败:%v", err)
  26165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26166. return
  26167. }
  26168. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26169. var result string
  26170. var requestLog string
  26171. 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, "")
  26172. saveLog(result, requestLog, "2203", "上传就诊信息")
  26173. var respJSON2 map[string]interface{}
  26174. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26177. return
  26178. }
  26179. userJSONBytes2, _ := json.Marshal(respJSON2)
  26180. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26181. utils.ErrorLog("解析失败:%v", err)
  26182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26183. return
  26184. }
  26185. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26186. data := make(map[string]interface{})
  26187. client := &http.Client{}
  26188. data["psn_no"] = his.PsnNo
  26189. data["mdtrt_id"] = his.Number
  26190. data["operator"] = roles.UserName
  26191. data["department"] = department.Name
  26192. data["org_name"] = miConfig.OrgName
  26193. var med_type string
  26194. if his.Insutype == "390" {
  26195. if reg_type == 992102 {
  26196. med_type = "992102"
  26197. data["sick_code"] = "ZDZ940"
  26198. data["sick_name"] = "慢性肾衰竭"
  26199. }
  26200. if reg_type == 140104 {
  26201. med_type = "140104"
  26202. data["sick_code"] = sickConfig.CountryCode
  26203. data["sick_name"] = sickConfig.ClassName
  26204. }
  26205. if reg_type == 14 {
  26206. med_type = "140104"
  26207. data["sick_code"] = sickConfig.CountryCode
  26208. data["sick_name"] = sickConfig.ClassName
  26209. }
  26210. } else if his.Insutype == "310" {
  26211. if reg_type == 992102 {
  26212. med_type = "992102"
  26213. data["sick_code"] = "ZDZ940"
  26214. data["sick_name"] = "慢性肾衰竭"
  26215. }
  26216. if reg_type == 140104 {
  26217. med_type = "140104"
  26218. data["sick_code"] = sickConfig.CountryCode
  26219. data["sick_name"] = sickConfig.ClassName
  26220. }
  26221. if reg_type == 14 {
  26222. med_type = "14"
  26223. data["sick_code"] = sickConfig.CountryCode
  26224. data["sick_name"] = sickConfig.ClassName
  26225. }
  26226. }
  26227. data["med_type"] = med_type
  26228. data["doctor_number"] = doctor_info.DoctorNumber
  26229. data["doctor_name"] = doctor_info.UserName
  26230. data["fixmedins_code"] = miConfig.Code
  26231. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26232. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26233. data["secret_key"] = miConfig.SecretKey
  26234. data["begin_time"] = begin_time
  26235. data["dept"] = strconv.FormatInt(department.ID, 10)
  26236. data["config"] = config
  26237. data["url"] = miConfig.Url
  26238. data["ak"] = miConfig.AccessKey
  26239. data["cainfo"] = miConfig.Cainfo
  26240. bytesData, _ := json.Marshal(data)
  26241. var req *http.Request
  26242. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  26243. resp, _ := client.Do(req)
  26244. defer resp.Body.Close()
  26245. body, ioErr := ioutil.ReadAll(resp.Body)
  26246. if ioErr != nil {
  26247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26249. return
  26250. }
  26251. var respJSON map[string]interface{}
  26252. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26255. return
  26256. }
  26257. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26258. if status == "0" {
  26259. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26260. c.ServeSuccessJSON(map[string]interface{}{
  26261. "failed_code": -10,
  26262. "msg": err_msg,
  26263. })
  26264. return
  26265. }
  26266. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26267. userJSONBytes, _ := json.Marshal(respJSON)
  26268. fmt.Println("log")
  26269. fmt.Println(string(userJSONBytes))
  26270. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26271. utils.ErrorLog("解析失败:%v", err)
  26272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26273. return
  26274. }
  26275. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26276. var result string
  26277. var requestLog string
  26278. 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, "")
  26279. saveLog(result, requestLog, "2203", "上传就诊信息")
  26280. var respJSON2 map[string]interface{}
  26281. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26284. return
  26285. }
  26286. userJSONBytes2, _ := json.Marshal(respJSON2)
  26287. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26288. utils.ErrorLog("解析失败:%v", err)
  26289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26290. return
  26291. }
  26292. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26293. data := make(map[string]interface{})
  26294. client := &http.Client{}
  26295. data["psn_no"] = his.PsnNo
  26296. data["mdtrt_id"] = his.Number
  26297. data["doctor"] = roles.UserName
  26298. data["department"] = department.Name
  26299. data["org_name"] = miConfig.OrgName
  26300. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26301. data["doctor_id"] = doctor_info.DoctorNumber
  26302. data["fixmedins_code"] = miConfig.Code
  26303. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26304. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26305. data["secret_key"] = miConfig.SecretKey
  26306. data["sick_code"] = sickConfig.CountryCode
  26307. data["sick_name"] = sickConfig.ClassName
  26308. data["begin_time"] = begin_time
  26309. data["new_doctor_name"] = doctor_info.UserName
  26310. data["dept"] = strconv.FormatInt(department.ID, 10)
  26311. data["config"] = config
  26312. bytesData, _ := json.Marshal(data)
  26313. var req *http.Request
  26314. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  26315. resp, _ := client.Do(req)
  26316. defer resp.Body.Close()
  26317. body, ioErr := ioutil.ReadAll(resp.Body)
  26318. if ioErr != nil {
  26319. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26321. return
  26322. }
  26323. var respJSON map[string]interface{}
  26324. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26327. return
  26328. }
  26329. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26330. userJSONBytes, _ := json.Marshal(respJSON)
  26331. fmt.Println("log")
  26332. fmt.Println(string(userJSONBytes))
  26333. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26334. utils.ErrorLog("解析失败:%v", err)
  26335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26336. return
  26337. }
  26338. } else {
  26339. var result string
  26340. var requestLog string
  26341. if miConfig.MdtrtareaAdmvs == "440781" { //
  26342. 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)
  26343. } else {
  26344. if miConfig.Code == "H15049901371" {
  26345. //赤峰地区国家医保医疗类别
  26346. //职工透析:医疗类别选特殊情况门诊990502
  26347. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26348. var med_type string
  26349. if his.Insutype == "390" {
  26350. if reg_type == 14 {
  26351. med_type = "9933"
  26352. } else if reg_type == 11 {
  26353. med_type = "11"
  26354. }
  26355. } else if his.Insutype == "310" {
  26356. if reg_type == 14 {
  26357. med_type = "990502"
  26358. } else if reg_type == 11 {
  26359. med_type = "11"
  26360. }
  26361. }
  26362. 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)
  26363. } else {
  26364. 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)
  26365. }
  26366. saveLog(result, requestLog, "2203", "上传就诊信息")
  26367. var respJSON2 map[string]interface{}
  26368. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26371. return
  26372. }
  26373. userJSONBytes2, _ := json.Marshal(respJSON2)
  26374. if miConfig.Code == "H15049901371" {
  26375. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  26376. utils.ErrorLog("解析失败:%v", err)
  26377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26378. return
  26379. }
  26380. res2.InfRefmsgid = resSix10265.InfRefmsgid
  26381. res2.Output = resSix10265.Output
  26382. res2.ErrMsg = resSix10265.ErrMsg
  26383. res2.Cainfo = resSix10265.Cainfo
  26384. res2.WarnMsg = resSix10265.WarnMsg
  26385. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  26386. res2.Infcode = infocode
  26387. } else {
  26388. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26389. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  26390. utils.ErrorLog("解析失败:%v", err)
  26391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26392. return
  26393. }
  26394. res2.Infcode = res3.Infcode
  26395. } else {
  26396. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26397. utils.ErrorLog("解析失败:%v", err)
  26398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26399. return
  26400. }
  26401. }
  26402. }
  26403. }
  26404. }
  26405. if res2.Infcode == -1 {
  26406. adminUser := c.GetAdminUserInfo()
  26407. errlog := &models.HisOrderError{
  26408. UserOrgId: adminUser.CurrentOrgId,
  26409. Ctime: time.Now().Unix(),
  26410. Mtime: time.Now().Unix(),
  26411. ErrMsg: res2.ErrMsg,
  26412. Status: 1,
  26413. PatientId: id,
  26414. RecordTime: recordDateTime,
  26415. Stage: 3,
  26416. }
  26417. service.CreateErrMsgLog(errlog)
  26418. c.ServeSuccessJSON(map[string]interface{}{
  26419. "failed_code": -10,
  26420. "msg": res2.ErrMsg,
  26421. })
  26422. return
  26423. }
  26424. if res2.Infcode != 0 {
  26425. adminUser := c.GetAdminUserInfo()
  26426. errlog := &models.HisOrderError{
  26427. UserOrgId: adminUser.CurrentOrgId,
  26428. Ctime: time.Now().Unix(),
  26429. Mtime: time.Now().Unix(),
  26430. ErrMsg: res2.ErrMsg,
  26431. Status: 1,
  26432. PatientId: id,
  26433. RecordTime: recordDateTime,
  26434. Stage: 3,
  26435. }
  26436. service.CreateErrMsgLog(errlog)
  26437. c.ServeSuccessJSON(map[string]interface{}{
  26438. "failed_code": -10,
  26439. "msg": res2.ErrMsg,
  26440. })
  26441. return
  26442. } else {
  26443. his.Diagnosis = diagnosis_id
  26444. his.SickType = sickConfig.ID
  26445. his.PType = fmt.Sprintf("%d", reg_type)
  26446. service.UpdateHisPatientThree(&his)
  26447. data := make(map[string]interface{})
  26448. if settle_accounts_type == 1 { //日结
  26449. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  26450. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  26451. } else {
  26452. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  26453. }
  26454. data["pre"] = prescriptions
  26455. } else { //月结
  26456. start_time_str := c.GetString("start_time")
  26457. end_time_str := c.GetString("end_time")
  26458. timeLayout := "2006-01-02"
  26459. loc, _ := time.LoadLocation("Local")
  26460. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  26461. if err != nil {
  26462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26463. return
  26464. }
  26465. recordStartTime := theStartTime.Unix()
  26466. start_time = recordStartTime
  26467. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  26468. if err != nil {
  26469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26470. return
  26471. }
  26472. recordEndTime := theEndTime.Unix()
  26473. end_time = recordEndTime
  26474. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  26475. data["pre"] = prescriptions
  26476. }
  26477. client := &http.Client{}
  26478. data["psn_no"] = his.PsnNo
  26479. data["mdtrt_id"] = his.Number
  26480. data["chrg_bchno"] = new_chrg_bchno
  26481. data["org_name"] = miConfig.OrgName
  26482. data["doctor"] = doctor_info.UserName
  26483. data["doctor_id"] = doctor_info.DoctorNumber
  26484. data["dept"] = department.Name
  26485. data["fixmedins_code"] = miConfig.Code
  26486. data["opter"] = roles.UserName
  26487. data["dept_code"] = department.Number
  26488. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26489. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26490. data["secret_key"] = miConfig.SecretKey
  26491. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  26492. data["url"] = miConfig.Url
  26493. data["ak"] = miConfig.AccessKey
  26494. data["new_doctor_name"] = patientPrescription.Doctor
  26495. if his.Insutype == "390" {
  26496. if reg_type == 992102 {
  26497. data["diag_code"] = "ZDZ940"
  26498. }
  26499. if reg_type == 140104 {
  26500. data["diag_code"] = sickConfig.CountryCode
  26501. }
  26502. if reg_type == 14 {
  26503. data["diag_code"] = sickConfig.CountryCode
  26504. }
  26505. } else if his.Insutype == "310" {
  26506. if reg_type == 992102 {
  26507. data["diag_code"] = "ZDZ940"
  26508. }
  26509. if reg_type == 14 {
  26510. data["diag_code"] = sickConfig.CountryCode
  26511. }
  26512. }
  26513. data["cainfo"] = miConfig.Cainfo
  26514. data["opter"] = roles.UserName
  26515. var ids []int64
  26516. for _, item := range prescriptions {
  26517. ids = append(ids, item.ID)
  26518. }
  26519. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26520. if config.IsOpen == 1 { //对接了医保,走医保流程
  26521. var res ResultFour
  26522. var resFour10265 ResultFour10265
  26523. if miConfig.MdtrtareaAdmvs == "421300" {
  26524. bytesData, _ := json.Marshal(data)
  26525. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26526. resp, _ := client.Do(req)
  26527. defer resp.Body.Close()
  26528. body, ioErr := ioutil.ReadAll(resp.Body)
  26529. if ioErr != nil {
  26530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26532. return
  26533. }
  26534. var respJSON map[string]interface{}
  26535. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26538. return
  26539. }
  26540. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26541. userJSONBytes, _ := json.Marshal(respJSON)
  26542. fmt.Println("log")
  26543. fmt.Println(string(userJSONBytes))
  26544. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26545. utils.ErrorLog("解析失败:%v", err)
  26546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26547. return
  26548. }
  26549. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26550. bytesData, _ := json.Marshal(data)
  26551. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26552. resp, _ := client.Do(req)
  26553. defer resp.Body.Close()
  26554. body, ioErr := ioutil.ReadAll(resp.Body)
  26555. if ioErr != nil {
  26556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26558. return
  26559. }
  26560. var respJSON map[string]interface{}
  26561. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26564. return
  26565. }
  26566. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26567. userJSONBytes, _ := json.Marshal(respJSON)
  26568. fmt.Println("log")
  26569. fmt.Println(string(userJSONBytes))
  26570. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26571. utils.ErrorLog("解析失败:%v", err)
  26572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26573. return
  26574. }
  26575. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26576. bytesData, _ := json.Marshal(data)
  26577. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26578. resp, _ := client.Do(req)
  26579. defer resp.Body.Close()
  26580. body, ioErr := ioutil.ReadAll(resp.Body)
  26581. if ioErr != nil {
  26582. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26584. return
  26585. }
  26586. var respJSON map[string]interface{}
  26587. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26590. return
  26591. }
  26592. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26593. userJSONBytes, _ := json.Marshal(respJSON)
  26594. fmt.Println("log")
  26595. fmt.Println(string(userJSONBytes))
  26596. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26597. utils.ErrorLog("解析失败:%v", err)
  26598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26599. return
  26600. }
  26601. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26602. bytesData, _ := json.Marshal(data)
  26603. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26604. resp, _ := client.Do(req)
  26605. defer resp.Body.Close()
  26606. body, ioErr := ioutil.ReadAll(resp.Body)
  26607. if ioErr != nil {
  26608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26610. return
  26611. }
  26612. var respJSON map[string]interface{}
  26613. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26616. return
  26617. }
  26618. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26619. userJSONBytes, _ := json.Marshal(respJSON)
  26620. fmt.Println("log")
  26621. fmt.Println(string(userJSONBytes))
  26622. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26623. utils.ErrorLog("解析失败:%v", err)
  26624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26625. return
  26626. }
  26627. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26628. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26629. if result3101.Infcode == "0" {
  26630. if len(result3101.Output.Result) > 0 {
  26631. var errMsgs []string
  26632. for _, item := range result3101.Output.Result {
  26633. errMsgs = append(errMsgs, item.VolaCont)
  26634. }
  26635. c.ServeSuccessJSON(map[string]interface{}{
  26636. "failed_code": -10,
  26637. "msg": errMsgs,
  26638. })
  26639. return
  26640. } else {
  26641. if miConfig.MdtrtareaAdmvs == "320921" {
  26642. data["doctor_id"] = "D320923012139"
  26643. } else {
  26644. data["doctor_id"] = "D371621008686"
  26645. }
  26646. bytesData, _ := json.Marshal(data)
  26647. var req *http.Request
  26648. if miConfig.MdtrtareaAdmvs == "320921" {
  26649. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26650. } else {
  26651. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26652. }
  26653. resp, _ := client.Do(req)
  26654. defer resp.Body.Close()
  26655. body, ioErr := ioutil.ReadAll(resp.Body)
  26656. if ioErr != nil {
  26657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26659. return
  26660. }
  26661. var respJSON map[string]interface{}
  26662. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26665. return
  26666. }
  26667. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26668. userJSONBytes, _ := json.Marshal(respJSON)
  26669. fmt.Println("log")
  26670. fmt.Println(string(userJSONBytes))
  26671. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26672. utils.ErrorLog("解析失败:%v", err)
  26673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26674. return
  26675. }
  26676. res.InfRefmsgid = resFour10265.InfRefmsgid
  26677. res.Output = resFour10265.Output
  26678. res.ErrMsg = resFour10265.ErrMsg
  26679. res.Cainfo = resFour10265.Cainfo
  26680. res.WarnMsg = resFour10265.WarnMsg
  26681. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26682. res.Infcode = infocode
  26683. }
  26684. }
  26685. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26686. var pagesize int = 5
  26687. var start int = 1
  26688. var stop int
  26689. var pagecount int
  26690. var curpage int
  26691. data["doctor_id"] = doctor_info.DoctorNumber
  26692. var res2 ResultFour
  26693. //var result res.
  26694. //总页数,向上取整,注意除之前要先转换类型为float64
  26695. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  26696. for curpage = 1; curpage <= pagecount; curpage++ {
  26697. if curpage == 1 {
  26698. start = 1
  26699. } else {
  26700. start = (curpage-1)*pagesize + 1
  26701. }
  26702. stop = curpage * pagesize
  26703. if stop > len(prescriptions) {
  26704. stop = len(prescriptions)
  26705. }
  26706. //var requestLog string
  26707. data["pre"] = prescriptions[start-1 : stop]
  26708. fmt.Println(data["pre"])
  26709. bytesData, _ := json.Marshal(data)
  26710. var req *http.Request
  26711. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  26712. resp, _ := client.Do(req)
  26713. defer resp.Body.Close()
  26714. body, ioErr := ioutil.ReadAll(resp.Body)
  26715. if ioErr != nil {
  26716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26718. return
  26719. }
  26720. var respJSON map[string]interface{}
  26721. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26724. return
  26725. }
  26726. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26727. userJSONBytes, _ := json.Marshal(respJSON)
  26728. fmt.Println("log")
  26729. fmt.Println(string(userJSONBytes))
  26730. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26731. utils.ErrorLog("解析失败:%v", err)
  26732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26733. return
  26734. }
  26735. res.InfRefmsgid = resFour10265.InfRefmsgid
  26736. res.Output = resFour10265.Output
  26737. res.ErrMsg = resFour10265.ErrMsg
  26738. res.Cainfo = resFour10265.Cainfo
  26739. res.WarnMsg = resFour10265.WarnMsg
  26740. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26741. res.Infcode = infocode
  26742. if infocode == 0 {
  26743. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  26744. } else {
  26745. isSuccess = false
  26746. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  26747. res.Infcode = -1
  26748. res.ErrMsg = resFour10265.ErrMsg
  26749. errlog := &models.HisOrderError{
  26750. UserOrgId: adminUser.CurrentOrgId,
  26751. Ctime: time.Now().Unix(),
  26752. Mtime: time.Now().Unix(),
  26753. Number: chrg_bchno,
  26754. ErrMsg: "",
  26755. Status: 1,
  26756. PatientId: id,
  26757. RecordTime: recordDateTime,
  26758. Stage: 4,
  26759. }
  26760. service.CreateErrMsgLog(errlog)
  26761. }
  26762. }
  26763. if isSuccess {
  26764. res.Infcode = 0
  26765. res.Output.Result = res2.Output.Result
  26766. } else {
  26767. order := &models.HisOrder{
  26768. UserOrgId: adminUser.CurrentOrgId,
  26769. HisPatientId: his.ID,
  26770. PatientId: his.PatientId,
  26771. SettleAccountsDate: recordDateTime,
  26772. Ctime: time.Now().Unix(),
  26773. Mtime: time.Now().Unix(),
  26774. MdtrtId: his.Number,
  26775. PsnNo: his.PsnNo,
  26776. MedType: strconv.FormatInt(reg_type, 10),
  26777. Status: 1,
  26778. Number: chrg_bchno,
  26779. Infcode: res.Infcode,
  26780. WarnMsg: res.WarnMsg,
  26781. Cainfo: res.Cainfo,
  26782. ErrMsg: res.ErrMsg,
  26783. RespondTime: res.RefmsgTime,
  26784. InfRefmsgid: res.InfRefmsgid,
  26785. OrderStatus: 1,
  26786. IsMedicineInsurance: 1,
  26787. SettleType: settle_accounts_type,
  26788. SettleStartTime: start_time,
  26789. SettleEndTime: end_time,
  26790. Creator: roles.AdminUserId,
  26791. Modify: roles.AdminUserId,
  26792. PType: 2,
  26793. Diagnosis: diagnosis_id,
  26794. }
  26795. err = service.CreateOrder(order)
  26796. if err != nil {
  26797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  26798. return
  26799. }
  26800. c.ServeSuccessJSON(map[string]interface{}{
  26801. "failed_code": -10,
  26802. "msg": res2.ErrMsg,
  26803. })
  26804. return
  26805. }
  26806. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26807. 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)
  26808. var dat map[string]interface{}
  26809. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26810. fmt.Println(dat)
  26811. } else {
  26812. fmt.Println(err)
  26813. }
  26814. saveLog(result, request_log, "2204", "上传费用明细")
  26815. userJSONBytes, _ := json.Marshal(dat)
  26816. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26817. utils.ErrorLog("解析失败:%v", err)
  26818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26819. return
  26820. }
  26821. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26822. 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, "", "")
  26823. var dat map[string]interface{}
  26824. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26825. fmt.Println(dat)
  26826. } else {
  26827. fmt.Println(err)
  26828. }
  26829. saveLog(result, request_log, "2204", "上传费用明细")
  26830. userJSONBytes, _ := json.Marshal(dat)
  26831. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26832. utils.ErrorLog("解析失败:%v", err)
  26833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26834. return
  26835. }
  26836. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26837. bytesData, _ := json.Marshal(data)
  26838. var req *http.Request
  26839. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  26840. resp, _ := client.Do(req)
  26841. defer resp.Body.Close()
  26842. body, ioErr := ioutil.ReadAll(resp.Body)
  26843. if ioErr != nil {
  26844. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26846. return
  26847. }
  26848. var respJSON map[string]interface{}
  26849. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26852. return
  26853. }
  26854. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26855. if status == "0" {
  26856. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26857. c.ServeSuccessJSON(map[string]interface{}{
  26858. "failed_code": -10,
  26859. "msg": err_msg,
  26860. })
  26861. return
  26862. }
  26863. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26864. userJSONBytes, _ := json.Marshal(respJSON)
  26865. fmt.Println("log")
  26866. fmt.Println(string(userJSONBytes))
  26867. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26868. utils.ErrorLog("解析失败:%v", err)
  26869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26870. return
  26871. }
  26872. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26873. 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, "", "")
  26874. var dat map[string]interface{}
  26875. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26876. fmt.Println(dat)
  26877. } else {
  26878. fmt.Println(err)
  26879. }
  26880. saveLog(result, request_log, "2204", "上传费用明细")
  26881. userJSONBytes, _ := json.Marshal(dat)
  26882. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26883. utils.ErrorLog("解析失败:%v", err)
  26884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26885. return
  26886. }
  26887. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26888. bytesData, _ := json.Marshal(data)
  26889. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  26890. resp, _ := client.Do(req)
  26891. defer resp.Body.Close()
  26892. body, ioErr := ioutil.ReadAll(resp.Body)
  26893. if ioErr != nil {
  26894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26896. return
  26897. }
  26898. var respJSON map[string]interface{}
  26899. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26902. return
  26903. }
  26904. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26905. userJSONBytes, _ := json.Marshal(respJSON)
  26906. fmt.Println("log")
  26907. fmt.Println(string(userJSONBytes))
  26908. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26909. utils.ErrorLog("解析失败:%v", err)
  26910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26911. return
  26912. }
  26913. } else {
  26914. if miConfig.MdtrtareaAdmvs == "441202" {
  26915. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26916. if result3101.Infcode == 0 {
  26917. if len(result3101.Output.Result) > 0 {
  26918. var errMsgs []string
  26919. for _, item := range result3101.Output.Result {
  26920. errMsgs = append(errMsgs, item.VolaCont)
  26921. }
  26922. c.ServeSuccessJSON(map[string]interface{}{
  26923. "failed_code": -10,
  26924. "msg": errMsgs,
  26925. })
  26926. return
  26927. } else {
  26928. 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)
  26929. var dat map[string]interface{}
  26930. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26931. fmt.Println(dat)
  26932. } else {
  26933. fmt.Println(err)
  26934. }
  26935. saveLog(result, request_log, "2204", "上传费用明细")
  26936. userJSONBytes, _ := json.Marshal(dat)
  26937. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26938. utils.ErrorLog("解析失败:%v", err)
  26939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26940. return
  26941. }
  26942. }
  26943. } else {
  26944. c.ServeSuccessJSON(map[string]interface{}{
  26945. "failed_code": -10,
  26946. "msg": result3101.ErrMsg,
  26947. })
  26948. return
  26949. }
  26950. } else if miConfig.MdtrtareaAdmvs == "440205" {
  26951. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26952. if result3101.Infcode == 0 {
  26953. if len(result3101.Output.Result) > 0 {
  26954. var errMsgs []string
  26955. for _, item := range result3101.Output.Result {
  26956. errMsgs = append(errMsgs, item.VolaCont)
  26957. }
  26958. c.ServeSuccessJSON(map[string]interface{}{
  26959. "failed_code": -10,
  26960. "msg": errMsgs,
  26961. })
  26962. return
  26963. } else {
  26964. 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)
  26965. var dat map[string]interface{}
  26966. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26967. fmt.Println(dat)
  26968. } else {
  26969. fmt.Println(err)
  26970. }
  26971. saveLog(result, request_log, "2204", "上传费用明细")
  26972. userJSONBytes, _ := json.Marshal(dat)
  26973. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26974. utils.ErrorLog("解析失败:%v", err)
  26975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26976. return
  26977. }
  26978. }
  26979. } else {
  26980. c.ServeSuccessJSON(map[string]interface{}{
  26981. "failed_code": -10,
  26982. "msg": result3101.ErrMsg,
  26983. })
  26984. return
  26985. }
  26986. } else {
  26987. if miConfig.Code == "H15049901371" {
  26988. 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)
  26989. var dat map[string]interface{}
  26990. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26991. fmt.Println(dat)
  26992. } else {
  26993. fmt.Println(err)
  26994. }
  26995. saveLog(result, request_log, "2204", "上传费用明细")
  26996. userJSONBytes, _ := json.Marshal(dat)
  26997. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26998. utils.ErrorLog("解析失败:%v", err)
  26999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27000. return
  27001. }
  27002. res.InfRefmsgid = resFour10265.InfRefmsgid
  27003. res.Output = resFour10265.Output
  27004. res.ErrMsg = resFour10265.ErrMsg
  27005. res.Cainfo = resFour10265.Cainfo
  27006. res.WarnMsg = resFour10265.WarnMsg
  27007. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27008. res.Infcode = infocode
  27009. } else {
  27010. 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)
  27011. var dat map[string]interface{}
  27012. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27013. fmt.Println(dat)
  27014. } else {
  27015. fmt.Println(err)
  27016. }
  27017. saveLog(result, request_log, "2204", "上传费用明细")
  27018. userJSONBytes, _ := json.Marshal(dat)
  27019. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27020. utils.ErrorLog("解析失败:%v", err)
  27021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27022. return
  27023. }
  27024. }
  27025. }
  27026. }
  27027. var total_two float64
  27028. if res.Infcode == -1 {
  27029. errlog := &models.HisOrderError{
  27030. UserOrgId: adminUser.CurrentOrgId,
  27031. Ctime: time.Now().Unix(),
  27032. Mtime: time.Now().Unix(),
  27033. Number: chrg_bchno,
  27034. ErrMsg: res.ErrMsg,
  27035. Status: 1,
  27036. PatientId: id,
  27037. RecordTime: recordDateTime,
  27038. Stage: 4,
  27039. }
  27040. service.CreateErrMsgLog(errlog)
  27041. c.ServeSuccessJSON(map[string]interface{}{
  27042. "failed_code": -10,
  27043. "msg": res.ErrMsg,
  27044. })
  27045. return
  27046. }
  27047. if res.Infcode == 0 {
  27048. order := &models.HisOrder{
  27049. UserOrgId: adminUser.CurrentOrgId,
  27050. HisPatientId: his.ID,
  27051. PatientId: his.PatientId,
  27052. SettleAccountsDate: recordDateTime,
  27053. Ctime: time.Now().Unix(),
  27054. Mtime: time.Now().Unix(),
  27055. MdtrtId: his.Number,
  27056. PsnNo: his.PsnNo,
  27057. MedType: strconv.FormatInt(reg_type, 10),
  27058. Status: 1,
  27059. Number: chrg_bchno,
  27060. Infcode: res.Infcode,
  27061. WarnMsg: res.WarnMsg,
  27062. Cainfo: res.Cainfo,
  27063. ErrMsg: res.ErrMsg,
  27064. RespondTime: res.RefmsgTime,
  27065. InfRefmsgid: res.InfRefmsgid,
  27066. OrderStatus: 1,
  27067. IsMedicineInsurance: 1,
  27068. SettleType: settle_accounts_type,
  27069. SettleStartTime: start_time,
  27070. SettleEndTime: end_time,
  27071. Creator: roles.AdminUserId,
  27072. Modify: roles.AdminUserId,
  27073. PType: 2,
  27074. Diagnosis: diagnosis_id,
  27075. }
  27076. err = service.CreateOrder(order)
  27077. if err != nil {
  27078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  27079. return
  27080. }
  27081. for _, item := range res.Output.Result {
  27082. temp := strings.Split(item.FeedetlSn, "-")
  27083. var advice_id int64 = 0
  27084. var project_id int64 = 0
  27085. var types int64 = 0
  27086. id, _ := strconv.ParseInt(temp[2], 10, 64)
  27087. types, _ = strconv.ParseInt(temp[1], 10, 64)
  27088. if temp[1] == "1" {
  27089. advice_id = id
  27090. project_id = 0
  27091. } else if temp[1] == "2" {
  27092. advice_id = 0
  27093. project_id = id
  27094. }
  27095. total_two = total_two + item.DetItemFeeSumamt
  27096. info := &models.HisOrderInfo{
  27097. OrderNumber: order.Number,
  27098. FeedetlSn: item.FeedetlSn,
  27099. UploadDate: time.Now().Unix(),
  27100. AdviceId: advice_id,
  27101. DetItemFeeSumamt: item.DetItemFeeSumamt,
  27102. Cnt: item.Cnt,
  27103. Pric: float64(item.Pric),
  27104. PatientId: his.PatientId,
  27105. PricUplmtAmt: item.PricUplmtAmt,
  27106. SelfpayProp: item.SelfpayProp,
  27107. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  27108. OverlmtAmt: item.OverlmtAmt,
  27109. PreselfpayAmt: item.PreselfpayAmt,
  27110. BasMednFlag: item.BasMednFlag,
  27111. MedChrgitmType: item.MedChrgitmType,
  27112. HiNegoDrugFlag: item.HiNegoDrugFlag,
  27113. Status: 1,
  27114. Memo: item.Memo,
  27115. Mtime: time.Now().Unix(),
  27116. InscpScpAmt: item.InscpScpAmt,
  27117. DrtReimFlag: item.DrtReimFlag,
  27118. Ctime: time.Now().Unix(),
  27119. ListSpItemFlag: item.ListSpItemFlag,
  27120. ChldMedcFlag: item.ChldMedcFlag,
  27121. LmtUsedFlag: item.LmtUsedFlag,
  27122. ChrgitmLv: item.ChrgitmLv,
  27123. UserOrgId: adminUser.CurrentOrgId,
  27124. HisPatientId: his.ID,
  27125. OrderId: order.ID,
  27126. ProjectId: project_id,
  27127. Type: types,
  27128. }
  27129. service.CreateOrderInfo(info)
  27130. }
  27131. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  27132. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  27133. var total float64
  27134. for _, item := range prescriptions {
  27135. if item.Type == 1 { //药品
  27136. for _, subItem := range item.HisDoctorAdviceInfo {
  27137. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27138. total_one := price * subItem.PrescribingNumber
  27139. fmt.Println("subItem")
  27140. fmt.Println(subItem.Price)
  27141. fmt.Println("price")
  27142. fmt.Println(price)
  27143. fmt.Println("total_one")
  27144. fmt.Println(total_one)
  27145. total = total + total_one
  27146. fmt.Println(total)
  27147. }
  27148. }
  27149. if item.Type == 2 { //项目
  27150. for _, subItem := range item.HisPrescriptionProject {
  27151. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  27152. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27153. total_one := price * cnt
  27154. total = total + total_one
  27155. }
  27156. }
  27157. }
  27158. allTotal := fmt.Sprintf("%.2f", total)
  27159. if res.Infcode == 0 {
  27160. var rf []*ResultFive
  27161. json.Unmarshal([]byte(his.Iinfo), &rf)
  27162. chrg_bchno := chrg_bchno
  27163. cert_no := his.Certno
  27164. var insutypes []string
  27165. var insutype string
  27166. var is390 int = 0
  27167. var is310 int = 0
  27168. for _, item := range rf {
  27169. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27170. insutypes = append(insutypes, item.Insutype)
  27171. }
  27172. }
  27173. if len(insutypes) == 1 {
  27174. insutype = insutypes[0]
  27175. } else {
  27176. for _, i := range insutypes {
  27177. if i == "390" {
  27178. is390 = 1
  27179. }
  27180. if i == "310" {
  27181. is310 = 1
  27182. }
  27183. }
  27184. }
  27185. if is390 == 1 {
  27186. insutype = "390"
  27187. }
  27188. if is310 == 1 {
  27189. insutype = "310"
  27190. }
  27191. if len(insutypes) == 0 {
  27192. insutype = "390"
  27193. }
  27194. if len(insutypes) == 2 {
  27195. insutype = strconv.FormatInt(his.SocialType, 10)
  27196. }
  27197. //insutype = "390"
  27198. if his.IdCardType == 1 {
  27199. cert_no = his.MedicalInsuranceNumber
  27200. } else {
  27201. cert_no = his.Certno
  27202. }
  27203. var res ResultSeven
  27204. var ahres ResultSevenAH
  27205. var resSeven10265 ResultSeven10265
  27206. var resSeven10265Two ResultSeven10265Two
  27207. var gzresSeven10265Two GZResultSeven10265Two
  27208. if miConfig.MdtrtareaAdmvs == "421300" {
  27209. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  27210. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27211. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27212. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27213. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27214. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27215. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27216. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27217. resp, requestErr := http.Get(api)
  27218. if requestErr != nil {
  27219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27220. return
  27221. }
  27222. body, ioErr := ioutil.ReadAll(resp.Body)
  27223. if ioErr != nil {
  27224. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27226. return
  27227. }
  27228. var respJSON map[string]interface{}
  27229. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27232. return
  27233. }
  27234. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27235. result, _ := json.Marshal(respJSON)
  27236. fmt.Println("log")
  27237. fmt.Println(string(result))
  27238. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27239. utils.ErrorLog("解析失败:%v", err)
  27240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27241. return
  27242. }
  27243. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27244. if reg_type == 11 && his.Insutype == "390" {
  27245. reg_type = 110104
  27246. }
  27247. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27248. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27249. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27250. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27251. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27252. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27253. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27254. resp, requestErr := http.Get(api)
  27255. if requestErr != nil {
  27256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27257. return
  27258. }
  27259. body, ioErr := ioutil.ReadAll(resp.Body)
  27260. if ioErr != nil {
  27261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27263. return
  27264. }
  27265. var respJSON map[string]interface{}
  27266. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27269. return
  27270. }
  27271. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27272. result, _ := json.Marshal(respJSON)
  27273. fmt.Println("log")
  27274. fmt.Println(string(result))
  27275. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27276. utils.ErrorLog("解析失败:%v", err)
  27277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27278. return
  27279. }
  27280. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27281. if reg_type == 11 && his.Insutype == "390" {
  27282. reg_type = 110104
  27283. }
  27284. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27285. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27286. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27287. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27288. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27289. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27290. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27291. resp, requestErr := http.Get(api)
  27292. if requestErr != nil {
  27293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27294. return
  27295. }
  27296. body, ioErr := ioutil.ReadAll(resp.Body)
  27297. if ioErr != nil {
  27298. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27300. return
  27301. }
  27302. var respJSON map[string]interface{}
  27303. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27306. return
  27307. }
  27308. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27309. result, _ := json.Marshal(respJSON)
  27310. fmt.Println("log")
  27311. fmt.Println(string(result))
  27312. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27313. utils.ErrorLog("解析失败:%v", err)
  27314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27315. return
  27316. }
  27317. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27318. if reg_type == 11 && his.Insutype == "390" {
  27319. reg_type = 110104
  27320. }
  27321. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27322. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27323. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27324. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27325. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27326. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27327. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27328. resp, requestErr := http.Get(api)
  27329. if requestErr != nil {
  27330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27331. return
  27332. }
  27333. body, ioErr := ioutil.ReadAll(resp.Body)
  27334. if ioErr != nil {
  27335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27337. return
  27338. }
  27339. var respJSON map[string]interface{}
  27340. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27343. return
  27344. }
  27345. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27346. result, _ := json.Marshal(respJSON)
  27347. fmt.Println("log")
  27348. fmt.Println(string(result))
  27349. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27350. utils.ErrorLog("解析失败:%v", err)
  27351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27352. return
  27353. }
  27354. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27355. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  27356. if result3101.Infcode == "0" {
  27357. if len(result3101.Output.Result) > 0 {
  27358. var errMsgs []string
  27359. for _, item := range result3101.Output.Result {
  27360. errMsgs = append(errMsgs, item.VolaCont)
  27361. }
  27362. c.ServeSuccessJSON(map[string]interface{}{
  27363. "failed_code": -10,
  27364. "msg": errMsgs,
  27365. })
  27366. return
  27367. } else {
  27368. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27369. if his.IdCardType != 4 {
  27370. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27371. bas := strings.Split(psn_info.CardInfo, "|")
  27372. if his.IdCardType == 1 {
  27373. cert_no = bas[2]
  27374. } else {
  27375. cert_no = bas[1]
  27376. }
  27377. } else {
  27378. cert_no = his.Certno
  27379. }
  27380. //江苏地区国家医保医疗类别
  27381. //职工透析:医疗类别选特殊情况门诊9933
  27382. //居民血透门慢: 医疗类别选门诊慢病1402
  27383. //var med_type string
  27384. //if his.Insutype == "310" {
  27385. // if reg_type == 14 {
  27386. // med_type = "9933"
  27387. // } else if reg_type == 11 {
  27388. // med_type = "11"
  27389. //
  27390. // }
  27391. //} else if his.Insutype == "390" {
  27392. // if reg_type == 14 {
  27393. // med_type = "1402"
  27394. // } else if reg_type == 11 {
  27395. // med_type = "11"
  27396. // }
  27397. //}
  27398. var api string
  27399. if miConfig.MdtrtareaAdmvs == "320921" {
  27400. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27401. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27402. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27403. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27404. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27405. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27406. "&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
  27407. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27408. } else {
  27409. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27410. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27411. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27412. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27413. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27414. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27415. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27416. "&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
  27417. }
  27418. resp, requestErr := http.Get(api)
  27419. if requestErr != nil {
  27420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27421. return
  27422. }
  27423. body, ioErr := ioutil.ReadAll(resp.Body)
  27424. if ioErr != nil {
  27425. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27427. return
  27428. }
  27429. var respJSON map[string]interface{}
  27430. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27433. return
  27434. }
  27435. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27436. result, _ := json.Marshal(respJSON)
  27437. fmt.Println("log")
  27438. fmt.Println(string(result))
  27439. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  27440. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27441. utils.ErrorLog("解析失败:%v", err)
  27442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27443. return
  27444. }
  27445. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27446. res.Output = resSeven10265.Output
  27447. res.ErrMsg = resSeven10265.ErrMsg
  27448. res.Cainfo = resSeven10265.Cainfo
  27449. res.WarnMsg = resSeven10265.WarnMsg
  27450. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27451. res.Infcode = infocode
  27452. } else {
  27453. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  27454. utils.ErrorLog("解析失败:%v", err)
  27455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27456. return
  27457. }
  27458. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  27459. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  27460. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  27461. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  27462. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  27463. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  27464. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  27465. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  27466. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  27467. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  27468. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  27469. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  27470. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  27471. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  27472. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  27473. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27474. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  27475. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  27476. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  27477. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  27478. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  27479. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27480. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  27481. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  27482. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  27483. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  27484. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  27485. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  27486. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  27487. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  27488. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27489. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  27490. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  27491. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  27492. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27493. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27494. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27495. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27496. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  27497. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  27498. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  27499. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  27500. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  27501. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  27502. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  27503. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  27504. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  27505. res.ErrMsg = resSeven10265Two.ErrMsg
  27506. res.Cainfo = resSeven10265Two.Cainfo
  27507. res.WarnMsg = resSeven10265Two.WarnMsg
  27508. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27509. res.Infcode = infocode
  27510. }
  27511. }
  27512. }
  27513. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27514. psn_info, _ := service.GetPsnByPatientId(id)
  27515. var verify_number string
  27516. if psn_info.IdCardType == 4 {
  27517. verify_number = psn_info.VerifyNumber
  27518. } else if psn_info.IdCardType == 1 {
  27519. bas := strings.Split(psn_info.CardInfo, "|")
  27520. cardNumber := bas[2]
  27521. verify_number = cardNumber
  27522. } else {
  27523. psn_info.IdCardType = 2
  27524. verify_number = psn_info.Certno
  27525. }
  27526. var api string
  27527. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27528. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27529. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27530. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27531. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27532. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27533. "&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
  27534. resp, requestErr := http.Get(api)
  27535. if requestErr != nil {
  27536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27537. return
  27538. }
  27539. body, ioErr := ioutil.ReadAll(resp.Body)
  27540. if ioErr != nil {
  27541. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27543. return
  27544. }
  27545. var respJSON map[string]interface{}
  27546. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27549. return
  27550. }
  27551. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27552. result, _ := json.Marshal(respJSON)
  27553. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27554. utils.ErrorLog("解析失败:%v", err)
  27555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27556. return
  27557. }
  27558. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27559. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  27560. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  27561. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  27562. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  27563. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  27564. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  27565. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  27566. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  27567. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  27568. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  27569. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  27570. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  27571. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  27572. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  27573. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  27574. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  27575. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  27576. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  27577. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  27578. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27579. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  27580. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  27581. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  27582. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  27583. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  27584. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  27585. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  27586. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  27587. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  27588. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  27589. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  27590. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  27591. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  27592. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27593. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  27594. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  27595. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  27596. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  27597. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  27598. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  27599. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  27600. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  27601. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  27602. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  27603. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  27604. res.ErrMsg = resSeven10265.ErrMsg
  27605. res.Cainfo = resSeven10265.Cainfo
  27606. res.WarnMsg = resSeven10265.WarnMsg
  27607. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27608. res.Infcode = infocode
  27609. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27610. acct_used_flag := "1"
  27611. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  27612. var result string
  27613. var request_log string
  27614. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  27615. 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)
  27616. } else {
  27617. 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)
  27618. }
  27619. var dat map[string]interface{}
  27620. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27621. fmt.Println(dat)
  27622. } else {
  27623. fmt.Println(err)
  27624. }
  27625. saveLog(result, request_log, "2206", "预结算")
  27626. userJSONBytes, _ := json.Marshal(dat)
  27627. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27628. utils.ErrorLog("解析失败:%v", err)
  27629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27630. return
  27631. }
  27632. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27633. var result string
  27634. var request_log string
  27635. if his.IdCardType == 2 {
  27636. 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, "")
  27637. } else if his.IdCardType == 1 {
  27638. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27639. bas := strings.Split(psn_info.CardInfo, "|")
  27640. basNumber := bas[2]
  27641. card_sn := bas[3]
  27642. var rf []*ResultFive
  27643. json.Unmarshal([]byte(his.Iinfo), &rf)
  27644. var psn_type string
  27645. for _, item := range rf {
  27646. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27647. psn_type = item.PsnType
  27648. }
  27649. }
  27650. 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)
  27651. } else {
  27652. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27653. //bas := strings.Split(psn_info.CardInfo, "|")
  27654. //basNumber := bas[2]
  27655. //card_sn := bas[3]
  27656. var rf []*ResultFive
  27657. json.Unmarshal([]byte(his.Iinfo), &rf)
  27658. var psn_type string
  27659. for _, item := range rf {
  27660. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27661. psn_type = item.PsnType
  27662. }
  27663. }
  27664. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27665. 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)
  27666. }
  27667. var dat map[string]interface{}
  27668. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27669. fmt.Println(dat)
  27670. } else {
  27671. fmt.Println(err)
  27672. }
  27673. saveLog(result, request_log, "2206", "预结算")
  27674. userJSONBytes, _ := json.Marshal(dat)
  27675. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27676. utils.ErrorLog("解析失败:%v", err)
  27677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27678. return
  27679. }
  27680. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27681. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27682. if his.IdCardType == 4 {
  27683. psn_info.VerifyNumber = psn_info.VerifyNumber
  27684. cert_no = psn_info.Certno
  27685. } else if his.IdCardType == 2 {
  27686. cert_no = psn_info.Certno
  27687. psn_info.VerifyNumber = psn_info.Certno
  27688. } else {
  27689. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27690. bas := strings.Split(psn_info.CardInfo, "|")
  27691. if his.IdCardType == 1 {
  27692. cert_no = bas[2]
  27693. } else {
  27694. cert_no = bas[1]
  27695. }
  27696. }
  27697. var api string
  27698. var med_type string
  27699. if his.Insutype == "390" {
  27700. if reg_type == 992102 {
  27701. med_type = "992102"
  27702. }
  27703. if reg_type == 140104 {
  27704. med_type = "140104"
  27705. }
  27706. if reg_type == 14 {
  27707. med_type = "140104"
  27708. }
  27709. } else if his.Insutype == "310" {
  27710. if reg_type == 992102 {
  27711. med_type = "992102"
  27712. }
  27713. if reg_type == 14 {
  27714. med_type = "14"
  27715. }
  27716. }
  27717. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27718. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27719. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27720. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27721. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27722. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27723. "&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
  27724. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27725. resp, requestErr := http.Get(api)
  27726. if requestErr != nil {
  27727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27728. return
  27729. }
  27730. body, ioErr := ioutil.ReadAll(resp.Body)
  27731. if ioErr != nil {
  27732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27734. return
  27735. }
  27736. var respJSON map[string]interface{}
  27737. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27740. return
  27741. }
  27742. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27743. if status == "0" {
  27744. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27745. c.ServeSuccessJSON(map[string]interface{}{
  27746. "failed_code": -10,
  27747. "msg": err_msg,
  27748. })
  27749. return
  27750. }
  27751. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27752. result, _ := json.Marshal(respJSON)
  27753. fmt.Println("log")
  27754. fmt.Println(string(result))
  27755. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  27756. utils.ErrorLog("解析失败:%v", err)
  27757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27758. return
  27759. }
  27760. res.InfRefmsgid = ahres.InfRefmsgid
  27761. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27762. // 创建对应的Time类型
  27763. t := time.UnixMilli(timestamp)
  27764. // 格式化成指定的日期字符串
  27765. str := t.Format("2006-01-02 15:04:05")
  27766. res.Output.Setlinfo.SetlTime = str
  27767. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27768. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27769. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27770. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27771. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27772. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27773. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27774. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27775. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27776. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  27777. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27778. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27779. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27780. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27781. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27782. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27783. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27784. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27785. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27786. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27787. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27788. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27789. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27790. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27791. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27792. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27793. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27794. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27795. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27796. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27797. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27798. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27799. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27800. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27801. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27802. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27803. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27804. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27805. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27806. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27807. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27808. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27809. //res.Output.Setldetail = ahres.Output.Setldetail
  27810. res.ErrMsg = ahres.ErrMsg
  27811. res.Cainfo = ahres.Cainfo
  27812. res.WarnMsg = ahres.WarnMsg
  27813. res.Infcode = ahres.Infcode
  27814. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27815. var result string
  27816. var request_log string
  27817. if his.IdCardType == 2 {
  27818. 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")
  27819. } else if his.IdCardType == 1 {
  27820. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27821. bas := strings.Split(psn_info.CardInfo, "|")
  27822. basNumber := bas[2]
  27823. card_sn := bas[3]
  27824. 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")
  27825. } else {
  27826. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27827. 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")
  27828. }
  27829. var dat map[string]interface{}
  27830. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27831. fmt.Println(dat)
  27832. } else {
  27833. fmt.Println(err)
  27834. }
  27835. saveLog(result, request_log, "2206", "预结算")
  27836. userJSONBytes, _ := json.Marshal(dat)
  27837. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27838. utils.ErrorLog("解析失败:%v", err)
  27839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27840. return
  27841. }
  27842. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27843. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27844. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27845. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27846. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27847. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27848. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27849. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27850. resp, requestErr := http.Get(api)
  27851. if requestErr != nil {
  27852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27853. return
  27854. }
  27855. body, ioErr := ioutil.ReadAll(resp.Body)
  27856. if ioErr != nil {
  27857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27859. return
  27860. }
  27861. var respJSON map[string]interface{}
  27862. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27865. return
  27866. }
  27867. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27868. result, _ := json.Marshal(respJSON)
  27869. fmt.Println("log")
  27870. fmt.Println(string(result))
  27871. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27872. utils.ErrorLog("解析失败:%v", err)
  27873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27874. return
  27875. }
  27876. } else {
  27877. if miConfig.MdtrtareaAdmvs == "441202" {
  27878. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  27879. if result3101.Infcode == 0 {
  27880. if len(result3101.Output.Result) > 0 {
  27881. var errMsgs []string
  27882. for _, item := range result3101.Output.Result {
  27883. errMsgs = append(errMsgs, item.VolaCont)
  27884. }
  27885. c.ServeSuccessJSON(map[string]interface{}{
  27886. "failed_code": -10,
  27887. "msg": errMsgs,
  27888. })
  27889. return
  27890. } else {
  27891. var result string
  27892. var request_log string
  27893. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27894. allTotal = fmt.Sprintf("%.2f", total_two)
  27895. if his.IdCardType == 4 {
  27896. 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)
  27897. } else {
  27898. 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)
  27899. }
  27900. var dat map[string]interface{}
  27901. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27902. fmt.Println(dat)
  27903. } else {
  27904. fmt.Println(err)
  27905. }
  27906. saveLog(result, request_log, "2206", "预结算")
  27907. //userJSONBytes, _ := json.Marshal(dat)
  27908. //
  27909. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27910. // utils.ErrorLog("解析失败:%v", err)
  27911. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27912. // return
  27913. //}
  27914. userJSONBytes, _ := json.Marshal(dat)
  27915. if miConfig.Code == "H15049901371" {
  27916. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27917. utils.ErrorLog("解析失败:%v", err)
  27918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27919. return
  27920. }
  27921. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27922. res.Output = resSeven10265.Output
  27923. res.ErrMsg = resSeven10265.ErrMsg
  27924. res.Cainfo = resSeven10265.Cainfo
  27925. res.WarnMsg = resSeven10265.WarnMsg
  27926. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27927. res.Infcode = infocode
  27928. } else {
  27929. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27930. utils.ErrorLog("解析失败:%v", err)
  27931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27932. return
  27933. }
  27934. }
  27935. }
  27936. } else {
  27937. c.ServeSuccessJSON(map[string]interface{}{
  27938. "failed_code": -10,
  27939. "msg": result3101.ErrMsg,
  27940. })
  27941. return
  27942. }
  27943. } else if miConfig.MdtrtareaAdmvs == "440205" {
  27944. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  27945. if result3101.Infcode == 0 {
  27946. if len(result3101.Output.Result) > 0 {
  27947. var errMsgs []string
  27948. for _, item := range result3101.Output.Result {
  27949. errMsgs = append(errMsgs, item.VolaCont)
  27950. }
  27951. c.ServeSuccessJSON(map[string]interface{}{
  27952. "failed_code": -10,
  27953. "msg": errMsgs,
  27954. })
  27955. return
  27956. } else {
  27957. var result string
  27958. var request_log string
  27959. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27960. allTotal = fmt.Sprintf("%.2f", total_two)
  27961. if his.IdCardType == 4 {
  27962. 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)
  27963. } else {
  27964. 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)
  27965. }
  27966. var dat map[string]interface{}
  27967. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27968. fmt.Println(dat)
  27969. } else {
  27970. fmt.Println(err)
  27971. }
  27972. saveLog(result, request_log, "2206", "预结算")
  27973. //userJSONBytes, _ := json.Marshal(dat)
  27974. //
  27975. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27976. // utils.ErrorLog("解析失败:%v", err)
  27977. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27978. // return
  27979. //}
  27980. userJSONBytes, _ := json.Marshal(dat)
  27981. if miConfig.Code == "H15049901371" {
  27982. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27983. utils.ErrorLog("解析失败:%v", err)
  27984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27985. return
  27986. }
  27987. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27988. res.Output = resSeven10265.Output
  27989. res.ErrMsg = resSeven10265.ErrMsg
  27990. res.Cainfo = resSeven10265.Cainfo
  27991. res.WarnMsg = resSeven10265.WarnMsg
  27992. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27993. res.Infcode = infocode
  27994. } else {
  27995. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27996. utils.ErrorLog("解析失败:%v", err)
  27997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27998. return
  27999. }
  28000. }
  28001. }
  28002. } else {
  28003. c.ServeSuccessJSON(map[string]interface{}{
  28004. "failed_code": -10,
  28005. "msg": result3101.ErrMsg,
  28006. })
  28007. return
  28008. }
  28009. } else {
  28010. var result string
  28011. var request_log string
  28012. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28013. allTotal = fmt.Sprintf("%.2f", total_two)
  28014. if his.IdCardType == 4 {
  28015. 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)
  28016. } else {
  28017. 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)
  28018. }
  28019. var dat map[string]interface{}
  28020. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28021. fmt.Println(dat)
  28022. } else {
  28023. fmt.Println(err)
  28024. }
  28025. saveLog(result, request_log, "2206", "预结算")
  28026. //userJSONBytes, _ := json.Marshal(dat)
  28027. //
  28028. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28029. // utils.ErrorLog("解析失败:%v", err)
  28030. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28031. // return
  28032. //}
  28033. userJSONBytes, _ := json.Marshal(dat)
  28034. if miConfig.Code == "H15049901371" {
  28035. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  28036. utils.ErrorLog("解析失败:%v", err)
  28037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28038. return
  28039. }
  28040. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28041. res.Output = resSeven10265.Output
  28042. res.ErrMsg = resSeven10265.ErrMsg
  28043. res.Cainfo = resSeven10265.Cainfo
  28044. res.WarnMsg = resSeven10265.WarnMsg
  28045. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28046. res.Infcode = infocode
  28047. } else {
  28048. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28049. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  28050. utils.ErrorLog("解析失败:%v", err)
  28051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28052. return
  28053. }
  28054. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  28055. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  28056. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  28057. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28058. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  28059. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  28060. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  28061. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28062. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  28063. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28064. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28065. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28066. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28067. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28068. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  28069. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  28070. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  28071. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  28072. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  28073. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  28074. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28075. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  28076. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  28077. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  28078. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  28079. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  28080. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  28081. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  28082. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  28083. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  28084. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  28085. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  28086. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  28087. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  28088. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  28089. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  28090. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  28091. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  28092. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28093. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  28094. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  28095. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  28096. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  28097. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  28098. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  28099. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  28100. res.ErrMsg = gzresSeven10265Two.ErrMsg
  28101. res.Cainfo = gzresSeven10265Two.Cainfo
  28102. res.WarnMsg = gzresSeven10265Two.WarnMsg
  28103. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  28104. //res.Infcode = infocode
  28105. } else {
  28106. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28107. utils.ErrorLog("解析失败:%v", err)
  28108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28109. return
  28110. }
  28111. }
  28112. }
  28113. }
  28114. }
  28115. utils.ErrorLog("解析失败:%v", res.Infcode)
  28116. if res.Infcode == -1 {
  28117. errlog := &models.HisOrderError{
  28118. UserOrgId: adminUser.CurrentOrgId,
  28119. Ctime: time.Now().Unix(),
  28120. Mtime: time.Now().Unix(),
  28121. Number: chrg_bchno,
  28122. ErrMsg: res.ErrMsg,
  28123. Status: 1,
  28124. PatientId: id,
  28125. RecordTime: recordDateTime,
  28126. Stage: 20,
  28127. }
  28128. service.CreateErrMsgLog(errlog)
  28129. c.ServeSuccessJSON(map[string]interface{}{
  28130. "failed_code": -10,
  28131. "msg": res.ErrMsg,
  28132. })
  28133. return
  28134. }
  28135. if res.Infcode != 0 {
  28136. errlog := &models.HisOrderError{
  28137. UserOrgId: adminUser.CurrentOrgId,
  28138. Ctime: time.Now().Unix(),
  28139. Mtime: time.Now().Unix(),
  28140. Number: chrg_bchno,
  28141. ErrMsg: res.ErrMsg,
  28142. Status: 1,
  28143. PatientId: id,
  28144. RecordTime: recordDateTime,
  28145. Stage: 20,
  28146. }
  28147. service.CreateErrMsgLog(errlog)
  28148. c.ServeSuccessJSON(map[string]interface{}{
  28149. "failed_code": -10,
  28150. "msg": res.ErrMsg,
  28151. })
  28152. return
  28153. } else {
  28154. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  28155. order.OrderStatus = 1
  28156. order.IsPre = 1
  28157. order.Status = 1
  28158. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  28159. order.SetlId = res.Output.Setlinfo.SetlID
  28160. order.PsnNo = res.Output.Setlinfo.PsnNo
  28161. order.PsnName = res.Output.Setlinfo.PsnName
  28162. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  28163. order.Certno = res.Output.Setlinfo.Certno
  28164. order.Gend = res.Output.Setlinfo.Gend
  28165. order.Naty = res.Output.Setlinfo.Naty
  28166. order.Age = res.Output.Setlinfo.Age
  28167. order.Insutype = res.Output.Setlinfo.Insutype
  28168. order.PsnType = res.Output.Setlinfo.PsnType
  28169. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  28170. order.SetlTime = res.Output.Setlinfo.SetlTime
  28171. order.AcctUsedFlag = acct_used_flag
  28172. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  28173. if res.Output.Setlinfo.MedType == "140101" {
  28174. order.MedType = "14"
  28175. } else {
  28176. if res.Output.Setlinfo.MedType == "110104" {
  28177. order.MedType = "11"
  28178. } else {
  28179. order.MedType = res.Output.Setlinfo.MedType
  28180. }
  28181. }
  28182. if res.Output.Setlinfo.MedType == "992102" {
  28183. order.MedType = "992102"
  28184. }
  28185. if res.Output.Setlinfo.MedType == "140104" {
  28186. order.MedType = "140104"
  28187. }
  28188. if res.Output.Setlinfo.MedType == "14" {
  28189. order.MedType = "14"
  28190. }
  28191. if reg_type == 1112 {
  28192. order.MedType = "1112"
  28193. }
  28194. if reg_type == 1111 {
  28195. order.MedType = "1111"
  28196. }
  28197. order.ClrType = res.Output.Setlinfo.ClrType
  28198. if adminUser.CurrentOrgId == 10480 {
  28199. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28200. order.ClrType = "11"
  28201. } else {
  28202. order.ClrType = "9903"
  28203. }
  28204. }
  28205. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  28206. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  28207. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  28208. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  28209. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  28210. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  28211. order.HifpPay = res.Output.Setlinfo.HifpPay
  28212. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  28213. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  28214. order.HifesPay = res.Output.Setlinfo.HifesPay
  28215. order.HifobPay = res.Output.Setlinfo.HifobPay
  28216. order.MafPay = res.Output.Setlinfo.MafPay
  28217. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  28218. order.OthPay = res.Output.Setlinfo.OthPay
  28219. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  28220. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  28221. order.AcctPay = res.Output.Setlinfo.AcctPay
  28222. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  28223. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  28224. order.Balc = res.Output.Setlinfo.Balc
  28225. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  28226. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  28227. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  28228. order.ClrWay = res.Output.Setlinfo.ClrWay
  28229. order.Creator = order.Creator
  28230. order.Modify = roles.AdminUserId
  28231. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28232. //detailStr := string(setlDetail)
  28233. //order.SetlDetail = detailStr
  28234. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28235. err = service.UpDateOrder(order)
  28236. if err == nil {
  28237. c.ServeSuccessJSON(map[string]interface{}{
  28238. "msg": "预结算成功",
  28239. })
  28240. } else {
  28241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28242. return
  28243. }
  28244. }
  28245. } else {
  28246. adminUser := c.GetAdminUserInfo()
  28247. errlog := &models.HisOrderError{
  28248. UserOrgId: adminUser.CurrentOrgId,
  28249. Ctime: time.Now().Unix(),
  28250. Mtime: time.Now().Unix(),
  28251. ErrMsg: res.ErrMsg,
  28252. Status: 1,
  28253. PatientId: id,
  28254. RecordTime: recordDateTime,
  28255. Stage: 4,
  28256. }
  28257. service.CreateErrMsgLog(errlog)
  28258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  28259. return
  28260. }
  28261. } else {
  28262. if miConfig.MdtrtareaAdmvs == "150499" {
  28263. order := &models.HisOrder{
  28264. UserOrgId: adminUser.CurrentOrgId,
  28265. HisPatientId: his.ID,
  28266. PatientId: his.PatientId,
  28267. SettleAccountsDate: recordDateTime,
  28268. Ctime: time.Now().Unix(),
  28269. Mtime: time.Now().Unix(),
  28270. MdtrtId: his.Number,
  28271. PsnNo: his.PsnNo,
  28272. MedType: strconv.FormatInt(reg_type, 10),
  28273. Status: 1,
  28274. Number: chrg_bchno,
  28275. Infcode: res.Infcode,
  28276. WarnMsg: res.WarnMsg,
  28277. Cainfo: res.Cainfo,
  28278. ErrMsg: res.ErrMsg,
  28279. RespondTime: res.RefmsgTime,
  28280. InfRefmsgid: res.InfRefmsgid,
  28281. OrderStatus: 1,
  28282. IsMedicineInsurance: 1,
  28283. SettleType: settle_accounts_type,
  28284. SettleStartTime: start_time,
  28285. SettleEndTime: end_time,
  28286. Creator: roles.AdminUserId,
  28287. Modify: roles.AdminUserId,
  28288. PType: 2,
  28289. Diagnosis: diagnosis_id,
  28290. }
  28291. err = service.CreateOrder(order)
  28292. if err != nil {
  28293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  28294. return
  28295. }
  28296. }
  28297. adminUser := c.GetAdminUserInfo()
  28298. errlog := &models.HisOrderError{
  28299. UserOrgId: adminUser.CurrentOrgId,
  28300. Ctime: time.Now().Unix(),
  28301. Mtime: time.Now().Unix(),
  28302. ErrMsg: res.ErrMsg,
  28303. Status: 1,
  28304. PatientId: id,
  28305. RecordTime: recordDateTime,
  28306. Stage: 4,
  28307. }
  28308. service.CreateErrMsgLog(errlog)
  28309. c.ServeSuccessJSON(map[string]interface{}{
  28310. "failed_code": -10,
  28311. "msg": res.ErrMsg,
  28312. })
  28313. return
  28314. }
  28315. }
  28316. }
  28317. }
  28318. // 退款
  28319. func (c *HisApiController) Refund() {
  28320. order_id, _ := c.GetInt64("order_id")
  28321. admin_user_id, _ := c.GetInt64("admin_user_id")
  28322. adminUser := c.GetAdminUserInfo()
  28323. var order models.HisOrder
  28324. order, _ = service.GetHisOrderByID(order_id)
  28325. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  28326. if fapiao.ID > 0 {
  28327. c.ServeSuccessJSON(map[string]interface{}{
  28328. "failed_code": -10,
  28329. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  28330. })
  28331. return
  28332. }
  28333. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28334. if order.ID == 0 {
  28335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28336. return
  28337. }
  28338. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  28339. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28340. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28341. if config.IsOpen == 1 { //对接了医保,走医保流程
  28342. var res ResultSixteen
  28343. var ahres ResultSevenAH
  28344. var resSixteen10265 ResultSixteen10265
  28345. var resSixteen10265Two ResultSixteen10265Two
  28346. var gz ResultgzSixteen10265Two
  28347. var src_resquest string
  28348. var result string
  28349. if miConfig.MdtrtareaAdmvs == "421300" {
  28350. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  28351. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28352. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28353. resp3, requestErr3 := http.Get(api3)
  28354. if requestErr3 != nil {
  28355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28356. return
  28357. }
  28358. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28359. if ioErr3 != nil {
  28360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28362. return
  28363. }
  28364. var respJSON3 map[string]interface{}
  28365. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28368. return
  28369. }
  28370. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28371. userJSONBytes3, _ := json.Marshal(respJSON3)
  28372. fmt.Println("log")
  28373. fmt.Println(string(userJSONBytes3))
  28374. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28375. utils.ErrorLog("解析失败:%v", err)
  28376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28377. return
  28378. }
  28379. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28380. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  28381. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28382. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28383. resp3, requestErr3 := http.Get(api3)
  28384. if requestErr3 != nil {
  28385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28386. return
  28387. }
  28388. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28389. if ioErr3 != nil {
  28390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28392. return
  28393. }
  28394. var respJSON3 map[string]interface{}
  28395. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28398. return
  28399. }
  28400. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28401. userJSONBytes3, _ := json.Marshal(respJSON3)
  28402. fmt.Println("log")
  28403. fmt.Println(string(userJSONBytes3))
  28404. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28405. utils.ErrorLog("解析失败:%v", err)
  28406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28407. return
  28408. }
  28409. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28410. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  28411. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28412. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28413. resp3, requestErr3 := http.Get(api3)
  28414. if requestErr3 != nil {
  28415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28416. return
  28417. }
  28418. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28419. if ioErr3 != nil {
  28420. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28422. return
  28423. }
  28424. var respJSON3 map[string]interface{}
  28425. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28426. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28428. return
  28429. }
  28430. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28431. userJSONBytes3, _ := json.Marshal(respJSON3)
  28432. fmt.Println("log")
  28433. fmt.Println(string(userJSONBytes3))
  28434. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28435. utils.ErrorLog("解析失败:%v", err)
  28436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28437. return
  28438. }
  28439. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28440. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  28441. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28442. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28443. resp3, requestErr3 := http.Get(api3)
  28444. if requestErr3 != nil {
  28445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28446. return
  28447. }
  28448. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28449. if ioErr3 != nil {
  28450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28452. return
  28453. }
  28454. var respJSON3 map[string]interface{}
  28455. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28458. return
  28459. }
  28460. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28461. userJSONBytes3, _ := json.Marshal(respJSON3)
  28462. fmt.Println("log")
  28463. fmt.Println(string(userJSONBytes3))
  28464. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28465. utils.ErrorLog("解析失败:%v", err)
  28466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28467. return
  28468. }
  28469. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28470. var api3 string
  28471. if miConfig.MdtrtareaAdmvs == "320921" {
  28472. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  28473. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28474. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28475. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28476. } else {
  28477. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28478. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  28479. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28480. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28481. }
  28482. resp3, requestErr3 := http.Get(api3)
  28483. if requestErr3 != nil {
  28484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28485. return
  28486. }
  28487. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28488. if ioErr3 != nil {
  28489. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28491. return
  28492. }
  28493. var respJSON3 map[string]interface{}
  28494. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28495. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28497. return
  28498. }
  28499. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28500. userJSONBytes3, _ := json.Marshal(respJSON3)
  28501. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  28502. utils.ErrorLog("解析失败:%v", err)
  28503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28504. return
  28505. }
  28506. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  28507. res.Output = resSixteen10265.Output
  28508. res.ErrMsg = resSixteen10265.ErrMsg
  28509. res.Cainfo = resSixteen10265.Cainfo
  28510. res.WarnMsg = resSixteen10265.WarnMsg
  28511. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  28512. res.Infcode = infocode
  28513. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28514. var api3 string
  28515. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  28516. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28517. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28518. resp3, requestErr3 := http.Get(api3)
  28519. if requestErr3 != nil {
  28520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28521. return
  28522. }
  28523. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28524. if ioErr3 != nil {
  28525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28527. return
  28528. }
  28529. var respJSON3 map[string]interface{}
  28530. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28533. return
  28534. }
  28535. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28536. userJSONBytes3, _ := json.Marshal(respJSON3)
  28537. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  28538. utils.ErrorLog("解析失败:%v", err)
  28539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28540. return
  28541. }
  28542. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  28543. res.Output = resSixteen10265.Output
  28544. res.ErrMsg = resSixteen10265.ErrMsg
  28545. res.Cainfo = resSixteen10265.Cainfo
  28546. res.WarnMsg = resSixteen10265.WarnMsg
  28547. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  28548. res.Infcode = infocode
  28549. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28550. 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)
  28551. var dat map[string]interface{}
  28552. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28553. fmt.Println(dat)
  28554. } else {
  28555. fmt.Println(err)
  28556. }
  28557. saveLog(result, src_resquest, "2208", "退费")
  28558. userJSONBytes, _ := json.Marshal(dat)
  28559. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28560. utils.ErrorLog("解析失败:%v", err)
  28561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28562. return
  28563. }
  28564. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28565. 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, "")
  28566. var dat map[string]interface{}
  28567. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28568. fmt.Println(dat)
  28569. } else {
  28570. fmt.Println(err)
  28571. }
  28572. saveLog(result, src_resquest, "2208", "退费")
  28573. userJSONBytes, _ := json.Marshal(dat)
  28574. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28575. utils.ErrorLog("解析失败:%v", err)
  28576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28577. return
  28578. }
  28579. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28580. var api3 string
  28581. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  28582. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28583. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28584. resp3, requestErr3 := http.Get(api3)
  28585. if requestErr3 != nil {
  28586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28587. return
  28588. }
  28589. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28590. if ioErr3 != nil {
  28591. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28593. return
  28594. }
  28595. var respJSON3 map[string]interface{}
  28596. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28599. return
  28600. }
  28601. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  28602. if status == "0" {
  28603. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  28604. c.ServeSuccessJSON(map[string]interface{}{
  28605. "failed_code": -10,
  28606. "msg": err_msg,
  28607. })
  28608. return
  28609. }
  28610. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28611. userJSONBytes3, _ := json.Marshal(respJSON3)
  28612. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28613. // utils.ErrorLog("解析失败:%v", err)
  28614. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28615. // return
  28616. //}
  28617. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  28618. utils.ErrorLog("解析失败:%v", err)
  28619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28620. return
  28621. }
  28622. res.InfRefmsgid = ahres.InfRefmsgid
  28623. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28624. // 创建对应的Time类型
  28625. t := time.UnixMilli(timestamp)
  28626. // 格式化成指定的日期字符串
  28627. str := t.Format("2006-01-02 15:04:05")
  28628. res.Output.Setlinfo.SetlTime = str
  28629. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28630. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28631. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28632. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28633. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28634. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28635. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28636. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28637. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28638. //
  28639. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  28640. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28641. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28642. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28643. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28644. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28645. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28646. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28647. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28648. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28649. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28650. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28651. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28652. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28653. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28654. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28655. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28656. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28657. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28658. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28659. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28660. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28661. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28662. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28663. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28664. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28665. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28666. //res.Output.Setldetail = ahres.Output.Setldetail
  28667. res.ErrMsg = ahres.ErrMsg
  28668. res.Cainfo = ahres.Cainfo
  28669. res.WarnMsg = ahres.WarnMsg
  28670. res.Infcode = ahres.Infcode
  28671. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28672. 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, "")
  28673. var dat map[string]interface{}
  28674. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28675. fmt.Println(dat)
  28676. } else {
  28677. fmt.Println(err)
  28678. }
  28679. saveLog(result, src_resquest, "2208", "退费")
  28680. userJSONBytes, _ := json.Marshal(dat)
  28681. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28682. utils.ErrorLog("解析失败:%v", err)
  28683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28684. return
  28685. }
  28686. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28687. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  28688. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28689. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28690. resp3, requestErr3 := http.Get(api3)
  28691. if requestErr3 != nil {
  28692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28693. return
  28694. }
  28695. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28696. if ioErr3 != nil {
  28697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28699. return
  28700. }
  28701. var respJSON3 map[string]interface{}
  28702. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28705. return
  28706. }
  28707. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28708. userJSONBytes3, _ := json.Marshal(respJSON3)
  28709. fmt.Println("log")
  28710. fmt.Println(string(userJSONBytes3))
  28711. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28712. utils.ErrorLog("解析失败:%v", err)
  28713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28714. return
  28715. }
  28716. } else {
  28717. if miConfig.Code == "H15049901371" {
  28718. 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)
  28719. var dat map[string]interface{}
  28720. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28721. fmt.Println(dat)
  28722. } else {
  28723. fmt.Println(err)
  28724. }
  28725. saveLog(result, src_resquest, "2208", "退费")
  28726. if strings.Contains(result, "Post") {
  28727. res.Infcode = -1
  28728. res.ErrMsg = result
  28729. }
  28730. userJSONBytes, _ := json.Marshal(dat)
  28731. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  28732. utils.ErrorLog("解析失败:%v", err)
  28733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28734. return
  28735. }
  28736. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  28737. res.Output = resSixteen10265.Output
  28738. res.ErrMsg = resSixteen10265.ErrMsg
  28739. res.Cainfo = resSixteen10265.Cainfo
  28740. res.WarnMsg = resSixteen10265.WarnMsg
  28741. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  28742. res.Infcode = infocode
  28743. } else {
  28744. 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)
  28745. var dat map[string]interface{}
  28746. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28747. fmt.Println(dat)
  28748. } else {
  28749. fmt.Println(err)
  28750. }
  28751. saveLog(result, src_resquest, "2208", "退费")
  28752. userJSONBytes, _ := json.Marshal(dat)
  28753. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28754. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  28755. utils.ErrorLog("解析失败:%v", err)
  28756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28757. return
  28758. }
  28759. res.Infcode = gz.Infcode
  28760. } else {
  28761. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28762. utils.ErrorLog("解析失败:%v", err)
  28763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28764. return
  28765. }
  28766. }
  28767. if strings.Contains(result, "Post") {
  28768. res.Infcode = -1
  28769. res.ErrMsg = result
  28770. }
  28771. }
  28772. }
  28773. if res.Infcode == -1 {
  28774. c.ServeSuccessJSON(map[string]interface{}{
  28775. "failed_code": -10,
  28776. "msg": res.ErrMsg,
  28777. })
  28778. return
  28779. }
  28780. if res.Infcode != -1 {
  28781. var res2 ResultSix
  28782. var resSix10265 ResultSix10265
  28783. if miConfig.MdtrtareaAdmvs == "421300" {
  28784. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  28785. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28786. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28787. resp3, requestErr3 := http.Get(api3)
  28788. if requestErr3 != nil {
  28789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28790. return
  28791. }
  28792. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28793. if ioErr3 != nil {
  28794. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28796. return
  28797. }
  28798. var respJSON3 map[string]interface{}
  28799. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28800. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28802. return
  28803. }
  28804. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28805. userJSONBytes3, _ := json.Marshal(respJSON3)
  28806. fmt.Println("log")
  28807. fmt.Println(string(userJSONBytes3))
  28808. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28809. utils.ErrorLog("解析失败:%v", err)
  28810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28811. return
  28812. }
  28813. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28814. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  28815. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28816. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28817. resp3, requestErr3 := http.Get(api3)
  28818. if requestErr3 != nil {
  28819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28820. return
  28821. }
  28822. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28823. if ioErr3 != nil {
  28824. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28826. return
  28827. }
  28828. var respJSON3 map[string]interface{}
  28829. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28830. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28832. return
  28833. }
  28834. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28835. userJSONBytes3, _ := json.Marshal(respJSON3)
  28836. fmt.Println("log")
  28837. fmt.Println(string(userJSONBytes3))
  28838. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28839. utils.ErrorLog("解析失败:%v", err)
  28840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28841. return
  28842. }
  28843. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28844. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  28845. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28846. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28847. resp3, requestErr3 := http.Get(api3)
  28848. if requestErr3 != nil {
  28849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28850. return
  28851. }
  28852. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28853. if ioErr3 != nil {
  28854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28856. return
  28857. }
  28858. var respJSON3 map[string]interface{}
  28859. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28862. return
  28863. }
  28864. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28865. userJSONBytes3, _ := json.Marshal(respJSON3)
  28866. fmt.Println("log")
  28867. fmt.Println(string(userJSONBytes3))
  28868. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28869. utils.ErrorLog("解析失败:%v", err)
  28870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28871. return
  28872. }
  28873. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28874. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  28875. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28876. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28877. resp3, requestErr3 := http.Get(api3)
  28878. if requestErr3 != nil {
  28879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28880. return
  28881. }
  28882. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28883. if ioErr3 != nil {
  28884. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28886. return
  28887. }
  28888. var respJSON3 map[string]interface{}
  28889. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28890. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28892. return
  28893. }
  28894. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28895. userJSONBytes3, _ := json.Marshal(respJSON3)
  28896. fmt.Println("log")
  28897. fmt.Println(string(userJSONBytes3))
  28898. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28899. utils.ErrorLog("解析失败:%v", err)
  28900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28901. return
  28902. }
  28903. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28904. var api3 string
  28905. if miConfig.MdtrtareaAdmvs == "320921" {
  28906. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  28907. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28908. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28909. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28910. } else {
  28911. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28912. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  28913. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28914. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28915. }
  28916. resp3, requestErr3 := http.Get(api3)
  28917. if requestErr3 != nil {
  28918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28919. return
  28920. }
  28921. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28922. if ioErr3 != nil {
  28923. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28925. return
  28926. }
  28927. var respJSON3 map[string]interface{}
  28928. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28929. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28931. return
  28932. }
  28933. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28934. userJSONBytes3, _ := json.Marshal(respJSON3)
  28935. fmt.Println("log")
  28936. fmt.Println(string(userJSONBytes3))
  28937. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  28938. utils.ErrorLog("解析失败:%v", err)
  28939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28940. return
  28941. }
  28942. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28943. res2.Output = resSix10265.Output
  28944. res2.ErrMsg = resSix10265.ErrMsg
  28945. res2.Cainfo = resSix10265.Cainfo
  28946. res2.WarnMsg = resSix10265.WarnMsg
  28947. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28948. res2.Infcode = infocode
  28949. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28950. var api3 string
  28951. new_chrg_bchno := order.Number
  28952. if adminUser.CurrentOrgId == 10265 {
  28953. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28954. new_chrg_bchno = "0000"
  28955. }
  28956. }
  28957. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  28958. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28959. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28960. resp3, requestErr3 := http.Get(api3)
  28961. if requestErr3 != nil {
  28962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28963. return
  28964. }
  28965. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28966. if ioErr3 != nil {
  28967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28969. return
  28970. }
  28971. var respJSON3 map[string]interface{}
  28972. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28975. return
  28976. }
  28977. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28978. userJSONBytes3, _ := json.Marshal(respJSON3)
  28979. fmt.Println("log")
  28980. fmt.Println(string(userJSONBytes3))
  28981. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  28982. utils.ErrorLog("解析失败:%v", err)
  28983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28984. return
  28985. }
  28986. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28987. res2.Output = resSix10265.Output
  28988. res2.ErrMsg = resSix10265.ErrMsg
  28989. res2.Cainfo = resSix10265.Cainfo
  28990. res2.WarnMsg = resSix10265.WarnMsg
  28991. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28992. res2.Infcode = infocode
  28993. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28994. 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)
  28995. var dat map[string]interface{}
  28996. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28997. fmt.Println(dat)
  28998. } else {
  28999. fmt.Println(err)
  29000. }
  29001. saveLog(result2, src_request, "2205", "撤销明细")
  29002. userJSONBytes, _ := json.Marshal(dat)
  29003. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29004. utils.ErrorLog("解析失败:%v", err)
  29005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29006. return
  29007. }
  29008. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29009. 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, "")
  29010. var dat map[string]interface{}
  29011. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29012. fmt.Println(dat)
  29013. } else {
  29014. fmt.Println(err)
  29015. }
  29016. saveLog(result2, src_request, "2205", "撤销明细")
  29017. userJSONBytes, _ := json.Marshal(dat)
  29018. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29019. utils.ErrorLog("解析失败:%v", err)
  29020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29021. return
  29022. }
  29023. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29024. var api3 string
  29025. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  29026. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29027. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29028. resp3, requestErr3 := http.Get(api3)
  29029. if requestErr3 != nil {
  29030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29031. return
  29032. }
  29033. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29034. if ioErr3 != nil {
  29035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29037. return
  29038. }
  29039. var respJSON3 map[string]interface{}
  29040. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29043. return
  29044. }
  29045. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  29046. if status == "0" {
  29047. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  29048. c.ServeSuccessJSON(map[string]interface{}{
  29049. "failed_code": -10,
  29050. "msg": err_msg,
  29051. })
  29052. return
  29053. }
  29054. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29055. userJSONBytes3, _ := json.Marshal(respJSON3)
  29056. fmt.Println("log")
  29057. fmt.Println(string(userJSONBytes3))
  29058. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29059. utils.ErrorLog("解析失败:%v", err)
  29060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29061. return
  29062. }
  29063. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29064. 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, "")
  29065. var dat map[string]interface{}
  29066. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29067. fmt.Println(dat)
  29068. } else {
  29069. fmt.Println(err)
  29070. }
  29071. saveLog(result2, src_request, "2205", "撤销明细")
  29072. userJSONBytes, _ := json.Marshal(dat)
  29073. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29074. utils.ErrorLog("解析失败:%v", err)
  29075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29076. return
  29077. }
  29078. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29079. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  29080. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29081. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29082. resp3, requestErr3 := http.Get(api3)
  29083. if requestErr3 != nil {
  29084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29085. return
  29086. }
  29087. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29088. if ioErr3 != nil {
  29089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29091. return
  29092. }
  29093. var respJSON3 map[string]interface{}
  29094. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29097. return
  29098. }
  29099. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29100. userJSONBytes3, _ := json.Marshal(respJSON3)
  29101. fmt.Println("log")
  29102. fmt.Println(string(userJSONBytes3))
  29103. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29104. utils.ErrorLog("解析失败:%v", err)
  29105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29106. return
  29107. }
  29108. } else {
  29109. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29110. res2.Infcode = 0
  29111. } else {
  29112. 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)
  29113. var dat map[string]interface{}
  29114. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29115. fmt.Println(dat)
  29116. } else {
  29117. fmt.Println(err)
  29118. }
  29119. saveLog(result2, src_request, "2205", "撤销明细")
  29120. userJSONBytes, _ := json.Marshal(dat)
  29121. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29122. utils.ErrorLog("解析失败:%v", err)
  29123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29124. return
  29125. }
  29126. }
  29127. }
  29128. if res2.Infcode == -1 {
  29129. c.ServeSuccessJSON(map[string]interface{}{
  29130. "failed_code": -10,
  29131. "msg": res2.ErrMsg,
  29132. })
  29133. return
  29134. }
  29135. if res2.Infcode == 0 {
  29136. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  29137. if err == nil {
  29138. //当押金不为零时产生退费记录
  29139. if order.Decimal != 0 {
  29140. tmp := strconv.FormatInt(order.ID, 10)
  29141. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  29142. if err != nil {
  29143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29144. return
  29145. }
  29146. }
  29147. c.ServeSuccessJSON(map[string]interface{}{
  29148. "msg": "退费成功",
  29149. })
  29150. } else {
  29151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29152. return
  29153. }
  29154. } else {
  29155. c.ServeSuccessJSON(map[string]interface{}{
  29156. "failed_code": -10,
  29157. "msg": res2.ErrMsg,
  29158. })
  29159. }
  29160. } else {
  29161. c.ServeSuccessJSON(map[string]interface{}{
  29162. "failed_code": -10,
  29163. "msg": res.ErrMsg,
  29164. })
  29165. }
  29166. }
  29167. }
  29168. func (c *HisApiController) RefundNumber() {
  29169. record_time := c.GetString("record_time")
  29170. //patient_id, _ := c.GetInt64("patient_id")
  29171. admin_user_id, _ := c.GetInt64("admin_user_id")
  29172. his_patient_id, _ := c.GetInt64("id")
  29173. timeLayout := "2006-01-02"
  29174. loc, _ := time.LoadLocation("Local")
  29175. adminUser := c.GetAdminUserInfo()
  29176. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29177. fmt.Println(err)
  29178. if err != nil {
  29179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29180. return
  29181. }
  29182. recordDateTime := theTime.Unix()
  29183. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  29184. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  29185. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  29186. //order, _ := service.GetHisOrderByID(order_id)
  29187. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29188. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29189. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29190. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  29191. if count > 0 {
  29192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  29193. return
  29194. }
  29195. if config.IsOpen == 1 { //对接了医保,走医保流程
  29196. var res2 ResultSix
  29197. var res3 GZResultSix
  29198. var resSix10265 ResultSix10265
  29199. if miConfig.MdtrtareaAdmvs == "421300" {
  29200. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  29201. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29202. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29203. resp3, requestErr3 := http.Get(api3)
  29204. if requestErr3 != nil {
  29205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29206. return
  29207. }
  29208. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29209. if ioErr3 != nil {
  29210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29212. return
  29213. }
  29214. var respJSON3 map[string]interface{}
  29215. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29218. return
  29219. }
  29220. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29221. userJSONBytes3, _ := json.Marshal(respJSON3)
  29222. fmt.Println("log")
  29223. fmt.Println(string(userJSONBytes3))
  29224. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29225. utils.ErrorLog("解析失败:%v", err)
  29226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29227. return
  29228. }
  29229. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29230. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  29231. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29232. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29233. resp3, requestErr3 := http.Get(api3)
  29234. if requestErr3 != nil {
  29235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29236. return
  29237. }
  29238. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29239. if ioErr3 != nil {
  29240. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29242. return
  29243. }
  29244. var respJSON3 map[string]interface{}
  29245. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29246. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29248. return
  29249. }
  29250. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29251. userJSONBytes3, _ := json.Marshal(respJSON3)
  29252. fmt.Println("log")
  29253. fmt.Println(string(userJSONBytes3))
  29254. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29255. utils.ErrorLog("解析失败:%v", err)
  29256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29257. return
  29258. }
  29259. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29260. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  29261. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29262. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29263. resp3, requestErr3 := http.Get(api3)
  29264. if requestErr3 != nil {
  29265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29266. return
  29267. }
  29268. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29269. if ioErr3 != nil {
  29270. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29272. return
  29273. }
  29274. var respJSON3 map[string]interface{}
  29275. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29278. return
  29279. }
  29280. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29281. userJSONBytes3, _ := json.Marshal(respJSON3)
  29282. fmt.Println("log")
  29283. fmt.Println(string(userJSONBytes3))
  29284. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29285. utils.ErrorLog("解析失败:%v", err)
  29286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29287. return
  29288. }
  29289. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29290. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  29291. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29292. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29293. resp3, requestErr3 := http.Get(api3)
  29294. if requestErr3 != nil {
  29295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29296. return
  29297. }
  29298. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29299. if ioErr3 != nil {
  29300. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29302. return
  29303. }
  29304. var respJSON3 map[string]interface{}
  29305. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29306. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29308. return
  29309. }
  29310. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29311. userJSONBytes3, _ := json.Marshal(respJSON3)
  29312. fmt.Println("log")
  29313. fmt.Println(string(userJSONBytes3))
  29314. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29315. utils.ErrorLog("解析失败:%v", err)
  29316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29317. return
  29318. }
  29319. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29320. var api3 string
  29321. if miConfig.MdtrtareaAdmvs == "320921" {
  29322. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  29323. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29324. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29325. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29326. } else {
  29327. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29328. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  29329. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29330. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29331. }
  29332. resp3, requestErr3 := http.Get(api3)
  29333. if requestErr3 != nil {
  29334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29335. return
  29336. }
  29337. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29338. if ioErr3 != nil {
  29339. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29341. return
  29342. }
  29343. var respJSON3 map[string]interface{}
  29344. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29345. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29347. return
  29348. }
  29349. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29350. userJSONBytes3, _ := json.Marshal(respJSON3)
  29351. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29352. utils.ErrorLog("解析失败:%v", err)
  29353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29354. return
  29355. }
  29356. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29357. res2.Output = resSix10265.Output
  29358. res2.ErrMsg = resSix10265.ErrMsg
  29359. res2.Cainfo = resSix10265.Cainfo
  29360. res2.WarnMsg = resSix10265.WarnMsg
  29361. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29362. res2.Infcode = infocode
  29363. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29364. var api3 string
  29365. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  29366. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29367. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29368. resp3, requestErr3 := http.Get(api3)
  29369. if requestErr3 != nil {
  29370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29371. return
  29372. }
  29373. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29374. if ioErr3 != nil {
  29375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29377. return
  29378. }
  29379. var respJSON3 map[string]interface{}
  29380. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29383. return
  29384. }
  29385. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29386. userJSONBytes3, _ := json.Marshal(respJSON3)
  29387. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29388. utils.ErrorLog("解析失败:%v", err)
  29389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29390. return
  29391. }
  29392. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29393. res2.Output = resSix10265.Output
  29394. res2.ErrMsg = resSix10265.ErrMsg
  29395. res2.Cainfo = resSix10265.Cainfo
  29396. res2.WarnMsg = resSix10265.WarnMsg
  29397. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29398. res2.Infcode = infocode
  29399. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29400. 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)
  29401. var dat map[string]interface{}
  29402. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29403. fmt.Println(dat)
  29404. } else {
  29405. fmt.Println(err)
  29406. }
  29407. saveLog(result, request, "2202", "退号")
  29408. userJSONBytes, _ := json.Marshal(dat)
  29409. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29410. utils.ErrorLog("解析失败:%v", err)
  29411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29412. return
  29413. }
  29414. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29415. 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, "")
  29416. var dat map[string]interface{}
  29417. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29418. fmt.Println(dat)
  29419. } else {
  29420. fmt.Println(err)
  29421. }
  29422. saveLog(result, request, "2202", "退号")
  29423. userJSONBytes, _ := json.Marshal(dat)
  29424. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29425. utils.ErrorLog("解析失败:%v", err)
  29426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29427. return
  29428. }
  29429. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29430. var api3 string
  29431. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  29432. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29433. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29434. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29435. resp3, requestErr3 := http.Get(api3)
  29436. if requestErr3 != nil {
  29437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29438. return
  29439. }
  29440. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29441. if ioErr3 != nil {
  29442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29444. return
  29445. }
  29446. var respJSON3 map[string]interface{}
  29447. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29450. return
  29451. }
  29452. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  29453. if status == "0" {
  29454. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  29455. c.ServeSuccessJSON(map[string]interface{}{
  29456. "failed_code": -10,
  29457. "msg": err_msg,
  29458. })
  29459. return
  29460. }
  29461. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29462. userJSONBytes3, _ := json.Marshal(respJSON3)
  29463. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29464. utils.ErrorLog("解析失败:%v", err)
  29465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29466. return
  29467. }
  29468. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  29469. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29470. 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, "")
  29471. var dat map[string]interface{}
  29472. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29473. fmt.Println(dat)
  29474. } else {
  29475. fmt.Println(err)
  29476. }
  29477. saveLog(result, request, "2202", "退号")
  29478. userJSONBytes, _ := json.Marshal(dat)
  29479. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29480. utils.ErrorLog("解析失败:%v", err)
  29481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29482. return
  29483. }
  29484. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29485. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  29486. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29487. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  29488. resp3, requestErr3 := http.Get(api3)
  29489. if requestErr3 != nil {
  29490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29491. return
  29492. }
  29493. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29494. if ioErr3 != nil {
  29495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29497. return
  29498. }
  29499. var respJSON3 map[string]interface{}
  29500. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29503. return
  29504. }
  29505. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29506. userJSONBytes3, _ := json.Marshal(respJSON3)
  29507. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29508. utils.ErrorLog("解析失败:%v", err)
  29509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29510. return
  29511. }
  29512. } else {
  29513. var api3 string
  29514. if miConfig.Code == "H15049901371" {
  29515. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  29516. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29517. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29518. } else {
  29519. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  29520. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29521. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  29522. }
  29523. resp3, requestErr3 := http.Get(api3)
  29524. if requestErr3 != nil {
  29525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29526. return
  29527. }
  29528. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29529. if ioErr3 != nil {
  29530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29532. return
  29533. }
  29534. var respJSON3 map[string]interface{}
  29535. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29538. return
  29539. }
  29540. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29541. userJSONBytes3, _ := json.Marshal(respJSON3)
  29542. if miConfig.Code == "H15049901371" {
  29543. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29544. utils.ErrorLog("解析失败:%v", err)
  29545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29546. return
  29547. }
  29548. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29549. res2.Output = resSix10265.Output
  29550. res2.ErrMsg = resSix10265.ErrMsg
  29551. res2.Cainfo = resSix10265.Cainfo
  29552. res2.WarnMsg = resSix10265.WarnMsg
  29553. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29554. res2.Infcode = infocode
  29555. } else {
  29556. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29557. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  29558. utils.ErrorLog("解析失败:%v", err)
  29559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29560. return
  29561. }
  29562. res2.Infcode = res3.Infcode
  29563. } else {
  29564. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29565. utils.ErrorLog("解析失败:%v", err)
  29566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29567. return
  29568. }
  29569. }
  29570. }
  29571. }
  29572. if res2.Infcode == -1 {
  29573. c.ServeSuccessJSON(map[string]interface{}{
  29574. "failed_code": -10,
  29575. "msg": res2.ErrMsg,
  29576. })
  29577. return
  29578. }
  29579. if res2.Infcode == 0 {
  29580. if err == nil {
  29581. c.ServeSuccessJSON(map[string]interface{}{
  29582. "msg": "退号成功",
  29583. })
  29584. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  29585. } else {
  29586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29587. return
  29588. }
  29589. }
  29590. } else {
  29591. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  29592. //if err == nil {
  29593. // c.ServeSuccessJSON(map[string]interface{}{
  29594. // "msg": "退费成功",
  29595. // })
  29596. //} else {
  29597. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29598. // return
  29599. //}
  29600. }
  29601. }
  29602. func (c *HisApiController) RefundDetail() {
  29603. order_id, _ := c.GetInt64("order_id")
  29604. admin_user_id, _ := c.GetInt64("admin_user_id")
  29605. //his_patient_id, _ := c.GetInt64("his_patient_id")
  29606. number := c.GetString("number")
  29607. record_time := c.GetString("record_time")
  29608. patient_id, _ := c.GetInt64("patient_id")
  29609. //med_type, _ := c.GetInt64("med_type")
  29610. timeLayout := "2006-01-02"
  29611. loc, _ := time.LoadLocation("Local")
  29612. adminUser := c.GetAdminUserInfo()
  29613. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29614. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29615. fmt.Println(err)
  29616. if err != nil {
  29617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29618. return
  29619. }
  29620. recordDateTime := theTime.Unix()
  29621. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29622. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  29623. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29624. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29625. var order models.HisOrder
  29626. order, _ = service.GetHisOrderByID(order_id)
  29627. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  29628. if config.IsOpen == 1 { //对接了医保,走医保流程
  29629. var res2 ResultSix
  29630. if miConfig.MdtrtareaAdmvs == "421300" {
  29631. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  29632. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29633. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29634. resp3, requestErr3 := http.Get(api3)
  29635. if requestErr3 != nil {
  29636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29637. return
  29638. }
  29639. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29640. if ioErr3 != nil {
  29641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29643. return
  29644. }
  29645. var respJSON3 map[string]interface{}
  29646. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29649. return
  29650. }
  29651. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29652. userJSONBytes3, _ := json.Marshal(respJSON3)
  29653. fmt.Println("log")
  29654. fmt.Println(string(userJSONBytes3))
  29655. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29656. utils.ErrorLog("解析失败:%v", err)
  29657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29658. return
  29659. }
  29660. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29661. if err == nil {
  29662. c.ServeSuccessJSON(map[string]interface{}{
  29663. "msg": "撤销明细成功",
  29664. })
  29665. return
  29666. } else {
  29667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29668. return
  29669. }
  29670. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29671. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  29672. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29673. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29674. resp3, requestErr3 := http.Get(api3)
  29675. if requestErr3 != nil {
  29676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29677. return
  29678. }
  29679. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29680. if ioErr3 != nil {
  29681. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29683. return
  29684. }
  29685. var respJSON3 map[string]interface{}
  29686. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29689. return
  29690. }
  29691. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29692. userJSONBytes3, _ := json.Marshal(respJSON3)
  29693. fmt.Println("log")
  29694. fmt.Println(string(userJSONBytes3))
  29695. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29696. utils.ErrorLog("解析失败:%v", err)
  29697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29698. return
  29699. }
  29700. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29701. if err == nil {
  29702. c.ServeSuccessJSON(map[string]interface{}{
  29703. "msg": "撤销明细成功",
  29704. })
  29705. return
  29706. } else {
  29707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29708. return
  29709. }
  29710. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29711. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  29712. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29713. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29714. resp3, requestErr3 := http.Get(api3)
  29715. if requestErr3 != nil {
  29716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29717. return
  29718. }
  29719. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29720. if ioErr3 != nil {
  29721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29723. return
  29724. }
  29725. var respJSON3 map[string]interface{}
  29726. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29729. return
  29730. }
  29731. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29732. userJSONBytes3, _ := json.Marshal(respJSON3)
  29733. fmt.Println("log")
  29734. fmt.Println(string(userJSONBytes3))
  29735. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29736. utils.ErrorLog("解析失败:%v", err)
  29737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29738. return
  29739. }
  29740. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29741. if err == nil {
  29742. c.ServeSuccessJSON(map[string]interface{}{
  29743. "msg": "撤销明细成功",
  29744. })
  29745. return
  29746. } else {
  29747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29748. return
  29749. }
  29750. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29751. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  29752. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29753. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29754. resp3, requestErr3 := http.Get(api3)
  29755. if requestErr3 != nil {
  29756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29757. return
  29758. }
  29759. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29760. if ioErr3 != nil {
  29761. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29763. return
  29764. }
  29765. var respJSON3 map[string]interface{}
  29766. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29769. return
  29770. }
  29771. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29772. userJSONBytes3, _ := json.Marshal(respJSON3)
  29773. fmt.Println("log")
  29774. fmt.Println(string(userJSONBytes3))
  29775. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29776. utils.ErrorLog("解析失败:%v", err)
  29777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29778. return
  29779. }
  29780. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29781. if err == nil {
  29782. c.ServeSuccessJSON(map[string]interface{}{
  29783. "msg": "撤销明细成功",
  29784. })
  29785. return
  29786. } else {
  29787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29788. return
  29789. }
  29790. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29791. var resSix10265 ResultSix10265
  29792. var api3 string
  29793. if miConfig.MdtrtareaAdmvs == "320921" {
  29794. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  29795. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29796. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29797. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29798. } else {
  29799. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29800. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  29801. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29802. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29803. }
  29804. resp3, requestErr3 := http.Get(api3)
  29805. utils.ErrorLog("接口: %v", requestErr3)
  29806. if requestErr3 != nil {
  29807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29808. return
  29809. }
  29810. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29811. if ioErr3 != nil {
  29812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29814. return
  29815. }
  29816. var respJSON3 map[string]interface{}
  29817. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29820. return
  29821. }
  29822. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29823. userJSONBytes3, _ := json.Marshal(respJSON3)
  29824. fmt.Println("log")
  29825. fmt.Println(string(userJSONBytes3))
  29826. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29827. utils.ErrorLog("解析失败:%v", err)
  29828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29829. return
  29830. }
  29831. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29832. res2.Output = resSix10265.Output
  29833. res2.ErrMsg = resSix10265.ErrMsg
  29834. res2.Cainfo = resSix10265.Cainfo
  29835. res2.WarnMsg = resSix10265.WarnMsg
  29836. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29837. res2.Infcode = infocode
  29838. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29839. if err == nil {
  29840. c.ServeSuccessJSON(map[string]interface{}{
  29841. "msg": "撤销明细成功",
  29842. })
  29843. return
  29844. } else {
  29845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29846. return
  29847. }
  29848. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29849. var api3 string
  29850. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  29851. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29852. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29853. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29854. resp3, requestErr3 := http.Get(api3)
  29855. utils.ErrorLog("接口: %v", requestErr3)
  29856. if requestErr3 != nil {
  29857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29858. return
  29859. }
  29860. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29861. if ioErr3 != nil {
  29862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29864. return
  29865. }
  29866. var respJSON3 map[string]interface{}
  29867. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29870. return
  29871. }
  29872. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  29873. if status == "0" {
  29874. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  29875. c.ServeSuccessJSON(map[string]interface{}{
  29876. "failed_code": -10,
  29877. "msg": err_msg,
  29878. })
  29879. return
  29880. }
  29881. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29882. userJSONBytes3, _ := json.Marshal(respJSON3)
  29883. fmt.Println("log")
  29884. fmt.Println(string(userJSONBytes3))
  29885. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29886. utils.ErrorLog("解析失败:%v", err)
  29887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29888. return
  29889. }
  29890. fmt.Println(res2.Infcode)
  29891. if res2.Infcode == -1 {
  29892. c.ServeSuccessJSON(map[string]interface{}{
  29893. "failed_code": -10,
  29894. "msg": res2.ErrMsg,
  29895. })
  29896. return
  29897. }
  29898. if res2.Infcode == 0 {
  29899. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29900. if err == nil {
  29901. c.ServeSuccessJSON(map[string]interface{}{
  29902. "msg": "撤销明细成功",
  29903. })
  29904. return
  29905. } else {
  29906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29907. return
  29908. }
  29909. } else {
  29910. c.ServeSuccessJSON(map[string]interface{}{
  29911. "failed_code": -10,
  29912. "msg": res2.ErrMsg,
  29913. })
  29914. }
  29915. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29916. if err == nil {
  29917. c.ServeSuccessJSON(map[string]interface{}{
  29918. "msg": "撤销明细成功",
  29919. })
  29920. return
  29921. } else {
  29922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29923. return
  29924. }
  29925. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29926. var resSix10265 ResultSix10265
  29927. new_chrg_bchno := order.Number
  29928. if adminUser.CurrentOrgId == 10265 {
  29929. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  29930. new_chrg_bchno = "0000"
  29931. }
  29932. }
  29933. var api3 string
  29934. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  29935. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29936. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29937. resp3, requestErr3 := http.Get(api3)
  29938. if requestErr3 != nil {
  29939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29940. return
  29941. }
  29942. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29943. if ioErr3 != nil {
  29944. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29946. return
  29947. }
  29948. var respJSON3 map[string]interface{}
  29949. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29952. return
  29953. }
  29954. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29955. userJSONBytes3, _ := json.Marshal(respJSON3)
  29956. fmt.Println("log")
  29957. fmt.Println(string(userJSONBytes3))
  29958. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29959. utils.ErrorLog("解析失败:%v", err)
  29960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29961. return
  29962. }
  29963. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29964. res2.Output = resSix10265.Output
  29965. res2.ErrMsg = resSix10265.ErrMsg
  29966. res2.Cainfo = resSix10265.Cainfo
  29967. res2.WarnMsg = resSix10265.WarnMsg
  29968. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29969. res2.Infcode = infocode
  29970. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29971. if err == nil {
  29972. c.ServeSuccessJSON(map[string]interface{}{
  29973. "msg": "撤销明细成功",
  29974. })
  29975. return
  29976. } else {
  29977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29978. return
  29979. }
  29980. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29981. 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)
  29982. var dat map[string]interface{}
  29983. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29984. fmt.Println(dat)
  29985. } else {
  29986. fmt.Println(err)
  29987. }
  29988. saveLog(result2, src_request, "2205", "撤销明细")
  29989. userJSONBytes, _ := json.Marshal(dat)
  29990. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29991. utils.ErrorLog("解析失败:%v", err)
  29992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29993. return
  29994. }
  29995. if res2.Infcode == 0 {
  29996. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29997. if err == nil {
  29998. c.ServeSuccessJSON(map[string]interface{}{
  29999. "msg": "撤销明细成功",
  30000. })
  30001. return
  30002. } else {
  30003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30004. return
  30005. }
  30006. } else {
  30007. c.ServeSuccessJSON(map[string]interface{}{
  30008. "failed_code": -10,
  30009. "msg": res2.ErrMsg,
  30010. })
  30011. }
  30012. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30013. 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, "")
  30014. var dat map[string]interface{}
  30015. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  30016. fmt.Println(dat)
  30017. } else {
  30018. fmt.Println(err)
  30019. }
  30020. saveLog(result2, src_request, "2205", "撤销明细")
  30021. userJSONBytes, _ := json.Marshal(dat)
  30022. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30023. utils.ErrorLog("解析失败:%v", err)
  30024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30025. return
  30026. }
  30027. if res2.Infcode == 0 {
  30028. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  30029. if err == nil {
  30030. c.ServeSuccessJSON(map[string]interface{}{
  30031. "msg": "撤销明细成功",
  30032. })
  30033. return
  30034. } else {
  30035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30036. return
  30037. }
  30038. } else {
  30039. c.ServeSuccessJSON(map[string]interface{}{
  30040. "failed_code": -10,
  30041. "msg": res2.ErrMsg,
  30042. })
  30043. }
  30044. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30045. 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, "")
  30046. var dat map[string]interface{}
  30047. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  30048. fmt.Println(dat)
  30049. } else {
  30050. fmt.Println(err)
  30051. }
  30052. saveLog(result2, src_request, "2205", "撤销明细")
  30053. userJSONBytes, _ := json.Marshal(dat)
  30054. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30055. utils.ErrorLog("解析失败:%v", err)
  30056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30057. return
  30058. }
  30059. if res2.Infcode == 0 {
  30060. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  30061. if err == nil {
  30062. c.ServeSuccessJSON(map[string]interface{}{
  30063. "msg": "撤销明细成功",
  30064. })
  30065. return
  30066. } else {
  30067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30068. return
  30069. }
  30070. } else {
  30071. c.ServeSuccessJSON(map[string]interface{}{
  30072. "failed_code": -10,
  30073. "msg": res2.ErrMsg,
  30074. })
  30075. }
  30076. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30077. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  30078. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30079. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30080. resp2, requestErr2 := http.Get(api2)
  30081. if requestErr2 != nil {
  30082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30083. return
  30084. }
  30085. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  30086. if ioErr2 != nil {
  30087. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  30088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30089. return
  30090. }
  30091. var respJSON2 map[string]interface{}
  30092. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  30093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30095. return
  30096. }
  30097. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30098. userJSONBytes3, _ := json.Marshal(respJSON2)
  30099. fmt.Println("log")
  30100. fmt.Println(string(userJSONBytes3))
  30101. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30102. utils.ErrorLog("解析失败:%v", err)
  30103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30104. return
  30105. }
  30106. if res2.Infcode == 0 {
  30107. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  30108. if err == nil {
  30109. c.ServeSuccessJSON(map[string]interface{}{
  30110. "msg": "撤销明细成功",
  30111. })
  30112. return
  30113. } else {
  30114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30115. return
  30116. }
  30117. } else {
  30118. c.ServeSuccessJSON(map[string]interface{}{
  30119. "failed_code": -10,
  30120. "msg": res2.ErrMsg,
  30121. })
  30122. }
  30123. } else {
  30124. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  30125. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30126. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  30127. resp2, requestErr2 := http.Get(api2)
  30128. if requestErr2 != nil {
  30129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30130. return
  30131. }
  30132. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  30133. if ioErr2 != nil {
  30134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  30135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30136. return
  30137. }
  30138. var respJSON2 map[string]interface{}
  30139. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  30140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30142. return
  30143. }
  30144. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30145. userJSONBytes3, _ := json.Marshal(respJSON2)
  30146. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30147. utils.ErrorLog("解析失败:%v", err)
  30148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30149. return
  30150. }
  30151. if res2.Infcode == -1 {
  30152. c.ServeSuccessJSON(map[string]interface{}{
  30153. "failed_code": -10,
  30154. "msg": res2.ErrMsg,
  30155. })
  30156. return
  30157. } else {
  30158. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  30159. if err == nil {
  30160. c.ServeSuccessJSON(map[string]interface{}{
  30161. "msg": "撤销明细成功",
  30162. })
  30163. return
  30164. } else {
  30165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30166. return
  30167. }
  30168. }
  30169. }
  30170. } else {
  30171. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  30172. if err == nil {
  30173. c.ServeSuccessJSON(map[string]interface{}{
  30174. "msg": "退费成功",
  30175. })
  30176. } else {
  30177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30178. return
  30179. }
  30180. }
  30181. }
  30182. // 对账
  30183. func (c *HisApiController) GetCheckAccount() {
  30184. start_time := c.GetString("start_time")
  30185. end_time := c.GetString("end_time")
  30186. insutype := c.GetString("insutype")
  30187. clr_type := c.GetString("clr_type")
  30188. clr_org := c.GetString("clr_optins")
  30189. admin_user_id, _ := c.GetInt64("admin_user_id")
  30190. adminUser := c.GetAdminUserInfo()
  30191. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30192. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30193. if len(clr_org) == 0 {
  30194. clr_org = miConfig.InsuplcAdmdvs
  30195. }
  30196. timeLayout := "2006-01-02"
  30197. loc, _ := time.LoadLocation("Local")
  30198. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30199. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30200. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  30201. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  30202. fixmedins_setl_cnt := int64(len(orders))
  30203. var medfee_sumamt float64
  30204. var acct_pay float64
  30205. var fund_pay_sumamt float64
  30206. for _, item := range orders {
  30207. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30208. acct_pay = acct_pay + item.AcctPay
  30209. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30210. }
  30211. var user_name string
  30212. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30213. if role.ID == 0 {
  30214. user_name = "xxx"
  30215. } else {
  30216. user_name = role.UserName
  30217. }
  30218. var res ResultEight
  30219. var res10188 ResultEightFor10188
  30220. if config.IsOpen == 1 {
  30221. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30222. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  30223. "insutype=" + insutype +
  30224. "&clr_type=" + clr_type +
  30225. "&setl_optins=" + clr_org +
  30226. "&stmt_begndate=" + start_time +
  30227. "&stm_enddate=" + end_time +
  30228. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30229. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30230. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30231. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  30232. "&fixmedins_code=" + miConfig.Code +
  30233. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30234. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30235. "&secret_key=" + miConfig.SecretKey +
  30236. "&org_name=" + miConfig.OrgName +
  30237. "&doctor=" + user_name +
  30238. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30239. fmt.Println(api)
  30240. resp, requestErr := http.Get(api)
  30241. if requestErr != nil {
  30242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30243. return
  30244. }
  30245. body, ioErr := ioutil.ReadAll(resp.Body)
  30246. fmt.Println(body)
  30247. if ioErr != nil {
  30248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30250. return
  30251. }
  30252. var respJSON map[string]interface{}
  30253. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30256. return
  30257. }
  30258. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30259. userJSONBytes, _ := json.Marshal(respJSON)
  30260. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30261. utils.ErrorLog("解析失败:%v", err)
  30262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30263. return
  30264. }
  30265. res.InfRefmsgid = res10188.InfRefmsgid
  30266. res.Output = res10188.Output
  30267. res.ErrMsg = res10188.ErrMsg
  30268. res.Cainfo = res10188.Cainfo
  30269. res.WarnMsg = res10188.WarnMsg
  30270. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  30271. res.Infcode = infocode
  30272. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30273. if clr_type != "9903" {
  30274. clr_type = "99" // 就诊 ID(来自2201接口返回)
  30275. }
  30276. if clr_type == "9903" {
  30277. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  30278. }
  30279. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  30280. "insutype=" + insutype +
  30281. "&clr_type=" + clr_type +
  30282. "&setl_optins=" + clr_org +
  30283. "&stmt_begndate=" + start_time +
  30284. "&stm_enddate=" + end_time +
  30285. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30286. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30287. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30288. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  30289. "&fixmedins_code=" + miConfig.Code +
  30290. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30291. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30292. "&secret_key=" + miConfig.SecretKey +
  30293. "&org_name=" + miConfig.OrgName +
  30294. "&doctor=" + user_name
  30295. resp, requestErr := http.Get(api)
  30296. if requestErr != nil {
  30297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30298. return
  30299. }
  30300. body, ioErr := ioutil.ReadAll(resp.Body)
  30301. if ioErr != nil {
  30302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30304. return
  30305. }
  30306. var respJSON map[string]interface{}
  30307. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30310. return
  30311. }
  30312. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30313. result, _ := json.Marshal(respJSON)
  30314. fmt.Println("log")
  30315. fmt.Println(string(result))
  30316. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  30317. utils.ErrorLog("解析失败:%v", err)
  30318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30319. return
  30320. }
  30321. res.InfRefmsgid = res10188.InfRefmsgid
  30322. res.Output = res10188.Output
  30323. res.ErrMsg = res10188.ErrMsg
  30324. res.Cainfo = res10188.Cainfo
  30325. res.WarnMsg = res10188.WarnMsg
  30326. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  30327. res.Infcode = infocode
  30328. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30329. var baseParams models.BaseParams
  30330. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  30331. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  30332. baseParams.SecretKey = miConfig.SecretKey
  30333. baseParams.OrgName = miConfig.OrgName
  30334. baseParams.FixmedinsCode = miConfig.Code
  30335. baseParams.EncKey = miConfig.EncKey
  30336. baseParams.AppSecret = miConfig.AppSecret
  30337. baseParams.SignKey = miConfig.SignKey
  30338. baseParams.AppID = miConfig.Code
  30339. baseParams.Doctor = role.UserName
  30340. baseParams.RequestUrl = miConfig.Url
  30341. businessParams := models.BusinessParams{
  30342. Insutype: insutype,
  30343. ClrType: clr_type,
  30344. SetlOptins: clr_org,
  30345. StmtBegndate: start_time,
  30346. StmtEnddate: end_time,
  30347. MedfeeSumamt: medfee_sumamt,
  30348. FundPaySumamt: fund_pay_sumamt,
  30349. AcctPay: acct_pay,
  30350. FixmedinsSetlCnt: fixmedins_setl_cnt,
  30351. }
  30352. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  30353. fmt.Println(requestLog)
  30354. fmt.Println(result)
  30355. fmt.Println(err_msg)
  30356. var dat map[string]interface{}
  30357. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30358. fmt.Println(dat)
  30359. } else {
  30360. fmt.Println(err)
  30361. }
  30362. userJSONBytes, _ := json.Marshal(dat)
  30363. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30364. utils.ErrorLog("解析失败:%v", err)
  30365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30366. return
  30367. }
  30368. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30369. var baseParams models.BaseParams
  30370. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  30371. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  30372. baseParams.SecretKey = miConfig.SecretKey
  30373. baseParams.OrgName = miConfig.OrgName
  30374. baseParams.FixmedinsCode = miConfig.Code
  30375. baseParams.EncKey = miConfig.EncKey
  30376. baseParams.AppSecret = miConfig.AppSecret
  30377. baseParams.SignKey = miConfig.SignKey
  30378. baseParams.AppID = miConfig.Code
  30379. baseParams.Doctor = role.UserName
  30380. baseParams.RequestUrl = miConfig.Url
  30381. baseParams.AccessKey = miConfig.AccessKey
  30382. businessParams := models.BusinessParams{
  30383. Insutype: insutype,
  30384. ClrType: clr_type,
  30385. SetlOptins: "430822",
  30386. StmtBegndate: start_time,
  30387. StmtEnddate: end_time,
  30388. MedfeeSumamt: medfee_sumamt,
  30389. FundPaySumamt: fund_pay_sumamt,
  30390. AcctPay: acct_pay,
  30391. FixmedinsSetlCnt: fixmedins_setl_cnt,
  30392. }
  30393. 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)
  30394. fmt.Println(requestLog)
  30395. fmt.Println(result)
  30396. var dat map[string]interface{}
  30397. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30398. fmt.Println(dat)
  30399. } else {
  30400. fmt.Println(err)
  30401. }
  30402. userJSONBytes, _ := json.Marshal(dat)
  30403. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30404. utils.ErrorLog("解析失败:%v", err)
  30405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30406. return
  30407. }
  30408. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30409. var baseParams models.BaseParams
  30410. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  30411. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  30412. baseParams.SecretKey = miConfig.SecretKey
  30413. baseParams.OrgName = miConfig.OrgName
  30414. baseParams.FixmedinsCode = miConfig.Code
  30415. baseParams.EncKey = miConfig.EncKey
  30416. baseParams.AppSecret = miConfig.AppSecret
  30417. baseParams.SignKey = miConfig.SignKey
  30418. baseParams.AppID = miConfig.Code
  30419. baseParams.Doctor = role.UserName
  30420. baseParams.RequestUrl = miConfig.Url
  30421. businessParams := models.BusinessParams{
  30422. Insutype: insutype,
  30423. ClrType: clr_type,
  30424. SetlOptins: clr_org,
  30425. StmtBegndate: start_time,
  30426. StmtEnddate: end_time,
  30427. MedfeeSumamt: medfee_sumamt,
  30428. FundPaySumamt: fund_pay_sumamt,
  30429. AcctPay: acct_pay,
  30430. FixmedinsSetlCnt: fixmedins_setl_cnt,
  30431. }
  30432. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  30433. fmt.Println(requestLog)
  30434. fmt.Println(result)
  30435. fmt.Println(err_msg)
  30436. var dat map[string]interface{}
  30437. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30438. fmt.Println(dat)
  30439. } else {
  30440. fmt.Println(err)
  30441. }
  30442. userJSONBytes, _ := json.Marshal(dat)
  30443. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30444. utils.ErrorLog("解析失败:%v", err)
  30445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30446. return
  30447. }
  30448. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30449. if len(clr_type) == 0 {
  30450. clr_type = "11"
  30451. }
  30452. api := miConfig.Url + "gdyb/ten?" +
  30453. "insutype=" + insutype +
  30454. "&clr_type=" + clr_type +
  30455. "&setl_optins=" + clr_org +
  30456. "&stmt_begndate=" + start_time +
  30457. "&stm_enddate=" + end_time +
  30458. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30459. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30460. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30461. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  30462. "&fixmedins_code=" + miConfig.Code +
  30463. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30464. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30465. "&secret_key=" + miConfig.SecretKey +
  30466. "&org_name=" + miConfig.OrgName +
  30467. "&doctor=" + user_name
  30468. fmt.Println(api)
  30469. resp, requestErr := http.Get(api)
  30470. if requestErr != nil {
  30471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30472. return
  30473. }
  30474. body, ioErr := ioutil.ReadAll(resp.Body)
  30475. fmt.Println(body)
  30476. if ioErr != nil {
  30477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30479. return
  30480. }
  30481. var respJSON map[string]interface{}
  30482. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30485. return
  30486. }
  30487. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30488. userJSONBytes, _ := json.Marshal(respJSON)
  30489. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30490. utils.ErrorLog("解析失败:%v", err)
  30491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30492. return
  30493. }
  30494. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30495. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  30496. fixmedins_setl_cnt := int64(len(orders_two))
  30497. var medfee_sumamt float64
  30498. var acct_pay float64
  30499. var fund_pay_sumamt float64
  30500. for _, item := range orders_two {
  30501. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30502. acct_pay = acct_pay + item.AcctPay
  30503. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30504. }
  30505. var baseParams models.BaseParams
  30506. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  30507. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  30508. baseParams.SecretKey = miConfig.SecretKey
  30509. baseParams.OrgName = miConfig.OrgName
  30510. baseParams.FixmedinsCode = miConfig.Code
  30511. baseParams.EncKey = miConfig.EncKey
  30512. baseParams.AppSecret = miConfig.AppSecret
  30513. baseParams.SignKey = miConfig.SignKey
  30514. baseParams.AppID = miConfig.Code
  30515. baseParams.Doctor = role.UserName
  30516. baseParams.RequestUrl = miConfig.Url
  30517. if clr_type == "9903" {
  30518. clr_type = "9994"
  30519. }
  30520. businessParams := models.BusinessParams{
  30521. Insutype: insutype,
  30522. ClrType: clr_type,
  30523. SetlOptins: "360302",
  30524. StmtBegndate: start_time,
  30525. StmtEnddate: end_time,
  30526. MedfeeSumamt: 0,
  30527. FundPaySumamt: 0,
  30528. AcctPay: 0,
  30529. FixmedinsSetlCnt: fixmedins_setl_cnt,
  30530. }
  30531. 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))
  30532. fmt.Println(requestLog)
  30533. fmt.Println(result)
  30534. var dat map[string]interface{}
  30535. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30536. fmt.Println(dat)
  30537. } else {
  30538. fmt.Println(err)
  30539. }
  30540. userJSONBytes, _ := json.Marshal(dat)
  30541. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30542. utils.ErrorLog("解析失败:%v", err)
  30543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30544. return
  30545. }
  30546. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30547. var api string
  30548. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  30549. "&clr_type=" + clr_type +
  30550. "&setl_optins=" + clr_org +
  30551. "&stmt_begndate=" + start_time +
  30552. "&stm_enddate=" + end_time +
  30553. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30554. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30555. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30556. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  30557. "&fixmedins_code=" + miConfig.Code +
  30558. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30559. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30560. "&secret_key=" + miConfig.SecretKey +
  30561. "&org_name=" + miConfig.OrgName +
  30562. "&doctor=" + user_name + "&url=" + miConfig.Url
  30563. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30564. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30565. resp, requestErr := http.Get(api)
  30566. if requestErr != nil {
  30567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30568. return
  30569. }
  30570. body, ioErr := ioutil.ReadAll(resp.Body)
  30571. if ioErr != nil {
  30572. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30574. return
  30575. }
  30576. var respJSON map[string]interface{}
  30577. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30578. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30580. return
  30581. }
  30582. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30583. if status == "0" {
  30584. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30585. c.ServeSuccessJSON(map[string]interface{}{
  30586. "failed_code": -10,
  30587. "msg": err_msg,
  30588. })
  30589. return
  30590. }
  30591. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30592. userJSONBytes, _ := json.Marshal(respJSON)
  30593. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30594. utils.ErrorLog("解析失败:%v", err)
  30595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30596. return
  30597. }
  30598. } else {
  30599. if len(clr_type) == 0 {
  30600. clr_type = "11"
  30601. }
  30602. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  30603. "insutype=" + insutype +
  30604. "&clr_type=" + clr_type +
  30605. "&setl_optins=" + clr_org +
  30606. "&stmt_begndate=" + start_time +
  30607. "&stm_enddate=" + end_time +
  30608. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30609. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30610. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30611. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  30612. "&fixmedins_code=" + miConfig.Code +
  30613. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30614. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30615. "&secret_key=" + miConfig.SecretKey +
  30616. "&org_name=" + miConfig.OrgName +
  30617. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  30618. fmt.Println(api)
  30619. resp, requestErr := http.Get(api)
  30620. if requestErr != nil {
  30621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30622. return
  30623. }
  30624. body, ioErr := ioutil.ReadAll(resp.Body)
  30625. fmt.Println(body)
  30626. if ioErr != nil {
  30627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30629. return
  30630. }
  30631. var respJSON map[string]interface{}
  30632. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30635. return
  30636. }
  30637. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30638. userJSONBytes, _ := json.Marshal(respJSON)
  30639. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30640. utils.ErrorLog("解析失败:%v", err)
  30641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30642. return
  30643. }
  30644. }
  30645. if res.Infcode == 0 {
  30646. if res.Output.Stmtinfo.StmtRslt == "0" {
  30647. micc := &models.MedicalInsuranceCostCompare{
  30648. StartTime: startime.Unix(),
  30649. EndTime: endtime.Unix(),
  30650. Insutype: insutype,
  30651. CheckType: 1,
  30652. Num: fixmedins_setl_cnt,
  30653. Mtime: time.Now().Unix(),
  30654. Status: 1,
  30655. UserOrgId: adminUser.CurrentOrgId,
  30656. CostTotal: medfee_sumamt,
  30657. FuncTotal: fund_pay_sumamt,
  30658. PsnPay: acct_pay,
  30659. Creator: admin_user_id,
  30660. Ctime: time.Now().Unix(),
  30661. ClrType: clr_type,
  30662. }
  30663. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  30664. if err == nil {
  30665. c.ServeSuccessJSON(map[string]interface{}{
  30666. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  30667. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  30668. })
  30669. } else {
  30670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30671. }
  30672. } else {
  30673. c.ServeSuccessJSON(map[string]interface{}{
  30674. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  30675. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  30676. })
  30677. }
  30678. } else {
  30679. c.ServeSuccessJSON(map[string]interface{}{
  30680. "failed_code": -10,
  30681. "msg": res.ErrMsg,
  30682. })
  30683. }
  30684. }
  30685. }
  30686. func (c *HisApiController) Check310() {
  30687. adminUser := c.GetAdminUserInfo()
  30688. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30689. var user_name string
  30690. user_name = "高慧裕"
  30691. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  30692. "insutype=" + "310" +
  30693. "&clr_type=" + "" +
  30694. "&setl_optins=" + "441202" +
  30695. "&stmt_begndate=" + "2022-03-01" +
  30696. "&stm_enddate=" + "2022-03-31" +
  30697. "&medfee_sumamt=" + "194930.12" +
  30698. "&fund_pay_sumamt=" + "188741.46" +
  30699. "&acct_pay=" + "0" +
  30700. "&fixmedins_setl_cnt=" + "452" +
  30701. "&fixmedins_code=" + miConfig.Code +
  30702. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30703. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30704. "&secret_key=" + miConfig.SecretKey +
  30705. "&org_name=" + miConfig.OrgName +
  30706. "&doctor=" + user_name
  30707. fmt.Println(api)
  30708. resp, requestErr := http.Get(api)
  30709. if requestErr != nil {
  30710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30711. return
  30712. }
  30713. body, ioErr := ioutil.ReadAll(resp.Body)
  30714. fmt.Println(body)
  30715. if ioErr != nil {
  30716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30718. return
  30719. }
  30720. var respJSON map[string]interface{}
  30721. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30724. return
  30725. }
  30726. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30727. userJSONBytes, _ := json.Marshal(respJSON)
  30728. var res ResultEight
  30729. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30730. utils.ErrorLog("解析失败:%v", err)
  30731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30732. return
  30733. }
  30734. }
  30735. func (c *HisApiController) Check390() {
  30736. adminUser := c.GetAdminUserInfo()
  30737. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30738. var user_name string
  30739. user_name = "高慧裕"
  30740. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  30741. "insutype=" + "390" +
  30742. "&clr_type=" + "" +
  30743. "&setl_optins=" + "441202" +
  30744. "&stmt_begndate=" + "2022-03-01" +
  30745. "&stm_enddate=" + "2022-03-31" +
  30746. "&medfee_sumamt=" + "1068448.89" +
  30747. "&fund_pay_sumamt=" + "1014677.62" +
  30748. "&acct_pay=" + "0" +
  30749. "&fixmedins_setl_cnt=" + "1950" +
  30750. "&fixmedins_code=" + miConfig.Code +
  30751. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30752. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30753. "&secret_key=" + miConfig.SecretKey +
  30754. "&org_name=" + miConfig.OrgName +
  30755. "&doctor=" + user_name
  30756. fmt.Println(api)
  30757. resp, requestErr := http.Get(api)
  30758. if requestErr != nil {
  30759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30760. return
  30761. }
  30762. body, ioErr := ioutil.ReadAll(resp.Body)
  30763. fmt.Println(body)
  30764. if ioErr != nil {
  30765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30767. return
  30768. }
  30769. var respJSON map[string]interface{}
  30770. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30771. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30773. return
  30774. }
  30775. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30776. userJSONBytes, _ := json.Marshal(respJSON)
  30777. var res ResultEight
  30778. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30779. utils.ErrorLog("解析失败:%v", err)
  30780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30781. return
  30782. }
  30783. }
  30784. // 对账明细
  30785. func (c *HisApiController) GetCheckDetailAccount() {
  30786. start_time := c.GetString("start_time")
  30787. end_time := c.GetString("end_time")
  30788. admin_user_id, _ := c.GetInt64("admin_user_id")
  30789. adminUser := c.GetAdminUserInfo()
  30790. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30791. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30792. timeLayout := "2006-01-02"
  30793. loc, _ := time.LoadLocation("Local")
  30794. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30795. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30796. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30797. rand.Seed(time.Now().UnixNano())
  30798. num := rand.Intn(30000)
  30799. Mkdir(miConfig.OrgName)
  30800. file := strconv.FormatInt(int64(num), 10)
  30801. file_name := file + ".txt"
  30802. zip_name := file + ".zip"
  30803. zip_path := miConfig.OrgName + "/" + zip_name
  30804. file_path := miConfig.OrgName + "/" + file_name
  30805. decimal.DivisionPrecision = 2
  30806. var medfee_sumamt float64
  30807. var psn_cash_pay float64
  30808. var fund_pay_sumamt float64
  30809. fixmedins_setl_cnt := int64(len(orders))
  30810. for _, item := range orders {
  30811. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30812. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  30813. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30814. }
  30815. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  30816. defer f.Close()
  30817. if err != nil {
  30818. fmt.Println(err.Error())
  30819. } else {
  30820. for _, item := range orders {
  30821. var refd_setl_flag string
  30822. if item.OrderStatus == 2 {
  30823. refd_setl_flag = "0"
  30824. var str string
  30825. str = item.SetlId + " " +
  30826. item.MdtrtId + " " +
  30827. item.PsnNo + " " +
  30828. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  30829. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  30830. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  30831. _, err = f.Write([]byte(str))
  30832. }
  30833. if item.OrderStatus == 3 {
  30834. var str string
  30835. str = item.SetlId + " " +
  30836. item.MdtrtId + " " +
  30837. item.PsnNo + " " +
  30838. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  30839. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  30840. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  30841. _, err = f.Write([]byte(str))
  30842. var str2 string
  30843. str2 = item.SetlId + " " +
  30844. item.MdtrtId + " " +
  30845. item.PsnNo + " " +
  30846. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  30847. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  30848. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  30849. _, err = f.Write([]byte(str2))
  30850. }
  30851. }
  30852. }
  30853. Zip(file_path, zip_path)
  30854. fmt.Println(ReadFile(zip_path))
  30855. fmt.Println(string(ReadFile(zip_path)))
  30856. if config.IsOpen == 1 {
  30857. var user_name string
  30858. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30859. if role.ID == 0 {
  30860. user_name = "管理员"
  30861. } else {
  30862. user_name = role.UserName
  30863. }
  30864. baseParams := models.BaseParams{
  30865. SecretKey: miConfig.SecretKey,
  30866. FixmedinsCode: miConfig.Code,
  30867. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  30868. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  30869. OrgName: miConfig.OrgName,
  30870. Doctor: user_name,
  30871. }
  30872. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  30873. var dat map[string]interface{}
  30874. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30875. fmt.Println(dat)
  30876. } else {
  30877. fmt.Println(err)
  30878. }
  30879. userJSONBytes, _ := json.Marshal(dat)
  30880. var res ResultNine
  30881. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30882. utils.ErrorLog("解析失败:%v", err)
  30883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30884. return
  30885. }
  30886. if res.Infcode == 0 {
  30887. fileNo := res.Output.FileQuryNo
  30888. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  30889. "file_qury_no=" + fileNo +
  30890. "&setl_optins=" + "定点医保中心" +
  30891. "&stmt_begndate=" + start_time +
  30892. "&stm_enddate=" + end_time +
  30893. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30894. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30895. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  30896. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  30897. "&fixmedins_code=" + miConfig.Code +
  30898. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30899. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30900. "&secret_key=" + miConfig.SecretKey +
  30901. "&org_name=" + miConfig.OrgName +
  30902. "&doctor=" + user_name
  30903. resp, requestErr := http.Get(api)
  30904. if requestErr != nil {
  30905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30906. return
  30907. }
  30908. body, ioErr := ioutil.ReadAll(resp.Body)
  30909. if ioErr != nil {
  30910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30912. return
  30913. }
  30914. var respJSON map[string]interface{}
  30915. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30918. return
  30919. }
  30920. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30921. userJSONBytes, _ := json.Marshal(respJSON)
  30922. var res ResultTen
  30923. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30924. utils.ErrorLog("解析失败:%v", err)
  30925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30926. return
  30927. }
  30928. if res.Infcode == 0 {
  30929. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  30930. micc := &models.MedicalInsuranceCostCompare{
  30931. StartTime: startime.Unix(),
  30932. EndTime: endtime.Unix(),
  30933. Insutype: "0",
  30934. CheckType: 2,
  30935. Num: fixmedins_setl_cnt,
  30936. Mtime: time.Now().Unix(),
  30937. Status: 1,
  30938. UserOrgId: adminUser.CurrentOrgId,
  30939. CostTotal: medfee_sumamt,
  30940. FuncTotal: fund_pay_sumamt,
  30941. PsnPay: psn_cash_pay,
  30942. Creator: admin_user_id,
  30943. Ctime: time.Now().Unix(),
  30944. }
  30945. service.CreateMedicalInsuranceCostCompareRecord(micc)
  30946. c.ServeSuccessJSON(map[string]interface{}{
  30947. "msg": "明细对账成功",
  30948. })
  30949. }
  30950. } else {
  30951. }
  30952. }
  30953. }
  30954. type CustomOrderInfo struct {
  30955. Name string
  30956. Spec string
  30957. Unit string
  30958. Count float64
  30959. Price float64
  30960. Total float64
  30961. }
  30962. func (c *HisApiController) GetBatchSettleAccounts() {
  30963. admin_user_id, _ := c.GetInt64("admin_user_id")
  30964. order_ids := c.GetString("order_ids")
  30965. order_ids_arr := strings.Split(order_ids, ",")
  30966. data3 := []map[string]interface{}{}
  30967. for _, item := range order_ids_arr {
  30968. id, _ := strconv.ParseInt(item, 10, 64)
  30969. order_id := id
  30970. adminUser := c.GetAdminUserInfo()
  30971. order, _ := service.GetHisOrderByID(order_id)
  30972. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  30973. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  30974. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  30975. orderInfos = append(orderInfos, orderInfos_two...)
  30976. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  30977. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  30978. var diagnosis_ids []string
  30979. if his.ID > 0 {
  30980. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  30981. } else {
  30982. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  30983. }
  30984. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  30985. var dia_config []*models.HisXtDiagnoseConfig
  30986. var name string
  30987. for _, item := range diagnosis_ids {
  30988. id, _ := strconv.ParseInt(item, 10, 64)
  30989. diagnosisConfig, _ := service.FindDiagnoseById(id)
  30990. dia_config = append(dia_config, &diagnosisConfig)
  30991. if len(name) == 0 {
  30992. name = diagnosisConfig.ClassName
  30993. }
  30994. //} else {
  30995. // name = name + "," + diagnosisConfig.ClassName
  30996. //}
  30997. }
  30998. var bedCostTotal float64 = 0 //床位总费
  30999. var bedCostSelfTotal float64 = 0 //床位自费
  31000. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  31001. var bedSelfTotal float64 = 0 //床位部分项目自费
  31002. var bedInscpTotal float64 = 0 //床位部分项目自费
  31003. var operationCostTotal float64 = 0 //手术费
  31004. var operationCostSelfTotal float64 = 0 //手术费
  31005. var operationCostPartSelfTotal float64 = 0 //手术费
  31006. var operationSelfTotal float64 = 0 //床位部分项目自费
  31007. var operationInscpTotal float64 = 0 //床位部分项目自费
  31008. var otherCostTotal float64 = 0 //其他费用
  31009. var otherCostSelfTotal float64 = 0 //其他费用
  31010. var otherCostPartSelfTotal float64 = 0 //其他费用
  31011. var otherSelfTotal float64 = 0 //床位部分项目自费
  31012. var otherInscpTotal float64 = 0 //床位部分项目自费
  31013. var materialCostTotal float64 = 0 //材料费
  31014. var materialCostSelfTotal float64 = 0 //材料费
  31015. var materialCostPartSelfTotal float64 = 0 //材料费
  31016. var materialSelfTotal float64 = 0 //床位部分项目自费
  31017. var materialInscpTotal float64 = 0 //床位部分项目自费
  31018. var westernMedicineCostTotal float64 = 0 //西药费
  31019. var westernMedicineCostSelfTotal float64 = 0 //西药费
  31020. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  31021. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  31022. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  31023. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  31024. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  31025. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  31026. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  31027. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  31028. var checkCostTotal float64 = 0 //检查费
  31029. var checkCostSelfTotal float64 = 0 //检查费
  31030. var checkCostPartSelfTotal float64 = 0 //检查费
  31031. var checkSelfTotal float64 = 0 //床位部分项目自费
  31032. var checkInscpTotal float64 = 0 //床位部分项目自费
  31033. var laboratoryCostTotal float64 = 0 //化验费
  31034. var laboratoryCostSelfTotal float64 = 0 //化验费
  31035. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  31036. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  31037. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  31038. var treatCostTotal float64 = 0 //治疗费用
  31039. var treatCostSelfTotal float64 = 0 //治疗费用
  31040. var treatCostPartSelfTotal float64 = 0 //治疗费用
  31041. var treatSelfTotal float64 = 0 //床位部分项目自费
  31042. var treatInscpTotal float64 = 0 //床位部分项目自费
  31043. decimal.DivisionPrecision = 2
  31044. for _, item := range orderInfos {
  31045. if item.MedChrgitmType == "01" { //床位费
  31046. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31047. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31048. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31049. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31050. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31051. }
  31052. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  31053. if item.MedChrgitmType == "03" { //检查费
  31054. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31055. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31056. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31057. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31058. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31059. }
  31060. } else {
  31061. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  31062. fmt.Println("------------")
  31063. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31064. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31065. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31066. }
  31067. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  31068. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31069. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31070. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31071. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31072. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31073. }
  31074. }
  31075. if item.MedChrgitmType == "04" { //化验费
  31076. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31077. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31078. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31079. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31080. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31081. }
  31082. if item.MedChrgitmType == "05" { //治疗费
  31083. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31084. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31085. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31086. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31087. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31088. }
  31089. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  31090. fmt.Println("------------")
  31091. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31092. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31093. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31094. }
  31095. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  31096. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31097. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31098. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31099. }
  31100. //if item.MedChrgitmType == "06" { //手术费
  31101. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31102. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31103. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31104. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31105. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31106. //
  31107. //}
  31108. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  31109. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31110. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31111. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31112. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31113. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31114. }
  31115. if item.MedChrgitmType == "09" { //西药费
  31116. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31117. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31118. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31119. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31120. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31121. }
  31122. if item.MedChrgitmType == "11" { //中成费
  31123. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31124. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31125. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31126. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31127. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31128. }
  31129. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  31130. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31131. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31132. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31133. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31134. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31135. }
  31136. }
  31137. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31138. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31139. var user_name string
  31140. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31141. if role.ID == 0 {
  31142. user_name = "管理员"
  31143. } else {
  31144. user_name = role.UserName
  31145. }
  31146. baseParams := models.BaseParams{
  31147. SecretKey: miConfig.SecretKey,
  31148. FixmedinsCode: miConfig.Code,
  31149. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  31150. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  31151. OrgName: miConfig.OrgName,
  31152. Doctor: user_name,
  31153. RequestUrl: miConfig.Url,
  31154. AccessKey: miConfig.AccessKey,
  31155. }
  31156. businessParams := models.BusinessParams{
  31157. PsnNo: order.PsnNo,
  31158. MdtrtId: order.MdtrtId,
  31159. SetlId: order.SetlId,
  31160. }
  31161. var res ResultEleven
  31162. var resEleven10265 ResultEleven10265
  31163. if config.IsOpen == 1 {
  31164. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  31165. result := service.Gdyb5203(baseParams, businessParams)
  31166. service.Gdyb5204(baseParams, businessParams)
  31167. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  31168. var dat map[string]interface{}
  31169. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31170. fmt.Println(dat)
  31171. } else {
  31172. fmt.Println(err)
  31173. }
  31174. userJSONBytes, _ := json.Marshal(dat)
  31175. if miConfig.Code == "H15049901371" {
  31176. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  31177. utils.ErrorLog("解析失败:%v", err)
  31178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31179. return
  31180. }
  31181. res.InfRefmsgid = resEleven10265.InfRefmsgid
  31182. res.Output = resEleven10265.Output
  31183. res.ErrMsg = resEleven10265.ErrMsg
  31184. res.Cainfo = resEleven10265.Cainfo
  31185. res.WarnMsg = resEleven10265.WarnMsg
  31186. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  31187. res.Infcode = infocode
  31188. } else {
  31189. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31190. utils.ErrorLog("解析失败:%v", err)
  31191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31192. return
  31193. }
  31194. }
  31195. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31196. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  31197. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  31198. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  31199. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  31200. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31201. var doctor_name string
  31202. if roles.ID == 0 {
  31203. doctor_name = "管理员"
  31204. } else {
  31205. doctor_name = roles.UserName
  31206. }
  31207. yiliao_leibie := ""
  31208. switch order.MedType {
  31209. case "11":
  31210. yiliao_leibie = "普通门诊"
  31211. break
  31212. case "12":
  31213. yiliao_leibie = "门诊挂号"
  31214. break
  31215. case "13":
  31216. yiliao_leibie = "急诊"
  31217. break
  31218. case "14":
  31219. yiliao_leibie = "门诊特殊病"
  31220. break
  31221. case "15":
  31222. yiliao_leibie = "门诊统筹"
  31223. break
  31224. case "16":
  31225. yiliao_leibie = "门诊慢性病"
  31226. break
  31227. case "21":
  31228. yiliao_leibie = "普通住院"
  31229. break
  31230. }
  31231. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  31232. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  31233. if res.Infcode == 0 {
  31234. data2 := map[string]interface{}{
  31235. "diagnosis": name,
  31236. "order_infos": orderInfos,
  31237. "number": order.MdtrtId,
  31238. "date": order.SettleAccountsDate,
  31239. "charge_admin": charge_admin,
  31240. "printor_admin": printor_admin,
  31241. "info": res.Output.Setlinfo,
  31242. "order": order,
  31243. "bedCostTotal": bedCostTotal,
  31244. "bedCostSelfTotal": bedCostSelfTotal,
  31245. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  31246. "bedSelfTotal": bedSelfTotal,
  31247. "bedInscpTotal": bedInscpTotal,
  31248. "operationCostTotal": operationCostTotal,
  31249. "operationCostSelfTotal": operationCostSelfTotal,
  31250. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  31251. "operationSelfTotal": operationSelfTotal,
  31252. "operationInscpTotal": operationInscpTotal,
  31253. "otherCostTotal": otherCostTotal,
  31254. "otherCostSelfTotal": otherCostSelfTotal,
  31255. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  31256. "otherSelfTotal": otherSelfTotal,
  31257. "otherInscpTotal": otherInscpTotal,
  31258. "materialCostTotal": materialCostTotal,
  31259. "materialCostSelfTotal": materialCostSelfTotal,
  31260. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  31261. "materialSelfTotal": materialSelfTotal,
  31262. "materialInscpTotal": materialInscpTotal,
  31263. "westernMedicineCostTotal": westernMedicineCostTotal,
  31264. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  31265. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  31266. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  31267. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  31268. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  31269. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  31270. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  31271. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  31272. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  31273. "checkCostTotal": checkCostTotal,
  31274. "checkCostSelfTotal": checkCostSelfTotal,
  31275. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  31276. "checkSelfTotal": checkSelfTotal,
  31277. "checkInscpTotal": checkInscpTotal,
  31278. "laboratoryCostTotal": laboratoryCostTotal,
  31279. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  31280. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  31281. "laboratorySelfTotal": laboratorySelfTotal,
  31282. "laboratoryInscpTotal": laboratoryInscpTotal,
  31283. "treatCostTotal": treatCostTotal,
  31284. "treatCostSelfTotal": treatCostSelfTotal,
  31285. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  31286. "treatSelfTotal": treatSelfTotal,
  31287. "treatInscpTotal": treatInscpTotal,
  31288. "doctor_info": doctor_info,
  31289. "doctor_code": adminRole_two.DoctorCode,
  31290. "doctor_name": doctor_name,
  31291. "health_card_no": order.PsnNo,
  31292. "department": departments.Name,
  31293. "yiliao_leibie": yiliao_leibie,
  31294. "after_money": order.AccountPrice,
  31295. "patient": patient,
  31296. "org_name": miConfig.OrgName,
  31297. "org_code": miConfig.Code,
  31298. "order_number": order.Number,
  31299. "his_hospital": his_hospital,
  31300. "his": his,
  31301. "dia_config": dia_config,
  31302. "psn_cash_pay": order.PsnCashPay,
  31303. //"check_order_info": cus_slice,
  31304. }
  31305. data3 = append(data3, data2)
  31306. }
  31307. }
  31308. }
  31309. c.ServeSuccessJSON(map[string]interface{}{
  31310. "infos": data3,
  31311. })
  31312. }
  31313. func (c *HisApiController) GetSettleAccounts() {
  31314. //id, _ := c.GetInt64("id")
  31315. //record_time := c.GetString("record_time")
  31316. order_id, _ := c.GetInt64("order_id")
  31317. admin_user_id, _ := c.GetInt64("admin_user_id")
  31318. //timeLayout := "2006-01-02"
  31319. //loc, _ := time.LoadLocation("Local")
  31320. //
  31321. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  31322. //if err != nil {
  31323. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31324. // return
  31325. //}Hbyb5203
  31326. //recordDateTime := theTime.Unix()
  31327. adminUser := c.GetAdminUserInfo()
  31328. order, _ := service.GetHisOrderByID(order_id)
  31329. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31330. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  31331. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  31332. orderInfos = append(orderInfos, orderInfos_two...)
  31333. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  31334. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  31335. var diagnosis_ids []string
  31336. if his.ID > 0 {
  31337. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  31338. } else {
  31339. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  31340. }
  31341. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  31342. var dia_config []*models.HisXtDiagnoseConfig
  31343. var name string
  31344. for _, item := range diagnosis_ids {
  31345. id, _ := strconv.ParseInt(item, 10, 64)
  31346. diagnosisConfig, _ := service.FindDiagnoseById(id)
  31347. dia_config = append(dia_config, &diagnosisConfig)
  31348. if len(name) == 0 {
  31349. name = diagnosisConfig.ClassName
  31350. } else {
  31351. name = name + "," + diagnosisConfig.ClassName
  31352. }
  31353. }
  31354. if patient.UserOrgId == 10215 {
  31355. name = "慢性肾功能不全(血透治疗)"
  31356. }
  31357. var bedCostTotal float64 = 0 //床位总费
  31358. var bedCostSelfTotal float64 = 0 //床位自费
  31359. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  31360. var bedSelfTotal float64 = 0 //床位部分项目自费
  31361. var bedInscpTotal float64 = 0 //床位部分项目自费
  31362. var operationCostTotal float64 = 0 //手术费
  31363. var operationCostSelfTotal float64 = 0 //手术费
  31364. var operationCostPartSelfTotal float64 = 0 //手术费
  31365. var operationSelfTotal float64 = 0 //床位部分项目自费
  31366. var operationInscpTotal float64 = 0 //床位部分项目自费
  31367. var otherCostTotal float64 = 0 //其他费用
  31368. var otherCostSelfTotal float64 = 0 //其他费用
  31369. var otherCostPartSelfTotal float64 = 0 //其他费用
  31370. var otherSelfTotal float64 = 0 //床位部分项目自费
  31371. var otherInscpTotal float64 = 0 //床位部分项目自费
  31372. var materialCostTotal float64 = 0 //材料费
  31373. var materialCostSelfTotal float64 = 0 //材料费
  31374. var materialCostPartSelfTotal float64 = 0 //材料费
  31375. var materialSelfTotal float64 = 0 //床位部分项目自费
  31376. var materialInscpTotal float64 = 0 //床位部分项目自费
  31377. var westernMedicineCostTotal float64 = 0 //西药费
  31378. var westernMedicineCostSelfTotal float64 = 0 //西药费
  31379. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  31380. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  31381. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  31382. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  31383. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  31384. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  31385. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  31386. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  31387. var checkCostTotal float64 = 0 //检查费
  31388. var checkCostSelfTotal float64 = 0 //检查费
  31389. var checkCostPartSelfTotal float64 = 0 //检查费
  31390. var checkSelfTotal float64 = 0 //床位部分项目自费
  31391. var checkInscpTotal float64 = 0 //床位部分项目自费
  31392. var laboratoryCostTotal float64 = 0 //化验费
  31393. var laboratoryCostSelfTotal float64 = 0 //化验费
  31394. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  31395. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  31396. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  31397. var treatCostTotal float64 = 0 //治疗费用
  31398. var treatCostSelfTotal float64 = 0 //治疗费用
  31399. var treatCostPartSelfTotal float64 = 0 //治疗费用
  31400. var treatSelfTotal float64 = 0 //床位部分项目自费
  31401. var treatInscpTotal float64 = 0 //床位部分项目自费
  31402. var zcCostTotal float64 = 0 //治疗费用
  31403. var zcCostSelfTotal float64 = 0 //治疗费用
  31404. var zcCostPartSelfTotal float64 = 0 //治疗费用
  31405. var zcSelfTotal float64 = 0 //床位部分项目自费
  31406. var zcInscpTotal float64 = 0 //床位部分项目自费
  31407. var huliCostTotal float64 = 0 //治疗费用
  31408. var huliCostSelfTotal float64 = 0 //治疗费用
  31409. var huliCostPartSelfTotal float64 = 0 //治疗费用
  31410. var huliSelfTotal float64 = 0 //床位部分项目自费
  31411. var huliInscpTotal float64 = 0 //床位部分项目自费
  31412. decimal.DivisionPrecision = 2
  31413. for _, item := range orderInfos {
  31414. if item.MedChrgitmType == "01" { //床位费
  31415. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31416. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31417. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31418. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31419. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31420. }
  31421. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  31422. if item.MedChrgitmType == "03" { //检查费
  31423. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31424. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31425. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31426. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31427. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31428. }
  31429. } else {
  31430. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  31431. fmt.Println("------------")
  31432. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31433. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31434. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31435. }
  31436. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  31437. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31438. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31439. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31440. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31441. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31442. }
  31443. }
  31444. if item.MedChrgitmType == "04" { //化验费
  31445. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31446. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31447. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31448. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31449. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31450. }
  31451. if item.MedChrgitmType == "05" { //治疗费
  31452. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31453. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31454. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31455. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31456. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31457. }
  31458. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  31459. fmt.Println("------------")
  31460. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31461. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31462. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31463. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31464. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31465. }
  31466. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  31467. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31468. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31469. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31470. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31471. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31472. }
  31473. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  31474. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31475. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31476. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31477. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31478. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31479. }
  31480. if item.MedChrgitmType == "09" { //西药费
  31481. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31482. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31483. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31484. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31485. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31486. }
  31487. if item.MedChrgitmType == "11" { //中成费
  31488. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31489. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31490. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31491. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31492. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31493. }
  31494. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  31495. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31496. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31497. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31498. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31499. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31500. }
  31501. if item.MedChrgitmType == "02" { //其他费
  31502. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31503. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31504. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31505. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31506. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31507. }
  31508. if item.MedChrgitmType == "07" { //其他费
  31509. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31510. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31511. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31512. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31513. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31514. }
  31515. }
  31516. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31517. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31518. var user_name string
  31519. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31520. if role.ID == 0 {
  31521. user_name = "管理员"
  31522. } else {
  31523. user_name = role.UserName
  31524. }
  31525. baseParams := models.BaseParams{
  31526. SecretKey: miConfig.SecretKey,
  31527. FixmedinsCode: miConfig.Code,
  31528. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  31529. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  31530. OrgName: miConfig.OrgName,
  31531. Doctor: user_name,
  31532. RequestUrl: miConfig.Url,
  31533. AccessKey: miConfig.AccessKey,
  31534. }
  31535. businessParams := models.BusinessParams{
  31536. PsnNo: order.PsnNo,
  31537. MdtrtId: order.MdtrtId,
  31538. SetlId: order.SetlId,
  31539. }
  31540. var res ResultEleven
  31541. var resah ResultElevenah
  31542. var resEleven10265 ResultEleven10265
  31543. if config.IsOpen == 1 {
  31544. if miConfig.MdtrtareaAdmvs == "421300" {
  31545. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31546. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31547. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  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), &res); err != nil {
  31570. utils.ErrorLog("解析失败:%v", err)
  31571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31572. return
  31573. }
  31574. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31575. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31576. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31577. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31578. resp, requestErr := http.Get(api)
  31579. if requestErr != nil {
  31580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31581. return
  31582. }
  31583. body, ioErr := ioutil.ReadAll(resp.Body)
  31584. if ioErr != nil {
  31585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31587. return
  31588. }
  31589. var respJSON map[string]interface{}
  31590. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31593. return
  31594. }
  31595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31596. result, _ := json.Marshal(respJSON)
  31597. fmt.Println("log")
  31598. fmt.Println(string(result))
  31599. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31600. utils.ErrorLog("解析失败:%v", err)
  31601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31602. return
  31603. }
  31604. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31605. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31606. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31607. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31608. resp, requestErr := http.Get(api)
  31609. if requestErr != nil {
  31610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31611. return
  31612. }
  31613. body, ioErr := ioutil.ReadAll(resp.Body)
  31614. if ioErr != nil {
  31615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31617. return
  31618. }
  31619. var respJSON map[string]interface{}
  31620. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31623. return
  31624. }
  31625. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31626. result, _ := json.Marshal(respJSON)
  31627. fmt.Println("log")
  31628. fmt.Println(string(result))
  31629. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31630. utils.ErrorLog("解析失败:%v", err)
  31631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31632. return
  31633. }
  31634. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31635. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31636. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31637. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  31638. resp, requestErr := http.Get(api)
  31639. if requestErr != nil {
  31640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31641. return
  31642. }
  31643. body, ioErr := ioutil.ReadAll(resp.Body)
  31644. if ioErr != nil {
  31645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31647. return
  31648. }
  31649. var respJSON map[string]interface{}
  31650. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31653. return
  31654. }
  31655. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31656. result, _ := json.Marshal(respJSON)
  31657. fmt.Println("log")
  31658. fmt.Println(string(result))
  31659. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31660. utils.ErrorLog("解析失败:%v", err)
  31661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31662. return
  31663. }
  31664. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31665. var api string
  31666. if miConfig.MdtrtareaAdmvs == "320921" {
  31667. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31668. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31669. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31670. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31671. } else {
  31672. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31673. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31674. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31675. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31676. }
  31677. resp, requestErr := http.Get(api)
  31678. if requestErr != nil {
  31679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31680. return
  31681. }
  31682. body, ioErr := ioutil.ReadAll(resp.Body)
  31683. if ioErr != nil {
  31684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31686. return
  31687. }
  31688. var respJSON map[string]interface{}
  31689. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31692. return
  31693. }
  31694. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31695. result, _ := json.Marshal(respJSON)
  31696. fmt.Println("log")
  31697. fmt.Println(string(result))
  31698. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  31699. utils.ErrorLog("解析失败:%v", err)
  31700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31701. return
  31702. }
  31703. res.InfRefmsgid = resEleven10265.InfRefmsgid
  31704. res.Output = resEleven10265.Output
  31705. res.ErrMsg = resEleven10265.ErrMsg
  31706. res.Cainfo = resEleven10265.Cainfo
  31707. res.WarnMsg = resEleven10265.WarnMsg
  31708. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  31709. res.Infcode = infocode
  31710. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31711. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  31712. saveLog(result, requestLog, "5203", "结算单")
  31713. var dat map[string]interface{}
  31714. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31715. fmt.Println(dat)
  31716. } else {
  31717. fmt.Println(err)
  31718. }
  31719. userJSONBytes, _ := json.Marshal(dat)
  31720. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31721. utils.ErrorLog("解析失败:%v", err)
  31722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31723. return
  31724. }
  31725. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31726. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  31727. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  31728. fmt.Println(result3)
  31729. fmt.Println(requestLog3)
  31730. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  31731. fmt.Println(result2)
  31732. fmt.Println(requestLog2)
  31733. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  31734. saveLog(result, requestLog, "5203", "结算单")
  31735. var dat map[string]interface{}
  31736. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31737. fmt.Println(dat)
  31738. } else {
  31739. fmt.Println(err)
  31740. }
  31741. userJSONBytes, _ := json.Marshal(dat)
  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 == "341203" {
  31748. var api string
  31749. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31750. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31751. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31752. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31753. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31754. resp, requestErr := http.Get(api)
  31755. if requestErr != nil {
  31756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31757. return
  31758. }
  31759. body, ioErr := ioutil.ReadAll(resp.Body)
  31760. if ioErr != nil {
  31761. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31763. return
  31764. }
  31765. var respJSON map[string]interface{}
  31766. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31769. return
  31770. }
  31771. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31772. if status == "0" {
  31773. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31774. c.ServeSuccessJSON(map[string]interface{}{
  31775. "failed_code": -10,
  31776. "msg": err_msg,
  31777. })
  31778. return
  31779. }
  31780. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31781. result, _ := json.Marshal(respJSON)
  31782. fmt.Println("log")
  31783. fmt.Println(string(result))
  31784. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  31785. utils.ErrorLog("解析失败:%v", err)
  31786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31787. return
  31788. }
  31789. res.InfRefmsgid = resah.InfRefmsgid
  31790. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31791. // 创建对应的Time类型
  31792. t := time.UnixMilli(timestamp)
  31793. // 格式化成指定的日期字符串
  31794. str := t.Format("2006-01-02 15:04:05")
  31795. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31796. // 创建对应的Time类型
  31797. t3 := time.UnixMilli(timestamp2)
  31798. // 格式化成指定的日期字符串
  31799. str2 := t3.Format("2006-01-02 15:04:05")
  31800. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  31801. // 创建对应的Time类型
  31802. t4 := time.UnixMilli(timestamp3)
  31803. // 格式化成指定的日期字符串
  31804. str3 := t4.Format("2006-01-02 15:04:05")
  31805. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  31806. // 创建对应的Time类型
  31807. t5 := time.UnixMilli(timestamp4)
  31808. // 格式化成指定的日期字符串
  31809. str5 := t5.Format("2006-01-02 15:04:05")
  31810. res.Output.Setlinfo.Brdy = str2
  31811. res.Output.Setlinfo.SetlTime = str
  31812. res.Output.Setlinfo.Begndate = str3
  31813. res.Output.Setlinfo.Enddate = str5
  31814. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  31815. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  31816. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  31817. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  31818. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  31819. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  31820. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  31821. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  31822. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  31823. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  31824. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  31825. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  31826. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31827. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  31828. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  31829. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  31830. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  31831. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  31832. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  31833. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  31834. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  31835. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  31836. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  31837. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  31838. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  31839. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31840. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  31841. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  31842. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  31843. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  31844. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31845. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  31846. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  31847. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  31848. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  31849. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  31850. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  31851. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  31852. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  31853. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  31854. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  31855. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  31856. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  31857. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  31858. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  31859. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31860. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  31861. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  31862. //res.Output.Setldetail = resah.Output.Setldetail
  31863. res.ErrMsg = resah.ErrMsg
  31864. res.Cainfo = resah.Cainfo
  31865. res.WarnMsg = resah.WarnMsg
  31866. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31867. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  31868. saveLog(result, requestLog, "5203", "结算单")
  31869. var dat map[string]interface{}
  31870. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31871. fmt.Println(dat)
  31872. } else {
  31873. fmt.Println(err)
  31874. }
  31875. userJSONBytes, _ := json.Marshal(dat)
  31876. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31877. utils.ErrorLog("解析失败:%v", err)
  31878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31879. return
  31880. }
  31881. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31882. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31883. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31884. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31885. resp, requestErr := http.Get(api)
  31886. if requestErr != nil {
  31887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31888. return
  31889. }
  31890. body, ioErr := ioutil.ReadAll(resp.Body)
  31891. if ioErr != nil {
  31892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31894. return
  31895. }
  31896. var respJSON map[string]interface{}
  31897. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31900. return
  31901. }
  31902. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31903. result, _ := json.Marshal(respJSON)
  31904. fmt.Println("log")
  31905. fmt.Println(string(result))
  31906. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  31907. utils.ErrorLog("解析失败:%v", err)
  31908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31909. return
  31910. }
  31911. res.InfRefmsgid = resEleven10265.InfRefmsgid
  31912. res.Output = resEleven10265.Output
  31913. res.ErrMsg = resEleven10265.ErrMsg
  31914. res.Cainfo = resEleven10265.Cainfo
  31915. res.WarnMsg = resEleven10265.WarnMsg
  31916. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  31917. res.Infcode = infocode
  31918. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31919. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31920. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31921. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31922. resp, requestErr := http.Get(api)
  31923. if requestErr != nil {
  31924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31925. return
  31926. }
  31927. body, ioErr := ioutil.ReadAll(resp.Body)
  31928. if ioErr != nil {
  31929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31931. return
  31932. }
  31933. var respJSON map[string]interface{}
  31934. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31937. return
  31938. }
  31939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31940. result, _ := json.Marshal(respJSON)
  31941. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31942. utils.ErrorLog("解析失败:%v", err)
  31943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31944. return
  31945. }
  31946. } else if miConfig.MdtrtareaAdmvs == "450721" {
  31947. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  31948. //return
  31949. } else {
  31950. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31951. if len(his.InsuplcAdmdvs) == 0 {
  31952. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  31953. } else {
  31954. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  31955. }
  31956. result := service.Gdyb5203(baseParams, businessParams)
  31957. //service.Gdyb5204(baseParams, businessParams)
  31958. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  31959. var dat map[string]interface{}
  31960. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31961. fmt.Println(dat)
  31962. } else {
  31963. fmt.Println(err)
  31964. }
  31965. userJSONBytes, _ := json.Marshal(dat)
  31966. if miConfig.Code == "H15049901371" {
  31967. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  31968. utils.ErrorLog("解析失败:%v", err)
  31969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31970. return
  31971. }
  31972. res.InfRefmsgid = resEleven10265.InfRefmsgid
  31973. res.Output = resEleven10265.Output
  31974. res.ErrMsg = resEleven10265.ErrMsg
  31975. res.Cainfo = resEleven10265.Cainfo
  31976. res.WarnMsg = resEleven10265.WarnMsg
  31977. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  31978. res.Infcode = infocode
  31979. } else {
  31980. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31981. utils.ErrorLog("解析失败:%v", err)
  31982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31983. return
  31984. }
  31985. }
  31986. }
  31987. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31988. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  31989. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  31990. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  31991. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  31992. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31993. var doctor_name string
  31994. if roles.ID == 0 {
  31995. doctor_name = "管理员"
  31996. } else {
  31997. doctor_name = roles.UserName
  31998. }
  31999. yiliao_leibie := ""
  32000. switch order.MedType {
  32001. case "11":
  32002. yiliao_leibie = "普通门诊"
  32003. break
  32004. case "12":
  32005. yiliao_leibie = "门诊挂号"
  32006. break
  32007. case "13":
  32008. yiliao_leibie = "急诊"
  32009. break
  32010. case "14":
  32011. yiliao_leibie = "门诊特殊病"
  32012. break
  32013. case "15":
  32014. yiliao_leibie = "门诊统筹"
  32015. break
  32016. case "16":
  32017. yiliao_leibie = "门诊慢性病"
  32018. break
  32019. case "21":
  32020. yiliao_leibie = "普通住院"
  32021. break
  32022. }
  32023. //var rf []CustomFundPay
  32024. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  32025. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  32026. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  32027. if res.Infcode == 0 {
  32028. 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 {
  32029. c.ServeSuccessJSON(map[string]interface{}{
  32030. "diagnosis": name,
  32031. "order_infos": orderInfos,
  32032. "number": order.MdtrtId,
  32033. "date": order.SettleAccountsDate,
  32034. "charge_admin": charge_admin,
  32035. "printor_admin": printor_admin,
  32036. "info": res.Output.Setlinfo,
  32037. "order": order,
  32038. "bedCostTotal": bedCostTotal,
  32039. "bedCostSelfTotal": bedCostSelfTotal,
  32040. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  32041. "bedSelfTotal": bedSelfTotal,
  32042. "bedInscpTotal": bedInscpTotal,
  32043. "operationCostTotal": operationCostTotal,
  32044. "operationCostSelfTotal": operationCostSelfTotal,
  32045. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  32046. "operationSelfTotal": operationSelfTotal,
  32047. "operationInscpTotal": operationInscpTotal,
  32048. "otherCostTotal": otherCostTotal,
  32049. "otherCostSelfTotal": otherCostSelfTotal,
  32050. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  32051. "otherSelfTotal": otherSelfTotal,
  32052. "otherInscpTotal": otherInscpTotal,
  32053. "materialCostTotal": materialCostTotal,
  32054. "materialCostSelfTotal": materialCostSelfTotal,
  32055. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  32056. "materialSelfTotal": materialSelfTotal,
  32057. "materialInscpTotal": materialInscpTotal,
  32058. "westernMedicineCostTotal": westernMedicineCostTotal,
  32059. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  32060. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  32061. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  32062. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  32063. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  32064. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  32065. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  32066. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  32067. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  32068. "checkCostTotal": checkCostTotal,
  32069. "checkCostSelfTotal": checkCostSelfTotal,
  32070. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  32071. "checkSelfTotal": checkSelfTotal,
  32072. "checkInscpTotal": checkInscpTotal,
  32073. "laboratoryCostTotal": laboratoryCostTotal,
  32074. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  32075. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  32076. "laboratorySelfTotal": laboratorySelfTotal,
  32077. "laboratoryInscpTotal": laboratoryInscpTotal,
  32078. "treatCostTotal": treatCostTotal,
  32079. "treatCostSelfTotal": treatCostSelfTotal,
  32080. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  32081. "treatSelfTotal": treatSelfTotal,
  32082. "treatInscpTotal": treatInscpTotal,
  32083. "doctor_info": doctor_info,
  32084. "doctor_code": adminRole_two.DoctorCode,
  32085. "doctor_name": doctor_name,
  32086. "health_card_no": order.PsnNo,
  32087. "department": departments.Name,
  32088. "yiliao_leibie": yiliao_leibie,
  32089. "after_money": order.AccountPrice,
  32090. "patient": patient,
  32091. "org_name": miConfig.OrgName,
  32092. "org_code": miConfig.Code,
  32093. "order_number": order.Number,
  32094. "his_hospital": his_hospital,
  32095. "his": his,
  32096. "dia_config": dia_config,
  32097. "psn_cash_pay": order.PsnCashPay,
  32098. "zcCostTotal": zcCostTotal,
  32099. "zcCostSelfTotal": zcCostSelfTotal,
  32100. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  32101. "zcSelfTotal": zcSelfTotal,
  32102. "zcInscpTotal": zcInscpTotal,
  32103. "huliCostTotal": huliCostTotal,
  32104. "huliCostSelfTotal": huliCostSelfTotal,
  32105. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  32106. "huliSelfTotal": huliSelfTotal,
  32107. "huliInscpTotal": huliInscpTotal,
  32108. //"funds": rf,
  32109. //"check_order_info": cus_slice,
  32110. })
  32111. } else {
  32112. c.ServeSuccessJSON(map[string]interface{}{
  32113. "diagnosis": name,
  32114. "order_infos": orderInfos,
  32115. "number": order.MdtrtId,
  32116. "date": order.SettleAccountsDate,
  32117. "charge_admin": charge_admin,
  32118. "printor_admin": printor_admin,
  32119. "info": order,
  32120. "order": order,
  32121. "bedCostTotal": bedCostTotal,
  32122. "bedCostSelfTotal": bedCostSelfTotal,
  32123. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  32124. "bedSelfTotal": bedSelfTotal,
  32125. "bedInscpTotal": bedInscpTotal,
  32126. "operationCostTotal": operationCostTotal,
  32127. "operationCostSelfTotal": operationCostSelfTotal,
  32128. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  32129. "operationSelfTotal": operationSelfTotal,
  32130. "operationInscpTotal": operationInscpTotal,
  32131. "otherCostTotal": otherCostTotal,
  32132. "otherCostSelfTotal": otherCostSelfTotal,
  32133. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  32134. "otherSelfTotal": otherSelfTotal,
  32135. "otherInscpTotal": otherInscpTotal,
  32136. "materialCostTotal": materialCostTotal,
  32137. "materialCostSelfTotal": materialCostSelfTotal,
  32138. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  32139. "materialSelfTotal": materialSelfTotal,
  32140. "materialInscpTotal": materialInscpTotal,
  32141. "westernMedicineCostTotal": westernMedicineCostTotal,
  32142. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  32143. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  32144. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  32145. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  32146. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  32147. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  32148. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  32149. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  32150. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  32151. "checkCostTotal": checkCostTotal,
  32152. "checkCostSelfTotal": checkCostSelfTotal,
  32153. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  32154. "checkSelfTotal": checkSelfTotal,
  32155. "checkInscpTotal": checkInscpTotal,
  32156. "laboratoryCostTotal": laboratoryCostTotal,
  32157. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  32158. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  32159. "laboratorySelfTotal": laboratorySelfTotal,
  32160. "laboratoryInscpTotal": laboratoryInscpTotal,
  32161. "treatCostTotal": treatCostTotal,
  32162. "treatCostSelfTotal": treatCostSelfTotal,
  32163. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  32164. "treatSelfTotal": treatSelfTotal,
  32165. "treatInscpTotal": treatInscpTotal,
  32166. "doctor_info": doctor_info,
  32167. "doctor_code": adminRole_two.DoctorCode,
  32168. "doctor_name": doctor_name,
  32169. "health_card_no": order.PsnNo,
  32170. "department": departments.Name,
  32171. "yiliao_leibie": yiliao_leibie,
  32172. "after_money": order.AccountPrice,
  32173. "patient": patient,
  32174. "org_name": miConfig.OrgName,
  32175. "org_code": miConfig.Code,
  32176. "order_number": order.Number,
  32177. "his_hospital": his_hospital,
  32178. "his": his,
  32179. "dia_config": dia_config,
  32180. "psn_cash_pay": order.PsnCashPay,
  32181. "zcCostTotal": zcCostTotal,
  32182. "zcCostSelfTotal": zcCostSelfTotal,
  32183. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  32184. "zcSelfTotal": zcSelfTotal,
  32185. "zcInscpTotal": zcInscpTotal,
  32186. "huliCostTotal": huliCostTotal,
  32187. "huliCostSelfTotal": huliCostSelfTotal,
  32188. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  32189. "huliSelfTotal": huliSelfTotal,
  32190. "huliInscpTotal": huliInscpTotal,
  32191. //"funds": rf,
  32192. //"check_order_info": cus_slice,
  32193. })
  32194. }
  32195. }
  32196. }
  32197. }
  32198. //func (c *HisApiController) CheckTreatment() {
  32199. // patient_id, _ := c.GetInt64("patient_id")
  32200. // id_card_no := c.GetString("id_card_no")
  32201. // insutype := c.GetString("insutype")
  32202. // med_type := c.GetString("med_type")
  32203. // admin_user_id, _ := c.GetInt64("admin_user_id")
  32204. //
  32205. // adminUser := c.GetAdminUserInfo()
  32206. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  32207. //
  32208. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32209. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32210. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32211. //
  32212. // if miConfig.MdtrtareaAdmvs == "421300" {
  32213. // var res ResultTwo
  32214. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  32215. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32216. // "&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)
  32217. // resp, requestErr := http.Get(api)
  32218. // if requestErr != nil {
  32219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32220. // return
  32221. // }
  32222. //
  32223. // body, ioErr := ioutil.ReadAll(resp.Body)
  32224. // if ioErr != nil {
  32225. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32226. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32227. // return
  32228. // }
  32229. // var respJSON map[string]interface{}
  32230. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32231. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32232. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32233. // return
  32234. // }
  32235. //
  32236. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32237. // result, _ := json.Marshal(respJSON)
  32238. //
  32239. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  32240. // utils.ErrorLog("解析失败:%v", err)
  32241. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32242. // return
  32243. // }
  32244. //
  32245. // if res.Infcode == 0 {
  32246. //
  32247. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  32248. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32249. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  32250. // resp, requestErr := http.Get(api)
  32251. // if requestErr != nil {
  32252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32253. // return
  32254. // }
  32255. //
  32256. // body, ioErr := ioutil.ReadAll(resp.Body)
  32257. // if ioErr != nil {
  32258. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32259. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32260. // return
  32261. // }
  32262. // var respJSON map[string]interface{}
  32263. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32264. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32265. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32266. // return
  32267. // }
  32268. // var res Result2001
  32269. //
  32270. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32271. // result2, _ := json.Marshal(respJSON)
  32272. //
  32273. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  32274. // utils.ErrorLog("解析失败:%v", err)
  32275. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32276. // return
  32277. // }
  32278. //
  32279. // if res.Infcode == 0 {
  32280. // c.ServeSuccessJSON(map[string]interface{}{
  32281. // "msg": res.Output.Trtinfo,
  32282. // })
  32283. // }
  32284. //
  32285. // } else {
  32286. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  32287. // return
  32288. // }
  32289. //
  32290. // } else {
  32291. //
  32292. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  32293. // var dat map[string]interface{}
  32294. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32295. // fmt.Println(dat)
  32296. // } else {
  32297. // fmt.Println(err)
  32298. // }
  32299. // userJSONBytes, _ := json.Marshal(dat)
  32300. // var res ResultTwo
  32301. // var res10265 ResultTwo10265
  32302. // if miConfig.Code == "H15049901371" {
  32303. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  32304. // utils.ErrorLog("解析失败:%v", err)
  32305. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32306. // return
  32307. // }
  32308. // res.ErrMsg = res10265.ErrMsg
  32309. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  32310. // res.Infcode = infocode
  32311. // res.Output = res10265.Output
  32312. // res.InfRefmsgid = res10265.InfRefmsgid
  32313. // } else {
  32314. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32315. // utils.ErrorLog("解析失败:%v", err)
  32316. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32317. // return
  32318. // }
  32319. // }
  32320. //
  32321. // var user_name string
  32322. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  32323. // if role.ID == 0 {
  32324. // user_name = "xxx"
  32325. // } else {
  32326. // user_name = role.UserName
  32327. // }
  32328. //
  32329. // baseParams := models.BaseParams{
  32330. // SecretKey: miConfig.SecretKey,
  32331. // FixmedinsCode: miConfig.Code,
  32332. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  32333. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  32334. // OrgName: miConfig.OrgName,
  32335. // Doctor: user_name,
  32336. // }
  32337. //
  32338. // if config.IsOpen == 1 {
  32339. // if miConfig.Code == "H15049901371" {
  32340. // if med_type == "14" {
  32341. // if insutype == "390" {
  32342. // med_type = "9933"
  32343. // } else if insutype == "310" {
  32344. // med_type = "990502"
  32345. // }
  32346. // } else if med_type == "11" {
  32347. // med_type = "11"
  32348. // }
  32349. // }
  32350. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  32351. // var dat map[string]interface{}
  32352. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32353. // fmt.Println(dat)
  32354. // } else {
  32355. // fmt.Println(err)
  32356. // }
  32357. // var res Result2001
  32358. // var res10265 Result2001Org10265
  32359. // if miConfig.Code == "H15049901371" {
  32360. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  32361. // utils.ErrorLog("解析失败:%v", err)
  32362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32363. // return
  32364. // }
  32365. // res.ErrMsg = res10265.ErrMsg
  32366. // res.Output = res10265.Output
  32367. // res.InfRefmsgid = res10265.InfRefmsgid
  32368. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  32369. // res.Infcode = infocode
  32370. // } else {
  32371. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  32372. // utils.ErrorLog("解析失败:%v", err)
  32373. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32374. // return
  32375. // }
  32376. // }
  32377. // if res.Infcode == 0 {
  32378. // c.ServeSuccessJSON(map[string]interface{}{
  32379. // "msg": res.Output.Trtinfo,
  32380. // })
  32381. // }
  32382. // }
  32383. // }
  32384. //}
  32385. //func (c *HisApiController) PutRecord() {
  32386. // id, _ := c.GetInt64("id")
  32387. // record_time := c.GetString("record_time")
  32388. // timeLayout := "2006-01-02"
  32389. // loc, _ := time.LoadLocation("Local")
  32390. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32391. // if err != nil {
  32392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32393. // return
  32394. // }
  32395. // recordDateTime := theTime.Unix()
  32396. //
  32397. // adminInfo := c.GetAdminUserInfo()
  32398. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  32399. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  32400. //
  32401. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  32402. //
  32403. // fmt.Println(miConfig.SecretKey)
  32404. //
  32405. // if patient == nil {
  32406. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  32407. // return
  32408. // }
  32409. // if len(patient.IdCardNo) == 0 {
  32410. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  32411. // return
  32412. // }
  32413. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  32414. // if config.IsOpen == 1 {
  32415. // 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
  32416. // resp, requestErr := http.Get(api)
  32417. // if requestErr != nil {
  32418. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32419. // return
  32420. // }
  32421. // defer resp.Body.Close()
  32422. // body, ioErr := ioutil.ReadAll(resp.Body)
  32423. // if ioErr != nil {
  32424. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32425. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32426. // return
  32427. // }
  32428. // var respJSON map[string]interface{}
  32429. //
  32430. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32431. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32432. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32433. // return
  32434. // }
  32435. //
  32436. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32437. // userJSONBytes, _ := json.Marshal(userJSON)
  32438. // var res ResultTwo
  32439. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32440. // utils.ErrorLog("解析失败:%v", err)
  32441. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32442. // return
  32443. // }
  32444. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  32445. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  32446. // infoStr := string(Iinfos)
  32447. // idetinfoStr := string(Idetinfos)
  32448. //
  32449. // if res.Infcode == 0 {
  32450. // his := models.VMHisPatient{
  32451. // Status: 1,
  32452. // Ctime: time.Now().Unix(),
  32453. // Mtime: time.Now().Unix(),
  32454. // PsnNo: res.Output.Baseinfo.PsnNo,
  32455. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  32456. // Certno: res.Output.Baseinfo.Certno,
  32457. // PsnName: res.Output.Baseinfo.PsnName,
  32458. // Gend: res.Output.Baseinfo.Gend,
  32459. // Naty: res.Output.Baseinfo.Naty,
  32460. // Brdy: res.Output.Baseinfo.Brdy,
  32461. // Age: res.Output.Baseinfo.Age,
  32462. // Iinfo: infoStr,
  32463. // Idetinfo: idetinfoStr,
  32464. // PatientId: patient.ID,
  32465. // RecordDate: theTime.Unix(),
  32466. // UserOrgId: adminInfo.CurrentOrgId,
  32467. // AdminUserId: adminInfo.AdminUser.Id,
  32468. // IsReturn: 1,
  32469. // }
  32470. //
  32471. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  32472. // //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")
  32473. // //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")
  32474. //
  32475. // //var dat map[string]interface{}
  32476. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32477. // // fmt.Println(dat)
  32478. // //} else {
  32479. // // fmt.Println(err)
  32480. // //}
  32481. //
  32482. // var dat2 map[string]interface{}
  32483. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  32484. // fmt.Println(dat2)
  32485. // } else {
  32486. // fmt.Println(err)
  32487. // }
  32488. //
  32489. // } else {
  32490. // adminUser := c.GetAdminUserInfo()
  32491. // errlog := &models.HisOrderError{
  32492. // UserOrgId: adminUser.CurrentOrgId,
  32493. // Ctime: time.Now().Unix(),
  32494. // Mtime: time.Now().Unix(),
  32495. // ErrMsg: res.ErrMsg,
  32496. // Status: 1,
  32497. // PatientId: id,
  32498. // RecordTime: recordDateTime,
  32499. // Stage: 1,
  32500. // }
  32501. // service.CreateErrMsgLog(errlog)
  32502. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  32503. // return
  32504. // }
  32505. // }
  32506. //
  32507. //}
  32508. //func (c *HisApiController) GetUploadDiag() {
  32509. // id, _ := c.GetInt64("id")
  32510. // record_time := c.GetString("record_time")
  32511. //
  32512. // diagnosis_id, _ := c.GetInt64("diagnosis")
  32513. // sick_type, _ := c.GetInt64("sick_type")
  32514. // reg_type, _ := c.GetInt64("reg_type")
  32515. //
  32516. // timeLayout := "2006-01-02"
  32517. // loc, _ := time.LoadLocation("Local")
  32518. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32519. // if err != nil {
  32520. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32521. // return
  32522. // }
  32523. //
  32524. // var patientPrescription models.HisPrescriptionInfo
  32525. // recordDateTime := theTime.Unix()
  32526. // adminInfo := c.GetAdminUserInfo()
  32527. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  32528. //
  32529. // if patientPrescription.ID == 0 {
  32530. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  32531. // }
  32532. //
  32533. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  32534. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  32535. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  32536. // sickConfig, _ := service.FindSickById(sick_type)
  32537. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  32538. //
  32539. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  32540. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  32541. // "&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 +
  32542. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  32543. // resp2, requestErr2 := http.Get(api2)
  32544. // if requestErr2 != nil {
  32545. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32546. // return
  32547. // }
  32548. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  32549. // if ioErr2 != nil {
  32550. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  32551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32552. // return
  32553. // }
  32554. // var respJSON2 map[string]interface{}
  32555. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  32556. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32557. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32558. // return
  32559. // }
  32560. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32561. // userJSONBytes2, _ := json.Marshal(respJSON2)
  32562. //
  32563. // var res2 ResultSix
  32564. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  32565. // utils.ErrorLog("解析失败:%v", err)
  32566. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32567. // return
  32568. // }
  32569. // if res2.Infcode != 0 {
  32570. // adminUser := c.GetAdminUserInfo()
  32571. // errlog := &models.HisOrderError{
  32572. // UserOrgId: adminUser.CurrentOrgId,
  32573. // Ctime: time.Now().Unix(),
  32574. // Mtime: time.Now().Unix(),
  32575. // ErrMsg: res2.ErrMsg,
  32576. // Status: 1,
  32577. // PatientId: id,
  32578. // RecordTime: recordDateTime,
  32579. // Stage: 3,
  32580. // }
  32581. // service.CreateErrMsgLog(errlog)
  32582. //
  32583. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  32584. // return
  32585. // }
  32586. //
  32587. // c.ServeSuccessJSON(map[string]interface{}{
  32588. // "msg": "上传成功",
  32589. // })
  32590. //
  32591. //}
  32592. type QueryResult struct {
  32593. ID int64
  32594. Name string
  32595. Code string
  32596. List_type_code string
  32597. }
  32598. func (c *HisApiController) GetCheckCode() {
  32599. ids_str := c.GetString("ids")
  32600. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  32601. ids_arr := strings.Split(ids_str, ",")
  32602. var queryResult []QueryResult
  32603. ids := make([]int64, 0)
  32604. for _, item := range ids_arr {
  32605. id, _ := strconv.ParseInt(item, 10, 64)
  32606. ids = append(ids, id)
  32607. }
  32608. if record_type == 1 {
  32609. drugs, _ := service.GetBatchDrugList(ids)
  32610. for _, item := range drugs {
  32611. result := QueryResult{
  32612. ID: item.ID,
  32613. Name: item.DrugName,
  32614. Code: item.MedicalInsuranceNumber,
  32615. List_type_code: "101",
  32616. }
  32617. queryResult = append(queryResult, result)
  32618. }
  32619. } else if record_type == 2 {
  32620. goods, _ := service.GetBatchGoodInformationList(ids)
  32621. fmt.Println(goods)
  32622. for _, item := range goods {
  32623. result := QueryResult{
  32624. ID: item.ID,
  32625. Name: item.GoodName,
  32626. Code: item.SocialSecurityDirectoryCode,
  32627. List_type_code: "301",
  32628. }
  32629. queryResult = append(queryResult, result)
  32630. }
  32631. } else if record_type == 3 {
  32632. projects, _ := service.GetBathchMyPorjecgList(ids)
  32633. for _, item := range projects {
  32634. result := QueryResult{
  32635. ID: item.ID,
  32636. Name: item.ProjectName,
  32637. Code: item.MedicalCode,
  32638. List_type_code: "201",
  32639. }
  32640. queryResult = append(queryResult, result)
  32641. }
  32642. }
  32643. admin_user_id, _ := c.GetInt64("admin_user_id")
  32644. adminUser := c.GetAdminUserInfo()
  32645. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32646. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32647. var user_name string
  32648. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32649. if role.ID == 0 {
  32650. user_name = "管理员"
  32651. } else {
  32652. user_name = role.UserName
  32653. }
  32654. baseParams := models.BaseParams{
  32655. SecretKey: miConfig.SecretKey,
  32656. FixmedinsCode: miConfig.Code,
  32657. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  32658. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  32659. OrgName: miConfig.OrgName,
  32660. Doctor: user_name,
  32661. }
  32662. var result string
  32663. if miConfig.MdtrtareaAdmvs == "430800" {
  32664. for _, item := range queryResult {
  32665. if record_type == 1 {
  32666. 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)
  32667. } else if record_type == 2 {
  32668. fmt.Println(item.Code)
  32669. 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)
  32670. } else if record_type == 3 {
  32671. 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)
  32672. }
  32673. var dat map[string]interface{}
  32674. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32675. fmt.Println(dat)
  32676. } else {
  32677. fmt.Println(err)
  32678. }
  32679. userJSONBytes, _ := json.Marshal(dat)
  32680. var res ResultSix
  32681. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32682. utils.ErrorLog("解析失败:%v", err)
  32683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32684. return
  32685. }
  32686. if res.Infcode == 0 {
  32687. if record_type == 1 {
  32688. service.UpdateBaseDrugById(item.ID)
  32689. } else if record_type == 2 {
  32690. service.UpdateGoodInformaitonByDetail(item.ID)
  32691. } else if record_type == 3 {
  32692. service.UpdateProjectById(item.ID)
  32693. }
  32694. c.ServeSuccessJSON(map[string]interface{}{
  32695. "failed_code": 0,
  32696. "msg": "目录对照成功",
  32697. })
  32698. } else {
  32699. c.ServeSuccessJSON(map[string]interface{}{
  32700. "failed_code": -10,
  32701. "msg": res.ErrMsg,
  32702. })
  32703. }
  32704. }
  32705. } else {
  32706. for _, item := range queryResult {
  32707. var result string
  32708. if record_type == 1 {
  32709. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  32710. } else if record_type == 2 {
  32711. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  32712. } else if record_type == 3 {
  32713. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  32714. }
  32715. var dat map[string]interface{}
  32716. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32717. fmt.Println(dat)
  32718. } else {
  32719. fmt.Println(err)
  32720. }
  32721. userJSONBytes, _ := json.Marshal(dat)
  32722. var res ResultSix
  32723. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32724. utils.ErrorLog("解析失败:%v", err)
  32725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32726. return
  32727. }
  32728. if res.Infcode == 0 {
  32729. if record_type == 1 {
  32730. service.UpdateBaseDrugById(item.ID)
  32731. } else if record_type == 2 {
  32732. service.UpdateGoodInformaitonByDetail(item.ID)
  32733. } else if record_type == 3 {
  32734. service.UpdateProjectById(item.ID)
  32735. }
  32736. c.ServeSuccessJSON(map[string]interface{}{
  32737. "failed_code": 0,
  32738. "msg": "目录对照成功",
  32739. })
  32740. } else {
  32741. c.ServeSuccessJSON(map[string]interface{}{
  32742. "failed_code": -10,
  32743. "msg": res.ErrMsg,
  32744. })
  32745. }
  32746. }
  32747. }
  32748. }
  32749. func (c *HisApiController) UnCheckCode() {
  32750. ids_str := c.GetString("ids")
  32751. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  32752. admin_user_id, _ := c.GetInt64("admin_user_id")
  32753. ids_arr := strings.Split(ids_str, ",")
  32754. var queryResult []QueryResult
  32755. ids := make([]int64, 0)
  32756. for _, item := range ids_arr {
  32757. id, _ := strconv.ParseInt(item, 10, 64)
  32758. ids = append(ids, id)
  32759. }
  32760. if record_type == 1 {
  32761. drugs, _ := service.GetBatchDrugList(ids)
  32762. for _, item := range drugs {
  32763. result := QueryResult{
  32764. ID: item.ID,
  32765. Name: item.DrugName,
  32766. Code: item.MedicalInsuranceNumber,
  32767. List_type_code: "101",
  32768. }
  32769. queryResult = append(queryResult, result)
  32770. }
  32771. } else if record_type == 2 {
  32772. goods, _ := service.GetBatchGoodInformationList(ids)
  32773. for _, item := range goods {
  32774. result := QueryResult{
  32775. ID: item.ID,
  32776. Name: item.GoodName,
  32777. Code: item.SocialSecurityDirectoryCode,
  32778. List_type_code: "301",
  32779. }
  32780. queryResult = append(queryResult, result)
  32781. }
  32782. } else if record_type == 3 {
  32783. projects, _ := service.GetBathchMyPorjecgList(ids)
  32784. for _, item := range projects {
  32785. result := QueryResult{
  32786. ID: item.ID,
  32787. Name: item.ProjectName,
  32788. Code: item.MedicalCode,
  32789. List_type_code: "201",
  32790. }
  32791. queryResult = append(queryResult, result)
  32792. }
  32793. }
  32794. adminUser := c.GetAdminUserInfo()
  32795. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32796. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32797. var user_name string
  32798. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32799. if role.ID == 0 {
  32800. user_name = "xxx"
  32801. } else {
  32802. user_name = role.UserName
  32803. }
  32804. baseParams := &models.BaseParams{
  32805. SecretKey: miConfig.SecretKey,
  32806. FixmedinsCode: miConfig.Code,
  32807. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  32808. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  32809. OrgName: miConfig.OrgName,
  32810. Doctor: user_name,
  32811. }
  32812. if config.IsOpen == 1 {
  32813. if miConfig.MdtrtareaAdmvs == "430800" {
  32814. for _, item := range queryResult {
  32815. var result string
  32816. if record_type == 1 {
  32817. 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)
  32818. } else if record_type == 2 {
  32819. fmt.Println(item.Code)
  32820. 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)
  32821. } else if record_type == 3 {
  32822. 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)
  32823. }
  32824. var dat map[string]interface{}
  32825. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32826. fmt.Println(dat)
  32827. } else {
  32828. fmt.Println(err)
  32829. }
  32830. userJSONBytes, _ := json.Marshal(dat)
  32831. var res ResultSix
  32832. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32833. utils.ErrorLog("解析失败:%v", err)
  32834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32835. return
  32836. }
  32837. if res.Infcode == 0 {
  32838. if record_type == 1 {
  32839. service.UpdateBaseDrugById(item.ID)
  32840. } else if record_type == 2 {
  32841. service.UpdateGoodInformaitonByDetail(item.ID)
  32842. } else if record_type == 3 {
  32843. service.UpdateProjectById(item.ID)
  32844. }
  32845. c.ServeSuccessJSON(map[string]interface{}{
  32846. "failed_code": 0,
  32847. "msg": "目录对照成功",
  32848. })
  32849. } else {
  32850. c.ServeSuccessJSON(map[string]interface{}{
  32851. "failed_code": -10,
  32852. "msg": res.ErrMsg,
  32853. })
  32854. }
  32855. }
  32856. } else {
  32857. for _, item := range queryResult {
  32858. var result string
  32859. if record_type == 1 {
  32860. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  32861. } else if record_type == 2 {
  32862. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  32863. } else if record_type == 3 {
  32864. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  32865. }
  32866. var dat2 map[string]interface{}
  32867. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  32868. fmt.Println(dat2)
  32869. } else {
  32870. fmt.Println(err)
  32871. }
  32872. userJSONBytes, _ := json.Marshal(dat2)
  32873. var res ResultSix
  32874. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32875. utils.ErrorLog("解析失败:%v", err)
  32876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32877. return
  32878. }
  32879. if res.Infcode == 0 {
  32880. if record_type == 1 {
  32881. service.UpdateDrugByIdDetail(item.ID)
  32882. } else if record_type == 2 {
  32883. service.UpdateGoodInfoById(item.ID)
  32884. } else if record_type == 3 {
  32885. service.UpdateMyProjectById(item.ID)
  32886. }
  32887. c.ServeSuccessJSON(map[string]interface{}{
  32888. "failed_code": 0,
  32889. "msg": "撤销目录对照成功",
  32890. })
  32891. } else {
  32892. c.ServeSuccessJSON(map[string]interface{}{
  32893. "failed_code": -10,
  32894. "msg": res.ErrMsg,
  32895. })
  32896. }
  32897. }
  32898. }
  32899. }
  32900. }
  32901. func (c *HisApiController) GetPatientInfo() {
  32902. id_card_no := c.GetString("id_card_no")
  32903. admin_user_id, _ := c.GetInt64("admin_user_id")
  32904. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  32905. if patient.ID == 0 {
  32906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  32907. return
  32908. }
  32909. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  32910. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  32911. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  32912. var res ResultTwo
  32913. var res10265 ResultTwo10265
  32914. if config.IsOpen == 1 {
  32915. if miConfig.MdtrtareaAdmvs == "150499" {
  32916. //请求内网数据
  32917. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  32918. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  32919. "&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
  32920. resp, requestErr := http.Get(api)
  32921. if requestErr != nil {
  32922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32923. return
  32924. }
  32925. body, ioErr := ioutil.ReadAll(resp.Body)
  32926. if ioErr != nil {
  32927. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32929. return
  32930. }
  32931. var respJSON map[string]interface{}
  32932. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32935. return
  32936. }
  32937. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32938. result_byte, _ := json.Marshal(respJSON)
  32939. result := string(result_byte)
  32940. var dat map[string]interface{}
  32941. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32942. fmt.Println(dat)
  32943. } else {
  32944. fmt.Println(err)
  32945. }
  32946. userJSONBytes, _ := json.Marshal(dat)
  32947. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  32948. utils.ErrorLog("解析失败:%v", err)
  32949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32950. return
  32951. }
  32952. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  32953. res.Infcode = Infcode
  32954. res.ErrMsg = res10265.ErrMsg
  32955. res.Output = res10265.Output
  32956. res.InfRefmsgid = res10265.InfRefmsgid
  32957. res.RespondTime = res10265.RespondTime
  32958. res.WarnInfo = res10265.WarnInfo
  32959. } else {
  32960. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  32961. var dat map[string]interface{}
  32962. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32963. fmt.Println(dat)
  32964. } else {
  32965. fmt.Println(err)
  32966. }
  32967. userJSONBytes, _ := json.Marshal(dat)
  32968. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32969. utils.ErrorLog("解析失败:%v", err)
  32970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32971. return
  32972. }
  32973. }
  32974. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32975. // utils.ErrorLog("解析失败:%v", err)
  32976. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32977. // return
  32978. //}
  32979. for index, item := range res.Output.Iinfo {
  32980. if item.PsnInsuStas == "2" {
  32981. fmt.Println("--------")
  32982. res.Output.Iinfo[index].Insutype = "300"
  32983. res.Output.Iinfo[index].PsnInsuStas = "1"
  32984. }
  32985. }
  32986. fmt.Println(res.Output.Iinfo)
  32987. if res.Infcode != 0 {
  32988. c.ServeSuccessJSON(map[string]interface{}{
  32989. "failed_code": -10,
  32990. "msg": res.ErrMsg,
  32991. })
  32992. } else {
  32993. c.ServeSuccessJSON(map[string]interface{}{
  32994. "failed_code": 0,
  32995. "info": res,
  32996. })
  32997. }
  32998. }
  32999. }
  33000. func (c *HisApiController) PsnPutOnRecord() {
  33001. record_type, _ := c.GetInt64("type")
  33002. patient_id, _ := c.GetInt64("patient_id")
  33003. admin_user_id, _ := c.GetInt64("admin_user_id")
  33004. start_time := c.GetString("start_time")
  33005. end_time := c.GetString("end_time")
  33006. adminUser := c.GetAdminUserInfo()
  33007. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33008. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33009. var patients []*models.Patients
  33010. if record_type == 1 { //全部备案
  33011. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  33012. patients = append(patients, patient...)
  33013. } else { //单个备案
  33014. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  33015. patients = append(patients, patient)
  33016. }
  33017. var user_name string
  33018. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33019. if role.ID == 0 {
  33020. user_name = "xxx"
  33021. } else {
  33022. user_name = role.UserName
  33023. }
  33024. if config.IsOpen == 1 {
  33025. for _, item := range patients {
  33026. 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
  33027. resp, requestErr := http.Get(api)
  33028. if requestErr != nil {
  33029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33030. return
  33031. }
  33032. defer resp.Body.Close()
  33033. body, ioErr := ioutil.ReadAll(resp.Body)
  33034. if ioErr != nil {
  33035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33037. return
  33038. }
  33039. var respJSON map[string]interface{}
  33040. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33043. return
  33044. }
  33045. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33046. userJSONBytes, _ := json.Marshal(userJSON)
  33047. var res ResultTwo
  33048. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33049. utils.ErrorLog("解析失败:%v", err)
  33050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33051. return
  33052. }
  33053. if res.Infcode == 0 {
  33054. 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)
  33055. var dat map[string]interface{}
  33056. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33057. fmt.Println(dat)
  33058. } else {
  33059. fmt.Println(err)
  33060. }
  33061. userJSONBytes, _ := json.Marshal(dat)
  33062. var res2 ResultThirteen
  33063. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33064. utils.ErrorLog("解析失败:%v", err)
  33065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33066. return
  33067. }
  33068. if res2.Infcode == 0 {
  33069. psnResult := &models.GdybPsnRecord{
  33070. UserOrgId: adminUser.CurrentOrgId,
  33071. PatientId: item.ID,
  33072. PsnNo: res.Output.Baseinfo.PsnNo,
  33073. Ctime: time.Now().Unix(),
  33074. Mtime: time.Now().Unix(),
  33075. Status: 1,
  33076. IsCancel: 1,
  33077. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  33078. }
  33079. service.CreatePsnRecord(psnResult)
  33080. } else {
  33081. c.ServeSuccessJSON(map[string]interface{}{
  33082. "failed_code": -10,
  33083. "msg": res2.ErrMsg,
  33084. })
  33085. return
  33086. }
  33087. }
  33088. }
  33089. }
  33090. }
  33091. func (c *HisApiController) PsnUnPutOnRecord() {
  33092. id, _ := c.GetInt64("id")
  33093. //record_type, _ := c.GetInt64("type")
  33094. admin_user_id, _ := c.GetInt64("admin_user_id")
  33095. adminUser := c.GetAdminUserInfo()
  33096. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33097. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33098. var user_name string
  33099. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33100. if role.ID == 0 {
  33101. user_name = "xxx"
  33102. } else {
  33103. user_name = role.UserName
  33104. }
  33105. psn_record, _ := service.GetPsnRecordById(id)
  33106. if psn_record.ID == 0 {
  33107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  33108. return
  33109. }
  33110. if config.IsOpen == 1 {
  33111. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  33112. var dat map[string]interface{}
  33113. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33114. fmt.Println(dat)
  33115. } else {
  33116. fmt.Println(err)
  33117. }
  33118. userJSONBytes, _ := json.Marshal(dat)
  33119. var res ResultFourteen
  33120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33121. utils.ErrorLog("解析失败:%v", err)
  33122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33123. return
  33124. }
  33125. if res.Infcode == 0 {
  33126. psn_record.IsCancel = 2
  33127. service.CreatePsnRecord(&psn_record)
  33128. } else {
  33129. c.ServeSuccessJSON(map[string]interface{}{
  33130. "failed_code": -10,
  33131. "msg": res.ErrMsg,
  33132. })
  33133. return
  33134. }
  33135. }
  33136. }
  33137. func (c *HisApiController) PsnPutNCDSOnRecord() {
  33138. patient_id, _ := c.GetInt64("patient_id")
  33139. insutype_two := c.GetString("insutype")
  33140. psn_no := c.GetString("psn_no")
  33141. doctor_id, _ := c.GetInt64("doctor_id")
  33142. sick_id, _ := c.GetInt64("sick_id")
  33143. department_id, _ := c.GetInt64("department_id")
  33144. start_time := c.GetString("start_time")
  33145. end_time := c.GetString("end_time")
  33146. check_time := c.GetString("check_time")
  33147. hospital_code := c.GetString("hospital_code")
  33148. hospital_name := c.GetString("hospital_name")
  33149. adminUser := c.GetAdminUserInfo()
  33150. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  33151. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33152. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33153. sick, _ := service.FindSickById(sick_id)
  33154. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  33155. if len(hospital_code) == 0 {
  33156. hospital_code = miConfig.Code
  33157. }
  33158. if len(hospital_name) == 0 {
  33159. hospital_name = miConfig.OrgName
  33160. }
  33161. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  33162. var res ResultTwo
  33163. var res10265 ResultTwo10265
  33164. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33165. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  33166. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  33167. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  33168. "&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
  33169. resp, requestErr := http.Get(api)
  33170. if requestErr != nil {
  33171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33172. return
  33173. }
  33174. body, ioErr := ioutil.ReadAll(resp.Body)
  33175. if ioErr != nil {
  33176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33178. return
  33179. }
  33180. var respJSON map[string]interface{}
  33181. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33184. return
  33185. }
  33186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33187. result, _ := json.Marshal(respJSON)
  33188. fmt.Println("log")
  33189. fmt.Println(string(result))
  33190. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  33191. utils.ErrorLog("解析失败:%v", err)
  33192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33193. return
  33194. }
  33195. res.ErrMsg = res10265.ErrMsg
  33196. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  33197. res.Infcode = infocode
  33198. res.Output = res10265.Output
  33199. res.InfRefmsgid = res10265.InfRefmsgid
  33200. } else {
  33201. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  33202. if miConfig.Code == "H15049901371" {
  33203. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  33204. utils.ErrorLog("解析失败:%v", err)
  33205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33206. return
  33207. }
  33208. res.ErrMsg = res10265.ErrMsg
  33209. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  33210. res.Infcode = infocode
  33211. res.Output = res10265.Output
  33212. res.InfRefmsgid = res10265.InfRefmsgid
  33213. } else {
  33214. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33215. utils.ErrorLog("解析失败:%v", err)
  33216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33217. return
  33218. }
  33219. }
  33220. }
  33221. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  33222. infoStr := string(Iinfos)
  33223. var rf []*ResultFive
  33224. json.Unmarshal([]byte(infoStr), &rf)
  33225. var insuplc_admdvs string
  33226. var insutype string
  33227. var is390 int = 0
  33228. var is310 int = 0
  33229. var insutypes []*ResultFive
  33230. for _, item := range rf {
  33231. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  33232. insutypes = append(insutypes, item)
  33233. }
  33234. }
  33235. if len(insutypes) == 1 {
  33236. insutype = insutypes[0].Insutype
  33237. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  33238. } else {
  33239. for _, i := range insutypes {
  33240. if i.Insutype == "390" {
  33241. is390 = 1
  33242. }
  33243. if i.Insutype == "310" {
  33244. is310 = 1
  33245. }
  33246. }
  33247. }
  33248. if is390 == 1 {
  33249. insutype = "390"
  33250. }
  33251. if is310 == 1 {
  33252. insutype = "310"
  33253. }
  33254. if len(insutypes) == 2 {
  33255. insutype = insutype_two
  33256. }
  33257. if len(insutypes) == 0 {
  33258. insutype = "310"
  33259. }
  33260. insutype = insutype_two
  33261. fmt.Println(insutype)
  33262. for _, item := range rf {
  33263. fmt.Println(item.Insutype)
  33264. fmt.Println(insutype)
  33265. if item.Insutype == insutype {
  33266. fmt.Println(item.Insutype)
  33267. fmt.Println(insutype)
  33268. insuplc_admdvs = item.InsuplcAdmdvs
  33269. }
  33270. }
  33271. fmt.Println(insuplc_admdvs)
  33272. var res2 ResultThirteen
  33273. var res10265_2 ResultThirteen10265
  33274. if config.IsOpen == 1 {
  33275. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33276. } else {
  33277. if miConfig.MdtrtareaAdmvs == "150499" {
  33278. //
  33279. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  33280. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  33281. // "&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
  33282. //resp, requestErr := http.Get(api)
  33283. //if requestErr != nil {
  33284. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33285. // return
  33286. //}
  33287. //
  33288. //body, ioErr := ioutil.ReadAll(resp.Body)
  33289. //if ioErr != nil {
  33290. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33291. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33292. // return
  33293. //}
  33294. //var respJSON map[string]interface{}
  33295. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33296. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33297. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33298. // return
  33299. //}
  33300. //
  33301. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33302. //result, _ := json.Marshal(respJSON)
  33303. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  33304. // utils.ErrorLog("解析失败:%v", err)
  33305. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33306. // return
  33307. //}
  33308. //infocode = resThree.Infcode
  33309. //result, _ := json.Marshal(respJSON)
  33310. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  33311. // utils.ErrorLog("解析失败:%v", err)
  33312. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33313. // return
  33314. //}
  33315. //
  33316. //resThree.ErrMsg = resThree10265.ErrMsg
  33317. //
  33318. //resThree.Output = resThree10265.Output
  33319. //
  33320. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  33321. //
  33322. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  33323. //
  33324. } else {
  33325. 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)
  33326. var dat map[string]interface{}
  33327. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33328. fmt.Println(dat)
  33329. } else {
  33330. fmt.Println(err)
  33331. }
  33332. userJSONBytes, _ := json.Marshal(dat)
  33333. if miConfig.Code == "H15049901371" {
  33334. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  33335. utils.ErrorLog("解析失败:%v", err)
  33336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33337. return
  33338. }
  33339. res2.ErrMsg = res10265_2.ErrMsg
  33340. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  33341. res2.Infcode = infocode
  33342. res2.Output = res10265_2.Output
  33343. res2.InfRefmsgid = res10265_2.InfRefmsgid
  33344. } else {
  33345. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33346. utils.ErrorLog("解析失败:%v", err)
  33347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33348. return
  33349. }
  33350. }
  33351. }
  33352. }
  33353. if res2.Infcode == 0 {
  33354. psnResult := &models.GdybPsnNcdsRecord{
  33355. UserOrgId: adminUser.CurrentOrgId,
  33356. PatientId: patient.ID,
  33357. PsnNo: psn_no,
  33358. DoctorId: doctor.AdminUserId,
  33359. DepartmentId: department_id,
  33360. SickType: sick_id,
  33361. Insutype: insutype,
  33362. Ctime: time.Now().Unix(),
  33363. Mtime: time.Now().Unix(),
  33364. Status: 1,
  33365. IsCancel: 1,
  33366. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  33367. }
  33368. service.CreatePsnNCDSRecord(psnResult)
  33369. c.ServeSuccessJSON(map[string]interface{}{
  33370. "failed_code": 0,
  33371. "msg": "备案成功",
  33372. "result": psnResult,
  33373. })
  33374. } else {
  33375. c.ServeSuccessJSON(map[string]interface{}{
  33376. "failed_code": -10,
  33377. "msg": res2.ErrMsg,
  33378. })
  33379. return
  33380. }
  33381. }
  33382. }
  33383. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  33384. id, _ := c.GetInt64("id")
  33385. admin_user_id, _ := c.GetInt64("admin_user_id")
  33386. adminUser := c.GetAdminUserInfo()
  33387. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33388. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33389. //config, _ := service.Ge(adminUser.CurrentOrgId)
  33390. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  33391. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33392. //var user_name string
  33393. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33394. //if role.ID == 0 {
  33395. // user_name = "xxx"
  33396. //} else {
  33397. // user_name = role.UserName
  33398. //}
  33399. psn_record, _ := service.GetPsnNCDSRecordById(id)
  33400. if psn_record.ID == 0 {
  33401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  33402. return
  33403. }
  33404. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  33405. var res ResultTwo
  33406. var res10265 ResultTwo10265
  33407. if miConfig.Code == "H15049901371" {
  33408. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  33409. utils.ErrorLog("解析失败:%v", err)
  33410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33411. return
  33412. }
  33413. res.ErrMsg = res10265.ErrMsg
  33414. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  33415. res.Infcode = infocode
  33416. res.Output = res10265.Output
  33417. res.InfRefmsgid = res10265.InfRefmsgid
  33418. } else {
  33419. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33420. utils.ErrorLog("解析失败:%v", err)
  33421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33422. return
  33423. }
  33424. }
  33425. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  33426. infoStr := string(Iinfos)
  33427. var rf []*ResultFive
  33428. json.Unmarshal([]byte(infoStr), &rf)
  33429. var insuplc_admdvs string
  33430. var insutype string
  33431. var is390 int = 0
  33432. var is310 int = 0
  33433. var insutypes []*ResultFive
  33434. for _, item := range rf {
  33435. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  33436. insutypes = append(insutypes, item)
  33437. }
  33438. }
  33439. if len(insutypes) == 1 {
  33440. insutype = insutypes[0].Insutype
  33441. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  33442. } else {
  33443. for _, i := range insutypes {
  33444. if i.Insutype == "390" {
  33445. is390 = 1
  33446. }
  33447. if i.Insutype == "310" {
  33448. is310 = 1
  33449. }
  33450. }
  33451. }
  33452. if is390 == 1 {
  33453. insutype = "390"
  33454. }
  33455. if is310 == 1 {
  33456. insutype = "310"
  33457. }
  33458. if len(insutypes) == 0 {
  33459. insutype = "310"
  33460. }
  33461. insutype = psn_record.Insutype
  33462. for _, item := range rf {
  33463. if item.Insutype == insutype {
  33464. insuplc_admdvs = item.InsuplcAdmdvs
  33465. }
  33466. }
  33467. if config.IsOpen == 1 {
  33468. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  33469. var dat map[string]interface{}
  33470. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33471. fmt.Println(dat)
  33472. } else {
  33473. fmt.Println(err)
  33474. }
  33475. userJSONBytes, _ := json.Marshal(dat)
  33476. var res ResultFourteen
  33477. var res10265 ResultFourteen10265
  33478. if miConfig.Code == "H15049901371" {
  33479. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  33480. utils.ErrorLog("解析失败:%v", err)
  33481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33482. return
  33483. }
  33484. res.ErrMsg = res10265.ErrMsg
  33485. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  33486. res.Infcode = infocode
  33487. res.Output = res10265.Output
  33488. res.InfRefmsgid = res10265.InfRefmsgid
  33489. } else {
  33490. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33491. utils.ErrorLog("解析失败:%v", err)
  33492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33493. return
  33494. }
  33495. }
  33496. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33497. // utils.ErrorLog("解析失败:%v", err)
  33498. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33499. // return
  33500. //}
  33501. if res.Infcode == 0 {
  33502. psn_record.IsCancel = 2
  33503. service.CreatePsnNCDSRecord(&psn_record)
  33504. c.ServeSuccessJSON(map[string]interface{}{
  33505. "failed_code": 0,
  33506. "msg": "撤销备案成功",
  33507. })
  33508. } else {
  33509. c.ServeSuccessJSON(map[string]interface{}{
  33510. "failed_code": -10,
  33511. "msg": res.ErrMsg,
  33512. })
  33513. return
  33514. }
  33515. }
  33516. }
  33517. func (c *HisApiController) TestTest() {
  33518. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  33519. fmt.Println(patient.Iinfo)
  33520. }
  33521. type CustomData struct {
  33522. MsgId string
  33523. PsnNo string
  33524. Info string
  33525. }
  33526. func (c *HisApiController) ReversalData() {
  33527. var customData []*CustomData
  33528. custom := &CustomData{
  33529. MsgId: "H44022900158202103301714472004",
  33530. PsnNo: "44020000001101329945",
  33531. Info: "2207",
  33532. }
  33533. customData = append(customData, custom)
  33534. custom1 := &CustomData{
  33535. MsgId: "H4402290015820210330172057803",
  33536. PsnNo: "44020000001101161813",
  33537. Info: "2207",
  33538. }
  33539. customData = append(customData, custom1)
  33540. custom2 := &CustomData{
  33541. MsgId: "H44022900158202103301705198813",
  33542. PsnNo: "44190000133097375417",
  33543. Info: "2207",
  33544. }
  33545. customData = append(customData, custom2)
  33546. custom3 := &CustomData{
  33547. MsgId: "H44022900158202103301715524756",
  33548. PsnNo: "44020000001100187221",
  33549. Info: "2207",
  33550. }
  33551. customData = append(customData, custom3)
  33552. custom4 := &CustomData{
  33553. MsgId: "H44022900158202103301730376224",
  33554. PsnNo: "44020000001101959155",
  33555. Info: "2207",
  33556. }
  33557. customData = append(customData, custom4)
  33558. custom5 := &CustomData{
  33559. MsgId: "H44022900158202103301748008725",
  33560. PsnNo: "44020000001104246641",
  33561. Info: "2207",
  33562. }
  33563. customData = append(customData, custom5)
  33564. custom6 := &CustomData{
  33565. MsgId: "H44022900158202103301718096755",
  33566. PsnNo: "44020000001102211860",
  33567. Info: "2207",
  33568. }
  33569. customData = append(customData, custom6)
  33570. custom7 := &CustomData{
  33571. MsgId: "H44022900158202103301736551640",
  33572. PsnNo: "44020000001102687718",
  33573. Info: "2207",
  33574. }
  33575. customData = append(customData, custom7)
  33576. custom8 := &CustomData{
  33577. MsgId: "H44022900158202103301743097676",
  33578. PsnNo: "44020000001102127785",
  33579. Info: "2207",
  33580. }
  33581. customData = append(customData, custom8)
  33582. custom9 := &CustomData{
  33583. MsgId: "H44022900158202103301712304203",
  33584. PsnNo: "44020000001101518097",
  33585. Info: "2207",
  33586. }
  33587. customData = append(customData, custom9)
  33588. custom10 := &CustomData{
  33589. MsgId: "H44022900158202103301738448785",
  33590. PsnNo: "44020000001100500813",
  33591. Info: "2207",
  33592. }
  33593. customData = append(customData, custom10)
  33594. custom11 := &CustomData{
  33595. MsgId: "H44022900158202103301732455843",
  33596. PsnNo: "44020000001102690557",
  33597. Info: "2207",
  33598. }
  33599. customData = append(customData, custom11)
  33600. custom12 := &CustomData{
  33601. MsgId: "H44022900158202103301745421708",
  33602. PsnNo: "44020000001102211928",
  33603. Info: "2207",
  33604. }
  33605. customData = append(customData, custom12)
  33606. custom1212 := &CustomData{
  33607. MsgId: "H440229001582021033017351627",
  33608. PsnNo: "44020000001102481733",
  33609. Info: "2207",
  33610. }
  33611. customData = append(customData, custom1212)
  33612. custom13 := &CustomData{
  33613. MsgId: "H44022900158202103301740327951",
  33614. PsnNo: "44020000001103174866",
  33615. Info: "2207",
  33616. }
  33617. customData = append(customData, custom13)
  33618. custom14 := &CustomData{
  33619. MsgId: "H4402290015820210330174922668",
  33620. PsnNo: "44020000001102927272",
  33621. Info: "2207",
  33622. }
  33623. customData = append(customData, custom14)
  33624. custom15 := &CustomData{
  33625. MsgId: "H44022900158202103301752362273",
  33626. PsnNo: "44020000001102942890",
  33627. Info: "2207",
  33628. }
  33629. customData = append(customData, custom15)
  33630. custom16 := &CustomData{
  33631. MsgId: "H44022900158202103301751082917",
  33632. PsnNo: "44020000001101662162",
  33633. Info: "2207",
  33634. }
  33635. customData = append(customData, custom16)
  33636. custom17 := &CustomData{
  33637. MsgId: "H44022900158202103301754147728",
  33638. PsnNo: "44020000000229014511",
  33639. Info: "2207",
  33640. }
  33641. customData = append(customData, custom17)
  33642. adminUser := c.GetAdminUserInfo()
  33643. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33644. for _, item := range customData {
  33645. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  33646. fmt.Println(result)
  33647. }
  33648. }
  33649. func (c *HisApiController) GetAllopatry() {
  33650. year := c.GetString("year")
  33651. month := c.GetString("month")
  33652. admin_user_id, _ := c.GetInt64("admin_user_id")
  33653. adminUser := c.GetAdminUserInfo()
  33654. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33655. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33656. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  33657. var dat map[string]interface{}
  33658. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33659. fmt.Println(dat)
  33660. } else {
  33661. fmt.Println(err)
  33662. }
  33663. userJSONBytes, _ := json.Marshal(dat)
  33664. var res models.Result9001
  33665. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33666. utils.ErrorLog("解析失败:%v", err)
  33667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33668. return
  33669. }
  33670. fmt.Println(res.Output.Signinoutb)
  33671. fmt.Println(res.Output.Signinoutb.SignNo)
  33672. fmt.Println(string(userJSONBytes))
  33673. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  33674. var dat3 map[string]interface{}
  33675. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  33676. fmt.Println(dat3)
  33677. } else {
  33678. fmt.Println(err)
  33679. }
  33680. userJSONBytes3, _ := json.Marshal(dat3)
  33681. var res3 models.Result3260
  33682. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  33683. utils.ErrorLog("解析失败:%v", err)
  33684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33685. return
  33686. }
  33687. var curpage int
  33688. var pagesize int = 100
  33689. var start int = 1
  33690. //var stop int
  33691. //pagecount := 10
  33692. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  33693. var res22 []models.Result3260
  33694. for curpage = 1; curpage <= pagecount; curpage++ {
  33695. if curpage == 1 {
  33696. start = 0
  33697. } else {
  33698. start = (curpage-1)*pagesize + 1
  33699. }
  33700. fmt.Println(start)
  33701. //stop = curpage * pagesize
  33702. //if stop > int(res3.Output.Totalrow) {
  33703. // stop =int(res3.Output.Totalrow)
  33704. //}
  33705. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  33706. var dat2 map[string]interface{}
  33707. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  33708. fmt.Println(dat)
  33709. } else {
  33710. fmt.Println(err)
  33711. }
  33712. userJSONBytes2, _ := json.Marshal(dat2)
  33713. var res2 models.Result3260
  33714. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  33715. utils.ErrorLog("解析失败:%v", err)
  33716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33717. return
  33718. }
  33719. if res2.Infcode == 0 {
  33720. res22 = append(res22, res2)
  33721. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  33722. //var dat2 map[string]interface{}
  33723. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  33724. // fmt.Println(dat)
  33725. //} else {
  33726. // fmt.Println(err)
  33727. //}
  33728. //c.ServeSuccessJSON(map[string]interface{}{
  33729. // "list": res2.Output.Data,
  33730. //})
  33731. //continue
  33732. }
  33733. }
  33734. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  33735. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  33736. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  33737. //var dat2 map[string]interface{}
  33738. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  33739. // fmt.Println(dat)
  33740. //} else {
  33741. // fmt.Println(err)
  33742. //}
  33743. //userJSONBytes2, _ := json.Marshal(dat2)
  33744. //var res2 models.Result3260
  33745. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  33746. // utils.ErrorLog("解析失败:%v", err)
  33747. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33748. // return
  33749. //}
  33750. //if res2.Infcode == 0 {
  33751. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  33752. // var dat2 map[string]interface{}
  33753. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  33754. // fmt.Println(dat)
  33755. // } else {
  33756. // fmt.Println(err)
  33757. // }
  33758. // c.ServeSuccessJSON(map[string]interface{}{
  33759. // "list": res2.Output.Data,
  33760. // })
  33761. //}
  33762. }
  33763. func (c *HisApiController) ComfirmAllopatry() {
  33764. year := c.GetString("year")
  33765. month := c.GetString("month")
  33766. admin_user_id, _ := c.GetInt64("admin_user_id")
  33767. adminUser := c.GetAdminUserInfo()
  33768. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33769. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33770. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  33771. var dat map[string]interface{}
  33772. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33773. fmt.Println(dat)
  33774. } else {
  33775. fmt.Println(err)
  33776. }
  33777. userJSONBytes, _ := json.Marshal(dat)
  33778. var res models.Result9001
  33779. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33780. utils.ErrorLog("解析失败:%v", err)
  33781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33782. return
  33783. }
  33784. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  33785. var dat2 map[string]interface{}
  33786. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  33787. fmt.Println(dat)
  33788. } else {
  33789. fmt.Println(err)
  33790. }
  33791. userJSONBytes2, _ := json.Marshal(dat2)
  33792. var res2 models.Result3260
  33793. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  33794. utils.ErrorLog("解析失败:%v", err)
  33795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33796. return
  33797. }
  33798. //if res2.Infcode == 0 {
  33799. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  33800. // var dat map[string]interface{}
  33801. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33802. // fmt.Println(dat)
  33803. // } else {
  33804. // fmt.Println(err)
  33805. // }
  33806. // userJSONBytes, _ := json.Marshal(dat)
  33807. // var res3 models.Result3261
  33808. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  33809. // utils.ErrorLog("解析失败:%v", err)
  33810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33811. // return
  33812. // }
  33813. //
  33814. // if res3.Infcode == 0 {
  33815. // record := &models.HisYidiClearRecord{
  33816. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  33817. // Ctime: time.Now().Unix(),
  33818. // Mtime: time.Now().Unix(),
  33819. // Status: 1,
  33820. // MsgId: msgId,
  33821. // }
  33822. // service.SaveClearRecord(record)
  33823. // c.ServeSuccessJSON(map[string]interface{}{
  33824. // "msg": "提取成功",
  33825. // })
  33826. // }
  33827. //}
  33828. }
  33829. func (c *HisApiController) RefundAllopatry() {
  33830. year := c.GetString("year")
  33831. month := c.GetString("month")
  33832. //id, _ := c.GetInt64("id")
  33833. admin_user_id, _ := c.GetInt64("admin_user_id")
  33834. adminUser := c.GetAdminUserInfo()
  33835. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33836. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33837. //record, _ := service.GetClearRecordById(id)
  33838. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  33839. var dat map[string]interface{}
  33840. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33841. fmt.Println(dat)
  33842. } else {
  33843. fmt.Println(err)
  33844. }
  33845. userJSONBytes, _ := json.Marshal(dat)
  33846. var res models.Result9001
  33847. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33848. utils.ErrorLog("解析失败:%v", err)
  33849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33850. return
  33851. }
  33852. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  33853. var dat2 map[string]interface{}
  33854. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  33855. fmt.Println(dat)
  33856. } else {
  33857. fmt.Println(err)
  33858. }
  33859. userJSONBytes2, _ := json.Marshal(dat2)
  33860. var empty ResultFourteen
  33861. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  33862. utils.ErrorLog("解析失败:%v", err)
  33863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33864. return
  33865. }
  33866. if empty.Infcode == 0 {
  33867. c.ServeSuccessJSON(map[string]interface{}{
  33868. "msg": "撤销成功",
  33869. })
  33870. return
  33871. }
  33872. }
  33873. func (c *HisApiController) ReversalOtherData() {
  33874. var customData []*CustomData
  33875. custom := &CustomData{
  33876. MsgId: "H44022900158202103301714472004",
  33877. PsnNo: "44020000001101329945",
  33878. Info: "2208",
  33879. }
  33880. customData = append(customData, custom)
  33881. custom1 := &CustomData{
  33882. MsgId: "H4402290015820210330172057803",
  33883. PsnNo: "44020000001101161813",
  33884. Info: "2208",
  33885. }
  33886. customData = append(customData, custom1)
  33887. custom2 := &CustomData{
  33888. MsgId: "H44022900158202103301705198813",
  33889. PsnNo: "44190000133097375417",
  33890. Info: "2208",
  33891. }
  33892. customData = append(customData, custom2)
  33893. custom3 := &CustomData{
  33894. MsgId: "H44022900158202103301715524756",
  33895. PsnNo: "44020000001100187221",
  33896. Info: "2208",
  33897. }
  33898. customData = append(customData, custom3)
  33899. custom4 := &CustomData{
  33900. MsgId: "H44022900158202103301730376224",
  33901. PsnNo: "44020000001101959155",
  33902. Info: "2208",
  33903. }
  33904. customData = append(customData, custom4)
  33905. custom5 := &CustomData{
  33906. MsgId: "H44022900158202103301748008725",
  33907. PsnNo: "44020000001104246641",
  33908. Info: "2208",
  33909. }
  33910. customData = append(customData, custom5)
  33911. custom6 := &CustomData{
  33912. MsgId: "H44022900158202103301718096755",
  33913. PsnNo: "44020000001102211860",
  33914. Info: "2208",
  33915. }
  33916. customData = append(customData, custom6)
  33917. custom7 := &CustomData{
  33918. MsgId: "H44022900158202103301736551640",
  33919. PsnNo: "44020000001102687718",
  33920. Info: "2208",
  33921. }
  33922. customData = append(customData, custom7)
  33923. custom8 := &CustomData{
  33924. MsgId: "H44022900158202103301743097676",
  33925. PsnNo: "44020000001102127785",
  33926. Info: "2208",
  33927. }
  33928. customData = append(customData, custom8)
  33929. custom9 := &CustomData{
  33930. MsgId: "H44022900158202103301712304203",
  33931. PsnNo: "44020000001101518097",
  33932. Info: "2208",
  33933. }
  33934. customData = append(customData, custom9)
  33935. custom10 := &CustomData{
  33936. MsgId: "H44022900158202103301738448785",
  33937. PsnNo: "44020000001100500813",
  33938. Info: "2208",
  33939. }
  33940. customData = append(customData, custom10)
  33941. custom11 := &CustomData{
  33942. MsgId: "H44022900158202103301732455843",
  33943. PsnNo: "44020000001102690557",
  33944. Info: "2208",
  33945. }
  33946. customData = append(customData, custom11)
  33947. custom12 := &CustomData{
  33948. MsgId: "H44022900158202103301745421708",
  33949. PsnNo: "44020000001102211928",
  33950. Info: "2208",
  33951. }
  33952. customData = append(customData, custom12)
  33953. custom1212 := &CustomData{
  33954. MsgId: "H440229001582021033017351627",
  33955. PsnNo: "44020000001102481733",
  33956. Info: "2208",
  33957. }
  33958. customData = append(customData, custom1212)
  33959. custom13 := &CustomData{
  33960. MsgId: "H44022900158202103301740327951",
  33961. PsnNo: "44020000001103174866",
  33962. Info: "2208",
  33963. }
  33964. customData = append(customData, custom13)
  33965. custom14 := &CustomData{
  33966. MsgId: "H4402290015820210330174922668",
  33967. PsnNo: "44020000001102927272",
  33968. Info: "2208",
  33969. }
  33970. customData = append(customData, custom14)
  33971. custom15 := &CustomData{
  33972. MsgId: "H44022900158202103301752362273",
  33973. PsnNo: "44020000001102942890",
  33974. Info: "2208",
  33975. }
  33976. customData = append(customData, custom15)
  33977. custom16 := &CustomData{
  33978. MsgId: "H44022900158202103301751082917",
  33979. PsnNo: "44020000001101662162",
  33980. Info: "2208",
  33981. }
  33982. customData = append(customData, custom16)
  33983. custom17 := &CustomData{
  33984. MsgId: "H44022900158202103301754147728",
  33985. PsnNo: "44020000000229014511",
  33986. Info: "2208",
  33987. }
  33988. customData = append(customData, custom17)
  33989. adminUser := c.GetAdminUserInfo()
  33990. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33991. for _, item := range customData {
  33992. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  33993. fmt.Println(result)
  33994. }
  33995. }
  33996. func PathExists(path string) (bool, error) {
  33997. _, err := os.Stat(path)
  33998. if err == nil {
  33999. return true, nil
  34000. }
  34001. if os.IsNotExist(err) {
  34002. return false, nil
  34003. }
  34004. return false, err
  34005. }
  34006. // 创建文件夹
  34007. func Mkdir(dir string) {
  34008. // 创建文件夹
  34009. exist, err := PathExists(dir)
  34010. if err != nil {
  34011. fmt.Println(err.Error())
  34012. } else {
  34013. if exist {
  34014. fmt.Println(dir + "文件夹已存在!")
  34015. } else {
  34016. // 文件夹名称,权限
  34017. err := os.Mkdir(dir, os.ModePerm)
  34018. if err != nil {
  34019. fmt.Println(dir+"文件夹创建失败:", err.Error())
  34020. } else {
  34021. fmt.Println(dir + "文件夹创建成功!")
  34022. }
  34023. }
  34024. }
  34025. }
  34026. // 压缩文件
  34027. func Zip(srcFile string, destZip string) error {
  34028. zipfile, err := os.Create(destZip)
  34029. if err != nil {
  34030. return err
  34031. }
  34032. defer zipfile.Close()
  34033. archive := zip.NewWriter(zipfile)
  34034. defer archive.Close()
  34035. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  34036. if err != nil {
  34037. return err
  34038. }
  34039. header, err := zip.FileInfoHeader(info)
  34040. if err != nil {
  34041. return err
  34042. }
  34043. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  34044. // header.Name = path
  34045. if info.IsDir() {
  34046. header.Name += "/"
  34047. } else {
  34048. header.Method = zip.Deflate
  34049. }
  34050. writer, err := archive.CreateHeader(header)
  34051. if err != nil {
  34052. return err
  34053. }
  34054. if !info.IsDir() {
  34055. file, err := os.Open(path)
  34056. if err != nil {
  34057. return err
  34058. }
  34059. defer file.Close()
  34060. _, err = io.Copy(writer, file)
  34061. }
  34062. return err
  34063. })
  34064. return err
  34065. }
  34066. func ReadFile(filePath string) []byte {
  34067. f, err := os.Open(filePath)
  34068. if err != nil {
  34069. fmt.Println("read file fail", err)
  34070. return nil
  34071. }
  34072. defer f.Close()
  34073. fd, err := ioutil.ReadAll(f)
  34074. if err != nil {
  34075. fmt.Println("read to fd fail", err)
  34076. return nil
  34077. }
  34078. return fd
  34079. }
  34080. func saveLogq(result string, request string, infno string, desc string) {
  34081. dir := "日志"
  34082. utils.Mkdir(dir)
  34083. month := time.Unix(1557042972, 0).Format("1")
  34084. year := time.Now().Format("2006")
  34085. month = time.Now().Format("01")
  34086. day := time.Now().Format("02")
  34087. hour := time.Now().Format("15")
  34088. min := time.Now().Format("04")
  34089. sec := time.Now().Format("05")
  34090. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  34091. file := year + month + day + "_log"
  34092. file_name := file + ".txt"
  34093. file_path := "日志" + "/" + file_name
  34094. exist, _ := utils.PathExists(file_path)
  34095. if exist { //存在
  34096. fmt.Println("存在")
  34097. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  34098. if err != nil {
  34099. fmt.Println("read fail")
  34100. }
  34101. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  34102. n, _ := f.Seek(0, 2)
  34103. _, err = f.WriteAt([]byte(content), n)
  34104. } else { //不存在
  34105. fmt.Println("文件不存在,创建文件")
  34106. f, err := os.Create("日志" + "/" + file_name)
  34107. defer f.Close()
  34108. if err != nil {
  34109. } else {
  34110. _, err = f.Write([]byte("记录日志"))
  34111. }
  34112. }
  34113. }
  34114. func saveLog(result string, request string, infno string, desc string) {
  34115. org_id, _ := beego.AppConfig.Int64("org_id")
  34116. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  34117. dir := miConfig.OrgName + "日志"
  34118. utils.Mkdir(dir)
  34119. month := time.Unix(1557042972, 0).Format("1")
  34120. year := time.Now().Format("2006")
  34121. month = time.Now().Format("01")
  34122. day := time.Now().Format("02")
  34123. hour := time.Now().Format("15")
  34124. min := time.Now().Format("04")
  34125. sec := time.Now().Format("05")
  34126. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  34127. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  34128. file_name := file + ".txt"
  34129. file_path := miConfig.OrgName + "日志" + "/" + file_name
  34130. exist, _ := utils.PathExists(file_path)
  34131. if exist { //存在
  34132. fmt.Println("存在")
  34133. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  34134. if err != nil {
  34135. fmt.Println("read fail")
  34136. }
  34137. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  34138. n, _ := f.Seek(0, 2)
  34139. _, err = f.WriteAt([]byte(content), n)
  34140. } else { //不存在
  34141. fmt.Println("文件不存在,创建文件")
  34142. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  34143. defer f.Close()
  34144. if err != nil {
  34145. } else {
  34146. _, err = f.Write([]byte("记录日志"))
  34147. }
  34148. }
  34149. }
  34150. type Charset string
  34151. const (
  34152. UTF8 = Charset("UTF-8")
  34153. GB18030 = Charset("GB18030")
  34154. )
  34155. func ConvertToString(src string, srcCode string, tagCode string) string {
  34156. srcCoder := mahonia.NewDecoder(srcCode)
  34157. srcResult := srcCoder.ConvertString(src)
  34158. tagCoder := mahonia.NewDecoder(tagCode)
  34159. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  34160. result := string(cdata)
  34161. return result
  34162. }
  34163. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  34164. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  34165. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  34166. var token string
  34167. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34168. var api string
  34169. if miConfig.MdtrtareaAdmvs == "320921" {
  34170. 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 +
  34171. "&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
  34172. fmt.Println(api)
  34173. } else {
  34174. 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 +
  34175. "&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
  34176. }
  34177. resp, requestErr := http.Get(api)
  34178. if requestErr != nil {
  34179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34180. return ""
  34181. }
  34182. body, ioErr := ioutil.ReadAll(resp.Body)
  34183. if ioErr != nil {
  34184. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34186. return ""
  34187. }
  34188. var respJSON map[string]interface{}
  34189. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34192. return ""
  34193. }
  34194. var status string
  34195. status = respJSON["data"].(map[string]interface{})["status"].(string)
  34196. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  34197. var res ResultTwo //1101结果
  34198. var res10265 ResultTwo10265 //1101结果
  34199. if status == "0" { //读卡成功
  34200. var card_info string //卡信息
  34201. var busi_card_info string
  34202. token = respJSON["data"].(map[string]interface{})["token"].(string)
  34203. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  34204. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  34205. fmt.Println(card_info)
  34206. fmt.Println(busi_card_info)
  34207. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  34208. result, _ := json.Marshal(respJSON)
  34209. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  34210. utils.ErrorLog("解析失败:%v", err)
  34211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34212. return ""
  34213. }
  34214. res.ErrMsg = res10265.ErrMsg
  34215. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  34216. res.Infcode = infocode
  34217. res.Output = res10265.Output
  34218. res.InfRefmsgid = res10265.InfRefmsgid
  34219. if res.Infcode == 0 {
  34220. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  34221. if err == gorm.ErrRecordNotFound {
  34222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  34223. return ""
  34224. } else if err != nil {
  34225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  34226. return ""
  34227. } else {
  34228. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  34229. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  34230. infoStr := string(Iinfos)
  34231. idetinfoStr := string(Idetinfos)
  34232. psn := &models.HisPsn{
  34233. PsnNo: res.Output.Baseinfo.PsnNo,
  34234. PatientId: patient.ID,
  34235. Certno: res.Output.Baseinfo.Certno,
  34236. Gend: res.Output.Baseinfo.Gend,
  34237. Naty: res.Output.Baseinfo.Naty,
  34238. PsnCertType: res.Output.Baseinfo.PsnCertType,
  34239. PsnName: res.Output.Baseinfo.PsnName,
  34240. Idetinfo: idetinfoStr,
  34241. Insuinfo: infoStr,
  34242. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  34243. CardInfo: card_info,
  34244. VerifyNumber: token,
  34245. }
  34246. service.CreateHisPsn(psn)
  34247. return token
  34248. }
  34249. }
  34250. } else {
  34251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34252. return ""
  34253. }
  34254. } else { //读卡失败
  34255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34256. return ""
  34257. }
  34258. return token
  34259. }
  34260. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  34261. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  34262. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  34263. var token string
  34264. var api string
  34265. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  34266. "&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
  34267. fmt.Println(api)
  34268. resp, requestErr := http.Get(api)
  34269. if requestErr != nil {
  34270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34271. return ""
  34272. }
  34273. body, ioErr := ioutil.ReadAll(resp.Body)
  34274. if ioErr != nil {
  34275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34277. return ""
  34278. }
  34279. var respJSON map[string]interface{}
  34280. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34281. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34283. return ""
  34284. }
  34285. var status string
  34286. status = respJSON["data"].(map[string]interface{})["status"].(string)
  34287. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  34288. var res ResultTwo //1101结果
  34289. if status == "1" { //读卡成功
  34290. var card_info string //卡信息
  34291. var busi_card_info string
  34292. token = respJSON["data"].(map[string]interface{})["token"].(string)
  34293. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  34294. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  34295. fmt.Println(card_info)
  34296. fmt.Println(busi_card_info)
  34297. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  34298. result, _ := json.Marshal(respJSON)
  34299. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34300. utils.ErrorLog("解析失败:%v", err)
  34301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34302. return ""
  34303. }
  34304. if res.Infcode == 0 {
  34305. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  34306. if err == gorm.ErrRecordNotFound {
  34307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  34308. return ""
  34309. } else if err != nil {
  34310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  34311. return ""
  34312. } else {
  34313. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  34314. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  34315. infoStr := string(Iinfos)
  34316. idetinfoStr := string(Idetinfos)
  34317. psn := &models.HisPsn{
  34318. PsnNo: res.Output.Baseinfo.PsnNo,
  34319. PatientId: patient.ID,
  34320. Certno: res.Output.Baseinfo.Certno,
  34321. Gend: res.Output.Baseinfo.Gend,
  34322. Naty: res.Output.Baseinfo.Naty,
  34323. PsnCertType: res.Output.Baseinfo.PsnCertType,
  34324. PsnName: res.Output.Baseinfo.PsnName,
  34325. Idetinfo: idetinfoStr,
  34326. Insuinfo: infoStr,
  34327. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  34328. CardInfo: card_info,
  34329. VerifyNumber: token,
  34330. }
  34331. service.CreateHisPsn(psn)
  34332. return token
  34333. }
  34334. }
  34335. } else {
  34336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34337. return ""
  34338. }
  34339. return token
  34340. }
  34341. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  34342. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  34343. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  34344. var token string
  34345. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34346. var api string
  34347. if miConfig.MdtrtareaAdmvs == "320921" {
  34348. 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 +
  34349. "&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
  34350. fmt.Println(api)
  34351. } else {
  34352. 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 +
  34353. "&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
  34354. }
  34355. resp, requestErr := http.Get(api)
  34356. if requestErr != nil {
  34357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34358. return ""
  34359. }
  34360. body, ioErr := ioutil.ReadAll(resp.Body)
  34361. if ioErr != nil {
  34362. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34364. return ""
  34365. }
  34366. var respJSON map[string]interface{}
  34367. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34370. return ""
  34371. }
  34372. var status string
  34373. status = respJSON["data"].(map[string]interface{})["status"].(string)
  34374. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  34375. var res ResultTwo //1101结果
  34376. var res10265 ResultTwo10265 //1101结果
  34377. if status == "0" { //读卡成功
  34378. var card_info string //卡信息
  34379. var busi_card_info string
  34380. token = respJSON["data"].(map[string]interface{})["token"].(string)
  34381. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  34382. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  34383. fmt.Println(card_info)
  34384. fmt.Println(busi_card_info)
  34385. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  34386. result, _ := json.Marshal(respJSON)
  34387. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  34388. utils.ErrorLog("解析失败:%v", err)
  34389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34390. return ""
  34391. }
  34392. res.ErrMsg = res10265.ErrMsg
  34393. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  34394. res.Infcode = infocode
  34395. res.Output = res10265.Output
  34396. res.InfRefmsgid = res10265.InfRefmsgid
  34397. if res.Infcode == 0 {
  34398. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  34399. if err == gorm.ErrRecordNotFound {
  34400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  34401. return ""
  34402. } else if err != nil {
  34403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  34404. return ""
  34405. } else {
  34406. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  34407. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  34408. infoStr := string(Iinfos)
  34409. idetinfoStr := string(Idetinfos)
  34410. psn := &models.HisPsn{
  34411. PsnNo: res.Output.Baseinfo.PsnNo,
  34412. PatientId: patient.ID,
  34413. Certno: res.Output.Baseinfo.Certno,
  34414. Gend: res.Output.Baseinfo.Gend,
  34415. Naty: res.Output.Baseinfo.Naty,
  34416. PsnCertType: res.Output.Baseinfo.PsnCertType,
  34417. PsnName: res.Output.Baseinfo.PsnName,
  34418. Idetinfo: idetinfoStr,
  34419. Insuinfo: infoStr,
  34420. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  34421. CardInfo: card_info,
  34422. VerifyNumber: token,
  34423. }
  34424. service.CreateHisPsn(psn)
  34425. return token
  34426. }
  34427. }
  34428. } else {
  34429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34430. return ""
  34431. }
  34432. } else { //读卡失败
  34433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34434. return ""
  34435. }
  34436. return token
  34437. }
  34438. func DeleteExtraSpaceTwo(s string) string {
  34439. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  34440. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  34441. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  34442. reg, _ := regexp.Compile(regstr) //编译正则表达式
  34443. s2 := make([]byte, len(s1)) //定义字符数组切片
  34444. copy(s2, s1) //将字符串复制到切片
  34445. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  34446. for len(spc_index) > 0 { //找到适配项
  34447. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  34448. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  34449. }
  34450. return string(s2)
  34451. }
  34452. func Remove0000(s string) string {
  34453. str := make([]rune, 0, len(s))
  34454. for _, v := range []rune(s) {
  34455. if v == 0 {
  34456. continue
  34457. }
  34458. str = append(str, v)
  34459. }
  34460. return string(str)
  34461. }
  34462. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  34463. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  34464. readCard := DllDef.MustFindProc("EcQuery")
  34465. pCardInfo := make([]byte, 8192)
  34466. pBusiCardInfo := make([]byte, 8192)
  34467. data := make(map[string]interface{})
  34468. //pData := make(map[string]interface{})
  34469. inputData := make(map[string]interface{})
  34470. inputData["orgId"] = code
  34471. inputData["businessType"] = "01101"
  34472. inputData["operatorId"] = operator_id
  34473. inputData["operatorName"] = operator_name
  34474. inputData["officeId"] = "001"
  34475. inputData["officeName"] = "血透室"
  34476. //
  34477. data["data"] = inputData
  34478. data["transType"] = "ec.query"
  34479. data["orgId"] = code
  34480. bytesData, _ := json.Marshal(data)
  34481. pCardInfo = bytesData
  34482. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  34483. fmt.Println(ret2)
  34484. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  34485. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  34486. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  34487. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  34488. if ret2 != 0 {
  34489. return "", ""
  34490. }
  34491. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  34492. }
  34493. func DeleteExtraSpace(s string) string {
  34494. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  34495. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  34496. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  34497. reg, _ := regexp.Compile(regstr) //编译正则表达式
  34498. s2 := make([]byte, len(s1)) //定义字符数组切片
  34499. copy(s2, s1) //将字符串复制到切片
  34500. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  34501. for len(spc_index) > 0 { //找到适配项
  34502. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  34503. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  34504. }
  34505. return string(s2)
  34506. }
  34507. // 对账
  34508. func (c *HisApiController) Post3202() {
  34509. start_time := c.GetString("start_time")
  34510. end_time := c.GetString("end_time")
  34511. //insutype := c.GetString("insutype")
  34512. clr_type := c.GetString("clr_type")
  34513. clr_org := c.GetString("clr_optins")
  34514. admin_user_id, _ := c.GetInt64("admin_user_id")
  34515. adminUser := c.GetAdminUserInfo()
  34516. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34517. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34518. if len(clr_org) == 0 {
  34519. clr_org = miConfig.MdtrtareaAdmvs
  34520. }
  34521. timeLayout := "2006-01-02"
  34522. loc, _ := time.LoadLocation("Local")
  34523. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34524. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34525. var orders []*models.HisOrder
  34526. if clr_org == "421300" {
  34527. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34528. } else if clr_org == "420902" {
  34529. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34530. } else {
  34531. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34532. }
  34533. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  34534. //fixmedins_setl_cnt := int64(len(orders))
  34535. var medfee_sumamt float64
  34536. var acct_pay float64
  34537. var fund_pay_sumamt float64
  34538. for _, item := range orders {
  34539. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34540. acct_pay = acct_pay + item.AcctPay
  34541. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34542. }
  34543. //var medfee_sumamt_two float64
  34544. //var acct_pay_two float64
  34545. //var fund_pay_sumamt_two float64
  34546. //for _, item := range orders_two {
  34547. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  34548. // acct_pay_two = acct_pay_two + item.AcctPay
  34549. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  34550. //}
  34551. //var user_name string
  34552. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34553. //if role.ID == 0 {
  34554. // user_name = "xxx"
  34555. //} else {
  34556. // user_name = role.UserName
  34557. //}
  34558. var res ResultSix
  34559. if config.IsOpen == 1 {
  34560. var bps []*models.BusinessParamsTwo
  34561. var bp models.BusinessParamsTwo
  34562. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  34563. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  34564. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  34565. bp.MedfeeSumamt = medfee_sumamt_str
  34566. bp.AcctPay = acct_pay_str
  34567. bp.FundPaySumamt = fund_pay_sumamt_str
  34568. bp.Insutype = ""
  34569. bp.StmtBegndate = start_time
  34570. bp.ClrType = clr_type
  34571. bp.SetlOptins = clr_org
  34572. bp.StmtEnddate = end_time
  34573. bps = append(bps, &bp)
  34574. data := make(map[string]interface{})
  34575. data["bps"] = bps
  34576. data["org_name"] = miConfig.OrgName
  34577. data["doctor"] = role.UserName
  34578. data["fixmedins_code"] = miConfig.Code
  34579. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34580. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34581. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34582. if miConfig.MdtrtareaAdmvs == "421300" {
  34583. client := &http.Client{}
  34584. bytesData, _ := json.Marshal(data)
  34585. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  34586. resp, _ := client.Do(req)
  34587. defer resp.Body.Close()
  34588. body, ioErr := ioutil.ReadAll(resp.Body)
  34589. if ioErr != nil {
  34590. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34592. return
  34593. }
  34594. var respJSON map[string]interface{}
  34595. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34596. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34598. return
  34599. }
  34600. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34601. userJSONBytes, _ := json.Marshal(respJSON)
  34602. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34603. utils.ErrorLog("解析失败:%v", err)
  34604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34605. return
  34606. }
  34607. }
  34608. if miConfig.MdtrtareaAdmvs == "420200" {
  34609. client := &http.Client{}
  34610. bytesData, _ := json.Marshal(data)
  34611. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  34612. resp, _ := client.Do(req)
  34613. defer resp.Body.Close()
  34614. body, ioErr := ioutil.ReadAll(resp.Body)
  34615. if ioErr != nil {
  34616. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34618. return
  34619. }
  34620. var respJSON map[string]interface{}
  34621. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34622. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34624. return
  34625. }
  34626. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34627. userJSONBytes, _ := json.Marshal(respJSON)
  34628. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34629. utils.ErrorLog("解析失败:%v", err)
  34630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34631. return
  34632. }
  34633. }
  34634. if miConfig.MdtrtareaAdmvs == "421182" {
  34635. client := &http.Client{}
  34636. bytesData, _ := json.Marshal(data)
  34637. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  34638. resp, _ := client.Do(req)
  34639. defer resp.Body.Close()
  34640. body, ioErr := ioutil.ReadAll(resp.Body)
  34641. if ioErr != nil {
  34642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34644. return
  34645. }
  34646. var respJSON map[string]interface{}
  34647. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34650. return
  34651. }
  34652. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34653. userJSONBytes, _ := json.Marshal(respJSON)
  34654. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34655. utils.ErrorLog("解析失败:%v", err)
  34656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34657. return
  34658. }
  34659. }
  34660. if miConfig.MdtrtareaAdmvs == "420902" {
  34661. client := &http.Client{}
  34662. bytesData, _ := json.Marshal(data)
  34663. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  34664. resp, _ := client.Do(req)
  34665. defer resp.Body.Close()
  34666. body, ioErr := ioutil.ReadAll(resp.Body)
  34667. if ioErr != nil {
  34668. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34670. return
  34671. }
  34672. var respJSON map[string]interface{}
  34673. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34676. return
  34677. }
  34678. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34679. userJSONBytes, _ := json.Marshal(respJSON)
  34680. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34681. utils.ErrorLog("解析失败:%v", err)
  34682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34683. return
  34684. }
  34685. }
  34686. if res.Infcode == 0 {
  34687. c.ServeSuccessJSON(map[string]interface{}{
  34688. "msg": "发起成功",
  34689. })
  34690. } else {
  34691. c.ServeSuccessJSON(map[string]interface{}{
  34692. "failed_code": -10,
  34693. "msg": res.ErrMsg,
  34694. })
  34695. }
  34696. }
  34697. }
  34698. func (c *HisApiController) Post3204a() {
  34699. start_time := c.GetString("start_time")
  34700. end_time := c.GetString("end_time")
  34701. //insutype := c.GetString("insutype")
  34702. clr_type := c.GetString("clr_type")
  34703. clr_org := c.GetString("clr_optins")
  34704. admin_user_id, _ := c.GetInt64("admin_user_id")
  34705. adminUser := c.GetAdminUserInfo()
  34706. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34707. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34708. if len(clr_org) == 0 {
  34709. clr_org = miConfig.MdtrtareaAdmvs
  34710. }
  34711. timeLayout := "2006-01-02"
  34712. loc, _ := time.LoadLocation("Local")
  34713. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34714. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34715. var orders []*models.HisOrder
  34716. if clr_org == "421300" {
  34717. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34718. } else if clr_org == "420902" {
  34719. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34720. } else {
  34721. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34722. }
  34723. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  34724. //fixmedins_setl_cnt := int64(len(orders))
  34725. var medfee_sumamt float64
  34726. var acct_pay float64
  34727. var fund_pay_sumamt float64
  34728. for _, item := range orders {
  34729. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34730. acct_pay = acct_pay + item.AcctPay
  34731. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34732. }
  34733. //var medfee_sumamt_two float64
  34734. //var acct_pay_two float64
  34735. //var fund_pay_sumamt_two float64
  34736. //for _, item := range orders_two {
  34737. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  34738. // acct_pay_two = acct_pay_two + item.AcctPay
  34739. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  34740. //}
  34741. //var user_name string
  34742. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34743. //if role.ID == 0 {
  34744. // user_name = "xxx"
  34745. //} else {
  34746. // user_name = role.UserName
  34747. //}
  34748. var res ResultSix
  34749. if config.IsOpen == 1 {
  34750. var bps []*models.BusinessParamsTwo
  34751. var bp models.BusinessParamsTwo
  34752. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  34753. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  34754. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  34755. bp.MedfeeSumamt = medfee_sumamt_str
  34756. bp.AcctPay = acct_pay_str
  34757. bp.FundPaySumamt = fund_pay_sumamt_str
  34758. bp.Insutype = ""
  34759. bp.StmtBegndate = start_time
  34760. bp.ClrType = clr_type
  34761. bp.SetlOptins = clr_org
  34762. bp.StmtEnddate = end_time
  34763. bps = append(bps, &bp)
  34764. data := make(map[string]interface{})
  34765. data["bps"] = bps
  34766. data["org_name"] = miConfig.OrgName
  34767. data["doctor"] = role.UserName
  34768. data["fixmedins_code"] = miConfig.Code
  34769. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34770. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34771. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34772. if miConfig.MdtrtareaAdmvs == "421300" {
  34773. client := &http.Client{}
  34774. bytesData, _ := json.Marshal(data)
  34775. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  34776. resp, _ := client.Do(req)
  34777. defer resp.Body.Close()
  34778. body, ioErr := ioutil.ReadAll(resp.Body)
  34779. if ioErr != nil {
  34780. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34782. return
  34783. }
  34784. var respJSON map[string]interface{}
  34785. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34786. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34788. return
  34789. }
  34790. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34791. userJSONBytes, _ := json.Marshal(respJSON)
  34792. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34793. utils.ErrorLog("解析失败:%v", err)
  34794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34795. return
  34796. }
  34797. }
  34798. if miConfig.MdtrtareaAdmvs == "420200" {
  34799. client := &http.Client{}
  34800. bytesData, _ := json.Marshal(data)
  34801. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  34802. resp, _ := client.Do(req)
  34803. defer resp.Body.Close()
  34804. body, ioErr := ioutil.ReadAll(resp.Body)
  34805. if ioErr != nil {
  34806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34808. return
  34809. }
  34810. var respJSON map[string]interface{}
  34811. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34814. return
  34815. }
  34816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34817. userJSONBytes, _ := json.Marshal(respJSON)
  34818. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34819. utils.ErrorLog("解析失败:%v", err)
  34820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34821. return
  34822. }
  34823. }
  34824. if miConfig.MdtrtareaAdmvs == "421182" {
  34825. client := &http.Client{}
  34826. bytesData, _ := json.Marshal(data)
  34827. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  34828. resp, _ := client.Do(req)
  34829. defer resp.Body.Close()
  34830. body, ioErr := ioutil.ReadAll(resp.Body)
  34831. if ioErr != nil {
  34832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34834. return
  34835. }
  34836. var respJSON map[string]interface{}
  34837. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34840. return
  34841. }
  34842. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34843. userJSONBytes, _ := json.Marshal(respJSON)
  34844. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34845. utils.ErrorLog("解析失败:%v", err)
  34846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34847. return
  34848. }
  34849. }
  34850. if miConfig.MdtrtareaAdmvs == "420902" {
  34851. client := &http.Client{}
  34852. bytesData, _ := json.Marshal(data)
  34853. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  34854. resp, _ := client.Do(req)
  34855. defer resp.Body.Close()
  34856. body, ioErr := ioutil.ReadAll(resp.Body)
  34857. if ioErr != nil {
  34858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34860. return
  34861. }
  34862. var respJSON map[string]interface{}
  34863. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34866. return
  34867. }
  34868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34869. userJSONBytes, _ := json.Marshal(respJSON)
  34870. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34871. utils.ErrorLog("解析失败:%v", err)
  34872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34873. return
  34874. }
  34875. }
  34876. if res.Infcode == 0 {
  34877. c.ServeSuccessJSON(map[string]interface{}{
  34878. "msg": "撤销成功",
  34879. })
  34880. } else {
  34881. c.ServeSuccessJSON(map[string]interface{}{
  34882. "failed_code": -10,
  34883. "msg": res.ErrMsg,
  34884. })
  34885. }
  34886. }
  34887. }
  34888. func (c *HisApiController) Post3204() {
  34889. admin_user_id, _ := c.GetInt64("admin_user_id")
  34890. id := c.GetString("id")
  34891. adminUser := c.GetAdminUserInfo()
  34892. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34893. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34894. //clr_org := miConfig.MdtrtareaAdmvs
  34895. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34896. var res ResultSix
  34897. if config.IsOpen == 1 {
  34898. data := make(map[string]interface{})
  34899. data["id"] = id
  34900. data["org_name"] = miConfig.OrgName
  34901. data["doctor"] = role.UserName
  34902. data["fixmedins_code"] = miConfig.Code
  34903. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34904. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34905. client := &http.Client{}
  34906. bytesData, _ := json.Marshal(data)
  34907. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  34908. resp, _ := client.Do(req)
  34909. defer resp.Body.Close()
  34910. body, ioErr := ioutil.ReadAll(resp.Body)
  34911. if ioErr != nil {
  34912. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34914. return
  34915. }
  34916. var respJSON map[string]interface{}
  34917. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34918. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34920. return
  34921. }
  34922. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34923. userJSONBytes, _ := json.Marshal(respJSON)
  34924. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34925. utils.ErrorLog("解析失败:%v", err)
  34926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34927. return
  34928. }
  34929. if res.Infcode == 0 {
  34930. c.ServeSuccessJSON(map[string]interface{}{
  34931. "msg": "发起成功",
  34932. })
  34933. } else {
  34934. c.ServeSuccessJSON(map[string]interface{}{
  34935. "failed_code": -10,
  34936. "msg": res.ErrMsg,
  34937. })
  34938. }
  34939. }
  34940. }
  34941. func (c *HisApiController) Post8404() {
  34942. admin_user_id, _ := c.GetInt64("admin_user_id")
  34943. month := c.GetString("month")
  34944. adminUser := c.GetAdminUserInfo()
  34945. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34946. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34947. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34948. var res ResultSix
  34949. if config.IsOpen == 1 {
  34950. data := make(map[string]interface{})
  34951. data["month"] = month
  34952. data["org_name"] = miConfig.OrgName
  34953. data["doctor"] = role.UserName
  34954. data["fixmedins_code"] = miConfig.Code
  34955. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34956. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34957. client := &http.Client{}
  34958. bytesData, _ := json.Marshal(data)
  34959. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  34960. resp, _ := client.Do(req)
  34961. defer resp.Body.Close()
  34962. body, ioErr := ioutil.ReadAll(resp.Body)
  34963. if ioErr != nil {
  34964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34966. return
  34967. }
  34968. var respJSON map[string]interface{}
  34969. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34972. return
  34973. }
  34974. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34975. userJSONBytes, _ := json.Marshal(respJSON)
  34976. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34977. utils.ErrorLog("解析失败:%v", err)
  34978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34979. return
  34980. }
  34981. if res.Infcode == 0 {
  34982. c.ServeSuccessJSON(map[string]interface{}{
  34983. "msg": "查询成功",
  34984. })
  34985. } else {
  34986. c.ServeSuccessJSON(map[string]interface{}{
  34987. "failed_code": -10,
  34988. "msg": res.ErrMsg,
  34989. })
  34990. }
  34991. }
  34992. }
  34993. func (c *HisApiController) Post3202b() {
  34994. start_time := c.GetString("start_time")
  34995. end_time := c.GetString("end_time")
  34996. //insutype := c.GetString("insutype")
  34997. clr_type := c.GetString("clr_type")
  34998. clr_org := c.GetString("clr_optins")
  34999. admin_user_id, _ := c.GetInt64("admin_user_id")
  35000. adminUser := c.GetAdminUserInfo()
  35001. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35002. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35003. if len(clr_org) == 0 {
  35004. clr_org = miConfig.MdtrtareaAdmvs
  35005. }
  35006. timeLayout := "2006-01-02"
  35007. loc, _ := time.LoadLocation("Local")
  35008. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35009. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35010. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  35011. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  35012. //fixmedins_setl_cnt := int64(len(orders))
  35013. var medfee_sumamt float64
  35014. var acct_pay float64
  35015. var fund_pay_sumamt float64
  35016. for _, item := range orders {
  35017. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35018. acct_pay = acct_pay + item.AcctPay
  35019. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35020. }
  35021. //var medfee_sumamt_two float64
  35022. //var acct_pay_two float64
  35023. //var fund_pay_sumamt_two float64
  35024. //for _, item := range orders_two {
  35025. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  35026. // acct_pay_two = acct_pay_two + item.AcctPay
  35027. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  35028. //}
  35029. //var user_name string
  35030. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35031. //if role.ID == 0 {
  35032. // user_name = "xxx"
  35033. //} else {
  35034. // user_name = role.UserName
  35035. //}
  35036. var res ResultSix
  35037. if config.IsOpen == 1 {
  35038. var bps []*models.BusinessParamsTwo
  35039. var bp models.BusinessParamsTwo
  35040. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  35041. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  35042. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  35043. bp.MedfeeSumamt = medfee_sumamt_str
  35044. bp.AcctPay = acct_pay_str
  35045. bp.FundPaySumamt = fund_pay_sumamt_str
  35046. bp.Insutype = "390"
  35047. bp.StmtBegndate = start_time
  35048. bp.ClrType = clr_type
  35049. bp.SetlOptins = clr_org
  35050. bp.StmtEnddate = end_time
  35051. bps = append(bps, &bp)
  35052. data := make(map[string]interface{})
  35053. data["bps"] = bps
  35054. data["org_name"] = miConfig.OrgName
  35055. data["doctor"] = role.UserName
  35056. data["fixmedins_code"] = miConfig.Code
  35057. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35058. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35059. if miConfig.MdtrtareaAdmvs == "421300" {
  35060. client := &http.Client{}
  35061. bytesData, _ := json.Marshal(data)
  35062. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  35063. resp, _ := client.Do(req)
  35064. defer resp.Body.Close()
  35065. body, ioErr := ioutil.ReadAll(resp.Body)
  35066. if ioErr != nil {
  35067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35069. return
  35070. }
  35071. var respJSON map[string]interface{}
  35072. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35075. return
  35076. }
  35077. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35078. userJSONBytes, _ := json.Marshal(respJSON)
  35079. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35080. utils.ErrorLog("解析失败:%v", err)
  35081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35082. return
  35083. }
  35084. }
  35085. if miConfig.MdtrtareaAdmvs == "420200" {
  35086. client := &http.Client{}
  35087. bytesData, _ := json.Marshal(data)
  35088. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  35089. resp, _ := client.Do(req)
  35090. defer resp.Body.Close()
  35091. body, ioErr := ioutil.ReadAll(resp.Body)
  35092. if ioErr != nil {
  35093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35095. return
  35096. }
  35097. var respJSON map[string]interface{}
  35098. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35101. return
  35102. }
  35103. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35104. userJSONBytes, _ := json.Marshal(respJSON)
  35105. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35106. utils.ErrorLog("解析失败:%v", err)
  35107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35108. return
  35109. }
  35110. }
  35111. if miConfig.MdtrtareaAdmvs == "421182" {
  35112. client := &http.Client{}
  35113. bytesData, _ := json.Marshal(data)
  35114. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  35115. resp, _ := client.Do(req)
  35116. defer resp.Body.Close()
  35117. body, ioErr := ioutil.ReadAll(resp.Body)
  35118. if ioErr != nil {
  35119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35121. return
  35122. }
  35123. var respJSON map[string]interface{}
  35124. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35127. return
  35128. }
  35129. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35130. userJSONBytes, _ := json.Marshal(respJSON)
  35131. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35132. utils.ErrorLog("解析失败:%v", err)
  35133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35134. return
  35135. }
  35136. }
  35137. if res.Infcode == 0 {
  35138. c.ServeSuccessJSON(map[string]interface{}{
  35139. "msg": "发起成功",
  35140. })
  35141. } else {
  35142. c.ServeSuccessJSON(map[string]interface{}{
  35143. "failed_code": -10,
  35144. "msg": res.ErrMsg,
  35145. })
  35146. }
  35147. }
  35148. }
  35149. func (c *HisApiController) Post1608() {
  35150. start_time := c.GetString("start_time")
  35151. end_time := c.GetString("end_time")
  35152. admin_user_id, _ := c.GetInt64("admin_user_id")
  35153. adminUser := c.GetAdminUserInfo()
  35154. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35155. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35156. timeLayout := "2006-01-02"
  35157. loc, _ := time.LoadLocation("Local")
  35158. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35159. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35160. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  35161. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  35162. fixmedins_setl_cnt := int64(len(orders))
  35163. var medfee_sumamt float64
  35164. var func_smamt float64
  35165. for _, item := range orders {
  35166. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35167. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  35168. }
  35169. times := strings.Split(start_time, "-")
  35170. time_tows := strings.Split(end_time, "-")
  35171. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35172. var res ResultSix
  35173. if config.IsOpen == 1 {
  35174. //var bps []*models.BusinessParamsTwo
  35175. //var bp models.BusinessParamsTwo
  35176. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  35177. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  35178. data := make(map[string]interface{})
  35179. data["org_name"] = miConfig.OrgName
  35180. data["doctor"] = role.UserName
  35181. data["func_smamt"] = func_smamt_str
  35182. data["fixmedins_code"] = miConfig.Code
  35183. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35184. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35185. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  35186. data["medfee_sumamt"] = medfee_sumamt_str
  35187. data["start_time"] = times[0] + times[1] + times[2]
  35188. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  35189. if miConfig.MdtrtareaAdmvs == "421300" {
  35190. client := &http.Client{}
  35191. bytesData, _ := json.Marshal(data)
  35192. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  35193. resp, _ := client.Do(req)
  35194. defer resp.Body.Close()
  35195. body, ioErr := ioutil.ReadAll(resp.Body)
  35196. if ioErr != nil {
  35197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35199. return
  35200. }
  35201. var respJSON map[string]interface{}
  35202. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35205. return
  35206. }
  35207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35208. userJSONBytes, _ := json.Marshal(respJSON)
  35209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35210. utils.ErrorLog("解析失败:%v", err)
  35211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35212. return
  35213. }
  35214. }
  35215. if miConfig.MdtrtareaAdmvs == "420200" {
  35216. client := &http.Client{}
  35217. bytesData, _ := json.Marshal(data)
  35218. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  35219. resp, _ := client.Do(req)
  35220. defer resp.Body.Close()
  35221. body, ioErr := ioutil.ReadAll(resp.Body)
  35222. if ioErr != nil {
  35223. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35225. return
  35226. }
  35227. var respJSON map[string]interface{}
  35228. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35229. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35231. return
  35232. }
  35233. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35234. userJSONBytes, _ := json.Marshal(respJSON)
  35235. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35236. utils.ErrorLog("解析失败:%v", err)
  35237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35238. return
  35239. }
  35240. }
  35241. if miConfig.MdtrtareaAdmvs == "421182" {
  35242. client := &http.Client{}
  35243. bytesData, _ := json.Marshal(data)
  35244. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  35245. resp, _ := client.Do(req)
  35246. defer resp.Body.Close()
  35247. body, ioErr := ioutil.ReadAll(resp.Body)
  35248. if ioErr != nil {
  35249. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35251. return
  35252. }
  35253. var respJSON map[string]interface{}
  35254. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35257. return
  35258. }
  35259. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35260. userJSONBytes, _ := json.Marshal(respJSON)
  35261. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35262. utils.ErrorLog("解析失败:%v", err)
  35263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35264. return
  35265. }
  35266. }
  35267. if res.Infcode == 0 {
  35268. c.ServeSuccessJSON(map[string]interface{}{
  35269. "msg": "发起成功",
  35270. })
  35271. } else {
  35272. c.ServeSuccessJSON(map[string]interface{}{
  35273. "failed_code": -10,
  35274. "msg": res.ErrMsg,
  35275. })
  35276. }
  35277. }
  35278. }
  35279. // 5.11.1.1【5262】结算信息按时间段查询
  35280. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  35281. admin_user_id, _ := c.GetInt64("admin_user_id")
  35282. adminUser := c.GetAdminUserInfo()
  35283. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35284. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35285. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35286. var res Result5262
  35287. if config.IsOpen == 1 {
  35288. if miConfig.MdtrtareaAdmvs == "421300" {
  35289. data := make(map[string]interface{})
  35290. data["bps"] = bp
  35291. data["org_name"] = miConfig.OrgName
  35292. data["doctor"] = role.UserName
  35293. data["fixmedins_code"] = miConfig.Code
  35294. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35295. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35296. data["page"] = strconv.FormatInt(page, 10)
  35297. data["limit"] = strconv.FormatInt(limit, 10)
  35298. fmt.Println(data)
  35299. client := &http.Client{}
  35300. bytesData, _ := json.Marshal(data)
  35301. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  35302. resp, _ := client.Do(req)
  35303. defer resp.Body.Close()
  35304. body, ioErr := ioutil.ReadAll(resp.Body)
  35305. if ioErr != nil {
  35306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35308. return
  35309. }
  35310. var respJSON map[string]interface{}
  35311. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35314. return
  35315. }
  35316. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35317. userJSONBytes, _ := json.Marshal(respJSON)
  35318. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35319. utils.ErrorLog("解析失败:%v", err)
  35320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35321. return
  35322. }
  35323. }
  35324. if miConfig.MdtrtareaAdmvs == "420200" {
  35325. data := make(map[string]interface{})
  35326. data["bps"] = bp
  35327. data["org_name"] = miConfig.OrgName
  35328. data["doctor"] = role.UserName
  35329. data["fixmedins_code"] = miConfig.Code
  35330. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35331. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35332. data["page"] = strconv.FormatInt(page, 10)
  35333. data["limit"] = strconv.FormatInt(limit, 10)
  35334. fmt.Println(data)
  35335. client := &http.Client{}
  35336. bytesData, _ := json.Marshal(data)
  35337. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  35338. resp, _ := client.Do(req)
  35339. defer resp.Body.Close()
  35340. body, ioErr := ioutil.ReadAll(resp.Body)
  35341. if ioErr != nil {
  35342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35344. return
  35345. }
  35346. var respJSON map[string]interface{}
  35347. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35350. return
  35351. }
  35352. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35353. userJSONBytes, _ := json.Marshal(respJSON)
  35354. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35355. utils.ErrorLog("解析失败:%v", err)
  35356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35357. return
  35358. }
  35359. }
  35360. if miConfig.MdtrtareaAdmvs == "421182" {
  35361. data := make(map[string]interface{})
  35362. data["bps"] = bp
  35363. data["org_name"] = miConfig.OrgName
  35364. data["doctor"] = role.UserName
  35365. data["fixmedins_code"] = miConfig.Code
  35366. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35367. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35368. data["page"] = strconv.FormatInt(page, 10)
  35369. data["limit"] = strconv.FormatInt(limit, 10)
  35370. fmt.Println(data)
  35371. client := &http.Client{}
  35372. bytesData, _ := json.Marshal(data)
  35373. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  35374. resp, _ := client.Do(req)
  35375. defer resp.Body.Close()
  35376. body, ioErr := ioutil.ReadAll(resp.Body)
  35377. if ioErr != nil {
  35378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35380. return
  35381. }
  35382. var respJSON map[string]interface{}
  35383. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35386. return
  35387. }
  35388. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35389. userJSONBytes, _ := json.Marshal(respJSON)
  35390. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35391. utils.ErrorLog("解析失败:%v", err)
  35392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35393. return
  35394. }
  35395. }
  35396. if miConfig.MdtrtareaAdmvs == "420902" {
  35397. data := make(map[string]interface{})
  35398. data["bps"] = bp
  35399. data["org_name"] = miConfig.OrgName
  35400. data["doctor"] = role.UserName
  35401. data["fixmedins_code"] = miConfig.Code
  35402. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35403. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35404. data["page"] = strconv.FormatInt(page, 10)
  35405. data["limit"] = strconv.FormatInt(limit, 10)
  35406. fmt.Println(data)
  35407. client := &http.Client{}
  35408. bytesData, _ := json.Marshal(data)
  35409. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  35410. resp, _ := client.Do(req)
  35411. defer resp.Body.Close()
  35412. body, ioErr := ioutil.ReadAll(resp.Body)
  35413. if ioErr != nil {
  35414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35416. return
  35417. }
  35418. var respJSON map[string]interface{}
  35419. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35422. return
  35423. }
  35424. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35425. userJSONBytes, _ := json.Marshal(respJSON)
  35426. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35427. utils.ErrorLog("解析失败:%v", err)
  35428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35429. return
  35430. }
  35431. }
  35432. if res.Infcode == 0 {
  35433. c.ServeSuccessJSON(map[string]interface{}{
  35434. "order": res.Output.Result,
  35435. "total": res.Output.PageInfo.RecordCounts,
  35436. })
  35437. } else {
  35438. c.ServeSuccessJSON(map[string]interface{}{
  35439. "failed_code": -10,
  35440. "msg": res.ErrMsg,
  35441. })
  35442. }
  35443. }
  35444. }
  35445. // 5.11.1.2【5267】异地结算信息时间段查询
  35446. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  35447. admin_user_id, _ := c.GetInt64("admin_user_id")
  35448. adminUser := c.GetAdminUserInfo()
  35449. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35450. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35451. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35452. var res Result5267
  35453. if config.IsOpen == 1 {
  35454. if miConfig.MdtrtareaAdmvs == "421300" {
  35455. data := make(map[string]interface{})
  35456. data["bps"] = bp
  35457. data["org_name"] = miConfig.OrgName
  35458. data["doctor"] = role.UserName
  35459. data["fixmedins_code"] = miConfig.Code
  35460. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35461. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35462. data["page"] = page
  35463. data["limit"] = limit
  35464. fmt.Println(data)
  35465. client := &http.Client{}
  35466. bytesData, _ := json.Marshal(data)
  35467. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  35468. resp, _ := client.Do(req)
  35469. defer resp.Body.Close()
  35470. body, ioErr := ioutil.ReadAll(resp.Body)
  35471. if ioErr != nil {
  35472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35474. return
  35475. }
  35476. var respJSON map[string]interface{}
  35477. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35480. return
  35481. }
  35482. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35483. userJSONBytes, _ := json.Marshal(respJSON)
  35484. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35485. utils.ErrorLog("解析失败:%v", err)
  35486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35487. return
  35488. }
  35489. }
  35490. if miConfig.MdtrtareaAdmvs == "420200" {
  35491. data := make(map[string]interface{})
  35492. data["bps"] = bp
  35493. data["org_name"] = miConfig.OrgName
  35494. data["doctor"] = role.UserName
  35495. data["fixmedins_code"] = miConfig.Code
  35496. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35497. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35498. data["page"] = page
  35499. data["limit"] = limit
  35500. fmt.Println(data)
  35501. client := &http.Client{}
  35502. bytesData, _ := json.Marshal(data)
  35503. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  35504. resp, _ := client.Do(req)
  35505. defer resp.Body.Close()
  35506. body, ioErr := ioutil.ReadAll(resp.Body)
  35507. if ioErr != nil {
  35508. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35510. return
  35511. }
  35512. var respJSON map[string]interface{}
  35513. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35516. return
  35517. }
  35518. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35519. userJSONBytes, _ := json.Marshal(respJSON)
  35520. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35521. utils.ErrorLog("解析失败:%v", err)
  35522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35523. return
  35524. }
  35525. }
  35526. if miConfig.MdtrtareaAdmvs == "421182" {
  35527. data := make(map[string]interface{})
  35528. data["bps"] = bp
  35529. data["org_name"] = miConfig.OrgName
  35530. data["doctor"] = role.UserName
  35531. data["fixmedins_code"] = miConfig.Code
  35532. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35533. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35534. data["page"] = page
  35535. data["limit"] = limit
  35536. fmt.Println(data)
  35537. client := &http.Client{}
  35538. bytesData, _ := json.Marshal(data)
  35539. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  35540. resp, _ := client.Do(req)
  35541. defer resp.Body.Close()
  35542. body, ioErr := ioutil.ReadAll(resp.Body)
  35543. if ioErr != nil {
  35544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35546. return
  35547. }
  35548. var respJSON map[string]interface{}
  35549. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35552. return
  35553. }
  35554. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35555. userJSONBytes, _ := json.Marshal(respJSON)
  35556. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35557. utils.ErrorLog("解析失败:%v", err)
  35558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35559. return
  35560. }
  35561. }
  35562. if res.Infcode == 0 {
  35563. c.ServeSuccessJSON(map[string]interface{}{
  35564. "order": res.Output.Result,
  35565. "total": res.Output.PageInfo.RecordCounts,
  35566. })
  35567. } else {
  35568. c.ServeSuccessJSON(map[string]interface{}{
  35569. "failed_code": -10,
  35570. "msg": res.ErrMsg,
  35571. })
  35572. }
  35573. }
  35574. }
  35575. func (c *HisApiController) Post3501() {
  35576. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35577. data := make(map[string]interface{})
  35578. var struct3501s []models.Struct3501
  35579. var struct3501 models.Struct3501
  35580. struct3501.OrgName = miConfig.OrgName
  35581. struct3501.AccessKey = miConfig.AccessKey
  35582. struct3501.RequestUrl = miConfig.Url
  35583. struct3501.SecretKey = miConfig.SecretKey
  35584. struct3501.ManuDate = "2022-08-17"
  35585. struct3501.FixmedinsBchno = ""
  35586. struct3501.ManuLotnum = ""
  35587. struct3501.RxFlag = "0"
  35588. struct3501.ExpyEnd = "2022-08-17"
  35589. struct3501.Invdate = "2022-08-17"
  35590. struct3501.InvCnt = "20.25"
  35591. struct3501.Memo = ""
  35592. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35593. struct3501.FixmedinsHilistId = miConfig.Code
  35594. struct3501.FixmedinsHilistName = miConfig.OrgName
  35595. struct3501s = append(struct3501s, struct3501)
  35596. data["struct_3501s"] = struct3501s
  35597. client := &http.Client{}
  35598. bytesData, _ := json.Marshal(data)
  35599. var req *http.Request
  35600. if miConfig.MdtrtareaAdmvs == "320921" {
  35601. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35602. } else {
  35603. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35604. }
  35605. resp, _ := client.Do(req)
  35606. defer resp.Body.Close()
  35607. body, ioErr := ioutil.ReadAll(resp.Body)
  35608. if ioErr != nil {
  35609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35611. return
  35612. }
  35613. var respJSON map[string]interface{}
  35614. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35617. return
  35618. }
  35619. var res ResultSix
  35620. var resSix10265 ResultSix10265 //1101结果
  35621. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35622. result, _ := json.Marshal(respJSON)
  35623. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35624. utils.ErrorLog("解析失败:%v", err)
  35625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35626. return
  35627. }
  35628. res.InfRefmsgid = resSix10265.InfRefmsgid
  35629. res.Output = resSix10265.Output
  35630. res.ErrMsg = resSix10265.ErrMsg
  35631. res.Cainfo = resSix10265.Cainfo
  35632. res.WarnMsg = resSix10265.WarnMsg
  35633. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35634. res.Infcode = infocode
  35635. if infocode == 0 {
  35636. c.ServeSuccessJSON(map[string]interface{}{
  35637. "msg": "上传成功",
  35638. })
  35639. return
  35640. } else {
  35641. c.ServeSuccessJSON(map[string]interface{}{
  35642. "failed_code": -10,
  35643. "msg": res.ErrMsg,
  35644. })
  35645. return
  35646. }
  35647. }
  35648. func (c *HisApiController) Post3502() {
  35649. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35650. data := make(map[string]interface{})
  35651. var struct3502s []models.Struct3502
  35652. var struct3502 models.Struct3502
  35653. struct3502.OrgName = miConfig.OrgName
  35654. struct3502.AccessKey = miConfig.AccessKey
  35655. struct3502.RequestUrl = miConfig.Url
  35656. struct3502.SecretKey = miConfig.SecretKey
  35657. struct3502.ManuDate = "2022-08-15"
  35658. struct3502.FixmedinsBchno = ""
  35659. struct3502.ManuLotnum = ""
  35660. struct3502.RxFlag = "0"
  35661. struct3502.ExpyEnd = "2022-08-15"
  35662. struct3502.Invdate = "2022-08-15"
  35663. struct3502.InvCnt = "20.25"
  35664. struct3502.Memo = ""
  35665. struct3502.MedListCodg = "XB01ABD056B002020200517"
  35666. struct3502.FixmedinsHilistId = miConfig.Code
  35667. struct3502.FixmedinsHilistName = miConfig.OrgName
  35668. struct3502s = append(struct3502s, struct3502)
  35669. data["struct_3502s"] = struct3502s
  35670. client := &http.Client{}
  35671. bytesData, _ := json.Marshal(data)
  35672. var req *http.Request
  35673. if miConfig.MdtrtareaAdmvs == "320921" {
  35674. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35675. } else {
  35676. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35677. }
  35678. resp, _ := client.Do(req)
  35679. defer resp.Body.Close()
  35680. body, ioErr := ioutil.ReadAll(resp.Body)
  35681. if ioErr != nil {
  35682. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35684. return
  35685. }
  35686. var respJSON map[string]interface{}
  35687. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35690. return
  35691. }
  35692. var res ResultSix
  35693. var resSix10265 ResultSix10265 //1101结果
  35694. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35695. result, _ := json.Marshal(respJSON)
  35696. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35697. utils.ErrorLog("解析失败:%v", err)
  35698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35699. return
  35700. }
  35701. res.InfRefmsgid = resSix10265.InfRefmsgid
  35702. res.Output = resSix10265.Output
  35703. res.ErrMsg = resSix10265.ErrMsg
  35704. res.Cainfo = resSix10265.Cainfo
  35705. res.WarnMsg = resSix10265.WarnMsg
  35706. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35707. res.Infcode = infocode
  35708. if infocode == 0 {
  35709. c.ServeSuccessJSON(map[string]interface{}{
  35710. "msg": "上传成功",
  35711. })
  35712. return
  35713. } else {
  35714. c.ServeSuccessJSON(map[string]interface{}{
  35715. "failed_code": -10,
  35716. "msg": res.ErrMsg,
  35717. })
  35718. return
  35719. }
  35720. }
  35721. func (c *HisApiController) Post3503() {
  35722. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35723. data := make(map[string]interface{})
  35724. var struct3501s []models.Struct3501
  35725. var struct3501 models.Struct3501
  35726. struct3501.OrgName = miConfig.OrgName
  35727. struct3501.AccessKey = miConfig.AccessKey
  35728. struct3501.RequestUrl = miConfig.Url
  35729. struct3501.SecretKey = miConfig.SecretKey
  35730. struct3501.ManuDate = "2022-08-15"
  35731. struct3501.FixmedinsBchno = ""
  35732. struct3501.ManuLotnum = ""
  35733. struct3501.RxFlag = "0"
  35734. struct3501.ExpyEnd = "2022-08-15"
  35735. struct3501.Invdate = "2022-08-15"
  35736. struct3501.InvCnt = "20.25"
  35737. struct3501.Memo = ""
  35738. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35739. struct3501.FixmedinsHilistId = miConfig.Code
  35740. struct3501.FixmedinsHilistName = miConfig.OrgName
  35741. struct3501s = append(struct3501s, struct3501)
  35742. data["struct_3501s"] = struct3501s
  35743. client := &http.Client{}
  35744. bytesData, _ := json.Marshal(data)
  35745. var req *http.Request
  35746. if miConfig.MdtrtareaAdmvs == "320921" {
  35747. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35748. } else {
  35749. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35750. }
  35751. resp, _ := client.Do(req)
  35752. defer resp.Body.Close()
  35753. body, ioErr := ioutil.ReadAll(resp.Body)
  35754. if ioErr != nil {
  35755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35757. return
  35758. }
  35759. var respJSON map[string]interface{}
  35760. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35763. return
  35764. }
  35765. var res ResultSix
  35766. var resSix10265 ResultSix10265 //1101结果
  35767. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35768. result, _ := json.Marshal(respJSON)
  35769. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35770. utils.ErrorLog("解析失败:%v", err)
  35771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35772. return
  35773. }
  35774. res.InfRefmsgid = resSix10265.InfRefmsgid
  35775. res.Output = resSix10265.Output
  35776. res.ErrMsg = resSix10265.ErrMsg
  35777. res.Cainfo = resSix10265.Cainfo
  35778. res.WarnMsg = resSix10265.WarnMsg
  35779. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35780. res.Infcode = infocode
  35781. if infocode == 0 {
  35782. c.ServeSuccessJSON(map[string]interface{}{
  35783. "msg": "上传成功",
  35784. })
  35785. return
  35786. } else {
  35787. c.ServeSuccessJSON(map[string]interface{}{
  35788. "failed_code": -10,
  35789. "msg": res.ErrMsg,
  35790. })
  35791. return
  35792. }
  35793. }
  35794. func (c *HisApiController) Post3504() {
  35795. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35796. data := make(map[string]interface{})
  35797. var struct3501s []models.Struct3501
  35798. var struct3501 models.Struct3501
  35799. struct3501.OrgName = miConfig.OrgName
  35800. struct3501.AccessKey = miConfig.AccessKey
  35801. struct3501.RequestUrl = miConfig.Url
  35802. struct3501.SecretKey = miConfig.SecretKey
  35803. struct3501.ManuDate = "2022-08-15"
  35804. struct3501.FixmedinsBchno = ""
  35805. struct3501.ManuLotnum = ""
  35806. struct3501.RxFlag = "0"
  35807. struct3501.ExpyEnd = "2022-08-15"
  35808. struct3501.Invdate = "2022-08-15"
  35809. struct3501.InvCnt = "20.25"
  35810. struct3501.Memo = ""
  35811. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35812. struct3501.FixmedinsHilistId = miConfig.Code
  35813. struct3501.FixmedinsHilistName = miConfig.OrgName
  35814. struct3501s = append(struct3501s, struct3501)
  35815. data["struct_3501s"] = struct3501s
  35816. client := &http.Client{}
  35817. bytesData, _ := json.Marshal(data)
  35818. var req *http.Request
  35819. if miConfig.MdtrtareaAdmvs == "320921" {
  35820. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35821. } else {
  35822. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35823. }
  35824. resp, _ := client.Do(req)
  35825. defer resp.Body.Close()
  35826. body, ioErr := ioutil.ReadAll(resp.Body)
  35827. if ioErr != nil {
  35828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35830. return
  35831. }
  35832. var respJSON map[string]interface{}
  35833. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35836. return
  35837. }
  35838. var res ResultSix
  35839. var resSix10265 ResultSix10265 //1101结果
  35840. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35841. result, _ := json.Marshal(respJSON)
  35842. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35843. utils.ErrorLog("解析失败:%v", err)
  35844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35845. return
  35846. }
  35847. res.InfRefmsgid = resSix10265.InfRefmsgid
  35848. res.Output = resSix10265.Output
  35849. res.ErrMsg = resSix10265.ErrMsg
  35850. res.Cainfo = resSix10265.Cainfo
  35851. res.WarnMsg = resSix10265.WarnMsg
  35852. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35853. res.Infcode = infocode
  35854. if infocode == 0 {
  35855. c.ServeSuccessJSON(map[string]interface{}{
  35856. "msg": "上传成功",
  35857. })
  35858. return
  35859. } else {
  35860. c.ServeSuccessJSON(map[string]interface{}{
  35861. "failed_code": -10,
  35862. "msg": res.ErrMsg,
  35863. })
  35864. return
  35865. }
  35866. }
  35867. func (c *HisApiController) Post3505() {
  35868. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35869. data := make(map[string]interface{})
  35870. var struct3501s []models.Struct3501
  35871. var struct3501 models.Struct3501
  35872. struct3501.OrgName = miConfig.OrgName
  35873. struct3501.AccessKey = miConfig.AccessKey
  35874. struct3501.RequestUrl = miConfig.Url
  35875. struct3501.SecretKey = miConfig.SecretKey
  35876. struct3501.ManuDate = "2022-08-15"
  35877. struct3501.FixmedinsBchno = ""
  35878. struct3501.ManuLotnum = ""
  35879. struct3501.RxFlag = "0"
  35880. struct3501.ExpyEnd = "2022-08-15"
  35881. struct3501.Invdate = "2022-08-15"
  35882. struct3501.InvCnt = "20.25"
  35883. struct3501.Memo = ""
  35884. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35885. struct3501.FixmedinsHilistId = miConfig.Code
  35886. struct3501.FixmedinsHilistName = miConfig.OrgName
  35887. struct3501s = append(struct3501s, struct3501)
  35888. data["struct_3501s"] = struct3501s
  35889. client := &http.Client{}
  35890. bytesData, _ := json.Marshal(data)
  35891. var req *http.Request
  35892. if miConfig.MdtrtareaAdmvs == "320921" {
  35893. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35894. } else {
  35895. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35896. }
  35897. resp, _ := client.Do(req)
  35898. defer resp.Body.Close()
  35899. body, ioErr := ioutil.ReadAll(resp.Body)
  35900. if ioErr != nil {
  35901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35903. return
  35904. }
  35905. var respJSON map[string]interface{}
  35906. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35909. return
  35910. }
  35911. var res ResultSix
  35912. var resSix10265 ResultSix10265 //1101结果
  35913. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35914. result, _ := json.Marshal(respJSON)
  35915. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35916. utils.ErrorLog("解析失败:%v", err)
  35917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35918. return
  35919. }
  35920. res.InfRefmsgid = resSix10265.InfRefmsgid
  35921. res.Output = resSix10265.Output
  35922. res.ErrMsg = resSix10265.ErrMsg
  35923. res.Cainfo = resSix10265.Cainfo
  35924. res.WarnMsg = resSix10265.WarnMsg
  35925. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35926. res.Infcode = infocode
  35927. if infocode == 0 {
  35928. c.ServeSuccessJSON(map[string]interface{}{
  35929. "msg": "上传成功",
  35930. })
  35931. return
  35932. } else {
  35933. c.ServeSuccessJSON(map[string]interface{}{
  35934. "failed_code": -10,
  35935. "msg": res.ErrMsg,
  35936. })
  35937. return
  35938. }
  35939. }
  35940. func (c *HisApiController) Post3506() {
  35941. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35942. data := make(map[string]interface{})
  35943. var struct3501s []models.Struct3501
  35944. var struct3501 models.Struct3501
  35945. struct3501.OrgName = miConfig.OrgName
  35946. struct3501.AccessKey = miConfig.AccessKey
  35947. struct3501.RequestUrl = miConfig.Url
  35948. struct3501.SecretKey = miConfig.SecretKey
  35949. struct3501.ManuDate = "2022-08-15"
  35950. struct3501.FixmedinsBchno = ""
  35951. struct3501.ManuLotnum = ""
  35952. struct3501.RxFlag = "0"
  35953. struct3501.ExpyEnd = "2022-08-15"
  35954. struct3501.Invdate = "2022-08-15"
  35955. struct3501.InvCnt = "20.25"
  35956. struct3501.Memo = ""
  35957. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35958. struct3501.FixmedinsHilistId = miConfig.Code
  35959. struct3501.FixmedinsHilistName = miConfig.OrgName
  35960. struct3501s = append(struct3501s, struct3501)
  35961. data["struct_3501s"] = struct3501s
  35962. client := &http.Client{}
  35963. bytesData, _ := json.Marshal(data)
  35964. var req *http.Request
  35965. if miConfig.MdtrtareaAdmvs == "320921" {
  35966. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35967. } else {
  35968. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35969. }
  35970. resp, _ := client.Do(req)
  35971. defer resp.Body.Close()
  35972. body, ioErr := ioutil.ReadAll(resp.Body)
  35973. if ioErr != nil {
  35974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35976. return
  35977. }
  35978. var respJSON map[string]interface{}
  35979. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35982. return
  35983. }
  35984. var res ResultSix
  35985. var resSix10265 ResultSix10265 //1101结果
  35986. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35987. result, _ := json.Marshal(respJSON)
  35988. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35989. utils.ErrorLog("解析失败:%v", err)
  35990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35991. return
  35992. }
  35993. res.InfRefmsgid = resSix10265.InfRefmsgid
  35994. res.Output = resSix10265.Output
  35995. res.ErrMsg = resSix10265.ErrMsg
  35996. res.Cainfo = resSix10265.Cainfo
  35997. res.WarnMsg = resSix10265.WarnMsg
  35998. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35999. res.Infcode = infocode
  36000. if infocode == 0 {
  36001. c.ServeSuccessJSON(map[string]interface{}{
  36002. "msg": "上传成功",
  36003. })
  36004. return
  36005. } else {
  36006. c.ServeSuccessJSON(map[string]interface{}{
  36007. "failed_code": -10,
  36008. "msg": res.ErrMsg,
  36009. })
  36010. return
  36011. }
  36012. }
  36013. func (c *HisApiController) Post3507() {
  36014. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  36015. data := make(map[string]interface{})
  36016. var struct3501s []models.Struct3501
  36017. var struct3501 models.Struct3501
  36018. struct3501.OrgName = miConfig.OrgName
  36019. struct3501.AccessKey = miConfig.AccessKey
  36020. struct3501.RequestUrl = miConfig.Url
  36021. struct3501.SecretKey = miConfig.SecretKey
  36022. struct3501.ManuDate = "2022-08-15"
  36023. struct3501.FixmedinsBchno = ""
  36024. struct3501.ManuLotnum = ""
  36025. struct3501.RxFlag = "0"
  36026. struct3501.ExpyEnd = "2022-08-15"
  36027. struct3501.Invdate = "2022-08-15"
  36028. struct3501.InvCnt = "20.25"
  36029. struct3501.Memo = ""
  36030. struct3501.MedListCodg = "XB01ABD056B002020200517"
  36031. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  36032. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  36033. struct3501s = append(struct3501s, struct3501)
  36034. data["struct_3501s"] = struct3501s
  36035. client := &http.Client{}
  36036. bytesData, _ := json.Marshal(data)
  36037. var req *http.Request
  36038. if miConfig.MdtrtareaAdmvs == "320921" {
  36039. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  36040. } else {
  36041. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  36042. }
  36043. resp, _ := client.Do(req)
  36044. defer resp.Body.Close()
  36045. body, ioErr := ioutil.ReadAll(resp.Body)
  36046. if ioErr != nil {
  36047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36049. return
  36050. }
  36051. var respJSON map[string]interface{}
  36052. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36055. return
  36056. }
  36057. var res ResultSix
  36058. var resSix10265 ResultSix10265 //1101结果
  36059. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  36060. result, _ := json.Marshal(respJSON)
  36061. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  36062. utils.ErrorLog("解析失败:%v", err)
  36063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36064. return
  36065. }
  36066. res.InfRefmsgid = resSix10265.InfRefmsgid
  36067. res.Output = resSix10265.Output
  36068. res.ErrMsg = resSix10265.ErrMsg
  36069. res.Cainfo = resSix10265.Cainfo
  36070. res.WarnMsg = resSix10265.WarnMsg
  36071. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  36072. res.Infcode = infocode
  36073. if infocode == 0 {
  36074. c.ServeSuccessJSON(map[string]interface{}{
  36075. "msg": "上传成功",
  36076. })
  36077. return
  36078. } else {
  36079. c.ServeSuccessJSON(map[string]interface{}{
  36080. "failed_code": -10,
  36081. "msg": res.ErrMsg,
  36082. })
  36083. return
  36084. }
  36085. }
  36086. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  36087. // WebSocket服务器地址
  36088. serverURL := "ws://127.0.0.1:8899"
  36089. // 解析WebSocket服务器地址
  36090. u, err := url.Parse(serverURL)
  36091. if err != nil {
  36092. }
  36093. // 建立WebSocket连接
  36094. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36095. if err != nil {
  36096. }
  36097. defer conn.Close()
  36098. input2 := make(map[string]interface{})
  36099. input := make(map[string]interface{})
  36100. inputData := make(map[string]interface{})
  36101. inputData["orgId"] = code
  36102. inputData["businessType"] = "01101"
  36103. inputData["operatorId"] = operator_id
  36104. inputData["operatorName"] = operator_name
  36105. inputData["officeId"] = "001"
  36106. inputData["officeName"] = "血透室"
  36107. inputData["deviceType"] = ""
  36108. input["data"] = inputData
  36109. input["orgId"] = code
  36110. input["transType"] = "ec.query"
  36111. //if md == ""
  36112. if md[:4] == "4403" {
  36113. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36114. } else if md[:4] == "4401" {
  36115. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36116. } else {
  36117. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36118. }
  36119. input2["indata"] = input
  36120. fmt.Println(input2)
  36121. bytesData, _ := json.Marshal(input2)
  36122. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36123. if err != nil {
  36124. fmt.Println(err)
  36125. }
  36126. // 接收消息
  36127. _, receivedMessage, err := conn.ReadMessage()
  36128. if err != nil {
  36129. fmt.Println(err)
  36130. }
  36131. return "", string(receivedMessage)
  36132. }
  36133. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  36134. // WebSocket服务器地址
  36135. serverURL := "ws://127.0.0.1:8899"
  36136. // 解析WebSocket服务器地址
  36137. u, err := url.Parse(serverURL)
  36138. if err != nil {
  36139. }
  36140. // 建立WebSocket连接
  36141. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36142. if err != nil {
  36143. }
  36144. defer conn.Close()
  36145. input2 := make(map[string]interface{})
  36146. input := make(map[string]interface{})
  36147. inputData := make(map[string]interface{})
  36148. inputData["orgId"] = code
  36149. inputData["businessType"] = "01101"
  36150. inputData["operatorId"] = operator_id
  36151. inputData["operatorName"] = operator_name
  36152. inputData["officeId"] = "001"
  36153. inputData["officeName"] = "血透室"
  36154. inputData["deviceType"] = ""
  36155. input["data"] = inputData
  36156. input["orgId"] = code
  36157. input["transType"] = "ec.query"
  36158. //if md == ""
  36159. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  36160. input2["indata"] = input
  36161. fmt.Println(input2)
  36162. bytesData, _ := json.Marshal(input2)
  36163. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36164. if err != nil {
  36165. fmt.Println(err)
  36166. }
  36167. // 接收消息
  36168. _, receivedMessage, err := conn.ReadMessage()
  36169. if err != nil {
  36170. fmt.Println(err)
  36171. }
  36172. return "", string(receivedMessage)
  36173. }
  36174. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  36175. // WebSocket服务器地址
  36176. serverURL := "ws://127.0.0.1:8899"
  36177. // 解析WebSocket服务器地址
  36178. u, err := url.Parse(serverURL)
  36179. if err != nil {
  36180. }
  36181. // 建立WebSocket连接
  36182. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36183. if err != nil {
  36184. }
  36185. defer conn.Close()
  36186. input2 := make(map[string]interface{})
  36187. input := make(map[string]interface{})
  36188. inputData := make(map[string]interface{})
  36189. inputData["orgId"] = code
  36190. inputData["businessType"] = "01301"
  36191. inputData["operatorId"] = operator_id
  36192. inputData["operatorName"] = operator_name
  36193. inputData["officeId"] = "001"
  36194. inputData["officeName"] = "血透室"
  36195. inputData["deviceType"] = ""
  36196. input["data"] = inputData
  36197. input["orgId"] = code
  36198. input["transType"] = "ec.query"
  36199. //if md == ""
  36200. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  36201. input2["indata"] = input
  36202. fmt.Println(input2)
  36203. bytesData, _ := json.Marshal(input2)
  36204. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36205. if err != nil {
  36206. fmt.Println(err)
  36207. }
  36208. // 接收消息
  36209. _, receivedMessage, err := conn.ReadMessage()
  36210. if err != nil {
  36211. fmt.Println(err)
  36212. }
  36213. return "", string(receivedMessage)
  36214. }
  36215. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  36216. // WebSocket服务器地址
  36217. serverURL := "ws://127.0.0.1:8899"
  36218. // 解析WebSocket服务器地址
  36219. u, err := url.Parse(serverURL)
  36220. if err != nil {
  36221. }
  36222. // 建立WebSocket连接
  36223. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36224. if err != nil {
  36225. }
  36226. defer conn.Close()
  36227. input2 := make(map[string]interface{})
  36228. input := make(map[string]interface{})
  36229. inputData := make(map[string]interface{})
  36230. inputData["orgId"] = code
  36231. inputData["businessType"] = "01103"
  36232. inputData["operatorId"] = operator_id
  36233. inputData["operatorName"] = operator_name
  36234. inputData["officeId"] = "001"
  36235. inputData["officeName"] = "血透室"
  36236. inputData["deviceType"] = ""
  36237. input["data"] = inputData
  36238. input["orgId"] = code
  36239. input["transType"] = "ec.query"
  36240. //if md ==
  36241. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  36242. input2["indata"] = input
  36243. fmt.Println(input2)
  36244. bytesData, _ := json.Marshal(input2)
  36245. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36246. if err != nil {
  36247. fmt.Println(err)
  36248. }
  36249. // 接收消息
  36250. _, receivedMessage, err := conn.ReadMessage()
  36251. if err != nil {
  36252. fmt.Println(err)
  36253. }
  36254. return "", string(receivedMessage)
  36255. }
  36256. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  36257. // WebSocket服务器地址
  36258. serverURL := "ws://127.0.0.1:8899"
  36259. // 解析WebSocket服务器地址
  36260. u, err := url.Parse(serverURL)
  36261. if err != nil {
  36262. }
  36263. // 建立WebSocket连接
  36264. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36265. if err != nil {
  36266. }
  36267. defer conn.Close()
  36268. input2 := make(map[string]interface{})
  36269. input := make(map[string]interface{})
  36270. inputData := make(map[string]interface{})
  36271. inputData["orgId"] = code
  36272. inputData["businessType"] = "01101"
  36273. inputData["operatorId"] = operator_id
  36274. inputData["operatorName"] = operator_name
  36275. inputData["officeId"] = "001"
  36276. inputData["officeName"] = "血透室"
  36277. inputData["deviceType"] = ""
  36278. input["data"] = inputData
  36279. input["orgId"] = code
  36280. input["transType"] = "ec.query"
  36281. //if md == ""
  36282. if md[:4] == "4403" {
  36283. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36284. } else if md[:4] == "4401" {
  36285. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36286. } else {
  36287. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36288. }
  36289. input2["indata"] = input
  36290. fmt.Println(input2)
  36291. bytesData, _ := json.Marshal(input2)
  36292. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36293. if err != nil {
  36294. fmt.Println(err)
  36295. }
  36296. // 接收消息
  36297. _, receivedMessage, err := conn.ReadMessage()
  36298. if err != nil {
  36299. fmt.Println(err)
  36300. }
  36301. return "", string(receivedMessage)
  36302. }
  36303. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  36304. // WebSocket服务器地址
  36305. serverURL := "ws://127.0.0.1:8899"
  36306. // 解析WebSocket服务器地址
  36307. u, err := url.Parse(serverURL)
  36308. if err != nil {
  36309. }
  36310. // 建立WebSocket连接
  36311. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36312. if err != nil {
  36313. }
  36314. defer conn.Close()
  36315. input2 := make(map[string]interface{})
  36316. input := make(map[string]interface{})
  36317. inputData := make(map[string]interface{})
  36318. inputData["orgId"] = code
  36319. inputData["businessType"] = "01301"
  36320. inputData["operatorId"] = operator_id
  36321. inputData["operatorName"] = operator_name
  36322. inputData["officeId"] = "001"
  36323. inputData["officeName"] = "血透室"
  36324. inputData["deviceType"] = ""
  36325. input["data"] = inputData
  36326. input["orgId"] = code
  36327. input["transType"] = "ec.query"
  36328. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36329. input2["indata"] = input
  36330. bytesData, _ := json.Marshal(input2)
  36331. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36332. if err != nil {
  36333. fmt.Println(err)
  36334. }
  36335. // 接收消息
  36336. _, receivedMessage, err := conn.ReadMessage()
  36337. if err != nil {
  36338. fmt.Println(err)
  36339. }
  36340. return "", string(receivedMessage)
  36341. }
  36342. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  36343. newArr = make([]string, 0)
  36344. for i := 0; i < len(arr); i++ {
  36345. repeat := false
  36346. for j := i + 1; j < len(arr); j++ {
  36347. if arr[i] == arr[j] {
  36348. repeat = true
  36349. break
  36350. }
  36351. }
  36352. if !repeat {
  36353. newArr = append(newArr, arr[i])
  36354. }
  36355. }
  36356. return
  36357. }
  36358. func getBirthdateAndAge(idNumber string) (string, int, error) {
  36359. if len(idNumber) != 18 {
  36360. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  36361. }
  36362. // 提取出生日期
  36363. year, err := strconv.Atoi(idNumber[6:10])
  36364. if err != nil {
  36365. return "", 0, err
  36366. }
  36367. month, err := strconv.Atoi(idNumber[10:12])
  36368. if err != nil {
  36369. return "", 0, err
  36370. }
  36371. day, err := strconv.Atoi(idNumber[12:14])
  36372. if err != nil {
  36373. return "", 0, err
  36374. }
  36375. // 格式化生日字符串
  36376. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  36377. birthdateFormatted := birthdate.Format("2006-01-02")
  36378. // 计算年龄
  36379. today := time.Now()
  36380. age := today.Year() - birthdate.Year()
  36381. if today.YearDay() < birthdate.YearDay() {
  36382. age--
  36383. }
  36384. return birthdateFormatted, age, nil
  36385. }
  36386. // 从身份证号码中提取出生年月日
  36387. func getBirthDateFromIDCard(idCard string) (string, error) {
  36388. // 身份证号码长度应为18位
  36389. if len(idCard) != 18 {
  36390. return "", fmt.Errorf("身份证号码长度应为18位")
  36391. }
  36392. // 提取出生日期部分 (YYYYMMDD)
  36393. birthDateStr := idCard[6:14]
  36394. // 解析出生日期
  36395. birthDate, err := time.Parse("20060102", birthDateStr)
  36396. if err != nil {
  36397. return "", fmt.Errorf("解析出生日期失败: %v", err)
  36398. }
  36399. // 格式化出生日期为 YYYY-MM-DD
  36400. formattedDate := birthDate.Format("2006-01-02")
  36401. return formattedDate, nil
  36402. }