his_api_controller.go 1.6MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/controllers"
  10. "gdyb/enums"
  11. "gdyb/models"
  12. "gdyb/service"
  13. "gdyb/utils"
  14. "github.com/astaxie/beego"
  15. "github.com/axgle/mahonia"
  16. "github.com/go-ole/go-ole/oleutil"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. )
  35. type HisApiController struct {
  36. controllers.BaseAuthAPIController
  37. }
  38. func HisManagerApiRegistRouters() {
  39. //挂号
  40. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  41. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  42. //上传就诊信息-上传明细-结算
  43. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  44. //查询
  45. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  46. //对总账
  47. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  48. //对明细
  49. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  50. //退费,退明细
  51. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  52. //退号
  53. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  54. //退明细
  55. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  56. //上传就诊信息-上传明细-预结算
  57. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  58. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  59. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  60. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  61. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  62. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  63. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  64. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  65. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  66. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  67. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  68. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  69. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  70. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  71. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  72. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  73. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  74. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  75. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  76. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  77. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  78. beego.Router("/api/check", &HisApiController{}, "get:Check")
  79. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  80. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  81. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  82. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  83. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  84. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  85. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  86. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  87. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  88. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  89. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  90. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  91. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  92. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  93. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  94. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  95. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  96. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  97. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  98. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  99. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  100. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  101. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  102. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  103. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  106. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  107. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  108. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  109. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  110. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  111. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  112. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  113. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  114. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  115. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  116. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  117. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  118. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  119. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  120. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  121. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  122. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  123. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  124. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  125. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  126. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  127. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  128. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  129. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  130. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  131. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  132. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  133. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  134. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  135. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  136. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  137. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  138. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  139. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  140. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  141. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  142. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  143. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  144. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  145. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  146. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  147. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  148. //库盘和变更
  149. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  150. //删除库盘和变更
  151. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  152. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  153. //药品变更
  154. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  155. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  156. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  157. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  158. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  159. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  160. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  161. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  162. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  163. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  164. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  165. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  166. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  167. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  168. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  169. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  170. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  171. }
  172. func (c *HisApiController) Get3201() {
  173. adminUser := c.GetAdminUserInfo()
  174. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  175. result, _ := service.AHyb3201(932, 0, 571536.19, 543283.9, "2024-10-01", "2024-10-31", "340699", "11", "390", miConfig.OrgName, "王幸子", miConfig.Code, "340399", "340399", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey, miConfig.Cainfo)
  176. var response Response
  177. if err := json.Unmarshal([]byte(result), &response); err != nil {
  178. fmt.Println("Error decoding JSON:", err)
  179. return
  180. }
  181. }
  182. func (c *HisApiController) TestNet() {
  183. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  184. //return
  185. c.ServeSuccessJSON(map[string]interface{}{
  186. "msg": "成功",
  187. })
  188. }
  189. func (c *HisApiController) Get3508() {
  190. admin_user_id, _ := c.GetInt64("admin_user_id")
  191. drug_id, _ := c.GetInt64("id")
  192. start_time := c.GetString("start_time")
  193. end_time := c.GetString("end_time")
  194. adminUser := c.GetAdminUserInfo()
  195. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  196. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  197. drug, _ := service.GetDrugByID(drug_id)
  198. var struct3508 models.Struct3508
  199. struct3508.OrgName = miConfig.OrgName
  200. struct3508.FixmedinsCode = miConfig.Code
  201. struct3508.AccessKey = miConfig.AccessKey
  202. struct3508.Opter = curRoles.UserName
  203. struct3508.RequestUrl = miConfig.Url
  204. struct3508.Url = miConfig.Url
  205. struct3508.AppId = miConfig.Cainfo
  206. struct3508.AppSecret = miConfig.AppSecret
  207. struct3508.Enckey = miConfig.EncKey
  208. struct3508.SignKey = miConfig.SignKey
  209. struct3508.SecretKey = miConfig.SecretKey
  210. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  211. struct3508.Begndate = start_time
  212. struct3508.Enddate = end_time
  213. result1, result2, _ := service.FJyb3508(struct3508)
  214. saveLog(result1, result2, "3508", "3508")
  215. var res models.Result3508
  216. var respJSON2 map[string]interface{}
  217. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  220. return
  221. }
  222. userJSONBytes2, _ := json.Marshal(respJSON2)
  223. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  224. utils.ErrorLog("解析失败:%v", err)
  225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  226. return
  227. }
  228. if res.Infcode == -1 {
  229. c.ServeSuccessJSON(map[string]interface{}{
  230. "failed_code": -10,
  231. "msg": res.ErrMsg,
  232. })
  233. } else {
  234. c.ServeSuccessJSON(map[string]interface{}{
  235. "info": res.Output,
  236. })
  237. }
  238. }
  239. func (c *HisApiController) Get3509() {
  240. admin_user_id, _ := c.GetInt64("admin_user_id")
  241. drug_id, _ := c.GetInt64("id")
  242. start_time := c.GetString("start_time")
  243. end_time := c.GetString("end_time")
  244. adminUser := c.GetAdminUserInfo()
  245. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  246. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  247. drug, _ := service.GetDrugByID(drug_id)
  248. var struct3508 models.Struct3509
  249. struct3508.OrgName = miConfig.OrgName
  250. struct3508.FixmedinsCode = miConfig.Code
  251. struct3508.AccessKey = miConfig.AccessKey
  252. struct3508.Opter = curRoles.UserName
  253. struct3508.RequestUrl = miConfig.Url
  254. struct3508.Url = miConfig.Url
  255. struct3508.AppId = miConfig.Cainfo
  256. struct3508.AppSecret = miConfig.AppSecret
  257. struct3508.Enckey = miConfig.EncKey
  258. struct3508.SignKey = miConfig.SignKey
  259. struct3508.SecretKey = miConfig.SecretKey
  260. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  261. struct3508.Begndate = start_time
  262. struct3508.Enddate = end_time
  263. result1, result2, _ := service.FJyb3509(struct3508)
  264. saveLog(result1, result2, "3509", "3509")
  265. var res models.Result3509
  266. var respJSON2 map[string]interface{}
  267. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  270. return
  271. }
  272. userJSONBytes2, _ := json.Marshal(respJSON2)
  273. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  274. utils.ErrorLog("解析失败:%v", err)
  275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  276. return
  277. }
  278. if res.Infcode == -1 {
  279. c.ServeSuccessJSON(map[string]interface{}{
  280. "failed_code": -10,
  281. "msg": res.ErrMsg,
  282. })
  283. } else {
  284. c.ServeSuccessJSON(map[string]interface{}{
  285. "info": res.Output,
  286. })
  287. }
  288. }
  289. func (c *HisApiController) Get3510() {
  290. admin_user_id, _ := c.GetInt64("admin_user_id")
  291. drug_id, _ := c.GetInt64("id")
  292. start_time := c.GetString("start_time")
  293. end_time := c.GetString("end_time")
  294. adminUser := c.GetAdminUserInfo()
  295. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  296. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  297. drug, _ := service.GetDrugByID(drug_id)
  298. var struct3508 models.Struct3510
  299. struct3508.FixmedinsCode = miConfig.Code
  300. struct3508.OrgName = miConfig.OrgName
  301. struct3508.AccessKey = miConfig.AccessKey
  302. struct3508.Opter = curRoles.UserName
  303. struct3508.RequestUrl = miConfig.Url
  304. struct3508.Url = miConfig.Url
  305. struct3508.AppId = miConfig.Cainfo
  306. struct3508.AppSecret = miConfig.AppSecret
  307. struct3508.Enckey = miConfig.EncKey
  308. struct3508.SignKey = miConfig.SignKey
  309. struct3508.SecretKey = miConfig.SecretKey
  310. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  311. struct3508.Begndate = start_time
  312. struct3508.Enddate = end_time
  313. result1, result2, _ := service.FJyb3510(struct3508)
  314. saveLog(result1, result2, "3510", "3510")
  315. var res models.Result3510
  316. var respJSON2 map[string]interface{}
  317. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  320. return
  321. }
  322. userJSONBytes2, _ := json.Marshal(respJSON2)
  323. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  324. utils.ErrorLog("解析失败:%v", err)
  325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  326. return
  327. }
  328. if res.Infcode == -1 {
  329. c.ServeSuccessJSON(map[string]interface{}{
  330. "failed_code": -10,
  331. "msg": res.ErrMsg,
  332. })
  333. } else {
  334. c.ServeSuccessJSON(map[string]interface{}{
  335. "info": res.Output,
  336. })
  337. }
  338. }
  339. func (c *HisApiController) Get3511() {
  340. admin_user_id, _ := c.GetInt64("admin_user_id")
  341. drug_id, _ := c.GetInt64("id")
  342. start_time := c.GetString("start_time")
  343. end_time := c.GetString("end_time")
  344. adminUser := c.GetAdminUserInfo()
  345. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  346. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  347. drug, _ := service.GetDrugByID(drug_id)
  348. var struct3508 models.Struct3511
  349. struct3508.FixmedinsCode = miConfig.Code
  350. struct3508.OrgName = miConfig.OrgName
  351. struct3508.AccessKey = miConfig.AccessKey
  352. struct3508.Opter = curRoles.UserName
  353. struct3508.RequestUrl = miConfig.Url
  354. struct3508.Url = miConfig.Url
  355. struct3508.AppId = miConfig.Cainfo
  356. struct3508.AppSecret = miConfig.AppSecret
  357. struct3508.Enckey = miConfig.EncKey
  358. struct3508.SignKey = miConfig.SignKey
  359. struct3508.SecretKey = miConfig.SecretKey
  360. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  361. struct3508.Begndate = start_time
  362. struct3508.Enddate = end_time
  363. result1, result2, _ := service.FJyb3511(struct3508)
  364. saveLog(result1, result2, "3511", "3511")
  365. var res models.Result3511
  366. var respJSON2 map[string]interface{}
  367. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  370. return
  371. }
  372. userJSONBytes2, _ := json.Marshal(respJSON2)
  373. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  374. utils.ErrorLog("解析失败:%v", err)
  375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  376. return
  377. }
  378. if res.Infcode == -1 {
  379. c.ServeSuccessJSON(map[string]interface{}{
  380. "failed_code": -10,
  381. "msg": res.ErrMsg,
  382. })
  383. } else {
  384. c.ServeSuccessJSON(map[string]interface{}{
  385. "info": res.Output,
  386. })
  387. }
  388. }
  389. func (c *HisApiController) Get3512() {
  390. admin_user_id, _ := c.GetInt64("admin_user_id")
  391. drug_id, _ := c.GetInt64("id")
  392. start_time := c.GetString("start_time")
  393. end_time := c.GetString("end_time")
  394. adminUser := c.GetAdminUserInfo()
  395. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  396. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  397. drug, _ := service.GetDrugByID(drug_id)
  398. var struct3508 models.Struct3512
  399. struct3508.FixmedinsCode = miConfig.Code
  400. struct3508.OrgName = miConfig.OrgName
  401. struct3508.AccessKey = miConfig.AccessKey
  402. struct3508.Opter = curRoles.UserName
  403. struct3508.RequestUrl = miConfig.Url
  404. struct3508.Url = miConfig.Url
  405. struct3508.AppId = miConfig.Cainfo
  406. struct3508.AppSecret = miConfig.AppSecret
  407. struct3508.Enckey = miConfig.EncKey
  408. struct3508.SignKey = miConfig.SignKey
  409. struct3508.SecretKey = miConfig.SecretKey
  410. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  411. struct3508.Begndate = start_time
  412. struct3508.Enddate = end_time
  413. result1, result2, _ := service.FJyb3512(struct3508)
  414. saveLog(result1, result2, "3512", "3512")
  415. var res models.Result3512
  416. var respJSON2 map[string]interface{}
  417. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  420. return
  421. }
  422. userJSONBytes2, _ := json.Marshal(respJSON2)
  423. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  424. utils.ErrorLog("解析失败:%v", err)
  425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  426. return
  427. }
  428. if res.Infcode == -1 {
  429. c.ServeSuccessJSON(map[string]interface{}{
  430. "failed_code": -10,
  431. "msg": res.ErrMsg,
  432. })
  433. } else {
  434. c.ServeSuccessJSON(map[string]interface{}{
  435. "info": res.Output,
  436. })
  437. }
  438. }
  439. func (c *HisApiController) Get3513() {
  440. admin_user_id, _ := c.GetInt64("admin_user_id")
  441. drug_id, _ := c.GetInt64("id")
  442. start_time := c.GetString("start_time")
  443. end_time := c.GetString("end_time")
  444. adminUser := c.GetAdminUserInfo()
  445. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  446. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  447. drug, _ := service.GetDrugByID(drug_id)
  448. var struct3508 models.Struct3513
  449. struct3508.FixmedinsCode = miConfig.Code
  450. struct3508.OrgName = miConfig.OrgName
  451. struct3508.AccessKey = miConfig.AccessKey
  452. struct3508.Opter = curRoles.UserName
  453. struct3508.RequestUrl = miConfig.Url
  454. struct3508.Url = miConfig.Url
  455. struct3508.AppId = miConfig.Cainfo
  456. struct3508.AppSecret = miConfig.AppSecret
  457. struct3508.Enckey = miConfig.EncKey
  458. struct3508.SignKey = miConfig.SignKey
  459. struct3508.SecretKey = miConfig.SecretKey
  460. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  461. struct3508.Begndate = start_time
  462. struct3508.Enddate = end_time
  463. result1, result2, _ := service.FJyb3513(struct3508)
  464. saveLog(result1, result2, "3513", "3513")
  465. var res models.Result3513
  466. var respJSON2 map[string]interface{}
  467. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  470. return
  471. }
  472. userJSONBytes2, _ := json.Marshal(respJSON2)
  473. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  474. utils.ErrorLog("解析失败:%v", err)
  475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  476. return
  477. }
  478. if res.Infcode == -1 {
  479. c.ServeSuccessJSON(map[string]interface{}{
  480. "failed_code": -10,
  481. "msg": res.ErrMsg,
  482. })
  483. } else {
  484. c.ServeSuccessJSON(map[string]interface{}{
  485. "info": res.Output,
  486. })
  487. }
  488. }
  489. func (c *HisApiController) Get35081() {
  490. admin_user_id, _ := c.GetInt64("admin_user_id")
  491. drug_id, _ := c.GetInt64("id")
  492. //start_time := c.GetString("start_time")
  493. //end_time := c.GetString("end_time")
  494. page, _ := c.GetInt("page")
  495. adminUser := c.GetAdminUserInfo()
  496. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  497. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  498. drug, _ := service.GetDrugByID(drug_id)
  499. var struct3508 models.Struct35081
  500. struct3508.FixmedinsCode = miConfig.Code
  501. struct3508.OrgName = miConfig.OrgName
  502. struct3508.AccessKey = miConfig.AccessKey
  503. struct3508.Opter = curRoles.UserName
  504. struct3508.RequestUrl = miConfig.Url
  505. struct3508.Url = miConfig.Url
  506. struct3508.AppId = miConfig.Cainfo
  507. struct3508.AppSecret = miConfig.AppSecret
  508. struct3508.Enckey = miConfig.EncKey
  509. struct3508.SignKey = miConfig.SignKey
  510. struct3508.SecretKey = miConfig.SecretKey
  511. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  512. struct3508.PageNum = page
  513. struct3508.PageSize = 10
  514. result1, result2, _ := service.FJyb35081(struct3508)
  515. saveLog(result1, result2, "35081", "35081")
  516. var res models.Result35081
  517. var respJSON2 map[string]interface{}
  518. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  521. return
  522. }
  523. userJSONBytes2, _ := json.Marshal(respJSON2)
  524. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  525. utils.ErrorLog("解析失败:%v", err)
  526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  527. return
  528. }
  529. if res.Infcode == -1 {
  530. c.ServeSuccessJSON(map[string]interface{}{
  531. "failed_code": -10,
  532. "msg": res.ErrMsg,
  533. })
  534. } else {
  535. c.ServeSuccessJSON(map[string]interface{}{
  536. "info": res.Output,
  537. })
  538. }
  539. }
  540. func (c *HisApiController) Get35082() {
  541. admin_user_id, _ := c.GetInt64("admin_user_id")
  542. drug_id, _ := c.GetInt64("id")
  543. //start_time := c.GetString("start_time")
  544. //end_time := c.GetString("end_time")
  545. page, _ := c.GetInt("page")
  546. adminUser := c.GetAdminUserInfo()
  547. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  548. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  549. drug, _ := service.GetDrugByID(drug_id)
  550. var struct3508 models.Struct35082
  551. struct3508.FixmedinsCode = miConfig.Code
  552. struct3508.OrgName = miConfig.OrgName
  553. struct3508.AccessKey = miConfig.AccessKey
  554. struct3508.Opter = curRoles.UserName
  555. struct3508.RequestUrl = miConfig.Url
  556. struct3508.Url = miConfig.Url
  557. struct3508.AppId = miConfig.Cainfo
  558. struct3508.AppSecret = miConfig.AppSecret
  559. struct3508.Enckey = miConfig.EncKey
  560. struct3508.SignKey = miConfig.SignKey
  561. struct3508.SecretKey = miConfig.SecretKey
  562. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  563. struct3508.PageNum = page
  564. struct3508.PageSize = 10
  565. result1, result2, _ := service.FJyb35082(struct3508)
  566. saveLog(result1, result2, "35082", "35082")
  567. var res models.Result35082
  568. var respJSON2 map[string]interface{}
  569. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  572. return
  573. }
  574. userJSONBytes2, _ := json.Marshal(respJSON2)
  575. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  576. utils.ErrorLog("解析失败:%v", err)
  577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  578. return
  579. }
  580. if res.Infcode == -1 {
  581. c.ServeSuccessJSON(map[string]interface{}{
  582. "failed_code": -10,
  583. "msg": res.ErrMsg,
  584. })
  585. } else {
  586. c.ServeSuccessJSON(map[string]interface{}{
  587. "info": res.Output,
  588. })
  589. }
  590. }
  591. func (c *HisApiController) FJ3501AND3502() {
  592. ids := c.GetString("ids")
  593. admin_user_id, _ := c.GetInt64("admin_user_id")
  594. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  595. id_arr := strings.Split(ids, ",")
  596. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  597. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  598. //库盘
  599. var errs []string
  600. for _, drug := range drugs {
  601. if drug.IsPc == 0 {
  602. var res2 ResultSix
  603. var res3 ResultSix
  604. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  605. var struct3501 models.Struct3501
  606. struct3501.Code = miConfig.Code
  607. struct3501.OrgName = miConfig.OrgName
  608. struct3501.AccessKey = miConfig.AccessKey
  609. struct3501.Opter = roles.UserName
  610. struct3501.RequestUrl = miConfig.Url
  611. struct3501.Url = miConfig.Url
  612. struct3501.AppId = miConfig.Cainfo
  613. struct3501.AppSecret = miConfig.AppSecret
  614. struct3501.Enckey = miConfig.EncKey
  615. struct3501.SignKey = miConfig.SignKey
  616. struct3501.SecretKey = miConfig.SecretKey
  617. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  618. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  619. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  620. struct3501.RxFlag = "1"
  621. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  622. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  623. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  624. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  625. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  626. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  627. struct3501.FixmedinsBchno = number
  628. struct3501.DrugTracCodg = drug.DrugCode
  629. memo := make(map[string]interface{})
  630. memo["pric"] = drug.Price
  631. bytesData, _ := json.Marshal(memo)
  632. struct3501.Memo = string(bytesData)
  633. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  634. result1, result2, _ := service.FJyb3501(struct3501)
  635. saveLog(result1, result2, "3501", "3501")
  636. //saveLog(result, requestLog, "2201", "挂号")
  637. var respJSON2 map[string]interface{}
  638. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  641. return
  642. }
  643. userJSONBytes2, _ := json.Marshal(respJSON2)
  644. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  645. utils.ErrorLog("解析失败:%v", err)
  646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  647. return
  648. }
  649. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  650. data := make(map[string]interface{})
  651. data["struct_3501s"] = struct3501
  652. client := &http.Client{}
  653. bytesData, _ := json.Marshal(data)
  654. var req *http.Request
  655. if miConfig.MdtrtareaAdmvs == "320921" {
  656. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  657. } else {
  658. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  659. }
  660. resp, _ := client.Do(req)
  661. defer resp.Body.Close()
  662. body, ioErr := ioutil.ReadAll(resp.Body)
  663. if ioErr != nil {
  664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  665. }
  666. var respJSON map[string]interface{}
  667. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  670. return
  671. }
  672. var resSix10265 ResultSix10265 //1101结果
  673. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  674. result, _ := json.Marshal(respJSON)
  675. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  676. utils.ErrorLog("解析失败:%v", err)
  677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  678. return
  679. }
  680. res2.InfRefmsgid = resSix10265.InfRefmsgid
  681. res2.Output = resSix10265.Output
  682. res2.ErrMsg = resSix10265.ErrMsg
  683. res2.Cainfo = resSix10265.Cainfo
  684. res2.WarnMsg = resSix10265.WarnMsg
  685. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  686. res2.Infcode = infocode
  687. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  688. data := make(map[string]interface{})
  689. data["struct_3501s"] = struct3501
  690. client := &http.Client{}
  691. bytesData, _ := json.Marshal(data)
  692. var req *http.Request
  693. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  694. resp, _ := client.Do(req)
  695. defer resp.Body.Close()
  696. body, ioErr := ioutil.ReadAll(resp.Body)
  697. if ioErr != nil {
  698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  699. }
  700. var respJSON map[string]interface{}
  701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  704. return
  705. }
  706. var resSix10265 ResultSix10265 //1101结果
  707. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  708. result, _ := json.Marshal(respJSON)
  709. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  710. utils.ErrorLog("解析失败:%v", err)
  711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  712. return
  713. }
  714. res2.InfRefmsgid = resSix10265.InfRefmsgid
  715. res2.Output = resSix10265.Output
  716. res2.ErrMsg = resSix10265.ErrMsg
  717. res2.Cainfo = resSix10265.Cainfo
  718. res2.WarnMsg = resSix10265.WarnMsg
  719. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  720. res2.Infcode = infocode
  721. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  722. data := make(map[string]interface{})
  723. data["struct_3501s"] = struct3501
  724. client := &http.Client{}
  725. bytesData, _ := json.Marshal(data)
  726. var req *http.Request
  727. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  728. resp, _ := client.Do(req)
  729. defer resp.Body.Close()
  730. body, ioErr := ioutil.ReadAll(resp.Body)
  731. if ioErr != nil {
  732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  733. }
  734. var respJSON map[string]interface{}
  735. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  738. return
  739. }
  740. var resSix10265 ResultSix10265 //1101结果
  741. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  742. result, _ := json.Marshal(respJSON)
  743. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  744. utils.ErrorLog("解析失败:%v", err)
  745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  746. return
  747. }
  748. res2.InfRefmsgid = resSix10265.InfRefmsgid
  749. res2.Output = resSix10265.Output
  750. res2.ErrMsg = resSix10265.ErrMsg
  751. res2.Cainfo = resSix10265.Cainfo
  752. res2.WarnMsg = resSix10265.WarnMsg
  753. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  754. res2.Infcode = infocode
  755. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  756. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  757. saveLog(result1, result2, "3501", "3501")
  758. //saveLog(result, requestLog, "2201", "挂号")
  759. var respJSON2 map[string]interface{}
  760. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  763. return
  764. }
  765. userJSONBytes2, _ := json.Marshal(respJSON2)
  766. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  767. utils.ErrorLog("解析失败:%v", err)
  768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  769. return
  770. }
  771. }
  772. if res2.Infcode != -1 {
  773. drug.IsPc = 1
  774. drug.Bchno = number
  775. drug.PcDate = time.Now().Unix()
  776. err := service.SaveW(drug)
  777. if err == nil {
  778. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  779. var struct3502 models.Struct3502
  780. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  781. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  782. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  783. struct3502.FixmedinsCode = miConfig.Code
  784. struct3502.Code = miConfig.Code
  785. struct3502.RxFlag = "0"
  786. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  787. struct3502.OrgName = miConfig.OrgName
  788. struct3502.Opter = roles.UserName
  789. struct3502.AccessKey = miConfig.AccessKey
  790. struct3502.RequestUrl = miConfig.Url
  791. struct3502.SecretKey = miConfig.SecretKey
  792. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  793. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  794. struct3502.Url = miConfig.Url
  795. struct3502.AppId = miConfig.Cainfo
  796. struct3502.AppSecret = miConfig.AppSecret
  797. struct3502.Enckey = miConfig.EncKey
  798. struct3502.SignKey = miConfig.SignKey
  799. struct3502.SecretKey = miConfig.SecretKey
  800. struct3502.DrugTracCodg = drug.DrugCode
  801. struct3502.Memo = ""
  802. struct3502.InvChgType = "108"
  803. struct3502.FixmedinsBchno = bg_number
  804. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  805. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  806. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  807. result11, result22, _ := service.FJyb3502(struct3502)
  808. saveLog(result11, result22, "3502", "3502")
  809. var respJSON3 map[string]interface{}
  810. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  813. return
  814. }
  815. userJSONBytes3, _ := json.Marshal(respJSON3)
  816. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  817. utils.ErrorLog("解析失败:%v", err)
  818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  819. return
  820. }
  821. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  822. data := make(map[string]interface{})
  823. data["struct_3502s"] = struct3502
  824. client := &http.Client{}
  825. bytesData, _ := json.Marshal(data)
  826. var req *http.Request
  827. if miConfig.MdtrtareaAdmvs == "320921" {
  828. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  829. } else {
  830. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  831. }
  832. resp, _ := client.Do(req)
  833. defer resp.Body.Close()
  834. body, ioErr := ioutil.ReadAll(resp.Body)
  835. if ioErr != nil {
  836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  837. }
  838. var respJSON map[string]interface{}
  839. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  842. return
  843. }
  844. var resSix10265 ResultSix10265 //1101结果
  845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  846. result, _ := json.Marshal(respJSON)
  847. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  848. utils.ErrorLog("解析失败:%v", err)
  849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  850. return
  851. }
  852. res3.InfRefmsgid = resSix10265.InfRefmsgid
  853. res3.Output = resSix10265.Output
  854. res3.ErrMsg = resSix10265.ErrMsg
  855. res3.Cainfo = resSix10265.Cainfo
  856. res3.WarnMsg = resSix10265.WarnMsg
  857. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  858. res3.Infcode = infocode
  859. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  860. data := make(map[string]interface{})
  861. data["struct_3502s"] = struct3502
  862. client := &http.Client{}
  863. bytesData, _ := json.Marshal(data)
  864. var req *http.Request
  865. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  866. resp, _ := client.Do(req)
  867. defer resp.Body.Close()
  868. body, ioErr := ioutil.ReadAll(resp.Body)
  869. if ioErr != nil {
  870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  871. }
  872. var respJSON map[string]interface{}
  873. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  876. return
  877. }
  878. var resSix10265 ResultSix10265 //1101结果
  879. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  880. result, _ := json.Marshal(respJSON)
  881. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  882. utils.ErrorLog("解析失败:%v", err)
  883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  884. return
  885. }
  886. res3.InfRefmsgid = resSix10265.InfRefmsgid
  887. res3.Output = resSix10265.Output
  888. res3.ErrMsg = resSix10265.ErrMsg
  889. res3.Cainfo = resSix10265.Cainfo
  890. res3.WarnMsg = resSix10265.WarnMsg
  891. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  892. res3.Infcode = infocode
  893. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  894. data := make(map[string]interface{})
  895. data["struct_3501s"] = struct3501
  896. client := &http.Client{}
  897. bytesData, _ := json.Marshal(data)
  898. var req *http.Request
  899. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  900. resp, _ := client.Do(req)
  901. defer resp.Body.Close()
  902. body, ioErr := ioutil.ReadAll(resp.Body)
  903. if ioErr != nil {
  904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  905. }
  906. var respJSON map[string]interface{}
  907. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  910. return
  911. }
  912. var resSix10265 ResultSix10265 //1101结果
  913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  914. result, _ := json.Marshal(respJSON)
  915. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  916. utils.ErrorLog("解析失败:%v", err)
  917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  918. return
  919. }
  920. res2.InfRefmsgid = resSix10265.InfRefmsgid
  921. res2.Output = resSix10265.Output
  922. res2.ErrMsg = resSix10265.ErrMsg
  923. res2.Cainfo = resSix10265.Cainfo
  924. res2.WarnMsg = resSix10265.WarnMsg
  925. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  926. res2.Infcode = infocode
  927. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  928. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  929. saveLog(result11, result22, "3502", "3502")
  930. var respJSON3 map[string]interface{}
  931. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  934. return
  935. }
  936. userJSONBytes3, _ := json.Marshal(respJSON3)
  937. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  938. utils.ErrorLog("解析失败:%v", err)
  939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  940. return
  941. }
  942. }
  943. if res3.Infcode == -1 {
  944. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  945. c.ServeSuccessJSON(map[string]interface{}{
  946. "failed_code": -10,
  947. "msg": res3.ErrMsg,
  948. })
  949. } else {
  950. drug.IsBg = 1
  951. drug.BgBchno = bg_number
  952. service.SaveW(drug)
  953. }
  954. }
  955. } else {
  956. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  957. }
  958. }
  959. //变更
  960. }
  961. if len(errs) == 0 {
  962. c.ServeSuccessJSON(map[string]interface{}{
  963. "msg": "盘存变更成功",
  964. })
  965. } else {
  966. c.ServeSuccessJSON(map[string]interface{}{
  967. "failed_code": -10,
  968. "msg": errs,
  969. })
  970. }
  971. }
  972. func (c *HisApiController) DeletePCandBG() {
  973. ids := c.GetString("ids")
  974. id_arr := strings.Split(ids, ",")
  975. admin_user_id, _ := c.GetInt64("admin_user_id")
  976. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  977. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  978. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  979. var err []string
  980. for _, item := range drugs {
  981. if item.IsPc == 1 && item.IsBg == 1 {
  982. var res FJ3507Result
  983. var res2 FJ3507Result
  984. var struct3507 models.Struct3507
  985. struct3507.FixmedinsBchno = item.Bchno
  986. struct3507.InvDataType = "1"
  987. struct3507.Opter = roles.UserName
  988. struct3507.OrgName = miConfig.OrgName
  989. struct3507.AccessKey = miConfig.AccessKey
  990. struct3507.RequestUrl = miConfig.Url
  991. struct3507.FixmedinsCode = miConfig.Code
  992. struct3507.Code = miConfig.Code
  993. struct3507.SecretKey = miConfig.SecretKey
  994. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  995. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  996. struct3507.Url = miConfig.Url
  997. struct3507.AppId = miConfig.Cainfo
  998. struct3507.AppSecret = miConfig.AppSecret
  999. struct3507.Enckey = miConfig.EncKey
  1000. struct3507.SignKey = miConfig.SignKey
  1001. struct3507.SecretKey = miConfig.SecretKey
  1002. if miConfig.MdtrtareaAdmvs == "350500" {
  1003. result, result1, _ := service.FJyb3507(struct3507)
  1004. saveLog(result, result1, "3507", "3507")
  1005. var respJSON2 map[string]interface{}
  1006. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1009. return
  1010. }
  1011. userJSONBytes2, _ := json.Marshal(respJSON2)
  1012. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1013. utils.ErrorLog("解析失败:%v", err)
  1014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1015. return
  1016. }
  1017. } else {
  1018. data := make(map[string]interface{})
  1019. data["struct_3507s"] = struct3507
  1020. client := &http.Client{}
  1021. bytesData, _ := json.Marshal(data)
  1022. var req *http.Request
  1023. if miConfig.MdtrtareaAdmvs == "320921" {
  1024. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1025. } else {
  1026. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1027. }
  1028. resp, _ := client.Do(req)
  1029. defer resp.Body.Close()
  1030. body, ioErr := ioutil.ReadAll(resp.Body)
  1031. if ioErr != nil {
  1032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1033. }
  1034. var respJSON map[string]interface{}
  1035. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1038. return
  1039. }
  1040. var resSix10265 ResultSix10265 //1101结果
  1041. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1042. result, _ := json.Marshal(respJSON)
  1043. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1044. utils.ErrorLog("解析失败:%v", err)
  1045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1046. return
  1047. }
  1048. res.InfRefmsgid = resSix10265.InfRefmsgid
  1049. //res.Output = resSix10265.Output
  1050. res.ErrMsg = resSix10265.ErrMsg
  1051. res.Cainfo = resSix10265.Cainfo
  1052. res.WarnMsg = resSix10265.WarnMsg
  1053. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1054. res.Infcode = infocode
  1055. }
  1056. if res.Infcode == 0 {
  1057. item.IsPc = 0
  1058. err2 := service.SaveW(item)
  1059. if err2 == nil {
  1060. var struct3507_2 models.Struct3507
  1061. struct3507_2.OrgName = miConfig.OrgName
  1062. struct3507_2.AccessKey = miConfig.AccessKey
  1063. struct3507_2.RequestUrl = miConfig.Url
  1064. struct3507_2.Opter = roles.UserName
  1065. struct3507_2.FixmedinsCode = miConfig.Code
  1066. struct3507_2.Code = miConfig.Code
  1067. struct3507_2.SecretKey = miConfig.SecretKey
  1068. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1069. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1070. struct3507_2.Url = miConfig.Url
  1071. struct3507_2.AppId = miConfig.Cainfo
  1072. struct3507_2.AppSecret = miConfig.AppSecret
  1073. struct3507_2.Enckey = miConfig.EncKey
  1074. struct3507_2.SignKey = miConfig.SignKey
  1075. struct3507_2.SecretKey = miConfig.SecretKey
  1076. struct3507_2.FixmedinsBchno = item.BgBchno
  1077. struct3507_2.InvDataType = "2"
  1078. if miConfig.MdtrtareaAdmvs == "350500" {
  1079. result11, result22, _ := service.FJyb3507(struct3507_2)
  1080. saveLog(result11, result22, "3507", "3507")
  1081. var respJSON3 map[string]interface{}
  1082. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1085. return
  1086. }
  1087. userJSONBytes3, _ := json.Marshal(respJSON3)
  1088. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1089. utils.ErrorLog("解析失败:%v", err)
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. } else {
  1094. data := make(map[string]interface{})
  1095. data["struct_3507s"] = struct3507_2
  1096. client := &http.Client{}
  1097. bytesData, _ := json.Marshal(data)
  1098. var req *http.Request
  1099. if miConfig.MdtrtareaAdmvs == "320921" {
  1100. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1101. } else {
  1102. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1103. }
  1104. resp, _ := client.Do(req)
  1105. defer resp.Body.Close()
  1106. body, ioErr := ioutil.ReadAll(resp.Body)
  1107. if ioErr != nil {
  1108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1109. }
  1110. var respJSON map[string]interface{}
  1111. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1114. return
  1115. }
  1116. var resSix10265 ResultSix10265 //1101结果
  1117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1118. result, _ := json.Marshal(respJSON)
  1119. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1120. utils.ErrorLog("解析失败:%v", err)
  1121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1122. return
  1123. }
  1124. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1125. //res2.Output = resSix10265.Output
  1126. res2.ErrMsg = resSix10265.ErrMsg
  1127. res2.Cainfo = resSix10265.Cainfo
  1128. res2.WarnMsg = resSix10265.WarnMsg
  1129. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1130. res2.Infcode = infocode
  1131. }
  1132. if res2.Infcode != -1 {
  1133. item.IsBg = 0
  1134. item.Bchno = ""
  1135. item.BgBchno = ""
  1136. item.PcDate = 0
  1137. service.SaveW(item)
  1138. } else {
  1139. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1140. }
  1141. }
  1142. } else {
  1143. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1144. }
  1145. }
  1146. if item.IsPc == 1 && item.IsBg == 0 {
  1147. var res FJ3507Result
  1148. var struct3507 models.Struct3507
  1149. struct3507.FixmedinsBchno = item.Bchno
  1150. struct3507.InvDataType = "1"
  1151. struct3507.Opter = roles.UserName
  1152. struct3507.FixmedinsCode = miConfig.Code
  1153. struct3507.Code = miConfig.Code
  1154. struct3507.OrgName = miConfig.OrgName
  1155. struct3507.AccessKey = miConfig.AccessKey
  1156. struct3507.RequestUrl = miConfig.Url
  1157. struct3507.SecretKey = miConfig.SecretKey
  1158. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1159. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1160. struct3507.Url = miConfig.Url
  1161. struct3507.AppId = miConfig.Cainfo
  1162. struct3507.AppSecret = miConfig.AppSecret
  1163. struct3507.Enckey = miConfig.EncKey
  1164. struct3507.SignKey = miConfig.SignKey
  1165. struct3507.SecretKey = miConfig.SecretKey
  1166. //result, result1, _ := service.FJyb3507(struct3507)
  1167. //saveLog(result, result1, "3507", "3507")
  1168. if miConfig.MdtrtareaAdmvs == "350500" {
  1169. result, result1, _ := service.FJyb3507(struct3507)
  1170. saveLog(result, result1, "3507", "3507")
  1171. var respJSON2 map[string]interface{}
  1172. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1175. return
  1176. }
  1177. userJSONBytes2, _ := json.Marshal(respJSON2)
  1178. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1179. utils.ErrorLog("解析失败:%v", err)
  1180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1181. return
  1182. }
  1183. } else {
  1184. data := make(map[string]interface{})
  1185. data["struct_3507s"] = struct3507
  1186. client := &http.Client{}
  1187. bytesData, _ := json.Marshal(data)
  1188. var req *http.Request
  1189. if miConfig.MdtrtareaAdmvs == "320921" {
  1190. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1191. } else {
  1192. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1193. }
  1194. resp, _ := client.Do(req)
  1195. defer resp.Body.Close()
  1196. body, ioErr := ioutil.ReadAll(resp.Body)
  1197. if ioErr != nil {
  1198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1199. }
  1200. var respJSON map[string]interface{}
  1201. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1204. return
  1205. }
  1206. var resSix10265 ResultSix10265 //1101结果
  1207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1208. result, _ := json.Marshal(respJSON)
  1209. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1210. utils.ErrorLog("解析失败:%v", err)
  1211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1212. return
  1213. }
  1214. res.InfRefmsgid = resSix10265.InfRefmsgid
  1215. //res.Output = resSix10265.Output
  1216. res.ErrMsg = resSix10265.ErrMsg
  1217. res.Cainfo = resSix10265.Cainfo
  1218. res.WarnMsg = resSix10265.WarnMsg
  1219. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1220. res.Infcode = infocode
  1221. }
  1222. if res.Infcode == 0 {
  1223. item.IsPc = 0
  1224. item.Bchno = ""
  1225. item.BgBchno = ""
  1226. item.PcDate = 0
  1227. service.SaveW(item)
  1228. } else {
  1229. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1230. }
  1231. }
  1232. if item.IsPc == 0 && item.IsBg == 1 {
  1233. var res FJ3507Result
  1234. var struct3507 models.Struct3507
  1235. struct3507.FixmedinsBchno = item.BgBchno
  1236. struct3507.InvDataType = "2"
  1237. struct3507.Opter = roles.UserName
  1238. struct3507.FixmedinsCode = miConfig.Code
  1239. struct3507.OrgName = miConfig.OrgName
  1240. struct3507.AccessKey = miConfig.AccessKey
  1241. struct3507.RequestUrl = miConfig.Url
  1242. struct3507.SecretKey = miConfig.SecretKey
  1243. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1244. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1245. struct3507.Url = miConfig.Url
  1246. struct3507.AppId = miConfig.Cainfo
  1247. struct3507.AppSecret = miConfig.AppSecret
  1248. struct3507.Enckey = miConfig.EncKey
  1249. struct3507.SignKey = miConfig.SignKey
  1250. struct3507.SecretKey = miConfig.SecretKey
  1251. //result, result1, _ := service.FJyb3507(struct3507)
  1252. //saveLog(result, result1, "3507", "3507")
  1253. if miConfig.MdtrtareaAdmvs == "350500" {
  1254. result, result1, _ := service.FJyb3507(struct3507)
  1255. saveLog(result, result1, "3507", "3507")
  1256. var respJSON2 map[string]interface{}
  1257. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1260. return
  1261. }
  1262. userJSONBytes2, _ := json.Marshal(respJSON2)
  1263. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1264. utils.ErrorLog("解析失败:%v", err)
  1265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1266. return
  1267. }
  1268. } else {
  1269. data := make(map[string]interface{})
  1270. data["struct_3507s"] = struct3507
  1271. client := &http.Client{}
  1272. bytesData, _ := json.Marshal(data)
  1273. var req *http.Request
  1274. if miConfig.MdtrtareaAdmvs == "320921" {
  1275. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1276. } else {
  1277. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1278. }
  1279. resp, _ := client.Do(req)
  1280. defer resp.Body.Close()
  1281. body, ioErr := ioutil.ReadAll(resp.Body)
  1282. if ioErr != nil {
  1283. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1284. }
  1285. var respJSON map[string]interface{}
  1286. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1289. return
  1290. }
  1291. var resSix10265 ResultSix10265 //1101结果
  1292. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1293. result, _ := json.Marshal(respJSON)
  1294. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1295. utils.ErrorLog("解析失败:%v", err)
  1296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1297. return
  1298. }
  1299. res.InfRefmsgid = resSix10265.InfRefmsgid
  1300. //res.Output = resSix10265.Output
  1301. res.ErrMsg = resSix10265.ErrMsg
  1302. res.Cainfo = resSix10265.Cainfo
  1303. res.WarnMsg = resSix10265.WarnMsg
  1304. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1305. res.Infcode = infocode
  1306. }
  1307. if res.Infcode == 0 {
  1308. item.IsBg = 0
  1309. item.Bchno = ""
  1310. item.BgBchno = ""
  1311. item.PcDate = 0
  1312. service.SaveW(item)
  1313. } else {
  1314. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1315. }
  1316. }
  1317. }
  1318. if len(err) == 0 {
  1319. c.ServeSuccessJSON(map[string]interface{}{
  1320. "msg": "删除盘存变更成功",
  1321. })
  1322. } else {
  1323. c.ServeSuccessJSON(map[string]interface{}{
  1324. "failed_code": -10,
  1325. "msg": err,
  1326. })
  1327. }
  1328. }
  1329. func (c *HisApiController) DeleteXSandBG() {
  1330. ids := c.GetString("ids")
  1331. id_arr := strings.Split(ids, ",")
  1332. admin_user_id, _ := c.GetInt64("admin_user_id")
  1333. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1334. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1335. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1336. var err []string
  1337. for _, item := range flows {
  1338. if item.IsSale == 1 && item.IsChange == 1 {
  1339. var res FJ3507Result
  1340. var res2 FJ3507Result
  1341. var struct3507 models.Struct3507
  1342. struct3507.FixmedinsBchno = item.Bchno
  1343. struct3507.InvDataType = "4"
  1344. struct3507.Opter = roles.UserName
  1345. struct3507.OrgName = miConfig.OrgName
  1346. struct3507.AccessKey = miConfig.AccessKey
  1347. struct3507.RequestUrl = miConfig.Url
  1348. struct3507.FixmedinsCode = miConfig.Code
  1349. struct3507.SecretKey = miConfig.SecretKey
  1350. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1351. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1352. struct3507.Url = miConfig.Url
  1353. struct3507.AppId = miConfig.Cainfo
  1354. struct3507.AppSecret = miConfig.AppSecret
  1355. struct3507.Enckey = miConfig.EncKey
  1356. struct3507.SignKey = miConfig.SignKey
  1357. struct3507.SecretKey = miConfig.SecretKey
  1358. //result, result1, _ := service.FJyb3507(struct3507)
  1359. //saveLog(result, result1, "3507", "3507")
  1360. if miConfig.MdtrtareaAdmvs == "350500" {
  1361. result, result1, _ := service.FJyb3507(struct3507)
  1362. saveLog(result, result1, "3507", "3507")
  1363. var respJSON2 map[string]interface{}
  1364. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1367. return
  1368. }
  1369. userJSONBytes2, _ := json.Marshal(respJSON2)
  1370. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1371. utils.ErrorLog("解析失败:%v", err)
  1372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1373. return
  1374. }
  1375. } else {
  1376. data := make(map[string]interface{})
  1377. data["struct_3507s"] = struct3507
  1378. client := &http.Client{}
  1379. bytesData, _ := json.Marshal(data)
  1380. var req *http.Request
  1381. if miConfig.MdtrtareaAdmvs == "320921" {
  1382. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1383. } else {
  1384. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1385. }
  1386. resp, _ := client.Do(req)
  1387. defer resp.Body.Close()
  1388. body, ioErr := ioutil.ReadAll(resp.Body)
  1389. if ioErr != nil {
  1390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1391. }
  1392. var respJSON map[string]interface{}
  1393. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1396. return
  1397. }
  1398. var resSix10265 ResultSix10265 //1101结果
  1399. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1400. result, _ := json.Marshal(respJSON)
  1401. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1402. utils.ErrorLog("解析失败:%v", err)
  1403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1404. return
  1405. }
  1406. res.InfRefmsgid = resSix10265.InfRefmsgid
  1407. //res.Output = resSix10265.Output
  1408. res.ErrMsg = resSix10265.ErrMsg
  1409. res.Cainfo = resSix10265.Cainfo
  1410. res.WarnMsg = resSix10265.WarnMsg
  1411. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1412. res.Infcode = infocode
  1413. }
  1414. if res.Infcode == 0 {
  1415. item.IsSale = 0
  1416. item.SaleDate = ""
  1417. item.Bchno = ""
  1418. err2 := service.SaveDF(item)
  1419. if err2 == nil {
  1420. var struct3507_2 models.Struct3507
  1421. struct3507_2.OrgName = miConfig.OrgName
  1422. struct3507_2.AccessKey = miConfig.AccessKey
  1423. struct3507_2.RequestUrl = miConfig.Url
  1424. struct3507_2.Opter = roles.UserName
  1425. struct3507_2.FixmedinsCode = miConfig.Code
  1426. struct3507_2.Code = miConfig.Code
  1427. struct3507_2.SecretKey = miConfig.SecretKey
  1428. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1429. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1430. struct3507_2.Url = miConfig.Url
  1431. struct3507_2.AppId = miConfig.Cainfo
  1432. struct3507_2.AppSecret = miConfig.AppSecret
  1433. struct3507_2.Enckey = miConfig.EncKey
  1434. struct3507_2.SignKey = miConfig.SignKey
  1435. struct3507_2.SecretKey = miConfig.SecretKey
  1436. struct3507_2.FixmedinsBchno = item.BgBchno
  1437. struct3507_2.InvDataType = "2"
  1438. if miConfig.MdtrtareaAdmvs == "350500" {
  1439. result11, result22, _ := service.FJyb3507(struct3507_2)
  1440. saveLog(result11, result22, "3507", "3507")
  1441. var respJSON3 map[string]interface{}
  1442. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1445. return
  1446. }
  1447. userJSONBytes3, _ := json.Marshal(respJSON3)
  1448. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1449. utils.ErrorLog("解析失败:%v", err)
  1450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1451. return
  1452. }
  1453. } else {
  1454. data := make(map[string]interface{})
  1455. data["struct_3507s"] = struct3507_2
  1456. client := &http.Client{}
  1457. bytesData, _ := json.Marshal(data)
  1458. var req *http.Request
  1459. if miConfig.MdtrtareaAdmvs == "320921" {
  1460. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1461. } else {
  1462. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1463. }
  1464. resp, _ := client.Do(req)
  1465. defer resp.Body.Close()
  1466. body, ioErr := ioutil.ReadAll(resp.Body)
  1467. if ioErr != nil {
  1468. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1469. }
  1470. var respJSON map[string]interface{}
  1471. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1474. return
  1475. }
  1476. var resSix10265 ResultSix10265 //1101结果
  1477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1478. result, _ := json.Marshal(respJSON)
  1479. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1480. utils.ErrorLog("解析失败:%v", err)
  1481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1482. return
  1483. }
  1484. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1485. //res.Output = resSix10265.Output
  1486. res2.ErrMsg = resSix10265.ErrMsg
  1487. res2.Cainfo = resSix10265.Cainfo
  1488. res2.WarnMsg = resSix10265.WarnMsg
  1489. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1490. res2.Infcode = infocode
  1491. }
  1492. if res2.Infcode == 0 {
  1493. item.IsChange = 0
  1494. item.BgBchno = ""
  1495. service.SaveDF2(item)
  1496. } else {
  1497. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1498. }
  1499. }
  1500. } else {
  1501. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1502. }
  1503. }
  1504. if item.IsSale == 2 && item.IsChange == 1 {
  1505. var res FJ3507Result
  1506. var res2 FJ3507Result
  1507. var struct3507 models.Struct3507
  1508. struct3507.FixmedinsBchno = item.Bchno
  1509. struct3507.InvDataType = "4"
  1510. struct3507.Opter = roles.UserName
  1511. struct3507.OrgName = miConfig.OrgName
  1512. struct3507.AccessKey = miConfig.AccessKey
  1513. struct3507.RequestUrl = miConfig.Url
  1514. struct3507.FixmedinsCode = miConfig.Code
  1515. struct3507.Code = miConfig.Code
  1516. struct3507.SecretKey = miConfig.SecretKey
  1517. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1518. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1519. struct3507.Url = miConfig.Url
  1520. struct3507.AppId = miConfig.Cainfo
  1521. struct3507.AppSecret = miConfig.AppSecret
  1522. struct3507.Enckey = miConfig.EncKey
  1523. struct3507.SignKey = miConfig.SignKey
  1524. struct3507.SecretKey = miConfig.SecretKey
  1525. //result, result1, _ := service.FJyb3507(struct3507)
  1526. //saveLog(result, result1, "3507", "3507")
  1527. //
  1528. //var respJSON2 map[string]interface{}
  1529. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1530. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1531. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1532. // return
  1533. //}
  1534. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1535. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1536. // utils.ErrorLog("解析失败:%v", err)
  1537. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1538. // return
  1539. //}
  1540. if miConfig.MdtrtareaAdmvs == "350500" {
  1541. result, result1, _ := service.FJyb3507(struct3507)
  1542. saveLog(result, result1, "3507", "3507")
  1543. var respJSON2 map[string]interface{}
  1544. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1547. return
  1548. }
  1549. userJSONBytes2, _ := json.Marshal(respJSON2)
  1550. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1551. utils.ErrorLog("解析失败:%v", err)
  1552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1553. return
  1554. }
  1555. } else {
  1556. data := make(map[string]interface{})
  1557. data["struct_3507s"] = struct3507
  1558. client := &http.Client{}
  1559. bytesData, _ := json.Marshal(data)
  1560. var req *http.Request
  1561. if miConfig.MdtrtareaAdmvs == "320921" {
  1562. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1563. } else {
  1564. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1565. }
  1566. resp, _ := client.Do(req)
  1567. defer resp.Body.Close()
  1568. body, ioErr := ioutil.ReadAll(resp.Body)
  1569. if ioErr != nil {
  1570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1571. }
  1572. var respJSON map[string]interface{}
  1573. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1576. return
  1577. }
  1578. var resSix10265 ResultSix10265 //1101结果
  1579. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1580. result, _ := json.Marshal(respJSON)
  1581. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1582. utils.ErrorLog("解析失败:%v", err)
  1583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1584. return
  1585. }
  1586. res.InfRefmsgid = resSix10265.InfRefmsgid
  1587. //res.Output = resSix10265.Output
  1588. res.ErrMsg = resSix10265.ErrMsg
  1589. res.Cainfo = resSix10265.Cainfo
  1590. res.WarnMsg = resSix10265.WarnMsg
  1591. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1592. res.Infcode = infocode
  1593. }
  1594. if res.Infcode == 0 {
  1595. item.IsSale = 0
  1596. item.SaleDate = ""
  1597. item.Bchno = ""
  1598. err2 := service.SaveDF(item)
  1599. if err2 == nil {
  1600. var struct3507_2 models.Struct3507
  1601. struct3507_2.OrgName = miConfig.OrgName
  1602. struct3507_2.AccessKey = miConfig.AccessKey
  1603. struct3507_2.RequestUrl = miConfig.Url
  1604. struct3507_2.Opter = roles.UserName
  1605. struct3507_2.FixmedinsCode = miConfig.Code
  1606. struct3507_2.Code = miConfig.Code
  1607. struct3507_2.SecretKey = miConfig.SecretKey
  1608. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1609. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1610. struct3507_2.Url = miConfig.Url
  1611. struct3507_2.AppId = miConfig.Cainfo
  1612. struct3507_2.AppSecret = miConfig.AppSecret
  1613. struct3507_2.Enckey = miConfig.EncKey
  1614. struct3507_2.SignKey = miConfig.SignKey
  1615. struct3507_2.SecretKey = miConfig.SecretKey
  1616. struct3507_2.FixmedinsBchno = item.BgBchno
  1617. struct3507_2.InvDataType = "2"
  1618. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1619. //saveLog(result11, result22, "3507", "3507")
  1620. //var respJSON3 map[string]interface{}
  1621. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1622. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1624. // return
  1625. //}
  1626. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1627. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1628. // utils.ErrorLog("解析失败:%v", err)
  1629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1630. // return
  1631. //}
  1632. if miConfig.MdtrtareaAdmvs == "350500" {
  1633. result11, result22, _ := service.FJyb3507(struct3507_2)
  1634. saveLog(result11, result22, "3507", "3507")
  1635. var respJSON3 map[string]interface{}
  1636. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1639. return
  1640. }
  1641. userJSONBytes3, _ := json.Marshal(respJSON3)
  1642. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1643. utils.ErrorLog("解析失败:%v", err)
  1644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1645. return
  1646. }
  1647. } else {
  1648. data := make(map[string]interface{})
  1649. data["struct_3507s"] = struct3507_2
  1650. client := &http.Client{}
  1651. bytesData, _ := json.Marshal(data)
  1652. var req *http.Request
  1653. if miConfig.MdtrtareaAdmvs == "320921" {
  1654. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1655. } else {
  1656. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1657. }
  1658. resp, _ := client.Do(req)
  1659. defer resp.Body.Close()
  1660. body, ioErr := ioutil.ReadAll(resp.Body)
  1661. if ioErr != nil {
  1662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1663. }
  1664. var respJSON map[string]interface{}
  1665. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1668. return
  1669. }
  1670. var resSix10265 ResultSix10265 //1101结果
  1671. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1672. result, _ := json.Marshal(respJSON)
  1673. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1674. utils.ErrorLog("解析失败:%v", err)
  1675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1676. return
  1677. }
  1678. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1679. //res.Output = resSix10265.Output
  1680. res2.ErrMsg = resSix10265.ErrMsg
  1681. res2.Cainfo = resSix10265.Cainfo
  1682. res2.WarnMsg = resSix10265.WarnMsg
  1683. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1684. res2.Infcode = infocode
  1685. }
  1686. if res2.Infcode == 0 {
  1687. item.IsChange = 0
  1688. item.BgBchno = ""
  1689. service.SaveDF2(item)
  1690. } else {
  1691. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1692. }
  1693. }
  1694. } else {
  1695. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1696. }
  1697. }
  1698. if item.IsSale == 1 && item.IsChange == 0 {
  1699. var res FJ3507Result
  1700. var struct3507 models.Struct3507
  1701. struct3507.FixmedinsBchno = item.Bchno
  1702. struct3507.InvDataType = "4"
  1703. struct3507.Opter = roles.UserName
  1704. struct3507.FixmedinsCode = miConfig.Code
  1705. struct3507.Code = miConfig.Code
  1706. struct3507.OrgName = miConfig.OrgName
  1707. struct3507.AccessKey = miConfig.AccessKey
  1708. struct3507.RequestUrl = miConfig.Url
  1709. struct3507.SecretKey = miConfig.SecretKey
  1710. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1711. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1712. struct3507.Url = miConfig.Url
  1713. struct3507.AppId = miConfig.Cainfo
  1714. struct3507.AppSecret = miConfig.AppSecret
  1715. struct3507.Enckey = miConfig.EncKey
  1716. struct3507.SignKey = miConfig.SignKey
  1717. struct3507.SecretKey = miConfig.SecretKey
  1718. //result, result1, _ := service.FJyb3507(struct3507)
  1719. //saveLog(result, result1, "3507", "3507")
  1720. //
  1721. //var respJSON3 map[string]interface{}
  1722. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1723. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1724. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1725. // return
  1726. //}
  1727. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1728. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1729. // utils.ErrorLog("解析失败:%v", err)
  1730. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1731. // return
  1732. //}
  1733. if miConfig.MdtrtareaAdmvs == "350500" {
  1734. result, result1, _ := service.FJyb3507(struct3507)
  1735. saveLog(result, result1, "3507", "3507")
  1736. var respJSON2 map[string]interface{}
  1737. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1740. return
  1741. }
  1742. userJSONBytes2, _ := json.Marshal(respJSON2)
  1743. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1744. utils.ErrorLog("解析失败:%v", err)
  1745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1746. return
  1747. }
  1748. } else {
  1749. data := make(map[string]interface{})
  1750. data["struct_3507s"] = struct3507
  1751. client := &http.Client{}
  1752. bytesData, _ := json.Marshal(data)
  1753. var req *http.Request
  1754. if miConfig.MdtrtareaAdmvs == "320921" {
  1755. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1756. } else {
  1757. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1758. }
  1759. resp, _ := client.Do(req)
  1760. defer resp.Body.Close()
  1761. body, ioErr := ioutil.ReadAll(resp.Body)
  1762. if ioErr != nil {
  1763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1764. }
  1765. var respJSON map[string]interface{}
  1766. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1769. return
  1770. }
  1771. var resSix10265 ResultSix10265 //1101结果
  1772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1773. result, _ := json.Marshal(respJSON)
  1774. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1775. utils.ErrorLog("解析失败:%v", err)
  1776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1777. return
  1778. }
  1779. res.InfRefmsgid = resSix10265.InfRefmsgid
  1780. //res.Output = resSix10265.Output
  1781. res.ErrMsg = resSix10265.ErrMsg
  1782. res.Cainfo = resSix10265.Cainfo
  1783. res.WarnMsg = resSix10265.WarnMsg
  1784. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1785. res.Infcode = infocode
  1786. }
  1787. if res.Infcode == 0 {
  1788. item.IsSale = 0
  1789. item.SaleDate = ""
  1790. service.SaveDF(item)
  1791. } else {
  1792. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1793. }
  1794. }
  1795. if item.IsSale == 2 && item.IsChange == 0 {
  1796. var res FJ3507Result
  1797. var struct3507 models.Struct3507
  1798. struct3507.FixmedinsBchno = item.Bchno
  1799. struct3507.InvDataType = "4"
  1800. struct3507.Opter = roles.UserName
  1801. struct3507.FixmedinsCode = miConfig.Code
  1802. struct3507.Code = miConfig.Code
  1803. struct3507.OrgName = miConfig.OrgName
  1804. struct3507.AccessKey = miConfig.AccessKey
  1805. struct3507.RequestUrl = miConfig.Url
  1806. struct3507.SecretKey = miConfig.SecretKey
  1807. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1808. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1809. struct3507.Url = miConfig.Url
  1810. struct3507.AppId = miConfig.Cainfo
  1811. struct3507.AppSecret = miConfig.AppSecret
  1812. struct3507.Enckey = miConfig.EncKey
  1813. struct3507.SignKey = miConfig.SignKey
  1814. struct3507.SecretKey = miConfig.SecretKey
  1815. //result, result1, _ := service.FJyb3507(struct3507)
  1816. //saveLog(result, result1, "3507", "3507")
  1817. //
  1818. //var respJSON3 map[string]interface{}
  1819. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1820. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1822. // return
  1823. //}
  1824. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1825. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1826. // utils.ErrorLog("解析失败:%v", err)
  1827. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1828. // return
  1829. //}
  1830. if miConfig.MdtrtareaAdmvs == "350500" {
  1831. result, result1, _ := service.FJyb3507(struct3507)
  1832. saveLog(result, result1, "3507", "3507")
  1833. var respJSON2 map[string]interface{}
  1834. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1837. return
  1838. }
  1839. userJSONBytes2, _ := json.Marshal(respJSON2)
  1840. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1841. utils.ErrorLog("解析失败:%v", err)
  1842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1843. return
  1844. }
  1845. } else {
  1846. data := make(map[string]interface{})
  1847. data["struct_3507s"] = struct3507
  1848. client := &http.Client{}
  1849. bytesData, _ := json.Marshal(data)
  1850. var req *http.Request
  1851. if miConfig.MdtrtareaAdmvs == "320921" {
  1852. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1853. } else {
  1854. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1855. }
  1856. resp, _ := client.Do(req)
  1857. defer resp.Body.Close()
  1858. body, ioErr := ioutil.ReadAll(resp.Body)
  1859. if ioErr != nil {
  1860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1861. }
  1862. var respJSON map[string]interface{}
  1863. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1866. return
  1867. }
  1868. var resSix10265 ResultSix10265 //1101结果
  1869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1870. result, _ := json.Marshal(respJSON)
  1871. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1872. utils.ErrorLog("解析失败:%v", err)
  1873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1874. return
  1875. }
  1876. res.InfRefmsgid = resSix10265.InfRefmsgid
  1877. //res.Output = resSix10265.Output
  1878. res.ErrMsg = resSix10265.ErrMsg
  1879. res.Cainfo = resSix10265.Cainfo
  1880. res.WarnMsg = resSix10265.WarnMsg
  1881. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1882. res.Infcode = infocode
  1883. }
  1884. if res.Infcode == 0 {
  1885. item.IsSale = 0
  1886. item.SaleDate = ""
  1887. item.Bchno = ""
  1888. service.SaveDF(item)
  1889. } else {
  1890. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1891. }
  1892. }
  1893. if item.IsSale == 0 && item.IsChange == 1 {
  1894. var res FJ3507Result
  1895. var struct3507 models.Struct3507
  1896. struct3507.FixmedinsBchno = item.BgBchno
  1897. struct3507.InvDataType = "2"
  1898. struct3507.Opter = roles.UserName
  1899. struct3507.FixmedinsCode = miConfig.Code
  1900. struct3507.Code = miConfig.Code
  1901. struct3507.OrgName = miConfig.OrgName
  1902. struct3507.AccessKey = miConfig.AccessKey
  1903. struct3507.RequestUrl = miConfig.Url
  1904. struct3507.SecretKey = miConfig.SecretKey
  1905. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1906. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1907. struct3507.Url = miConfig.Url
  1908. struct3507.AppId = miConfig.Cainfo
  1909. struct3507.AppSecret = miConfig.AppSecret
  1910. struct3507.Enckey = miConfig.EncKey
  1911. struct3507.SignKey = miConfig.SignKey
  1912. struct3507.SecretKey = miConfig.SecretKey
  1913. //result, result1, _ := service.FJyb3507(struct3507)
  1914. //saveLog(result, result1, "3507", "3507")
  1915. //
  1916. //var respJSON3 map[string]interface{}
  1917. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1918. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1919. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1920. // return
  1921. //}
  1922. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1923. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1924. // utils.ErrorLog("解析失败:%v", err)
  1925. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1926. // return
  1927. //}
  1928. if miConfig.MdtrtareaAdmvs == "350500" {
  1929. result, result1, _ := service.FJyb3507(struct3507)
  1930. saveLog(result, result1, "3507", "3507")
  1931. var respJSON2 map[string]interface{}
  1932. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1935. return
  1936. }
  1937. userJSONBytes2, _ := json.Marshal(respJSON2)
  1938. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1939. utils.ErrorLog("解析失败:%v", err)
  1940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1941. return
  1942. }
  1943. } else {
  1944. data := make(map[string]interface{})
  1945. data["struct_3507s"] = struct3507
  1946. client := &http.Client{}
  1947. bytesData, _ := json.Marshal(data)
  1948. var req *http.Request
  1949. if miConfig.MdtrtareaAdmvs == "320921" {
  1950. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1951. } else {
  1952. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1953. }
  1954. resp, _ := client.Do(req)
  1955. defer resp.Body.Close()
  1956. body, ioErr := ioutil.ReadAll(resp.Body)
  1957. if ioErr != nil {
  1958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1959. }
  1960. var respJSON map[string]interface{}
  1961. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1964. return
  1965. }
  1966. var resSix10265 ResultSix10265 //1101结果
  1967. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1968. result, _ := json.Marshal(respJSON)
  1969. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1970. utils.ErrorLog("解析失败:%v", err)
  1971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1972. return
  1973. }
  1974. res.InfRefmsgid = resSix10265.InfRefmsgid
  1975. //res.Output = resSix10265.Output
  1976. res.ErrMsg = resSix10265.ErrMsg
  1977. res.Cainfo = resSix10265.Cainfo
  1978. res.WarnMsg = resSix10265.WarnMsg
  1979. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1980. res.Infcode = infocode
  1981. }
  1982. if res.Infcode == 0 {
  1983. item.IsChange = 0
  1984. item.BgBchno = ""
  1985. service.SaveDF2(item)
  1986. } else {
  1987. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1988. }
  1989. }
  1990. }
  1991. if len(err) == 0 {
  1992. c.ServeSuccessJSON(map[string]interface{}{
  1993. "msg": "删除销售变更成功",
  1994. })
  1995. } else {
  1996. c.ServeSuccessJSON(map[string]interface{}{
  1997. "failed_code": -10,
  1998. "msg": err,
  1999. })
  2000. }
  2001. }
  2002. //func (c *HisApiController) BatchFJ3501AND3502() {
  2003. // //ids := c.GetString("ids")
  2004. // start_time := c.GetString("start_time")
  2005. // end_time := c.GetString("end_time")
  2006. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2007. //
  2008. //
  2009. // timeLayout := "2006-01-02"
  2010. // loc, _ := time.LoadLocation("Local")
  2011. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2012. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2013. //
  2014. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2015. // //id_arr := strings.Split(ids, ",")
  2016. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2017. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2018. // //库盘
  2019. // var errs []string
  2020. // for _, drug := range drugs {
  2021. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2022. // var res2 ResultSix
  2023. // var res3 ResultSix
  2024. //
  2025. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2026. // var struct3501 models.Struct3501
  2027. // struct3501.Code = miConfig.Code
  2028. // struct3501.OrgName = miConfig.OrgName
  2029. // struct3501.AccessKey = miConfig.AccessKey
  2030. // struct3501.Opter = roles.UserName
  2031. // struct3501.RequestUrl = miConfig.Url
  2032. // struct3501.Url = miConfig.Url
  2033. // struct3501.AppId = miConfig.Cainfo
  2034. // struct3501.AppSecret = miConfig.AppSecret
  2035. // struct3501.Enckey = miConfig.EncKey
  2036. // struct3501.SignKey = miConfig.SignKey
  2037. // struct3501.SecretKey = miConfig.SecretKey
  2038. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2039. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2040. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2041. // struct3501.RxFlag = "1"
  2042. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2043. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2044. //
  2045. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2046. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2047. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2048. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2049. // struct3501.FixmedinsBchno = number
  2050. // struct3501.DrugTracCodg = drug.DrugCode
  2051. // memo := make(map[string]interface{})
  2052. // memo["pric"] = drug.Price
  2053. // bytesData, _ := json.Marshal(memo)
  2054. // struct3501.Memo = string(bytesData)
  2055. //
  2056. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2057. //
  2058. // result1, result2, _ := service.FJyb3501(struct3501)
  2059. // saveLog(result1, result2, "3501", "3501")
  2060. // //saveLog(result, requestLog, "2201", "挂号")
  2061. //
  2062. // var respJSON2 map[string]interface{}
  2063. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2064. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2065. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2066. // return
  2067. // }
  2068. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2069. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2070. // utils.ErrorLog("解析失败:%v", err)
  2071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2072. // return
  2073. // }
  2074. //
  2075. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2076. // data := make(map[string]interface{})
  2077. // data["struct_3501s"] = struct3501
  2078. // client := &http.Client{}
  2079. // bytesData, _ := json.Marshal(data)
  2080. // var req *http.Request
  2081. // if miConfig.MdtrtareaAdmvs == "320921" {
  2082. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2083. // } else {
  2084. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2085. // }
  2086. //
  2087. // resp, _ := client.Do(req)
  2088. // defer resp.Body.Close()
  2089. // body, ioErr := ioutil.ReadAll(resp.Body)
  2090. // if ioErr != nil {
  2091. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2092. // }
  2093. // var respJSON map[string]interface{}
  2094. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2095. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2096. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2097. // return
  2098. // }
  2099. // var resSix10265 ResultSix10265 //1101结果
  2100. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2101. // result, _ := json.Marshal(respJSON)
  2102. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2103. // utils.ErrorLog("解析失败:%v", err)
  2104. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2105. // return
  2106. // }
  2107. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2108. // res2.Output = resSix10265.Output
  2109. // res2.ErrMsg = resSix10265.ErrMsg
  2110. // res2.Cainfo = resSix10265.Cainfo
  2111. // res2.WarnMsg = resSix10265.WarnMsg
  2112. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2113. // res2.Infcode = infocode
  2114. //
  2115. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2116. // data := make(map[string]interface{})
  2117. // data["struct_3501s"] = struct3501
  2118. // client := &http.Client{}
  2119. // bytesData, _ := json.Marshal(data)
  2120. // var req *http.Request
  2121. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2122. // resp, _ := client.Do(req)
  2123. // defer resp.Body.Close()
  2124. // body, ioErr := ioutil.ReadAll(resp.Body)
  2125. // if ioErr != nil {
  2126. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2127. // }
  2128. // var respJSON map[string]interface{}
  2129. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2130. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2131. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2132. // return
  2133. // }
  2134. // var resSix10265 ResultSix10265 //1101结果
  2135. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2136. // result, _ := json.Marshal(respJSON)
  2137. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2138. // utils.ErrorLog("解析失败:%v", err)
  2139. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2140. // return
  2141. // }
  2142. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2143. // res2.Output = resSix10265.Output
  2144. // res2.ErrMsg = resSix10265.ErrMsg
  2145. // res2.Cainfo = resSix10265.Cainfo
  2146. // res2.WarnMsg = resSix10265.WarnMsg
  2147. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2148. // res2.Infcode = infocode
  2149. //
  2150. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2151. // data := make(map[string]interface{})
  2152. // data["struct_3501s"] = struct3501
  2153. // client := &http.Client{}
  2154. // bytesData, _ := json.Marshal(data)
  2155. // var req *http.Request
  2156. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2157. // resp, _ := client.Do(req)
  2158. // defer resp.Body.Close()
  2159. // body, ioErr := ioutil.ReadAll(resp.Body)
  2160. // if ioErr != nil {
  2161. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2162. // }
  2163. // var respJSON map[string]interface{}
  2164. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2165. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2167. // return
  2168. // }
  2169. // var resSix10265 ResultSix10265 //1101结果
  2170. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2171. // result, _ := json.Marshal(respJSON)
  2172. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2173. // utils.ErrorLog("解析失败:%v", err)
  2174. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2175. // return
  2176. // }
  2177. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2178. // res2.Output = resSix10265.Output
  2179. // res2.ErrMsg = resSix10265.ErrMsg
  2180. // res2.Cainfo = resSix10265.Cainfo
  2181. // res2.WarnMsg = resSix10265.WarnMsg
  2182. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2183. // res2.Infcode = infocode
  2184. //
  2185. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2186. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2187. // saveLog(result1, result2, "3501", "3501")
  2188. // //saveLog(result, requestLog, "2201", "挂号")
  2189. //
  2190. // var respJSON2 map[string]interface{}
  2191. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2192. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2194. // return
  2195. // }
  2196. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2197. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2198. // utils.ErrorLog("解析失败:%v", err)
  2199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2200. // return
  2201. // }
  2202. //
  2203. // }
  2204. //
  2205. // if res2.Infcode != -1 {
  2206. // drug.IsPc = 1
  2207. // drug.Bchno = number
  2208. // drug.PcDate = time.Now().Unix()
  2209. // err := service.SaveW(drug)
  2210. // if err == nil {
  2211. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2212. // var struct3502 models.Struct3502
  2213. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2214. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2215. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2216. // struct3502.FixmedinsCode = miConfig.Code
  2217. // struct3502.Code = miConfig.Code
  2218. //
  2219. // struct3502.RxFlag = "0"
  2220. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2221. // struct3502.OrgName = miConfig.OrgName
  2222. // struct3502.Opter = roles.UserName
  2223. // struct3502.AccessKey = miConfig.AccessKey
  2224. // struct3502.RequestUrl = miConfig.Url
  2225. // struct3502.SecretKey = miConfig.SecretKey
  2226. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2227. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2228. // struct3502.Url = miConfig.Url
  2229. // struct3502.AppId = miConfig.Cainfo
  2230. // struct3502.AppSecret = miConfig.AppSecret
  2231. // struct3502.Enckey = miConfig.EncKey
  2232. // struct3502.SignKey = miConfig.SignKey
  2233. // struct3502.SecretKey = miConfig.SecretKey
  2234. // struct3502.DrugTracCodg = drug.DrugCode
  2235. //
  2236. // struct3502.Memo = ""
  2237. // struct3502.InvChgType = "108"
  2238. // struct3502.FixmedinsBchno = bg_number
  2239. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2240. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2241. //
  2242. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2243. // result11, result22, _ := service.FJyb3502(struct3502)
  2244. // saveLog(result11, result22, "3502", "3502")
  2245. //
  2246. // var respJSON3 map[string]interface{}
  2247. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2248. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2249. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2250. // return
  2251. // }
  2252. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2253. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2254. // utils.ErrorLog("解析失败:%v", err)
  2255. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2256. // return
  2257. // }
  2258. //
  2259. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2260. // data := make(map[string]interface{})
  2261. // data["struct_3502s"] = struct3502
  2262. // client := &http.Client{}
  2263. // bytesData, _ := json.Marshal(data)
  2264. // var req *http.Request
  2265. // if miConfig.MdtrtareaAdmvs == "320921" {
  2266. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2267. // } else {
  2268. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2269. // }
  2270. //
  2271. // resp, _ := client.Do(req)
  2272. // defer resp.Body.Close()
  2273. // body, ioErr := ioutil.ReadAll(resp.Body)
  2274. // if ioErr != nil {
  2275. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2276. // }
  2277. // var respJSON map[string]interface{}
  2278. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2279. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2280. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2281. // return
  2282. // }
  2283. // var resSix10265 ResultSix10265 //1101结果
  2284. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2285. // result, _ := json.Marshal(respJSON)
  2286. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2287. // utils.ErrorLog("解析失败:%v", err)
  2288. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2289. // return
  2290. // }
  2291. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2292. // res3.Output = resSix10265.Output
  2293. // res3.ErrMsg = resSix10265.ErrMsg
  2294. // res3.Cainfo = resSix10265.Cainfo
  2295. // res3.WarnMsg = resSix10265.WarnMsg
  2296. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2297. // res3.Infcode = infocode
  2298. //
  2299. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2300. //
  2301. // data := make(map[string]interface{})
  2302. // data["struct_3502s"] = struct3502
  2303. // client := &http.Client{}
  2304. // bytesData, _ := json.Marshal(data)
  2305. // var req *http.Request
  2306. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2307. // resp, _ := client.Do(req)
  2308. // defer resp.Body.Close()
  2309. // body, ioErr := ioutil.ReadAll(resp.Body)
  2310. // if ioErr != nil {
  2311. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2312. // }
  2313. // var respJSON map[string]interface{}
  2314. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2315. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2316. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2317. // return
  2318. // }
  2319. // var resSix10265 ResultSix10265 //1101结果
  2320. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2321. // result, _ := json.Marshal(respJSON)
  2322. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2323. // utils.ErrorLog("解析失败:%v", err)
  2324. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2325. // return
  2326. // }
  2327. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2328. // res3.Output = resSix10265.Output
  2329. // res3.ErrMsg = resSix10265.ErrMsg
  2330. // res3.Cainfo = resSix10265.Cainfo
  2331. // res3.WarnMsg = resSix10265.WarnMsg
  2332. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2333. // res3.Infcode = infocode
  2334. //
  2335. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2336. //
  2337. // data := make(map[string]interface{})
  2338. // data["struct_3501s"] = struct3501
  2339. // client := &http.Client{}
  2340. // bytesData, _ := json.Marshal(data)
  2341. // var req *http.Request
  2342. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2343. // resp, _ := client.Do(req)
  2344. // defer resp.Body.Close()
  2345. // body, ioErr := ioutil.ReadAll(resp.Body)
  2346. // if ioErr != nil {
  2347. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2348. // }
  2349. // var respJSON map[string]interface{}
  2350. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2351. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2353. // return
  2354. // }
  2355. // var resSix10265 ResultSix10265 //1101结果
  2356. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2357. // result, _ := json.Marshal(respJSON)
  2358. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2359. // utils.ErrorLog("解析失败:%v", err)
  2360. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2361. // return
  2362. // }
  2363. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2364. // res2.Output = resSix10265.Output
  2365. // res2.ErrMsg = resSix10265.ErrMsg
  2366. // res2.Cainfo = resSix10265.Cainfo
  2367. // res2.WarnMsg = resSix10265.WarnMsg
  2368. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2369. // res2.Infcode = infocode
  2370. //
  2371. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2372. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2373. // saveLog(result11, result22, "3502", "3502")
  2374. //
  2375. // var respJSON3 map[string]interface{}
  2376. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2377. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2378. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2379. // return
  2380. // }
  2381. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2382. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2383. // utils.ErrorLog("解析失败:%v", err)
  2384. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2385. // return
  2386. // }
  2387. // }
  2388. // if res3.Infcode == -1 {
  2389. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2390. // c.ServeSuccessJSON(map[string]interface{}{
  2391. // "failed_code": -10,
  2392. // "msg": res3.ErrMsg,
  2393. // })
  2394. // } else {
  2395. // drug.IsBg = 1
  2396. // drug.BgBchno = bg_number
  2397. // service.SaveW(drug)
  2398. // }
  2399. // }
  2400. // } else {
  2401. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2402. // }
  2403. // }
  2404. // //变更
  2405. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2406. // var res3 ResultSix
  2407. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2408. //
  2409. // var struct3502 models.Struct3502
  2410. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2411. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2412. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2413. // struct3502.FixmedinsCode = miConfig.Code
  2414. // struct3502.Code = miConfig.Code
  2415. //
  2416. // struct3502.Opter = roles.UserName
  2417. // struct3502.RxFlag = "0"
  2418. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2419. // struct3502.OrgName = miConfig.OrgName
  2420. // struct3502.AccessKey = miConfig.AccessKey
  2421. // struct3502.RequestUrl = miConfig.Url
  2422. // struct3502.SecretKey = miConfig.SecretKey
  2423. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2424. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2425. // struct3502.InvChgType = "108"
  2426. // struct3502.DrugTracCodg = drug.DrugCode
  2427. //
  2428. // struct3502.Url = miConfig.Url
  2429. // struct3502.AppId = miConfig.Cainfo
  2430. // struct3502.AppSecret = miConfig.AppSecret
  2431. // struct3502.Enckey = miConfig.EncKey
  2432. // struct3502.SignKey = miConfig.SignKey
  2433. // struct3502.SecretKey = miConfig.SecretKey
  2434. //
  2435. // struct3502.FixmedinsBchno = bg_number
  2436. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2437. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2438. //
  2439. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2440. // result1, result2, _ := service.FJyb3502(struct3502)
  2441. // saveLog(result1, result2, "3502", "3502")
  2442. // var respJSON3 map[string]interface{}
  2443. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2444. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2446. // return
  2447. // }
  2448. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2449. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2450. // utils.ErrorLog("解析失败:%v", err)
  2451. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2452. // return
  2453. // }
  2454. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2455. // data := make(map[string]interface{})
  2456. // data["struct_3502s"] = struct3502
  2457. // client := &http.Client{}
  2458. // bytesData, _ := json.Marshal(data)
  2459. // var req *http.Request
  2460. // if miConfig.MdtrtareaAdmvs == "320921" {
  2461. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2462. // } else {
  2463. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2464. // }
  2465. // resp, _ := client.Do(req)
  2466. // defer resp.Body.Close()
  2467. // body, ioErr := ioutil.ReadAll(resp.Body)
  2468. // if ioErr != nil {
  2469. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2470. // }
  2471. // var respJSON map[string]interface{}
  2472. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2473. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2475. // return
  2476. // }
  2477. // var resSix10265 ResultSix10265 //1101结果
  2478. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2479. // result, _ := json.Marshal(respJSON)
  2480. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2481. // utils.ErrorLog("解析失败:%v", err)
  2482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2483. // return
  2484. // }
  2485. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2486. // res3.Output = resSix10265.Output
  2487. // res3.ErrMsg = resSix10265.ErrMsg
  2488. // res3.Cainfo = resSix10265.Cainfo
  2489. // res3.WarnMsg = resSix10265.WarnMsg
  2490. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2491. // res3.Infcode = infocode
  2492. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2493. //
  2494. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2495. //
  2496. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2497. //
  2498. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2499. //
  2500. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2501. // saveLog(result1, result2, "3501", "3501")
  2502. // //saveLog(result, requestLog, "2201", "挂号")
  2503. //
  2504. // var respJSON2 map[string]interface{}
  2505. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2506. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2508. // return
  2509. // }
  2510. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2511. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2512. // utils.ErrorLog("解析失败:%v", err)
  2513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2514. // return
  2515. // }
  2516. //
  2517. // }
  2518. // if res3.Infcode == -1 {
  2519. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2520. // } else {
  2521. // drug.IsBg = 1
  2522. // drug.BgBchno = bg_number
  2523. // service.SaveW(drug)
  2524. // }
  2525. // }
  2526. // }
  2527. //
  2528. // if len(errs) == 0 {
  2529. // c.ServeSuccessJSON(map[string]interface{}{
  2530. // "msg": "盘存变更成功",
  2531. // })
  2532. // } else {
  2533. // c.ServeSuccessJSON(map[string]interface{}{
  2534. // "failed_code": -10,
  2535. // "msg": errs,
  2536. // })
  2537. // }
  2538. //}
  2539. func (c *HisApiController) DeleteXSandBGTwo() {
  2540. patient_id, _ := c.GetInt64("patient_id")
  2541. admin_user_id, _ := c.GetInt64("admin_user_id")
  2542. times := c.GetString("time", "")
  2543. timeLayout := "2006-01-02"
  2544. loc, _ := time.LoadLocation("Local")
  2545. var stime, etime int64
  2546. if times == "" {
  2547. stime, etime = GetNowTime()
  2548. } else {
  2549. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2550. stime = stmp.Unix()
  2551. etime = stime + 86399
  2552. }
  2553. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2554. var flows []*models.DrugFlow
  2555. for _, item := range advicelist {
  2556. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2557. flows = append(flows, flow...)
  2558. }
  2559. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2560. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2561. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2562. var err []string
  2563. for _, item := range flows {
  2564. if item.IsSale == 1 {
  2565. var res FJ3507Result
  2566. var struct3507 models.Struct3507
  2567. struct3507.FixmedinsBchno = item.Bchno
  2568. struct3507.InvDataType = "4"
  2569. struct3507.Opter = roles.UserName
  2570. struct3507.OrgName = miConfig.OrgName
  2571. struct3507.AccessKey = miConfig.AccessKey
  2572. struct3507.RequestUrl = miConfig.Url
  2573. struct3507.FixmedinsCode = miConfig.Code
  2574. struct3507.SecretKey = miConfig.SecretKey
  2575. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2576. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2577. struct3507.Url = miConfig.Url
  2578. struct3507.AppId = miConfig.Cainfo
  2579. struct3507.AppSecret = miConfig.AppSecret
  2580. struct3507.Enckey = miConfig.EncKey
  2581. struct3507.SignKey = miConfig.SignKey
  2582. struct3507.SecretKey = miConfig.SecretKey
  2583. if miConfig.MdtrtareaAdmvs == "350500" {
  2584. result, result1, _ := service.FJyb3507(struct3507)
  2585. saveLog(result, result1, "3507", "3507")
  2586. var respJSON2 map[string]interface{}
  2587. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2590. return
  2591. }
  2592. userJSONBytes2, _ := json.Marshal(respJSON2)
  2593. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2594. utils.ErrorLog("解析失败:%v", err)
  2595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2596. return
  2597. }
  2598. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2599. data := make(map[string]interface{})
  2600. data["struct_3507s"] = struct3507
  2601. client := &http.Client{}
  2602. bytesData, _ := json.Marshal(data)
  2603. var req *http.Request
  2604. if miConfig.MdtrtareaAdmvs == "320921" {
  2605. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2606. } else {
  2607. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2608. }
  2609. resp, _ := client.Do(req)
  2610. defer resp.Body.Close()
  2611. body, ioErr := ioutil.ReadAll(resp.Body)
  2612. if ioErr != nil {
  2613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2614. }
  2615. var respJSON map[string]interface{}
  2616. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2619. return
  2620. }
  2621. var resSix10265 ResultSix10265 //1101结果
  2622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2623. result, _ := json.Marshal(respJSON)
  2624. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2625. utils.ErrorLog("解析失败:%v", err)
  2626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2627. return
  2628. }
  2629. res.InfRefmsgid = resSix10265.InfRefmsgid
  2630. //res.Output = resSix10265.Output
  2631. res.ErrMsg = resSix10265.ErrMsg
  2632. res.Cainfo = resSix10265.Cainfo
  2633. res.WarnMsg = resSix10265.WarnMsg
  2634. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2635. res.Infcode = infocode
  2636. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2637. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2638. saveLog(result2, result1, "3507", "3507")
  2639. var respJSON2 map[string]interface{}
  2640. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2643. return
  2644. }
  2645. userJSONBytes2, _ := json.Marshal(respJSON2)
  2646. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2647. utils.ErrorLog("解析失败:%v", err)
  2648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2649. return
  2650. }
  2651. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2652. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2653. saveLog(result2, result1, "3507", "3507")
  2654. var respJSON2 map[string]interface{}
  2655. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2658. return
  2659. }
  2660. userJSONBytes2, _ := json.Marshal(respJSON2)
  2661. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2662. utils.ErrorLog("解析失败:%v", err)
  2663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2664. return
  2665. }
  2666. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2667. result1, result2 := service.Jxyb3507(struct3507)
  2668. saveLog(result2, result1, "3507", "3507")
  2669. var respJSON2 map[string]interface{}
  2670. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2673. return
  2674. }
  2675. userJSONBytes2, _ := json.Marshal(respJSON2)
  2676. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2677. utils.ErrorLog("解析失败:%v", err)
  2678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2679. return
  2680. }
  2681. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2682. result1, result2 := service.AHyb3507(struct3507)
  2683. saveLog(result2, result1, "3507", "3507")
  2684. var respJSON2 map[string]interface{}
  2685. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2688. return
  2689. }
  2690. userJSONBytes2, _ := json.Marshal(respJSON2)
  2691. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2692. utils.ErrorLog("解析失败:%v", err)
  2693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2694. return
  2695. }
  2696. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2697. data := make(map[string]interface{})
  2698. data["struct_3507s"] = struct3507
  2699. client := &http.Client{}
  2700. bytesData, _ := json.Marshal(data)
  2701. var req *http.Request
  2702. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2703. resp, _ := client.Do(req)
  2704. defer resp.Body.Close()
  2705. body, ioErr := ioutil.ReadAll(resp.Body)
  2706. if ioErr != nil {
  2707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2708. }
  2709. var respJSON map[string]interface{}
  2710. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2712. }
  2713. var resSix10265 ResultSix10265 //1101结果
  2714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2715. result, _ := json.Marshal(respJSON)
  2716. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2717. utils.ErrorLog("解析失败:%v", err)
  2718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2719. return
  2720. }
  2721. res.InfRefmsgid = resSix10265.InfRefmsgid
  2722. res.ErrMsg = resSix10265.ErrMsg
  2723. res.Cainfo = resSix10265.Cainfo
  2724. res.WarnMsg = resSix10265.WarnMsg
  2725. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2726. res.Infcode = infocode
  2727. }
  2728. if res.Infcode == 0 {
  2729. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2730. item.IsSale = 0
  2731. item.SaleDate = ""
  2732. item.Bchno = ""
  2733. service.SaveDF(item)
  2734. } else {
  2735. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2736. }
  2737. }
  2738. }
  2739. c.ServeSuccessJSON(map[string]interface{}{
  2740. "msg": "删除销售数据成功",
  2741. })
  2742. }
  2743. // 删除
  2744. func (c *HisApiController) DeleteXSandBGThree() {
  2745. id, _ := c.GetInt64("id")
  2746. admin_user_id, _ := c.GetInt64("admin_user_id")
  2747. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  2748. var flows []*models.DrugFlow
  2749. for _, item := range advicelist {
  2750. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  2751. flows = append(flows, flow...)
  2752. }
  2753. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2754. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2755. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2756. var err []string
  2757. for _, item := range flows {
  2758. if item.IsSale == 1 {
  2759. var res FJ3507Result
  2760. var struct3507 models.Struct3507
  2761. struct3507.FixmedinsBchno = item.Bchno
  2762. struct3507.InvDataType = "4"
  2763. struct3507.Opter = roles.UserName
  2764. struct3507.OrgName = miConfig.OrgName
  2765. struct3507.AccessKey = miConfig.AccessKey
  2766. struct3507.RequestUrl = miConfig.Url
  2767. struct3507.FixmedinsCode = miConfig.Code
  2768. struct3507.SecretKey = miConfig.SecretKey
  2769. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2770. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2771. struct3507.Url = miConfig.Url
  2772. struct3507.AppId = miConfig.Cainfo
  2773. struct3507.AppSecret = miConfig.AppSecret
  2774. struct3507.Enckey = miConfig.EncKey
  2775. struct3507.SignKey = miConfig.SignKey
  2776. struct3507.SecretKey = miConfig.SecretKey
  2777. if miConfig.MdtrtareaAdmvs == "350500" {
  2778. result, result1, _ := service.FJyb3507(struct3507)
  2779. saveLog(result, result1, "3507", "3507")
  2780. var respJSON2 map[string]interface{}
  2781. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2784. return
  2785. }
  2786. userJSONBytes2, _ := json.Marshal(respJSON2)
  2787. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2788. utils.ErrorLog("解析失败:%v", err)
  2789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2790. return
  2791. }
  2792. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2793. data := make(map[string]interface{})
  2794. data["struct_3507s"] = struct3507
  2795. client := &http.Client{}
  2796. bytesData, _ := json.Marshal(data)
  2797. var req *http.Request
  2798. if miConfig.MdtrtareaAdmvs == "320921" {
  2799. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2800. } else {
  2801. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2802. }
  2803. resp, _ := client.Do(req)
  2804. defer resp.Body.Close()
  2805. body, ioErr := ioutil.ReadAll(resp.Body)
  2806. if ioErr != nil {
  2807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2808. }
  2809. var respJSON map[string]interface{}
  2810. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2813. return
  2814. }
  2815. var resSix10265 ResultSix10265 //1101结果
  2816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2817. result, _ := json.Marshal(respJSON)
  2818. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2819. utils.ErrorLog("解析失败:%v", err)
  2820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2821. return
  2822. }
  2823. res.InfRefmsgid = resSix10265.InfRefmsgid
  2824. //res.Output = resSix10265.Output
  2825. res.ErrMsg = resSix10265.ErrMsg
  2826. res.Cainfo = resSix10265.Cainfo
  2827. res.WarnMsg = resSix10265.WarnMsg
  2828. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2829. res.Infcode = infocode
  2830. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2831. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2832. saveLog(result2, result1, "3507", "3507")
  2833. var respJSON2 map[string]interface{}
  2834. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2837. return
  2838. }
  2839. userJSONBytes2, _ := json.Marshal(respJSON2)
  2840. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2841. utils.ErrorLog("解析失败:%v", err)
  2842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2843. return
  2844. }
  2845. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2846. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2847. saveLog(result2, result1, "3507", "3507")
  2848. var respJSON2 map[string]interface{}
  2849. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2852. return
  2853. }
  2854. userJSONBytes2, _ := json.Marshal(respJSON2)
  2855. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2856. utils.ErrorLog("解析失败:%v", err)
  2857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2858. return
  2859. }
  2860. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2861. result1, result2 := service.Jxyb3507(struct3507)
  2862. saveLog(result2, result1, "3507", "3507")
  2863. var respJSON2 map[string]interface{}
  2864. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2867. return
  2868. }
  2869. userJSONBytes2, _ := json.Marshal(respJSON2)
  2870. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2871. utils.ErrorLog("解析失败:%v", err)
  2872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2873. return
  2874. }
  2875. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2876. result1, result2 := service.AHyb3507(struct3507)
  2877. saveLog(result2, result1, "3507", "3507")
  2878. var respJSON2 map[string]interface{}
  2879. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2882. return
  2883. }
  2884. userJSONBytes2, _ := json.Marshal(respJSON2)
  2885. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2886. utils.ErrorLog("解析失败:%v", err)
  2887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2888. return
  2889. }
  2890. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2891. data := make(map[string]interface{})
  2892. data["struct_3507s"] = struct3507
  2893. client := &http.Client{}
  2894. bytesData, _ := json.Marshal(data)
  2895. var req *http.Request
  2896. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2897. resp, _ := client.Do(req)
  2898. defer resp.Body.Close()
  2899. body, ioErr := ioutil.ReadAll(resp.Body)
  2900. if ioErr != nil {
  2901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2902. }
  2903. var respJSON map[string]interface{}
  2904. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2906. }
  2907. var resSix10265 ResultSix10265 //1101结果
  2908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2909. result, _ := json.Marshal(respJSON)
  2910. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2911. utils.ErrorLog("解析失败:%v", err)
  2912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2913. return
  2914. }
  2915. res.InfRefmsgid = resSix10265.InfRefmsgid
  2916. res.ErrMsg = resSix10265.ErrMsg
  2917. res.Cainfo = resSix10265.Cainfo
  2918. res.WarnMsg = resSix10265.WarnMsg
  2919. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2920. res.Infcode = infocode
  2921. }
  2922. if res.Infcode == 0 {
  2923. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2924. item.IsSale = 0
  2925. item.SaleDate = ""
  2926. item.Bchno = ""
  2927. service.SaveDF(item)
  2928. } else {
  2929. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2930. }
  2931. }
  2932. }
  2933. c.ServeSuccessJSON(map[string]interface{}{
  2934. "msg": "删除销售数据成功",
  2935. })
  2936. }
  2937. // 获取当天起止时间戳
  2938. func GetNowTime() (int64, int64) {
  2939. t := time.Now()
  2940. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2941. timesamp := addTime.Unix()
  2942. return timesamp, timesamp + 86399
  2943. }
  2944. func (c *HisApiController) ChangeDrugfour() {
  2945. patient_id, _ := c.GetInt64("patient_id")
  2946. admin_user_id, _ := c.GetInt64("admin_user_id")
  2947. times := c.GetString("time", "")
  2948. timeLayout := "2006-01-02"
  2949. loc, _ := time.LoadLocation("Local")
  2950. var stime, etime int64
  2951. if times == "" {
  2952. stime, etime = GetNowTime()
  2953. } else {
  2954. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2955. stime = stmp.Unix()
  2956. etime = stime + 86399
  2957. }
  2958. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2959. var flows []*models.DrugFlow
  2960. for _, item := range advicelist {
  2961. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2962. flows = append(flows, flow...)
  2963. }
  2964. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2965. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2966. var err []string
  2967. for _, item := range flows {
  2968. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2969. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2970. if prescription.OrderStatus == 2 {
  2971. if item.IsSale == 0 {
  2972. var res FJ3507Result
  2973. var res3507for10188 FJ3507ResultFor10188
  2974. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2975. //进行商品销售接口
  2976. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2977. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2978. var respJSON3 map[string]interface{}
  2979. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2982. return
  2983. }
  2984. userJSONBytes3, _ := json.Marshal(respJSON3)
  2985. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2986. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2987. utils.ErrorLog("解析失败:%v", err)
  2988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2989. return
  2990. }
  2991. //if res3507for10188.Infcode
  2992. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2993. //res.Output = resSix10265.Output
  2994. res.ErrMsg = res3507for10188.ErrMsg
  2995. res.Cainfo = res3507for10188.Cainfo
  2996. res.WarnMsg = res3507for10188.WarnMsg
  2997. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2998. res.Infcode = infocode
  2999. } else {
  3000. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3001. utils.ErrorLog("解析失败:%v", err)
  3002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3003. return
  3004. }
  3005. }
  3006. if res.Infcode == 0 {
  3007. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3008. item.IsSale = 1
  3009. item.Bchno = number
  3010. item.SaleDate = time.Now().Format("2006-01-02")
  3011. service.SaveDF(item)
  3012. } else {
  3013. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3014. }
  3015. }
  3016. } else { //还没结,提示用户去结算,并药品追溯上传
  3017. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3018. }
  3019. }
  3020. }
  3021. str := strings.Join(err, " ")
  3022. saveLog(str, str, "3505", "3505自动上传日志")
  3023. c.ServeSuccessJSON(map[string]interface{}{
  3024. "status": "1",
  3025. "msg": err,
  3026. })
  3027. }
  3028. func (c *HisApiController) ChangeDrugFive() {
  3029. id, _ := c.GetInt64("id")
  3030. admin_user_id, _ := c.GetInt64("admin_user_id")
  3031. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  3032. var flows []*models.DrugFlow
  3033. for _, item := range advicelist {
  3034. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3035. flows = append(flows, flow...)
  3036. }
  3037. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3038. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3039. var err []string
  3040. for _, item := range flows {
  3041. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3042. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3043. if prescription.OrderStatus == 2 {
  3044. if item.IsSale == 0 {
  3045. var res FJ3507Result
  3046. var res3507for10188 FJ3507ResultFor10188
  3047. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3048. //进行商品销售接口
  3049. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3050. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3051. var respJSON3 map[string]interface{}
  3052. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3055. return
  3056. }
  3057. userJSONBytes3, _ := json.Marshal(respJSON3)
  3058. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3059. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3060. utils.ErrorLog("解析失败:%v", err)
  3061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3062. return
  3063. }
  3064. //if res3507for10188.Infcode
  3065. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3066. //res.Output = resSix10265.Output
  3067. res.ErrMsg = res3507for10188.ErrMsg
  3068. res.Cainfo = res3507for10188.Cainfo
  3069. res.WarnMsg = res3507for10188.WarnMsg
  3070. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3071. res.Infcode = infocode
  3072. } else {
  3073. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3074. utils.ErrorLog("解析失败:%v", err)
  3075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3076. return
  3077. }
  3078. }
  3079. if res.Infcode == 0 {
  3080. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3081. item.IsSale = 1
  3082. item.Bchno = number
  3083. item.SaleDate = time.Now().Format("2006-01-02")
  3084. service.SaveDF(item)
  3085. } else {
  3086. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3087. }
  3088. }
  3089. } else { //还没结,提示用户去结算,并药品追溯上传
  3090. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3091. }
  3092. }
  3093. }
  3094. str := strings.Join(err, " ")
  3095. saveLog(str, str, "3505", "3505自动上传日志")
  3096. c.ServeSuccessJSON(map[string]interface{}{
  3097. "status": "1",
  3098. "msg": err,
  3099. })
  3100. }
  3101. //func (c *HisApiController) ChangeDrugfour() {
  3102. // patient_id, _ := c.GetInt64("patient_id")
  3103. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3104. // //id_arr := strings.Split(ids, ",")
  3105. // times := c.GetString("time", "")
  3106. // timeLayout := "2006-01-02"
  3107. // loc, _ := time.LoadLocation("Local")
  3108. // var stime, etime int64
  3109. // if times == "" {
  3110. // stime, etime = GetNowTime()
  3111. // } else {
  3112. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3113. // stime = stmp.Unix()
  3114. // etime = stime + 86399
  3115. // }
  3116. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3117. // var flows []*models.DrugFlow
  3118. // for _, item := range advicelist {
  3119. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3120. // flows = append(flows, flow...)
  3121. // }
  3122. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3123. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3124. // var err []string
  3125. //
  3126. // for _, item := range flows {
  3127. // var res3 ResultSix
  3128. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3129. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3130. // if prescription.OrderStatus == 2 {
  3131. // //已经结算
  3132. // //判断是否已经销售
  3133. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3134. // //是否已经变更 1是 0否
  3135. // if item.IsChange == 0 { //没变更,进行变更操作
  3136. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3137. //
  3138. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3139. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3140. // var respJSON3 map[string]interface{}
  3141. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3142. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3143. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3144. // return
  3145. // }
  3146. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3147. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3148. // utils.ErrorLog("解析失败:%v", err)
  3149. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3150. // return
  3151. // }
  3152. // if res3.Infcode == 0 {
  3153. // item.IsChange = 1
  3154. // item.BgBchno = bg_number
  3155. // service.SaveDF2(item)
  3156. // } else {
  3157. //
  3158. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3159. // }
  3160. // }
  3161. // } else { //没销售,
  3162. // var res FJ3507Result
  3163. // var res3507for10188 FJ3507ResultFor10188
  3164. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3165. //
  3166. // //进行商品销售接口
  3167. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3168. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3169. // var respJSON3 map[string]interface{}
  3170. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3171. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3172. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3173. // return
  3174. // }
  3175. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3176. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3177. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3178. // utils.ErrorLog("解析失败:%v", err)
  3179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3180. // return
  3181. // }
  3182. // //if res3507for10188.Infcode
  3183. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3184. // //res.Output = resSix10265.Output
  3185. // res.ErrMsg = res3507for10188.ErrMsg
  3186. // res.Cainfo = res3507for10188.Cainfo
  3187. // res.WarnMsg = res3507for10188.WarnMsg
  3188. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3189. // res.Infcode = infocode
  3190. // } else {
  3191. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3192. // utils.ErrorLog("解析失败:%v", err)
  3193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3194. // return
  3195. // }
  3196. //
  3197. // }
  3198. // if res.Infcode == 0 {
  3199. // item.IsSale = 1
  3200. // item.Bchno = number
  3201. // item.SaleDate = time.Now().Format("2006-01-02")
  3202. //
  3203. // err5 := service.SaveDF(item)
  3204. // if err5 == nil {
  3205. // if item.IsChange == 0 { //没变更,进行变更操作
  3206. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3207. //
  3208. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3209. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3210. //
  3211. // var respJSON3 map[string]interface{}
  3212. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3213. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3214. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3215. // return
  3216. // }
  3217. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3218. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3219. // utils.ErrorLog("解析失败:%v", err)
  3220. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3221. // return
  3222. // }
  3223. // //if res3507for10188.Infcode
  3224. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3225. // //res.Output = resSix10265.Output
  3226. // res3.ErrMsg = res3507for10188.ErrMsg
  3227. // res3.Cainfo = res3507for10188.Cainfo
  3228. // res3.WarnMsg = res3507for10188.WarnMsg
  3229. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3230. // res3.Infcode = infocode
  3231. // } else {
  3232. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3233. // utils.ErrorLog("解析失败:%v", err)
  3234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3235. // return
  3236. // }
  3237. // }
  3238. // if res3.Infcode == 0 {
  3239. // item.IsChange = 1
  3240. // item.BgBchno = bg_number
  3241. // service.SaveDF2(item)
  3242. // } else {
  3243. //
  3244. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3245. // }
  3246. // }
  3247. // }
  3248. // } else {
  3249. //
  3250. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3251. // }
  3252. // }
  3253. //
  3254. // } else { //还没结,提示用户去结算,并药品追溯上传
  3255. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3256. // }
  3257. // }
  3258. // }
  3259. // if len(err) == 0 {
  3260. // c.ServeSuccessJSON(map[string]interface{}{
  3261. // "msg": "销售变更成功",
  3262. // })
  3263. // } else {
  3264. // c.ServeSuccessJSON(map[string]interface{}{
  3265. // "failed_code": -10,
  3266. // "msg": err,
  3267. // })
  3268. // }
  3269. //}
  3270. func (c *HisApiController) ChangeDrug() {
  3271. ids := c.GetString("ids")
  3272. id_arr := strings.Split(ids, ",")
  3273. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3274. admin_user_id, _ := c.GetInt64("admin_user_id")
  3275. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3276. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3277. var err []string
  3278. for _, item := range flows {
  3279. var res3 ResultSix
  3280. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3281. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3282. if prescription.OrderStatus == 2 {
  3283. //已经结算
  3284. //判断是否已经销售
  3285. if item.IsSale == 1 { //是否已经销售,1是 0否
  3286. //是否已经变更 1是 0否
  3287. if item.IsChange == 0 { //没变更,进行变更操作
  3288. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3289. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3290. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3291. var respJSON3 map[string]interface{}
  3292. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3295. return
  3296. }
  3297. userJSONBytes3, _ := json.Marshal(respJSON3)
  3298. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3299. utils.ErrorLog("解析失败:%v", err)
  3300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3301. return
  3302. }
  3303. if res3.Infcode == 0 {
  3304. item.IsChange = 1
  3305. item.BgBchno = bg_number
  3306. service.SaveDF2(item)
  3307. } else {
  3308. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3309. }
  3310. }
  3311. } else { //没销售,
  3312. var res FJ3507Result
  3313. var res3507for10188 FJ3507ResultFor10188
  3314. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3315. //进行商品销售接口
  3316. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3317. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3318. var respJSON3 map[string]interface{}
  3319. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3322. return
  3323. }
  3324. userJSONBytes3, _ := json.Marshal(respJSON3)
  3325. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3326. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3327. utils.ErrorLog("解析失败:%v", err)
  3328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3329. return
  3330. }
  3331. //if res3507for10188.Infcode
  3332. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3333. //res.Output = resSix10265.Output
  3334. res.ErrMsg = res3507for10188.ErrMsg
  3335. res.Cainfo = res3507for10188.Cainfo
  3336. res.WarnMsg = res3507for10188.WarnMsg
  3337. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3338. res.Infcode = infocode
  3339. } else {
  3340. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3341. utils.ErrorLog("解析失败:%v", err)
  3342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3343. return
  3344. }
  3345. }
  3346. if res.Infcode == 0 {
  3347. item.IsSale = 1
  3348. item.Bchno = number
  3349. item.SaleDate = time.Now().Format("2006-01-02")
  3350. err5 := service.SaveDF(item)
  3351. if err5 == nil {
  3352. if item.IsChange == 0 { //没变更,进行变更操作
  3353. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3354. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3355. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3356. var respJSON3 map[string]interface{}
  3357. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3360. return
  3361. }
  3362. userJSONBytes3, _ := json.Marshal(respJSON3)
  3363. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3364. utils.ErrorLog("解析失败:%v", err)
  3365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3366. return
  3367. }
  3368. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3369. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3370. utils.ErrorLog("解析失败:%v", err)
  3371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3372. return
  3373. }
  3374. //if res3507for10188.Infcode
  3375. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3376. //res.Output = resSix10265.Output
  3377. res3.ErrMsg = res3507for10188.ErrMsg
  3378. res3.Cainfo = res3507for10188.Cainfo
  3379. res3.WarnMsg = res3507for10188.WarnMsg
  3380. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3381. res3.Infcode = infocode
  3382. } else {
  3383. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3384. utils.ErrorLog("解析失败:%v", err)
  3385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3386. return
  3387. }
  3388. }
  3389. if res3.Infcode == 0 {
  3390. item.IsChange = 1
  3391. item.BgBchno = bg_number
  3392. service.SaveDF2(item)
  3393. } else {
  3394. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3395. }
  3396. }
  3397. }
  3398. } else {
  3399. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3400. }
  3401. }
  3402. } else { //还没结算
  3403. var res3507for10188 FJ3507ResultFor10188
  3404. if item.IsChange == 0 { //没变更,进行变更操作
  3405. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3406. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3407. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3408. var respJSON3 map[string]interface{}
  3409. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3412. return
  3413. }
  3414. userJSONBytes3, _ := json.Marshal(respJSON3)
  3415. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3416. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3417. utils.ErrorLog("解析失败:%v", err)
  3418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3419. return
  3420. }
  3421. //if res3507for10188.Infcode
  3422. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3423. //res.Output = resSix10265.Output
  3424. res3.ErrMsg = res3507for10188.ErrMsg
  3425. res3.Cainfo = res3507for10188.Cainfo
  3426. res3.WarnMsg = res3507for10188.WarnMsg
  3427. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3428. res3.Infcode = infocode
  3429. } else {
  3430. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3431. utils.ErrorLog("解析失败:%v", err)
  3432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3433. return
  3434. }
  3435. }
  3436. if res3.Infcode == 0 {
  3437. item.IsChange = 1
  3438. item.BgBchno = bg_number
  3439. service.SaveDF2(item)
  3440. } else {
  3441. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3442. }
  3443. }
  3444. }
  3445. } else if item.ConsumableType == 7 {
  3446. var res3507for10188 FJ3507ResultFor10188
  3447. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3448. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3449. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3450. //判断是否已经销售
  3451. if item.IsSale == 2 { //是否已经销售,1是 0否
  3452. //是否已经变更 1是 0否
  3453. if item.IsChange == 0 { //没变更,进行变更操作
  3454. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3455. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3456. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3457. var respJSON3 map[string]interface{}
  3458. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3461. return
  3462. }
  3463. userJSONBytes3, _ := json.Marshal(respJSON3)
  3464. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3465. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3466. utils.ErrorLog("解析失败:%v", err)
  3467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3468. return
  3469. }
  3470. //if res3507for10188.Infcode
  3471. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3472. //res.Output = resSix10265.Output
  3473. res3.ErrMsg = res3507for10188.ErrMsg
  3474. res3.Cainfo = res3507for10188.Cainfo
  3475. res3.WarnMsg = res3507for10188.WarnMsg
  3476. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3477. res3.Infcode = infocode
  3478. } else {
  3479. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3480. utils.ErrorLog("解析失败:%v", err)
  3481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3482. return
  3483. }
  3484. }
  3485. if res3.Infcode == 0 {
  3486. item.IsChange = 1
  3487. item.BgBchno = bg_number
  3488. service.SaveDF2(item)
  3489. } else {
  3490. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3491. }
  3492. }
  3493. } else { //没销售,
  3494. //进行商品销售退货接口
  3495. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3496. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3497. saveLog(result111, result222, "3506", "销售退货")
  3498. var res7 FJ3507Result
  3499. //进行商品销售接口
  3500. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3501. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3502. var respJSON3 map[string]interface{}
  3503. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3506. return
  3507. }
  3508. userJSONBytes3, _ := json.Marshal(respJSON3)
  3509. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3510. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3511. utils.ErrorLog("解析失败:%v", err)
  3512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3513. return
  3514. }
  3515. //if res3507for10188.Infcode
  3516. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3517. //res.Output = resSix10265.Output
  3518. res7.ErrMsg = res3507for10188.ErrMsg
  3519. res7.Cainfo = res3507for10188.Cainfo
  3520. res7.WarnMsg = res3507for10188.WarnMsg
  3521. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3522. res7.Infcode = infocode
  3523. } else {
  3524. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3525. utils.ErrorLog("解析失败:%v", err)
  3526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3527. return
  3528. }
  3529. }
  3530. if res7.Infcode == 0 {
  3531. item.IsSale = 2
  3532. item.SaleDate = item.SaleDate
  3533. item.Bchno = number
  3534. service.SaveDF(item)
  3535. if item.IsChange == 0 { //没变更,进行变更操作
  3536. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3537. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3538. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3539. var respJSON3 map[string]interface{}
  3540. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3543. return
  3544. }
  3545. userJSONBytes3, _ := json.Marshal(respJSON3)
  3546. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3547. // utils.ErrorLog("解析失败:%v", err)
  3548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3549. // return
  3550. //}
  3551. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3552. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3553. utils.ErrorLog("解析失败:%v", err)
  3554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3555. return
  3556. }
  3557. //if res3507for10188.Infcode
  3558. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3559. //res.Output = resSix10265.Output
  3560. res3.ErrMsg = res3507for10188.ErrMsg
  3561. res3.Cainfo = res3507for10188.Cainfo
  3562. res3.WarnMsg = res3507for10188.WarnMsg
  3563. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3564. res3.Infcode = infocode
  3565. } else {
  3566. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3567. utils.ErrorLog("解析失败:%v", err)
  3568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3569. return
  3570. }
  3571. }
  3572. if res3.Infcode == 0 {
  3573. item.IsChange = 1
  3574. item.BgBchno = bg_number
  3575. service.SaveDF2(item)
  3576. } else {
  3577. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3578. }
  3579. }
  3580. } else {
  3581. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3582. }
  3583. }
  3584. } else { //还没结算
  3585. if item.IsChange == 0 { //没变更,进行变更操作
  3586. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3587. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3588. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3589. var respJSON3 map[string]interface{}
  3590. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3593. return
  3594. }
  3595. userJSONBytes3, _ := json.Marshal(respJSON3)
  3596. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3597. // utils.ErrorLog("解析失败:%v", err)
  3598. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3599. // return
  3600. //}
  3601. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3602. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3603. utils.ErrorLog("解析失败:%v", err)
  3604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3605. return
  3606. }
  3607. //if res3507for10188.Infcode
  3608. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3609. //res.Output = resSix10265.Output
  3610. res3.ErrMsg = res3507for10188.ErrMsg
  3611. res3.Cainfo = res3507for10188.Cainfo
  3612. res3.WarnMsg = res3507for10188.WarnMsg
  3613. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3614. res3.Infcode = infocode
  3615. } else {
  3616. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3617. utils.ErrorLog("解析失败:%v", err)
  3618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3619. return
  3620. }
  3621. }
  3622. if res3.Infcode == 0 {
  3623. item.IsChange = 1
  3624. item.BgBchno = bg_number
  3625. service.SaveDF2(item)
  3626. } else {
  3627. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3628. }
  3629. }
  3630. }
  3631. }
  3632. }
  3633. if len(err) == 0 {
  3634. c.ServeSuccessJSON(map[string]interface{}{
  3635. "msg": "销售变更成功",
  3636. })
  3637. } else {
  3638. c.ServeSuccessJSON(map[string]interface{}{
  3639. "failed_code": -10,
  3640. "msg": err,
  3641. })
  3642. }
  3643. }
  3644. func (c *HisApiController) ChangeDrugtwo() {
  3645. //ids := c.GetString("ids")
  3646. //id_arr := strings.Split(ids, ",")
  3647. flows, _ := service.GetNewDrugFlowInfothree123()
  3648. admin_user_id, _ := c.GetInt64("admin_user_id")
  3649. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3650. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3651. var err []string
  3652. for _, item := range flows {
  3653. var res3 ResultSix
  3654. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3655. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3656. if prescription.OrderStatus == 2 {
  3657. //已经结算
  3658. //判断是否已经销售
  3659. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3660. // //是否已经变更 1是 0否
  3661. // if item.IsChange == 0 { //没变更,进行变更操作
  3662. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3663. //
  3664. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3665. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3666. // var respJSON3 map[string]interface{}
  3667. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3668. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3669. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3670. // return
  3671. // }
  3672. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3673. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3674. // utils.ErrorLog("解析失败:%v", err)
  3675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3676. // return
  3677. // }
  3678. // if res3.Infcode == 0 {
  3679. // item.IsChange = 1
  3680. // item.BgBchno = bg_number
  3681. // service.SaveDF2(item)
  3682. // } else {
  3683. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3684. // }
  3685. // }
  3686. //}
  3687. //else
  3688. { //没销售,
  3689. var res FJ3507Result
  3690. var res3507for10188 FJ3507ResultFor10188
  3691. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3692. //进行商品销售接口
  3693. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3694. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3695. var respJSON3 map[string]interface{}
  3696. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3699. return
  3700. }
  3701. userJSONBytes3, _ := json.Marshal(respJSON3)
  3702. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3703. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3704. utils.ErrorLog("解析失败:%v", err)
  3705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3706. return
  3707. }
  3708. //if res3507for10188.Infcode
  3709. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3710. //res.Output = resSix10265.Output
  3711. res.ErrMsg = res3507for10188.ErrMsg
  3712. res.Cainfo = res3507for10188.Cainfo
  3713. res.WarnMsg = res3507for10188.WarnMsg
  3714. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3715. res.Infcode = infocode
  3716. } else {
  3717. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3718. utils.ErrorLog("解析失败:%v", err)
  3719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3720. return
  3721. }
  3722. }
  3723. if res.Infcode == 0 {
  3724. item.IsSale = 1
  3725. item.Bchno = number
  3726. item.SaleDate = time.Now().Format("2006-01-02")
  3727. service.SaveDF(item)
  3728. //if err5 == nil {
  3729. // if item.IsChange == 0 { //没变更,进行变更操作
  3730. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3731. //
  3732. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3733. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3734. //
  3735. // var respJSON3 map[string]interface{}
  3736. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3737. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3738. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3739. // return
  3740. // }
  3741. //
  3742. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3743. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3744. // utils.ErrorLog("解析失败:%v", err)
  3745. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3746. // return
  3747. // }
  3748. // //if res3507for10188.Infcode
  3749. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3750. // //res.Output = resSix10265.Output
  3751. // res3.ErrMsg = res3507for10188.ErrMsg
  3752. // res3.Cainfo = res3507for10188.Cainfo
  3753. // res3.WarnMsg = res3507for10188.WarnMsg
  3754. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3755. // res3.Infcode = infocode
  3756. // } else {
  3757. //
  3758. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3759. // utils.ErrorLog("解析失败:%v", err)
  3760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3761. // return
  3762. // }
  3763. //
  3764. // }
  3765. //
  3766. // if res3.Infcode == 0 {
  3767. // item.IsChange = 1
  3768. // item.BgBchno = bg_number
  3769. // service.SaveDF2(item)
  3770. // } else {
  3771. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3772. // }
  3773. // }
  3774. //}
  3775. } else {
  3776. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3777. }
  3778. }
  3779. } else { //还没结算
  3780. var res3507for10188 FJ3507ResultFor10188
  3781. if item.IsChange == 0 { //没变更,进行变更操作
  3782. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3783. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3784. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3785. var respJSON3 map[string]interface{}
  3786. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3789. return
  3790. }
  3791. userJSONBytes3, _ := json.Marshal(respJSON3)
  3792. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3793. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3794. utils.ErrorLog("解析失败:%v", err)
  3795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3796. return
  3797. }
  3798. //if res3507for10188.Infcode
  3799. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3800. //res.Output = resSix10265.Output
  3801. res3.ErrMsg = res3507for10188.ErrMsg
  3802. res3.Cainfo = res3507for10188.Cainfo
  3803. res3.WarnMsg = res3507for10188.WarnMsg
  3804. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3805. res3.Infcode = infocode
  3806. } else {
  3807. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3808. utils.ErrorLog("解析失败:%v", err)
  3809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3810. return
  3811. }
  3812. }
  3813. if res3.Infcode == 0 {
  3814. item.IsChange = 1
  3815. item.BgBchno = bg_number
  3816. service.SaveDF2(item)
  3817. } else {
  3818. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3819. }
  3820. }
  3821. }
  3822. }
  3823. //if item.ConsumableType == 7 {
  3824. // var res3507for10188 FJ3507ResultFor10188
  3825. //
  3826. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3827. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3828. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3829. // //判断是否已经销售
  3830. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3831. // //是否已经变更 1是 0否
  3832. // if item.IsChange == 0 { //没变更,进行变更操作
  3833. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3834. //
  3835. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3836. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3837. //
  3838. // var respJSON3 map[string]interface{}
  3839. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3840. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3841. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3842. // return
  3843. // }
  3844. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3845. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3846. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3847. // utils.ErrorLog("解析失败:%v", err)
  3848. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3849. // return
  3850. // }
  3851. // //if res3507for10188.Infcode
  3852. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3853. // //res.Output = resSix10265.Output
  3854. // res3.ErrMsg = res3507for10188.ErrMsg
  3855. // res3.Cainfo = res3507for10188.Cainfo
  3856. // res3.WarnMsg = res3507for10188.WarnMsg
  3857. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3858. // res3.Infcode = infocode
  3859. // } else {
  3860. //
  3861. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3862. // utils.ErrorLog("解析失败:%v", err)
  3863. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3864. // return
  3865. // }
  3866. //
  3867. // }
  3868. // if res3.Infcode == 0 {
  3869. // item.IsChange = 1
  3870. // item.BgBchno = bg_number
  3871. // service.SaveDF2(item)
  3872. // } else {
  3873. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3874. // }
  3875. // }
  3876. // } else { //没销售,
  3877. // //进行商品销售退货接口
  3878. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3879. //
  3880. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3881. // saveLog(result111, result222, "3506", "销售退货")
  3882. // var res7 FJ3507Result
  3883. //
  3884. // //进行商品销售接口
  3885. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3886. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3887. // var respJSON3 map[string]interface{}
  3888. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3889. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3890. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3891. // return
  3892. // }
  3893. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3894. //
  3895. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3896. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3897. // utils.ErrorLog("解析失败:%v", err)
  3898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3899. // return
  3900. // }
  3901. // //if res3507for10188.Infcode
  3902. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3903. // //res.Output = resSix10265.Output
  3904. // res7.ErrMsg = res3507for10188.ErrMsg
  3905. // res7.Cainfo = res3507for10188.Cainfo
  3906. // res7.WarnMsg = res3507for10188.WarnMsg
  3907. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3908. // res7.Infcode = infocode
  3909. // } else {
  3910. //
  3911. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3912. // utils.ErrorLog("解析失败:%v", err)
  3913. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3914. // return
  3915. // }
  3916. //
  3917. // }
  3918. // if res7.Infcode == 0 {
  3919. // item.IsSale = 2
  3920. // item.SaleDate = item.SaleDate
  3921. // item.Bchno = number
  3922. // service.SaveDF(item)
  3923. // if item.IsChange == 0 { //没变更,进行变更操作
  3924. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3925. //
  3926. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3927. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3928. //
  3929. // var respJSON3 map[string]interface{}
  3930. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3931. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3933. // return
  3934. // }
  3935. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3936. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3937. // // utils.ErrorLog("解析失败:%v", err)
  3938. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3939. // // return
  3940. // //}
  3941. //
  3942. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3943. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3944. // utils.ErrorLog("解析失败:%v", err)
  3945. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3946. // return
  3947. // }
  3948. // //if res3507for10188.Infcode
  3949. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3950. // //res.Output = resSix10265.Output
  3951. // res3.ErrMsg = res3507for10188.ErrMsg
  3952. // res3.Cainfo = res3507for10188.Cainfo
  3953. // res3.WarnMsg = res3507for10188.WarnMsg
  3954. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3955. // res3.Infcode = infocode
  3956. // } else {
  3957. //
  3958. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3959. // utils.ErrorLog("解析失败:%v", err)
  3960. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3961. // return
  3962. // }
  3963. //
  3964. // }
  3965. // if res3.Infcode == 0 {
  3966. // item.IsChange = 1
  3967. // item.BgBchno = bg_number
  3968. // service.SaveDF2(item)
  3969. // } else {
  3970. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3971. // }
  3972. // }
  3973. // } else {
  3974. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3975. // }
  3976. // }
  3977. // } else { //还没结算
  3978. // if item.IsChange == 0 { //没变更,进行变更操作
  3979. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3980. //
  3981. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3982. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3983. //
  3984. // var respJSON3 map[string]interface{}
  3985. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3986. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3987. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3988. // return
  3989. // }
  3990. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3991. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3992. // // utils.ErrorLog("解析失败:%v", err)
  3993. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3994. // // return
  3995. // //}
  3996. //
  3997. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3998. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3999. // utils.ErrorLog("解析失败:%v", err)
  4000. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4001. // return
  4002. // }
  4003. // //if res3507for10188.Infcode
  4004. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4005. // //res.Output = resSix10265.Output
  4006. // res3.ErrMsg = res3507for10188.ErrMsg
  4007. // res3.Cainfo = res3507for10188.Cainfo
  4008. // res3.WarnMsg = res3507for10188.WarnMsg
  4009. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4010. // res3.Infcode = infocode
  4011. // } else {
  4012. //
  4013. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4014. // utils.ErrorLog("解析失败:%v", err)
  4015. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4016. // return
  4017. // }
  4018. //
  4019. // }
  4020. // if res3.Infcode == 0 {
  4021. // item.IsChange = 1
  4022. // item.BgBchno = bg_number
  4023. // service.SaveDF2(item)
  4024. // } else {
  4025. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4026. // }
  4027. // }
  4028. // }
  4029. //}
  4030. }
  4031. if len(err) == 0 {
  4032. c.ServeSuccessJSON(map[string]interface{}{
  4033. "msg": "销售变更成功",
  4034. })
  4035. } else {
  4036. c.ServeSuccessJSON(map[string]interface{}{
  4037. "failed_code": -10,
  4038. "msg": err,
  4039. })
  4040. }
  4041. }
  4042. func (c *HisApiController) ChangeDrugthree() {
  4043. //ids := c.GetString("ids")
  4044. //id_arr := strings.Split(ids, ",")
  4045. flows, _ := service.GetNewDrugFlowInfothree()
  4046. admin_user_id, _ := c.GetInt64("admin_user_id")
  4047. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4048. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4049. var err []string
  4050. for _, item := range flows {
  4051. var res3 ResultSix
  4052. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4053. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4054. if prescription.OrderStatus == 2 {
  4055. //已经结算
  4056. //判断是否已经销售
  4057. if item.IsSale == 1 { //是否已经销售,1是 0否
  4058. //是否已经变更 1是 0否
  4059. if item.IsChange == 0 { //没变更,进行变更操作
  4060. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4061. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4062. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4063. var respJSON3 map[string]interface{}
  4064. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4067. return
  4068. }
  4069. userJSONBytes3, _ := json.Marshal(respJSON3)
  4070. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4071. utils.ErrorLog("解析失败:%v", err)
  4072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4073. return
  4074. }
  4075. if res3.Infcode == 0 {
  4076. item.IsChange = 1
  4077. item.BgBchno = bg_number
  4078. service.SaveDF2(item)
  4079. } else {
  4080. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4081. }
  4082. }
  4083. } else { //没销售,
  4084. var res FJ3507Result
  4085. var res3507for10188 FJ3507ResultFor10188
  4086. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4087. //进行商品销售接口
  4088. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4089. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4090. var respJSON3 map[string]interface{}
  4091. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4094. return
  4095. }
  4096. userJSONBytes3, _ := json.Marshal(respJSON3)
  4097. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4098. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4099. utils.ErrorLog("解析失败:%v", err)
  4100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4101. return
  4102. }
  4103. //if res3507for10188.Infcode
  4104. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4105. //res.Output = resSix10265.Output
  4106. res.ErrMsg = res3507for10188.ErrMsg
  4107. res.Cainfo = res3507for10188.Cainfo
  4108. res.WarnMsg = res3507for10188.WarnMsg
  4109. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4110. res.Infcode = infocode
  4111. } else {
  4112. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4113. utils.ErrorLog("解析失败:%v", err)
  4114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4115. return
  4116. }
  4117. }
  4118. if res.Infcode == 0 {
  4119. item.IsSale = 1
  4120. item.Bchno = number
  4121. item.SaleDate = time.Now().Format("2006-01-02")
  4122. err5 := service.SaveDF(item)
  4123. if err5 == nil {
  4124. if item.IsChange == 0 { //没变更,进行变更操作
  4125. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4126. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4127. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4128. var respJSON3 map[string]interface{}
  4129. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4132. return
  4133. }
  4134. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4135. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4136. utils.ErrorLog("解析失败:%v", err)
  4137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4138. return
  4139. }
  4140. //if res3507for10188.Infcode
  4141. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4142. //res.Output = resSix10265.Output
  4143. res3.ErrMsg = res3507for10188.ErrMsg
  4144. res3.Cainfo = res3507for10188.Cainfo
  4145. res3.WarnMsg = res3507for10188.WarnMsg
  4146. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4147. res3.Infcode = infocode
  4148. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4149. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4150. utils.ErrorLog("解析失败:%v", err)
  4151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4152. return
  4153. }
  4154. //if res3507for10188.Infcode
  4155. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4156. //res.Output = resSix10265.Output
  4157. res3.ErrMsg = res3507for10188.ErrMsg
  4158. res3.Cainfo = res3507for10188.Cainfo
  4159. res3.WarnMsg = res3507for10188.WarnMsg
  4160. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4161. res3.Infcode = infocode
  4162. } else {
  4163. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4164. utils.ErrorLog("解析失败:%v", err)
  4165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4166. return
  4167. }
  4168. }
  4169. if res3.Infcode == 0 {
  4170. item.IsChange = 1
  4171. item.BgBchno = bg_number
  4172. service.SaveDF2(item)
  4173. } else {
  4174. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4175. }
  4176. }
  4177. }
  4178. } else {
  4179. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4180. }
  4181. }
  4182. } else { //还没结算
  4183. var res3507for10188 FJ3507ResultFor10188
  4184. if item.IsChange == 0 { //没变更,进行变更操作
  4185. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4186. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4187. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4188. var respJSON3 map[string]interface{}
  4189. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4192. return
  4193. }
  4194. userJSONBytes3, _ := json.Marshal(respJSON3)
  4195. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4196. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4197. utils.ErrorLog("解析失败:%v", err)
  4198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4199. return
  4200. }
  4201. //if res3507for10188.Infcode
  4202. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4203. //res.Output = resSix10265.Output
  4204. res3.ErrMsg = res3507for10188.ErrMsg
  4205. res3.Cainfo = res3507for10188.Cainfo
  4206. res3.WarnMsg = res3507for10188.WarnMsg
  4207. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4208. res3.Infcode = infocode
  4209. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4210. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4211. utils.ErrorLog("解析失败:%v", err)
  4212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4213. return
  4214. }
  4215. //if res3507for10188.Infcode
  4216. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4217. //res.Output = resSix10265.Output
  4218. res3.ErrMsg = res3507for10188.ErrMsg
  4219. res3.Cainfo = res3507for10188.Cainfo
  4220. res3.WarnMsg = res3507for10188.WarnMsg
  4221. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4222. res3.Infcode = infocode
  4223. } else {
  4224. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4225. utils.ErrorLog("解析失败:%v", err)
  4226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4227. return
  4228. }
  4229. }
  4230. if res3.Infcode == 0 {
  4231. item.IsChange = 1
  4232. item.BgBchno = bg_number
  4233. service.SaveDF2(item)
  4234. } else {
  4235. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4236. }
  4237. }
  4238. }
  4239. } else if item.ConsumableType == 7 {
  4240. var res3507for10188 FJ3507ResultFor10188
  4241. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4242. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4243. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4244. //判断是否已经销售
  4245. if item.IsSale == 2 { //是否已经销售,1是 0否
  4246. //是否已经变更 1是 0否
  4247. if item.IsChange == 0 { //没变更,进行变更操作
  4248. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4249. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4250. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4251. var respJSON3 map[string]interface{}
  4252. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4255. return
  4256. }
  4257. userJSONBytes3, _ := json.Marshal(respJSON3)
  4258. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4259. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4260. utils.ErrorLog("解析失败:%v", err)
  4261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4262. return
  4263. }
  4264. //if res3507for10188.Infcode
  4265. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4266. //res.Output = resSix10265.Output
  4267. res3.ErrMsg = res3507for10188.ErrMsg
  4268. res3.Cainfo = res3507for10188.Cainfo
  4269. res3.WarnMsg = res3507for10188.WarnMsg
  4270. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4271. res3.Infcode = infocode
  4272. } else {
  4273. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4274. utils.ErrorLog("解析失败:%v", err)
  4275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4276. return
  4277. }
  4278. }
  4279. if res3.Infcode == 0 {
  4280. item.IsChange = 1
  4281. item.BgBchno = bg_number
  4282. service.SaveDF2(item)
  4283. } else {
  4284. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4285. }
  4286. }
  4287. } else { //没销售,
  4288. //进行商品销售退货接口
  4289. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4290. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4291. saveLog(result111, result222, "3506", "销售退货")
  4292. var res7 FJ3507Result
  4293. //进行商品销售接口
  4294. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4295. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4296. var respJSON3 map[string]interface{}
  4297. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4300. return
  4301. }
  4302. userJSONBytes3, _ := json.Marshal(respJSON3)
  4303. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4304. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4305. utils.ErrorLog("解析失败:%v", err)
  4306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4307. return
  4308. }
  4309. //if res3507for10188.Infcode
  4310. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4311. //res.Output = resSix10265.Output
  4312. res7.ErrMsg = res3507for10188.ErrMsg
  4313. res7.Cainfo = res3507for10188.Cainfo
  4314. res7.WarnMsg = res3507for10188.WarnMsg
  4315. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4316. res7.Infcode = infocode
  4317. } else {
  4318. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4319. utils.ErrorLog("解析失败:%v", err)
  4320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4321. return
  4322. }
  4323. }
  4324. if res7.Infcode == 0 {
  4325. item.IsSale = 2
  4326. item.SaleDate = item.SaleDate
  4327. item.Bchno = number
  4328. service.SaveDF(item)
  4329. if item.IsChange == 0 { //没变更,进行变更操作
  4330. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4331. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4332. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4333. var respJSON3 map[string]interface{}
  4334. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4337. return
  4338. }
  4339. userJSONBytes3, _ := json.Marshal(respJSON3)
  4340. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4341. // utils.ErrorLog("解析失败:%v", err)
  4342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4343. // return
  4344. //}
  4345. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4346. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4347. utils.ErrorLog("解析失败:%v", err)
  4348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4349. return
  4350. }
  4351. //if res3507for10188.Infcode
  4352. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4353. //res.Output = resSix10265.Output
  4354. res3.ErrMsg = res3507for10188.ErrMsg
  4355. res3.Cainfo = res3507for10188.Cainfo
  4356. res3.WarnMsg = res3507for10188.WarnMsg
  4357. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4358. res3.Infcode = infocode
  4359. } else {
  4360. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4361. utils.ErrorLog("解析失败:%v", err)
  4362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4363. return
  4364. }
  4365. }
  4366. if res3.Infcode == 0 {
  4367. item.IsChange = 1
  4368. item.BgBchno = bg_number
  4369. service.SaveDF2(item)
  4370. } else {
  4371. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4372. }
  4373. }
  4374. } else {
  4375. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4376. }
  4377. }
  4378. } else { //还没结算
  4379. if item.IsChange == 0 { //没变更,进行变更操作
  4380. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4381. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4382. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4383. var respJSON3 map[string]interface{}
  4384. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4387. return
  4388. }
  4389. userJSONBytes3, _ := json.Marshal(respJSON3)
  4390. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4391. // utils.ErrorLog("解析失败:%v", err)
  4392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4393. // return
  4394. //}
  4395. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4396. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4397. utils.ErrorLog("解析失败:%v", err)
  4398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4399. return
  4400. }
  4401. //if res3507for10188.Infcode
  4402. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4403. //res.Output = resSix10265.Output
  4404. res3.ErrMsg = res3507for10188.ErrMsg
  4405. res3.Cainfo = res3507for10188.Cainfo
  4406. res3.WarnMsg = res3507for10188.WarnMsg
  4407. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4408. res3.Infcode = infocode
  4409. } else {
  4410. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4411. utils.ErrorLog("解析失败:%v", err)
  4412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4413. return
  4414. }
  4415. }
  4416. if res3.Infcode == 0 {
  4417. item.IsChange = 1
  4418. item.BgBchno = bg_number
  4419. service.SaveDF2(item)
  4420. } else {
  4421. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4422. }
  4423. }
  4424. }
  4425. }
  4426. }
  4427. if len(err) == 0 {
  4428. c.ServeSuccessJSON(map[string]interface{}{
  4429. "msg": "销售变更成功",
  4430. })
  4431. } else {
  4432. c.ServeSuccessJSON(map[string]interface{}{
  4433. "failed_code": -10,
  4434. "msg": err,
  4435. })
  4436. }
  4437. }
  4438. func (c *HisApiController) ChangeDrugTen() {
  4439. start_time_str := c.GetString("start_time")
  4440. end_time_str := c.GetString("end_time")
  4441. //ids := c.GetString("ids")
  4442. //id_arr := strings.Split(ids, ",")
  4443. timeLayout := "2006-01-02"
  4444. loc, _ := time.LoadLocation("Local")
  4445. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4446. recordStartTime := theStartTime.Unix()
  4447. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4448. recordEndTime := theEndTime.Unix()
  4449. //timestamp := int64(1729612800)
  4450. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4451. admin_user_id, _ := c.GetInt64("admin_user_id")
  4452. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4453. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4454. var err []string
  4455. for _, item := range flows {
  4456. var res3 ResultSix
  4457. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4458. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4459. continue
  4460. }
  4461. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4462. continue
  4463. }
  4464. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4465. if prescription.OrderStatus == 2 {
  4466. //已经结算
  4467. //判断 是否已经销售
  4468. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4469. ////是否已经变更 1是 0否
  4470. //if item.IsChange == 0 { //没变更,进行变更操作
  4471. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4472. //
  4473. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4474. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4475. // var respJSON3 map[string]interface{}
  4476. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4477. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4478. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4479. // return
  4480. // }
  4481. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4482. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4483. // utils.ErrorLog("解析失败:%v", err)
  4484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4485. // return
  4486. // }
  4487. // if res3.Infcode == 0 {
  4488. // item.IsChange = 1
  4489. // item.BgBchno = bg_number
  4490. // service.SaveDF2(item)
  4491. // } else {
  4492. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4493. // }
  4494. //}
  4495. //} else
  4496. if item.IsSale == 0 { //没销售,
  4497. var res FJ3507Result
  4498. var res3507for10188 FJ3507ResultFor10188
  4499. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4500. //进行商品销售接口
  4501. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4502. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4503. var respJSON3 map[string]interface{}
  4504. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4507. return
  4508. }
  4509. userJSONBytes3, _ := json.Marshal(respJSON3)
  4510. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4511. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4512. utils.ErrorLog("解析失败:%v", err)
  4513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4514. return
  4515. }
  4516. //if res3507for10188.Infcode
  4517. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4518. //res.Output = resSix10265.Output
  4519. res.ErrMsg = res3507for10188.ErrMsg
  4520. res.Cainfo = res3507for10188.Cainfo
  4521. res.WarnMsg = res3507for10188.WarnMsg
  4522. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4523. res.Infcode = infocode
  4524. } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4525. } else {
  4526. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4527. utils.ErrorLog("解析失败:%v", err)
  4528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4529. return
  4530. }
  4531. }
  4532. if res.Infcode == 0 {
  4533. item.IsSale = 1
  4534. item.Bchno = number
  4535. item.SaleDate = time.Now().Format("2006-01-02")
  4536. err5 := service.SaveDF(item)
  4537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4538. //if err5 == nil {
  4539. //
  4540. // if item.IsChange == 1 { //没变更,进行变更操作
  4541. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4542. //
  4543. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4544. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4545. //
  4546. // var respJSON3 map[string]interface{}
  4547. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4548. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4550. // return
  4551. // }
  4552. //
  4553. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  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. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4561. // //res.Output = resSix10265.Output
  4562. // res3.ErrMsg = res3507for10188.ErrMsg
  4563. // res3.Cainfo = res3507for10188.Cainfo
  4564. // res3.WarnMsg = res3507for10188.WarnMsg
  4565. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4566. // res3.Infcode = infocode
  4567. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4568. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4569. // utils.ErrorLog("解析失败:%v", err)
  4570. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4571. // return
  4572. // }
  4573. // //if res3507for10188.Infcode
  4574. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4575. // //res.Output = resSix10265.Output
  4576. // res3.ErrMsg = res3507for10188.ErrMsg
  4577. // res3.Cainfo = res3507for10188.Cainfo
  4578. // res3.WarnMsg = res3507for10188.WarnMsg
  4579. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4580. // res3.Infcode = infocode
  4581. //
  4582. // } else {
  4583. //
  4584. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4585. // utils.ErrorLog("解析失败:%v", err)
  4586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4587. // return
  4588. // }
  4589. //
  4590. // }
  4591. //
  4592. // if res3.Infcode == 0 {
  4593. // item.IsChange = 1
  4594. // item.BgBchno = bg_number
  4595. // service.SaveDF2(item)
  4596. // return
  4597. // } else {
  4598. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4599. // }
  4600. // }
  4601. //}
  4602. } else {
  4603. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4604. }
  4605. }
  4606. }
  4607. } else if item.ConsumableType == 7 {
  4608. var res3507for10188 FJ3507ResultFor10188
  4609. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4610. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4611. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4612. //判断是否已经销售
  4613. if item.IsSale == 2 { //是否已经销售,1是 0否
  4614. //是否已经变更 1是 0否
  4615. if item.IsChange == 0 { //没变更,进行变更操作
  4616. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4617. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4618. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4619. var respJSON3 map[string]interface{}
  4620. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4623. return
  4624. }
  4625. userJSONBytes3, _ := json.Marshal(respJSON3)
  4626. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4627. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4628. utils.ErrorLog("解析失败:%v", err)
  4629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4630. return
  4631. }
  4632. //if res3507for10188.Infcode
  4633. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4634. //res.Output = resSix10265.Output
  4635. res3.ErrMsg = res3507for10188.ErrMsg
  4636. res3.Cainfo = res3507for10188.Cainfo
  4637. res3.WarnMsg = res3507for10188.WarnMsg
  4638. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4639. res3.Infcode = infocode
  4640. } else {
  4641. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4642. utils.ErrorLog("解析失败:%v", err)
  4643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4644. return
  4645. }
  4646. }
  4647. if res3.Infcode == 0 {
  4648. item.IsChange = 1
  4649. item.BgBchno = bg_number
  4650. service.SaveDF2(item)
  4651. } else {
  4652. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4653. }
  4654. }
  4655. } else { //没销售,
  4656. //进行商品销售退货接口
  4657. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4658. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4659. saveLog(result111, result222, "3506", "销售退货")
  4660. var res7 FJ3507Result
  4661. //进行商品销售接口
  4662. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4663. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4664. var respJSON3 map[string]interface{}
  4665. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4668. return
  4669. }
  4670. userJSONBytes3, _ := json.Marshal(respJSON3)
  4671. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4672. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4673. utils.ErrorLog("解析失败:%v", err)
  4674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4675. return
  4676. }
  4677. //if res3507for10188.Infcode
  4678. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4679. //res.Output = resSix10265.Output
  4680. res7.ErrMsg = res3507for10188.ErrMsg
  4681. res7.Cainfo = res3507for10188.Cainfo
  4682. res7.WarnMsg = res3507for10188.WarnMsg
  4683. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4684. res7.Infcode = infocode
  4685. } else {
  4686. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4687. utils.ErrorLog("解析失败:%v", err)
  4688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4689. return
  4690. }
  4691. }
  4692. if res7.Infcode == 0 {
  4693. item.IsSale = 2
  4694. item.SaleDate = item.SaleDate
  4695. item.Bchno = number
  4696. service.SaveDF(item)
  4697. if item.IsChange == 0 { //没变更,进行变更操作
  4698. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4699. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4700. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4701. var respJSON3 map[string]interface{}
  4702. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4705. return
  4706. }
  4707. userJSONBytes3, _ := json.Marshal(respJSON3)
  4708. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4709. // utils.ErrorLog("解析失败:%v", err)
  4710. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4711. // return
  4712. //}
  4713. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4714. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4715. utils.ErrorLog("解析失败:%v", err)
  4716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4717. return
  4718. }
  4719. //if res3507for10188.Infcode
  4720. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4721. //res.Output = resSix10265.Output
  4722. res3.ErrMsg = res3507for10188.ErrMsg
  4723. res3.Cainfo = res3507for10188.Cainfo
  4724. res3.WarnMsg = res3507for10188.WarnMsg
  4725. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4726. res3.Infcode = infocode
  4727. } else {
  4728. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4729. utils.ErrorLog("解析失败:%v", err)
  4730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4731. return
  4732. }
  4733. }
  4734. if res3.Infcode == 0 {
  4735. item.IsChange = 1
  4736. item.BgBchno = bg_number
  4737. service.SaveDF2(item)
  4738. } else {
  4739. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4740. }
  4741. }
  4742. } else {
  4743. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4744. }
  4745. }
  4746. } else { //还没结算
  4747. if item.IsChange == 0 { //没变更,进行变更操作
  4748. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4749. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4750. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4751. var respJSON3 map[string]interface{}
  4752. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4755. return
  4756. }
  4757. userJSONBytes3, _ := json.Marshal(respJSON3)
  4758. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4759. // utils.ErrorLog("解析失败:%v", err)
  4760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4761. // return
  4762. //}
  4763. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4764. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4765. utils.ErrorLog("解析失败:%v", err)
  4766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4767. return
  4768. }
  4769. //if res3507for10188.Infcode
  4770. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4771. //res.Output = resSix10265.Output
  4772. res3.ErrMsg = res3507for10188.ErrMsg
  4773. res3.Cainfo = res3507for10188.Cainfo
  4774. res3.WarnMsg = res3507for10188.WarnMsg
  4775. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4776. res3.Infcode = infocode
  4777. } else {
  4778. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4779. utils.ErrorLog("解析失败:%v", err)
  4780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4781. return
  4782. }
  4783. }
  4784. if res3.Infcode == 0 {
  4785. item.IsChange = 1
  4786. item.BgBchno = bg_number
  4787. service.SaveDF2(item)
  4788. } else {
  4789. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4790. }
  4791. }
  4792. }
  4793. }
  4794. }
  4795. if len(err) == 0 {
  4796. c.ServeSuccessJSON(map[string]interface{}{
  4797. "msg": "销售变更成功",
  4798. })
  4799. } else {
  4800. c.ServeSuccessJSON(map[string]interface{}{
  4801. "failed_code": -10,
  4802. "msg": err,
  4803. })
  4804. }
  4805. }
  4806. func ChangeDrugTenone() {
  4807. //ids := c.GetString("ids")
  4808. //id_arr := strings.Split(ids, ",")
  4809. now := time.Now()
  4810. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4811. //timestamp := int64(1729612800)
  4812. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  4813. admin_user_id := int64(2463)
  4814. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  4815. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  4816. var err []string
  4817. for _, item := range flows {
  4818. var res3 ResultSix
  4819. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4820. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4821. continue
  4822. }
  4823. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4824. continue
  4825. }
  4826. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4827. if prescription.OrderStatus == 2 {
  4828. //已经结算
  4829. //判断是否已经销售
  4830. if item.IsSale == 1 { //是否已经销售,1是 0否
  4831. //是否已经变更 1是 0否
  4832. if item.IsChange == 0 { //没变更,进行变更操作
  4833. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4834. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4835. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4836. var respJSON3 map[string]interface{}
  4837. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4839. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4840. return
  4841. }
  4842. userJSONBytes3, _ := json.Marshal(respJSON3)
  4843. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4844. utils.ErrorLog("解析失败:%v", err)
  4845. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4846. return
  4847. }
  4848. if res3.Infcode == 0 {
  4849. item.IsChange = 1
  4850. item.BgBchno = bg_number
  4851. service.SaveDF2(item)
  4852. } else {
  4853. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4854. }
  4855. }
  4856. } else { //没销售,
  4857. var res FJ3507Result
  4858. var res3507for10188 FJ3507ResultFor10188
  4859. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4860. //进行商品销售接口
  4861. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  4862. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4863. var respJSON3 map[string]interface{}
  4864. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4866. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4867. return
  4868. }
  4869. userJSONBytes3, _ := json.Marshal(respJSON3)
  4870. {
  4871. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4872. utils.ErrorLog("解析失败:%v", err)
  4873. return
  4874. }
  4875. //if res3507for10188.Infcode
  4876. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4877. //res.Output = resSix10265.Output
  4878. res.ErrMsg = res3507for10188.ErrMsg
  4879. res.Cainfo = res3507for10188.Cainfo
  4880. res.WarnMsg = res3507for10188.WarnMsg
  4881. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4882. res.Infcode = infocode
  4883. }
  4884. if res.Infcode == 0 {
  4885. item.IsSale = 1
  4886. item.Bchno = number
  4887. item.SaleDate = time.Now().Format("2006-01-02")
  4888. err5 := service.SaveDF(item)
  4889. if err5 == nil {
  4890. if item.IsChange == 1 { //没变更,进行变更操作
  4891. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4892. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4893. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4894. var respJSON3 map[string]interface{}
  4895. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4897. return
  4898. }
  4899. {
  4900. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4901. utils.ErrorLog("解析失败:%v", err)
  4902. return
  4903. }
  4904. //if res3507for10188.Infcode
  4905. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4906. //res.Output = resSix10265.Output
  4907. res3.ErrMsg = res3507for10188.ErrMsg
  4908. res3.Cainfo = res3507for10188.Cainfo
  4909. res3.WarnMsg = res3507for10188.WarnMsg
  4910. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4911. res3.Infcode = infocode
  4912. }
  4913. if res3.Infcode == 0 {
  4914. item.IsChange = 1
  4915. item.BgBchno = bg_number
  4916. service.SaveDF2(item)
  4917. } else {
  4918. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4919. }
  4920. }
  4921. }
  4922. } else {
  4923. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4924. }
  4925. }
  4926. }
  4927. }
  4928. }
  4929. }
  4930. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4931. var struct3502 models.Struct3502
  4932. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4933. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4934. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4935. struct3502.FixmedinsCode = miConfig.Code
  4936. struct3502.Code = miConfig.Code
  4937. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4938. struct3502.Opter = role.UserName
  4939. struct3502.RxFlag = "1"
  4940. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4941. struct3502.OrgName = miConfig.OrgName
  4942. struct3502.AccessKey = miConfig.AccessKey
  4943. struct3502.RequestUrl = miConfig.Url
  4944. struct3502.SecretKey = miConfig.SecretKey
  4945. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4946. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4947. struct3502.Url = miConfig.Url
  4948. struct3502.AppId = miConfig.Cainfo
  4949. struct3502.AppSecret = miConfig.AppSecret
  4950. struct3502.Enckey = miConfig.EncKey
  4951. struct3502.SignKey = miConfig.SignKey
  4952. struct3502.SecretKey = miConfig.SecretKey
  4953. struct3502.InvChgType = chgType
  4954. struct3502.FixmedinsBchno = number
  4955. struct3502.Cnt = strconv.FormatInt(count, 10)
  4956. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4957. //result1, result2, _ := service.FJyb3502(struct3502)
  4958. if miConfig.MdtrtareaAdmvs == "350500" {
  4959. result1, result2, _ := service.FJyb3502(struct3502)
  4960. //saveLog(result1, result2, "3502", "3502")
  4961. return result1, result2
  4962. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4963. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4964. return result1, result2
  4965. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4966. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4967. return result1, result2
  4968. } else {
  4969. data := make(map[string]interface{})
  4970. data["struct_3502s"] = struct3502
  4971. client := &http.Client{}
  4972. bytesData, _ := json.Marshal(data)
  4973. var req *http.Request
  4974. if miConfig.MdtrtareaAdmvs == "320921" {
  4975. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4976. } else {
  4977. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4978. }
  4979. resp, _ := client.Do(req)
  4980. defer resp.Body.Close()
  4981. body, ioErr := ioutil.ReadAll(resp.Body)
  4982. if ioErr != nil {
  4983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4984. }
  4985. var respJSON map[string]interface{}
  4986. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4988. }
  4989. //var resSix10265 ResultSix10265 //1101结果
  4990. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4991. result, _ := json.Marshal(respJSON)
  4992. return string(result), ""
  4993. }
  4994. }
  4995. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4996. var struct3505 models.Struct3505
  4997. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4998. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4999. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5000. struct3505.FixmedinsBchno = number
  5001. struct3505.Opter = role.UserName
  5002. struct3505.Bchno = "---"
  5003. struct3505.FixmedinsCode = miConfig.Code
  5004. struct3505.Code = miConfig.Code
  5005. struct3505.FinlTrnsPric = drug.HisDoctorAdviceInfo.Price
  5006. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5007. struct3505.PrscDrName = roles.UserName
  5008. if org_id == 10191 {
  5009. struct3505.PharName = "刘水山"
  5010. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5011. }
  5012. if org_id == 10188 {
  5013. struct3505.PharName = "李汉清"
  5014. struct3505.PharPracCertNo = "30220200932022010034"
  5015. }
  5016. if org_id == 10217 {
  5017. struct3505.PharName = "张敏"
  5018. struct3505.PharPracCertNo = "30220230432090100108"
  5019. }
  5020. if org_id == 10318 {
  5021. struct3505.PharName = "邹刘阳"
  5022. struct3505.PharPracCertNo = "210441200001378"
  5023. }
  5024. if org_id == 10402 {
  5025. struct3505.PharName = "刘韶健"
  5026. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5027. }
  5028. if org_id == 9919 {
  5029. struct3505.PharName = "周君权"
  5030. struct3505.PharPracCertNo = "089644396094401375"
  5031. }
  5032. if org_id == 10644 {
  5033. struct3505.PharName = "陈金娣"
  5034. struct3505.PharPracCertNo = "20181441500320100066"
  5035. }
  5036. if org_id == 10567 {
  5037. struct3505.PharName = "范小兰"
  5038. struct3505.PharPracCertNo = "0200102079485"
  5039. }
  5040. if org_id == 10721 {
  5041. struct3505.PharName = "孙莉侠"
  5042. struct3505.PharPracCertNo = "060399"
  5043. }
  5044. if org_id == 10726 {
  5045. struct3505.PharName = "彭建福"
  5046. struct3505.PharPracCertNo = "D445281006261"
  5047. }
  5048. if org_id == 10265 {
  5049. struct3505.PharName = "李彩星"
  5050. struct3505.PharPracCertNo = "20171110600110100019"
  5051. }
  5052. if org_id == 10028 {
  5053. struct3505.PharName = "曾细平"
  5054. struct3505.PharPracCertNo = "D440307022134"
  5055. }
  5056. if org_id == 10138 {
  5057. struct3505.PharName = "彭斯遥"
  5058. struct3505.PharPracCertNo = "30220200943042010052"
  5059. }
  5060. if org_id == 10278 {
  5061. struct3505.PharName = "彭斯遥"
  5062. struct3505.PharPracCertNo = "30220200943042010052"
  5063. }
  5064. if org_id == 10610 {
  5065. struct3505.PharName = "彭斯遥"
  5066. struct3505.PharPracCertNo = "30220200943042010052"
  5067. }
  5068. if org_id == 10537 {
  5069. struct3505.PharName = "彭斯遥"
  5070. struct3505.PharPracCertNo = "30220200943042010052"
  5071. }
  5072. if org_id == 9504 {
  5073. struct3505.PharName = "资美红"
  5074. struct3505.PharPracCertNo = "D440904006635"
  5075. }
  5076. if org_id == 10480 {
  5077. struct3505.PharName = "陈思"
  5078. struct3505.PharPracCertNo = "30220240434110010470"
  5079. }
  5080. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5081. struct3505.SetlId = order.SetlId
  5082. struct3505.MdtrtSn = order.MdtrtId
  5083. struct3505.ManuLotnum = drug.BatchNumber
  5084. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5085. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5086. struct3505.RxFlag = "1"
  5087. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5088. struct3505.TrdnFlag = "0"
  5089. } else {
  5090. struct3505.TrdnFlag = "1"
  5091. }
  5092. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5093. struct3505.TrdnFlag = "1"
  5094. }
  5095. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5096. struct3505.TrdnFlag = "0"
  5097. }
  5098. struct3505.RtalDocno = order.Number
  5099. struct3505.PsnCertType = "01"
  5100. struct3505.CertNo = order.Certno
  5101. struct3505.PsnNo = order.PsnNo
  5102. struct3505.PsnName = order.PsnName
  5103. struct3505.Url = miConfig.Url
  5104. struct3505.AppId = miConfig.Cainfo
  5105. struct3505.AppSecret = miConfig.AppSecret
  5106. struct3505.Enckey = miConfig.EncKey
  5107. struct3505.SignKey = miConfig.SignKey
  5108. struct3505.SecretKey = miConfig.SecretKey
  5109. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5110. struct3505.SelRetnCnt = strValue
  5111. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5112. struct3505.SelRetnOpterName = role.UserName
  5113. if order.IsMedicineInsurance == 1 {
  5114. struct3505.MdtrtSetlType = "1"
  5115. } else {
  5116. struct3505.MdtrtSetlType = "2"
  5117. }
  5118. struct3505.OrgName = miConfig.OrgName
  5119. struct3505.AccessKey = miConfig.AccessKey
  5120. struct3505.RequestUrl = miConfig.Url
  5121. struct3505.SecretKey = miConfig.SecretKey
  5122. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5123. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5124. struct3505.Cainfo = miConfig.Cainfo
  5125. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5126. if miConfig.MdtrtareaAdmvs == "350500" {
  5127. result1, result2, _ := service.FJyb3505(struct3505)
  5128. return result1, result2
  5129. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5130. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5131. return result1, result2
  5132. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5133. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5134. return result1, result2
  5135. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5136. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5137. return result1, result2
  5138. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5139. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5140. return result1, result2
  5141. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5142. data := make(map[string]interface{})
  5143. data["struct_3505s"] = struct3505
  5144. client := &http.Client{}
  5145. bytesData, _ := json.Marshal(data)
  5146. var req *http.Request
  5147. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5148. resp, _ := client.Do(req)
  5149. defer resp.Body.Close()
  5150. body, ioErr := ioutil.ReadAll(resp.Body)
  5151. if ioErr != nil {
  5152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5153. }
  5154. var respJSON map[string]interface{}
  5155. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5157. }
  5158. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5159. result, _ := json.Marshal(respJSON)
  5160. return string(result), ""
  5161. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5162. data := make(map[string]interface{})
  5163. data["struct_3505s"] = struct3505
  5164. client := &http.Client{}
  5165. bytesData, _ := json.Marshal(data)
  5166. var req *http.Request
  5167. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5168. resp, _ := client.Do(req)
  5169. defer resp.Body.Close()
  5170. body, ioErr := ioutil.ReadAll(resp.Body)
  5171. if ioErr != nil {
  5172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5173. }
  5174. var respJSON map[string]interface{}
  5175. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5177. }
  5178. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5179. if status == "0" {
  5180. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5181. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5182. }
  5183. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5184. result, _ := json.Marshal(respJSON)
  5185. return string(result), ""
  5186. } else {
  5187. data := make(map[string]interface{})
  5188. data["struct_3505s"] = struct3505
  5189. client := &http.Client{}
  5190. bytesData, _ := json.Marshal(data)
  5191. var req *http.Request
  5192. if miConfig.MdtrtareaAdmvs == "320921" {
  5193. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5194. } else {
  5195. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5196. }
  5197. resp, _ := client.Do(req)
  5198. defer resp.Body.Close()
  5199. body, ioErr := ioutil.ReadAll(resp.Body)
  5200. if ioErr != nil {
  5201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5202. }
  5203. var respJSON map[string]interface{}
  5204. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5206. }
  5207. //var resSix10265 ResultSix10265 //1101结果
  5208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5209. result, _ := json.Marshal(respJSON)
  5210. return string(result), ""
  5211. }
  5212. }
  5213. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5214. var struct3505 models.Struct3505
  5215. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5216. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5217. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5218. struct3505.FixmedinsBchno = number
  5219. struct3505.Opter = role.UserName
  5220. struct3505.FixmedinsCode = miConfig.Code
  5221. struct3505.Code = miConfig.Code
  5222. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5223. struct3505.PrscDrName = roles.UserName
  5224. if org_id == 10191 {
  5225. struct3505.PharName = "刘水山"
  5226. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5227. }
  5228. if org_id == 10188 {
  5229. struct3505.PharName = "李汉清"
  5230. struct3505.PharPracCertNo = "30220200932022010034"
  5231. }
  5232. if org_id == 10217 {
  5233. struct3505.PharName = "张敏"
  5234. struct3505.PharPracCertNo = "30220230432090100108"
  5235. }
  5236. if org_id == 10318 {
  5237. struct3505.PharName = "邹刘阳"
  5238. struct3505.PharPracCertNo = "210441200001378"
  5239. }
  5240. if org_id == 10402 {
  5241. struct3505.PharName = "刘韶健"
  5242. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5243. }
  5244. if org_id == 9919 {
  5245. struct3505.PharName = "周君权"
  5246. struct3505.PharPracCertNo = "089644396094401375"
  5247. }
  5248. if org_id == 10644 {
  5249. struct3505.PharName = "陈金娣"
  5250. struct3505.PharPracCertNo = "20181441500320100066"
  5251. }
  5252. if org_id == 10567 {
  5253. struct3505.PharName = "范小兰"
  5254. struct3505.PharPracCertNo = "0200102079485"
  5255. }
  5256. if org_id == 10721 {
  5257. struct3505.PharName = "孙莉侠"
  5258. struct3505.PharPracCertNo = "060399"
  5259. }
  5260. if org_id == 10726 {
  5261. struct3505.PharName = "彭建福"
  5262. struct3505.PharPracCertNo = "D445281006261"
  5263. }
  5264. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5265. struct3505.SetlId = order.SetlId
  5266. struct3505.MdtrtSn = order.MdtrtId
  5267. struct3505.ManuLotnum = drug.Number
  5268. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5269. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5270. struct3505.RxFlag = "1"
  5271. struct3505.TrdnFlag = "0"
  5272. struct3505.RtalDocno = order.Number
  5273. struct3505.PsnCertType = "01"
  5274. struct3505.CertNo = order.Certno
  5275. struct3505.PsnNo = order.PsnNo
  5276. struct3505.PsnName = order.PsnName
  5277. struct3505.Url = miConfig.Url
  5278. struct3505.AppId = miConfig.Cainfo
  5279. struct3505.AppSecret = miConfig.AppSecret
  5280. struct3505.Enckey = miConfig.EncKey
  5281. struct3505.SignKey = miConfig.SignKey
  5282. struct3505.SecretKey = miConfig.SecretKey
  5283. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5284. struct3505.SelRetnCnt = strValue
  5285. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5286. struct3505.SelRetnOpterName = role.UserName
  5287. if order.IsMedicineInsurance == 1 {
  5288. struct3505.MdtrtSetlType = "1"
  5289. } else {
  5290. struct3505.MdtrtSetlType = "2"
  5291. }
  5292. struct3505.OrgName = miConfig.OrgName
  5293. struct3505.AccessKey = miConfig.AccessKey
  5294. struct3505.RequestUrl = miConfig.Url
  5295. struct3505.SecretKey = miConfig.SecretKey
  5296. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5297. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5298. struct3505.Cainfo = miConfig.Cainfo
  5299. struct3505.DrugTracCodg = drug.DrugCode
  5300. if miConfig.MdtrtareaAdmvs == "350500" {
  5301. result1, result2, _ := service.FJyb3505(struct3505)
  5302. return result1, result2
  5303. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5304. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5305. return result1, result2
  5306. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5307. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5308. return result1, result2
  5309. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5310. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5311. return result1, result2
  5312. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5313. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5314. return result1, result2
  5315. } else {
  5316. data := make(map[string]interface{})
  5317. data["struct_3505s"] = struct3505
  5318. client := &http.Client{}
  5319. bytesData, _ := json.Marshal(data)
  5320. var req *http.Request
  5321. if miConfig.MdtrtareaAdmvs == "320921" {
  5322. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5323. } else {
  5324. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5325. }
  5326. resp, _ := client.Do(req)
  5327. defer resp.Body.Close()
  5328. body, ioErr := ioutil.ReadAll(resp.Body)
  5329. if ioErr != nil {
  5330. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5331. }
  5332. var respJSON map[string]interface{}
  5333. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5335. }
  5336. //var resSix10265 ResultSix10265 //1101结果
  5337. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5338. result, _ := json.Marshal(respJSON)
  5339. return string(result), ""
  5340. }
  5341. }
  5342. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5343. var struct3506 models.Struct3506
  5344. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5345. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5346. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5347. struct3506.FixmedinsCode = miConfig.Code
  5348. struct3506.Code = miConfig.Code
  5349. struct3506.FixmedinsBchno = number
  5350. struct3506.Opter = role.UserName
  5351. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5352. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5353. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5354. struct3506.MdtrtSn = order.MdtrtId
  5355. struct3506.ExpyEnd = ""
  5356. struct3506.RxFlag = "0"
  5357. struct3506.TrdnFlag = "1"
  5358. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5359. struct3506.SelRetnCnt = strValue
  5360. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5361. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5362. struct3506.SelRetnOpterName = role.UserName
  5363. struct3506.OrgName = miConfig.OrgName
  5364. struct3506.AccessKey = miConfig.AccessKey
  5365. struct3506.RequestUrl = miConfig.Url
  5366. struct3506.SecretKey = miConfig.SecretKey
  5367. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5368. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5369. struct3506.Url = miConfig.Url
  5370. struct3506.AppId = miConfig.Cainfo
  5371. struct3506.AppSecret = miConfig.AppSecret
  5372. struct3506.Enckey = miConfig.EncKey
  5373. struct3506.SignKey = miConfig.SignKey
  5374. struct3506.SecretKey = miConfig.SecretKey
  5375. struct3506.DrugTracCodg = drug.DrugCode
  5376. if miConfig.MdtrtareaAdmvs == "350500" {
  5377. result1, result2, _ := service.FJyb3506(struct3506)
  5378. return result1, result2
  5379. } else {
  5380. data := make(map[string]interface{})
  5381. data["struct_3506s"] = struct3506
  5382. client := &http.Client{}
  5383. bytesData, _ := json.Marshal(data)
  5384. var req *http.Request
  5385. if miConfig.MdtrtareaAdmvs == "320921" {
  5386. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5387. } else {
  5388. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5389. }
  5390. resp, _ := client.Do(req)
  5391. defer resp.Body.Close()
  5392. body, ioErr := ioutil.ReadAll(resp.Body)
  5393. if ioErr != nil {
  5394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5395. }
  5396. var respJSON map[string]interface{}
  5397. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5398. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5399. }
  5400. //var resSix10265 ResultSix10265 //1101结果
  5401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5402. result, _ := json.Marshal(respJSON)
  5403. return string(result), ""
  5404. }
  5405. }
  5406. func (c *HisApiController) Get1318() {
  5407. adminUser := c.GetAdminUserInfo()
  5408. admin_user_id, _ := c.GetInt64("admin_user_id")
  5409. code := c.GetString("code")
  5410. code = ""
  5411. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5412. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5413. api := ""
  5414. if miConfig.MdtrtareaAdmvs == "320921" {
  5415. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5416. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5417. } else {
  5418. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5419. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5420. }
  5421. resp, requestErr := http.Get(api)
  5422. if requestErr != nil {
  5423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5424. return
  5425. }
  5426. body, ioErr := ioutil.ReadAll(resp.Body)
  5427. if ioErr != nil {
  5428. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5430. return
  5431. }
  5432. var respJSON map[string]interface{}
  5433. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5436. return
  5437. }
  5438. //var res Result2406
  5439. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5440. result, _ := json.Marshal(respJSON)
  5441. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5442. utils.ErrorLog("解析失败:%v", err)
  5443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5444. return
  5445. }
  5446. if res.Infcode == "0" {
  5447. c.ServeSuccessJSON(map[string]interface{}{
  5448. "result": "",
  5449. })
  5450. } else {
  5451. c.ServeSuccessJSON(map[string]interface{}{
  5452. "failed_code": -10,
  5453. "msg": res.ErrMsg,
  5454. })
  5455. */return
  5456. //}
  5457. }
  5458. func (c *HisApiController) Get2503() {
  5459. adminUser := c.GetAdminUserInfo()
  5460. admin_user_id, _ := c.GetInt64("admin_user_id")
  5461. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5462. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5463. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5464. }
  5465. func (c *HisApiController) Get2406() {
  5466. id, _ := c.GetInt64("id")
  5467. record_time := c.GetString("record_time")
  5468. his_patient_id, _ := c.GetInt64("his_patient_id")
  5469. admin_user_id, _ := c.GetInt64("admin_user_id")
  5470. diagnosis_id := c.GetString("diagnosis")
  5471. timeLayout := "2006-01-02"
  5472. loc, _ := time.LoadLocation("Local")
  5473. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5474. if err != nil {
  5475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5476. return
  5477. }
  5478. recordDateTime := theTime.Unix()
  5479. adminUser := c.GetAdminUserInfo()
  5480. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5481. var config []*models.HisXtDiagnoseConfig
  5482. for _, item := range diagnosis_ids {
  5483. id, _ := strconv.ParseInt(item, 10, 64)
  5484. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5485. config = append(config, &diagnosisConfig)
  5486. }
  5487. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5488. fmt.Println(his_patient_id)
  5489. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5490. //timestamp := time.Now().Unix()
  5491. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5492. var patientPrescription models.HisPrescriptionInfo
  5493. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5494. if patientPrescription.ID == 0 {
  5495. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5496. }
  5497. var res2 Result2406
  5498. if miConfig.MdtrtareaAdmvs == "341203" {
  5499. data := make(map[string]interface{})
  5500. client := &http.Client{}
  5501. data["psn_no"] = his.PsnNo
  5502. data["mdtrt_id"] = his.Number
  5503. data["operator"] = roles.UserName
  5504. data["cert_no"] = his.IdCardNo
  5505. data["org_name"] = miConfig.OrgName
  5506. data["psn_name"] = his.Name
  5507. data["ipt_otp_no"] = his.IptOtpNo
  5508. data["ipt_psn_sp_flag_type"] = "0901"
  5509. data["ipt_psn_sp_flag"] = "1"
  5510. data["fixmedins_code"] = miConfig.Code
  5511. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5512. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5513. data["url"] = miConfig.Url
  5514. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5515. bytesData, _ := json.Marshal(data)
  5516. var req *http.Request
  5517. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5518. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5519. resp, _ := client.Do(req)
  5520. defer resp.Body.Close()
  5521. body, ioErr := ioutil.ReadAll(resp.Body)
  5522. if ioErr != nil {
  5523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5525. return
  5526. }
  5527. var respJSON map[string]interface{}
  5528. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5531. return
  5532. }
  5533. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5534. if status == "0" {
  5535. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5536. c.ServeSuccessJSON(map[string]interface{}{
  5537. "failed_code": -10,
  5538. "msg": err_msg,
  5539. })
  5540. return
  5541. }
  5542. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5543. userJSONBytes, _ := json.Marshal(respJSON)
  5544. fmt.Println("log")
  5545. fmt.Println(string(userJSONBytes))
  5546. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5547. utils.ErrorLog("解析失败:%v", err)
  5548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5549. return
  5550. }
  5551. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5552. data := make(map[string]interface{})
  5553. client := &http.Client{}
  5554. data["psn_no"] = his.PsnNo
  5555. data["mdtrt_id"] = his.Number
  5556. data["operator"] = roles.UserName
  5557. data["cert_no"] = his.IdCardNo
  5558. data["org_name"] = miConfig.OrgName
  5559. data["psn_name"] = his.Name
  5560. data["ipt_otp_no"] = his.IptOtpNo
  5561. data["ipt_psn_sp_flag_type"] = "0901"
  5562. data["ipt_psn_sp_flag"] = "1"
  5563. data["fixmedins_code"] = miConfig.Code
  5564. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5565. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5566. data["url"] = miConfig.Url
  5567. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5568. bytesData, _ := json.Marshal(data)
  5569. var req *http.Request
  5570. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5571. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5572. resp, _ := client.Do(req)
  5573. defer resp.Body.Close()
  5574. body, ioErr := ioutil.ReadAll(resp.Body)
  5575. if ioErr != nil {
  5576. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5578. return
  5579. }
  5580. var respJSON map[string]interface{}
  5581. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5584. return
  5585. }
  5586. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5587. if status == "0" {
  5588. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5589. c.ServeSuccessJSON(map[string]interface{}{
  5590. "failed_code": -10,
  5591. "msg": err_msg,
  5592. })
  5593. return
  5594. }
  5595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5596. userJSONBytes, _ := json.Marshal(respJSON)
  5597. fmt.Println("log")
  5598. fmt.Println(string(userJSONBytes))
  5599. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5600. utils.ErrorLog("解析失败:%v", err)
  5601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5602. return
  5603. }
  5604. }
  5605. if res2.Infcode != 0 {
  5606. adminUser := c.GetAdminUserInfo()
  5607. errlog := &models.HisOrderError{
  5608. UserOrgId: adminUser.CurrentOrgId,
  5609. Ctime: time.Now().Unix(),
  5610. Mtime: time.Now().Unix(),
  5611. ErrMsg: res2.ErrMsg,
  5612. Status: 1,
  5613. PatientId: id,
  5614. RecordTime: recordDateTime,
  5615. Stage: 3,
  5616. }
  5617. service.CreateErrMsgLog(errlog)
  5618. c.ServeSuccessJSON(map[string]interface{}{
  5619. "failed_code": -10,
  5620. "msg": res2.ErrMsg,
  5621. })
  5622. return
  5623. } else {
  5624. c.ServeSuccessJSON(map[string]interface{}{
  5625. "msg": "上传成功",
  5626. })
  5627. return
  5628. }
  5629. }
  5630. func (c *HisApiController) Get4105() {
  5631. }
  5632. func (c *HisApiController) Post5302() {
  5633. patient_id, _ := c.GetInt64("id")
  5634. admin_user_id, _ := c.GetInt64("admin_user_id")
  5635. p, _ := service.GetHisPatientById(patient_id)
  5636. adminUser := c.GetAdminUserInfo()
  5637. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5638. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5639. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5640. }
  5641. func (c *HisApiController) Get4104() {
  5642. }
  5643. type Output struct {
  5644. CertNo string `json:"certno"`
  5645. PsnName string `json:"psn_name"`
  5646. CardNo string `json:"card_no"`
  5647. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5648. CardSN string `json:"card_sn"`
  5649. PsnCertType string `json:"psn_cert_type"`
  5650. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5651. MdtrtCertType string `json:"mdtrt_cert_type"`
  5652. QRCode string `json:"qrCode"`
  5653. EcToken string `json:"ecToken"`
  5654. }
  5655. type AHResponse struct {
  5656. Body AHBody `json:"body"`
  5657. Code int `json:"code"`
  5658. CSBCode int `json:"csbCode"`
  5659. Message string `json:"message"`
  5660. RequestID string `json:"requestId"`
  5661. State struct{} `json:"state"`
  5662. }
  5663. type AHBody struct {
  5664. ErrMsg string `json:"err_msg"`
  5665. InfRefMsgID string `json:"inf_refmsgid"`
  5666. InfCode int `json:"infcode"`
  5667. Output struct {
  5668. Result []struct {
  5669. BasMednFlag string `json:"bas_medn_flag"`
  5670. ChldMedcFlag string `json:"chld_medc_flag"`
  5671. ChrgitmLv string `json:"chrgitm_lv"`
  5672. Cnt float64 `json:"cnt"`
  5673. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5674. DrtReimFlag string `json:"drt_reim_flag"`
  5675. FeedetlSn string `json:"feedetl_sn"`
  5676. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5677. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5678. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5679. ListSpItemFlag string `json:"list_sp_item_flag"`
  5680. LmtUsedFlag string `json:"lmt_used_flag"`
  5681. MedChrgitmType string `json:"med_chrgitm_type"`
  5682. Memo string `json:"memo"`
  5683. OverlmtAmt float64 `json:"overlmt_amt"`
  5684. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5685. Pric float64 `json:"pric"`
  5686. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5687. SelfpayProp float64 `json:"selfpay_prop"`
  5688. } `json:"result"`
  5689. } `json:"output"`
  5690. }
  5691. type Response struct {
  5692. Output Output `json:"output"`
  5693. Infcode int `json:"infcode"`
  5694. InfRefMsgID string `json:"inf_refmsgid"`
  5695. RefMsgTime string `json:"refmsg_time"`
  5696. RespondTime string `json:"respond_time"`
  5697. ErrMsg string `json:"err_msg"`
  5698. WarnMsg string `json:"warn_msg"`
  5699. SignType string `json:"signtype"`
  5700. CAInfo string `json:"cainfo"`
  5701. }
  5702. func (c *HisApiController) Getquerydata() {
  5703. query_type, _ := c.GetInt64("type")
  5704. refd_setl_flag := c.GetString("refd_setl_flag")
  5705. med_type := c.GetString("med_type")
  5706. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5707. cert_no := c.GetString("cert_no")
  5708. psn_no := c.GetString("psn_no")
  5709. start_time := c.GetString("start_time")
  5710. end_time := c.GetString("end_time")
  5711. page, _ := c.GetInt64("page")
  5712. limit, _ := c.GetInt64("limit")
  5713. var bp models.BusinessParams5262
  5714. bp.RefdSetlFlag = refd_setl_flag
  5715. bp.MedType = med_type
  5716. bp.Certno = cert_no
  5717. bp.Psnno = psn_no
  5718. bp.QBegntime = start_time
  5719. bp.QEndtime = end_time
  5720. if query_type == 1 { //本地
  5721. Post5262(c, bp, page, limit)
  5722. } else { //异地
  5723. Post5267(c, bp, page, limit)
  5724. }
  5725. }
  5726. func (c *HisApiController) Drugscheck() {
  5727. admin_user_id, _ := c.GetInt64("admin_user_id")
  5728. adminUser := c.GetAdminUserInfo()
  5729. var queryResult []QueryResult
  5730. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5731. for _, item := range drugs {
  5732. result := QueryResult{
  5733. ID: item.ID,
  5734. Name: item.DrugName,
  5735. Code: item.MedicalInsuranceNumber,
  5736. List_type_code: "101",
  5737. }
  5738. queryResult = append(queryResult, result)
  5739. }
  5740. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5741. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5742. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5743. for _, item := range queryResult {
  5744. 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)
  5745. }
  5746. }
  5747. func (c *HisApiController) Goodcheck() {
  5748. admin_user_id, _ := c.GetInt64("admin_user_id")
  5749. adminUser := c.GetAdminUserInfo()
  5750. var queryResult []QueryResult
  5751. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5752. for _, item := range goods {
  5753. result := QueryResult{
  5754. ID: item.ID,
  5755. Name: item.GoodName,
  5756. Code: item.SocialSecurityDirectoryCode,
  5757. List_type_code: "301",
  5758. }
  5759. queryResult = append(queryResult, result)
  5760. }
  5761. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5762. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5763. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5764. for _, item := range queryResult {
  5765. 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)
  5766. //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)
  5767. }
  5768. }
  5769. func (c *HisApiController) Projectcheck() {
  5770. admin_user_id, _ := c.GetInt64("admin_user_id")
  5771. adminUser := c.GetAdminUserInfo()
  5772. var queryResult []QueryResult
  5773. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5774. for _, item := range projects {
  5775. result := QueryResult{
  5776. ID: item.ID,
  5777. Name: item.ProjectName,
  5778. Code: item.MedicalCode,
  5779. List_type_code: "201",
  5780. }
  5781. queryResult = append(queryResult, result)
  5782. }
  5783. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5784. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5785. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5786. for _, item := range queryResult {
  5787. 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)
  5788. }
  5789. }
  5790. //func (c *HisApiController)CancleDia(){
  5791. //
  5792. // id, _ := c.GetInt64("id")
  5793. // record_time := c.GetString("record_time")
  5794. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5795. //
  5796. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5797. //
  5798. // diagnosis_id := c.GetString("diagnosis")
  5799. // sick_type, _ := c.GetInt64("sick_type")
  5800. // reg_type, _ := c.GetInt64("p_type")
  5801. // begin_time := c.GetString("begin_time")
  5802. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5803. //
  5804. //
  5805. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5806. //
  5807. // fmt.Println(acct_used_flag)
  5808. //
  5809. //
  5810. // timeLayout := "2006-01-02"
  5811. // loc, _ := time.LoadLocation("Local")
  5812. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5813. // if err != nil {
  5814. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5815. // return
  5816. // }
  5817. // recordDateTime := theTime.Unix()
  5818. // adminUser := c.GetAdminUserInfo()
  5819. //
  5820. //
  5821. //
  5822. //
  5823. //
  5824. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5825. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5826. // var patientPrescription models.HisPrescriptionInfo
  5827. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5828. // if patientPrescription.ID == 0 {
  5829. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5830. // }
  5831. // //if patientPrescription.Do
  5832. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5833. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5834. //
  5835. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5836. //
  5837. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5838. //
  5839. // var config []*models.HisXtDiagnoseConfig
  5840. // for _, item := range diagnosis_ids {
  5841. // id, _ := strconv.ParseInt(item, 10, 64)
  5842. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5843. // config = append(config, &diagnosisConfig)
  5844. // }
  5845. //
  5846. // sickConfig, _ := service.FindSickById(sick_type)
  5847. //
  5848. //
  5849. // data := make(map[string]interface{})
  5850. // client := &http.Client{}
  5851. // data["psn_no"] = his.PsnNo
  5852. // data["mdtrt_id"] = his.Number
  5853. // data["doctor"] = roles.UserName
  5854. // data["department"] = department.Name
  5855. // data["org_name"] = miConfig.OrgName
  5856. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5857. // data["doctor_id"] = doctor_info.DoctorNumber
  5858. // data["new_doctor_name"] = doctor_info.UserName
  5859. // data["fixmedins_code"] = miConfig.Code
  5860. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5861. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5862. // data["secret_key"] = miConfig.SecretKey
  5863. // data["sick_code"] = sickConfig.CountryCode
  5864. // data["sick_name"] = sickConfig.ClassName
  5865. // data["url"] = miConfig.Url
  5866. // data["ak"] = miConfig.AccessKey
  5867. // data["begin_time"] = begin_time
  5868. // data["cainfo"] = miConfig.Cainfo
  5869. // data["is_vaild"] = "0"
  5870. //
  5871. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5872. // data["config"] = config
  5873. // bytesData, _ := json.Marshal(data)
  5874. //
  5875. // var req *http.Request
  5876. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5877. // resp, _ := client.Do(req)
  5878. // defer resp.Body.Close()
  5879. // body, ioErr := ioutil.ReadAll(resp.Body)
  5880. // if ioErr != nil {
  5881. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5882. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5883. // return
  5884. // }
  5885. // var respJSON map[string]interface{}
  5886. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5887. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5888. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5889. // return
  5890. // }
  5891. //
  5892. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5893. // userJSONBytes, _ := json.Marshal(respJSON)
  5894. // fmt.Println("log")
  5895. // fmt.Println(string(userJSONBytes))
  5896. //
  5897. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5898. // utils.ErrorLog("解析失败:%v", err)
  5899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5900. // return
  5901. // }
  5902. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5903. // res2.Output = ressix10265.Output
  5904. // res2.ErrMsg = ressix10265.ErrMsg
  5905. // res2.Cainfo = ressix10265.Cainfo
  5906. // res2.WarnMsg = ressix10265.WarnMsg
  5907. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5908. // res2.Infcode = infocode
  5909. //
  5910. //}
  5911. func (c *HisApiController) Get4102() {
  5912. order_id, _ := c.GetInt64("order_id")
  5913. admin_user_id, _ := c.GetInt64("admin_user_id")
  5914. stas_type := c.GetString("stas_type")
  5915. order, _ := service.GetHisOrderByIDTwo(order_id)
  5916. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5917. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5918. var pp models.PublicParams
  5919. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5920. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5921. pp.FixmedinsName = miConfig.OrgName
  5922. pp.FixmedinsCode = miConfig.Code
  5923. pp.RequestUrl = miConfig.Url
  5924. pp.Cainfo = miConfig.Cainfo
  5925. pp.SecretKey = miConfig.SecretKey
  5926. pp.AccessKey = miConfig.AccessKey
  5927. pp.OpterName = curRoles.UserName
  5928. if miConfig.MdtrtareaAdmvs == "350500" {
  5929. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5930. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5931. saveLog(result, request, "4102", "清单确认")
  5932. var dat map[string]interface{}
  5933. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5934. fmt.Println(dat)
  5935. } else {
  5936. fmt.Println(err)
  5937. }
  5938. var empty ResultFourteen
  5939. userJSONBytes, _ := json.Marshal(dat)
  5940. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5941. utils.ErrorLog("解析失败:%v", err)
  5942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5943. return
  5944. }
  5945. if empty.Infcode == 0 {
  5946. c.ServeSuccessJSON(map[string]interface{}{
  5947. "msg": "确认成功",
  5948. })
  5949. return
  5950. }
  5951. } else {
  5952. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5953. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5954. result3, request3 := service.Jxyb4105(pp)
  5955. saveLog(result, request, "4102", "清单确认")
  5956. saveLog(result2, request2, "4103", "清单确认")
  5957. saveLog(result3, request3, "4105", "清单统计")
  5958. var dat map[string]interface{}
  5959. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5960. fmt.Println(dat)
  5961. } else {
  5962. fmt.Println(err)
  5963. }
  5964. var empty ResultFourteen
  5965. userJSONBytes, _ := json.Marshal(dat)
  5966. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5967. utils.ErrorLog("解析失败:%v", err)
  5968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5969. return
  5970. }
  5971. if empty.Infcode == 0 {
  5972. c.ServeSuccessJSON(map[string]interface{}{
  5973. "msg": "确认成功",
  5974. })
  5975. return
  5976. }
  5977. }
  5978. }
  5979. // 对账权限查询
  5980. func (c *HisApiController) Get3260() {
  5981. admin_user_id, _ := c.GetInt64("admin_user_id")
  5982. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5983. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5984. var api string
  5985. var res models.JSResult3260
  5986. if miConfig.MdtrtareaAdmvs == "320921" {
  5987. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5988. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5989. } else {
  5990. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5991. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5992. }
  5993. resp, requestErr := http.Get(api)
  5994. if requestErr != nil {
  5995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5996. return
  5997. }
  5998. body, ioErr := ioutil.ReadAll(resp.Body)
  5999. if ioErr != nil {
  6000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6002. return
  6003. }
  6004. var respJSON map[string]interface{}
  6005. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6008. return
  6009. }
  6010. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6011. result, _ := json.Marshal(respJSON)
  6012. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6013. utils.ErrorLog("解析失败:%v", err)
  6014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6015. return
  6016. }
  6017. if res.Infcode == "0" {
  6018. c.ServeSuccessJSON(map[string]interface{}{
  6019. "result": res.Output.Data,
  6020. })
  6021. } else {
  6022. c.ServeSuccessJSON(map[string]interface{}{
  6023. "failed_code": -10,
  6024. "msg": res.ErrMsg,
  6025. })
  6026. return
  6027. }
  6028. }
  6029. func (c *HisApiController) Get3261() {
  6030. admin_user_id, _ := c.GetInt64("admin_user_id")
  6031. //month := c.GetString("month")
  6032. startTime := c.GetString("start_time")
  6033. //endTime, _ := c.GetString("end_time")
  6034. times := strings.Split(startTime, "-")
  6035. stmt_mon := times[0] + times[1]
  6036. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6037. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6038. var api string
  6039. var res models.JSResult3261
  6040. //var res10265 Result5301For10265
  6041. if miConfig.MdtrtareaAdmvs == "320921" {
  6042. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6043. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6044. } else {
  6045. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6046. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6047. }
  6048. resp, requestErr := http.Get(api)
  6049. if requestErr != nil {
  6050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6051. return
  6052. }
  6053. body, ioErr := ioutil.ReadAll(resp.Body)
  6054. if ioErr != nil {
  6055. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6057. return
  6058. }
  6059. var respJSON map[string]interface{}
  6060. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6061. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6063. return
  6064. }
  6065. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6066. result, _ := json.Marshal(respJSON)
  6067. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6068. utils.ErrorLog("解析失败:%v", err)
  6069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6070. return
  6071. }
  6072. if res.Infcode == "0" {
  6073. c.ServeSuccessJSON(map[string]interface{}{
  6074. "result": res.Output,
  6075. })
  6076. } else {
  6077. c.ServeSuccessJSON(map[string]interface{}{
  6078. "failed_code": -10,
  6079. "msg": res.ErrMsg,
  6080. })
  6081. return
  6082. }
  6083. }
  6084. type TempFun struct {
  6085. FundKey string
  6086. FundCode string
  6087. }
  6088. func (c *HisApiController) Get3262() {
  6089. admin_user_id, _ := c.GetInt64("admin_user_id")
  6090. startTime := c.GetString("start_time")
  6091. endTime := c.GetString("end_time")
  6092. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6093. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6094. //timeLayout := "2006-01-02"
  6095. //loc, _ := time.LoadLocation("Local")
  6096. //var theStartTIme int64
  6097. //if len(startTime) > 0 {
  6098. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6099. // if err != nil {
  6100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6101. // return
  6102. // }
  6103. // theStartTIme = theTime.Unix()
  6104. //}
  6105. //var theEndtTIme int64
  6106. //if len(endTime) > 0 {
  6107. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6108. // if err != nil {
  6109. // utils.ErrorLog(err.Error())
  6110. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6111. // return
  6112. // }
  6113. // theEndtTIme = theTime.Unix()
  6114. //}
  6115. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6116. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6117. for _, team := range datas {
  6118. fmt.Println(team.PsnTime)
  6119. for _, team_two := range datas_two {
  6120. fmt.Println(team_two.PsnTime)
  6121. if team.FundKey == team_two.FundKey {
  6122. fmt.Println(team_two.PsnTime)
  6123. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6124. fmt.Println(team.PsnTime)
  6125. }
  6126. }
  6127. }
  6128. fmt.Println("1111")
  6129. fmt.Println(datas)
  6130. fmt.Println("1111")
  6131. var twos []models.FixMonRecDetailFileInTwo
  6132. for _, team := range datas {
  6133. var two models.FixMonRecDetailFileInTwo
  6134. two.MedType = team.MedType
  6135. two.Insutype = team.Insutype
  6136. two.PsnType = team.PsnType
  6137. two.MedType = team.MedType
  6138. two.FixBlngAdmdvs = "999999"
  6139. two.InsuAdmdvs = "555555"
  6140. two.PsnTime = team.PsnTime
  6141. two.PsnCnt = team.PsnCnt
  6142. two.FundKey = team.FundKey
  6143. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6144. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6145. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6146. two.MedfeeSumAmt = ms
  6147. two.InscpAmt = ia
  6148. two.FundPaySumAmt = fps
  6149. twos = append(twos, two)
  6150. }
  6151. //startTime := c.GetString("start_time")
  6152. //endTime, _ := c.GetString("end_time")
  6153. times := strings.Split(startTime, "-")
  6154. stmt_mon := times[0] + times[1]
  6155. var funs []models.FundDetail
  6156. for _, item := range datas {
  6157. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6158. funs = append(funs, fun...)
  6159. }
  6160. var funInfos []models.Fund
  6161. //for _, item := range funs {
  6162. // var rf []models.FundInfo
  6163. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6164. // for _, subitem := range rf {
  6165. // var fund models.Fund
  6166. // fund.FundCode = subitem.FundPayType
  6167. // fund.FundName = subitem.FundPayTypeName
  6168. // fund.FundAmt = subitem.FundPayAmt
  6169. // fund.FundKey = item.FundKey
  6170. // fund.InsuAdmdvs = "555555"
  6171. // fund.FixBlngAdmdvs = "999999"
  6172. // funInfos = append(funInfos, fund)
  6173. // }
  6174. //}
  6175. var tempFuns []TempFun
  6176. for _, funInfo := range funInfos {
  6177. var tempFun TempFun
  6178. tempFun.FundKey = funInfo.FundKey
  6179. tempFun.FundCode = funInfo.FundCode
  6180. tempFuns = append(tempFuns, tempFun)
  6181. }
  6182. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6183. fmt.Println(tempFuns)
  6184. var funInfosTwo []models.Fund
  6185. decimal.DivisionPrecision = 2
  6186. for _, item := range tempFuns {
  6187. var fund models.Fund
  6188. for _, subItem := range funInfos {
  6189. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6190. fund.FundKey = subItem.FundKey
  6191. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6192. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6193. fund.FundName = subItem.FundName
  6194. fund.FundCode = subItem.FundCode
  6195. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6196. }
  6197. }
  6198. funInfosTwo = append(funInfosTwo, fund)
  6199. }
  6200. fmt.Println("funInfosTwo")
  6201. fmt.Println(funInfosTwo)
  6202. var upld_btch string
  6203. var empty models.JSResultEmpty
  6204. data := make(map[string]interface{})
  6205. data["org_name"] = miConfig.OrgName
  6206. data["doctor"] = curRoles.UserName
  6207. data["doctor_name"] = curRoles.UserName
  6208. data["fixmedins_code"] = miConfig.Code
  6209. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6210. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6211. data["secret_key"] = miConfig.SecretKey
  6212. data["url"] = miConfig.Url
  6213. data["ak"] = miConfig.AccessKey
  6214. data["cainfo"] = miConfig.Cainfo
  6215. data["datas"] = twos
  6216. data["fund"] = funInfosTwo
  6217. fmt.Println(twos)
  6218. month := time.Unix(1557042972, 0).Format("1")
  6219. year := time.Now().Format("2006")
  6220. month = time.Now().Format("01")
  6221. day := time.Now().Format("02")
  6222. hour := time.Now().Format("15")
  6223. min := time.Now().Format("04")
  6224. sec := time.Now().Format("05")
  6225. fix_fill_date := year + month + day + hour + min + sec
  6226. data["fix_fill_dept"] = miConfig.OrgName
  6227. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6228. data["fix_fill_psn"] = curRoles.UserName
  6229. data["fix_fill_date"] = fix_fill_date
  6230. data["stmt_loc"] = "2"
  6231. data["setl_mon"] = stmt_mon
  6232. upld_btch = "0"
  6233. data["upld_btch"] = upld_btch
  6234. //fmt.Println(data)
  6235. client := &http.Client{}
  6236. bytesData, _ := json.Marshal(data)
  6237. var req *http.Request
  6238. if miConfig.MdtrtareaAdmvs == "320921" {
  6239. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6240. } else {
  6241. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6242. }
  6243. resp, _ := client.Do(req)
  6244. defer resp.Body.Close()
  6245. body, ioErr := ioutil.ReadAll(resp.Body)
  6246. if ioErr != nil {
  6247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6249. }
  6250. var respJSON map[string]interface{}
  6251. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6254. }
  6255. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6256. //fmt.Println(respJSON)
  6257. result, _ := json.Marshal(respJSON)
  6258. //fmt.Println(result)
  6259. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6260. utils.ErrorLog("解析失败:%v", err)
  6261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6262. }
  6263. if empty.Infcode != "0" {
  6264. c.ServeSuccessJSON(map[string]interface{}{
  6265. "failed_code": -10,
  6266. "msg": empty.ErrMsg,
  6267. })
  6268. return
  6269. } else {
  6270. c.ServeSuccessJSON(map[string]interface{}{
  6271. "msg": "上传成功",
  6272. })
  6273. return
  6274. }
  6275. }
  6276. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6277. newArr = make([]TempFun, 0)
  6278. for i := 0; i < len(arr); i++ {
  6279. repeat := false
  6280. for j := i + 1; j < len(arr); j++ {
  6281. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6282. repeat = true
  6283. break
  6284. }
  6285. }
  6286. if !repeat {
  6287. newArr = append(newArr, arr[i])
  6288. }
  6289. }
  6290. return
  6291. }
  6292. func (c *HisApiController) Get3263() {
  6293. admin_user_id, _ := c.GetInt64("admin_user_id")
  6294. startTime := c.GetString("start_time")
  6295. //endTime, _ := c.GetString("end_time")
  6296. times := strings.Split(startTime, "-")
  6297. setl_mon := times[0] + times[1]
  6298. upld_btch := "0"
  6299. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6300. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6301. var result3263 models.JSResult3263
  6302. data := make(map[string]interface{})
  6303. data["org_name"] = miConfig.OrgName
  6304. data["doctor"] = curRoles.UserName
  6305. data["doctor_name"] = curRoles.UserName
  6306. data["fixmedins_code"] = miConfig.Code
  6307. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6308. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6309. data["secret_key"] = miConfig.SecretKey
  6310. data["url"] = miConfig.Url
  6311. data["ak"] = miConfig.AccessKey
  6312. data["cainfo"] = miConfig.Cainfo
  6313. data["setl_mon"] = setl_mon
  6314. data["stmt_loc"] = "2"
  6315. data["upld_btch"] = upld_btch
  6316. client := &http.Client{}
  6317. bytesData, _ := json.Marshal(data)
  6318. var req *http.Request
  6319. if miConfig.MdtrtareaAdmvs == "320921" {
  6320. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6321. } else {
  6322. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6323. }
  6324. resp, _ := client.Do(req)
  6325. defer resp.Body.Close()
  6326. body, ioErr := ioutil.ReadAll(resp.Body)
  6327. if ioErr != nil {
  6328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6330. }
  6331. var respJSON map[string]interface{}
  6332. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6335. }
  6336. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6337. fmt.Println(respJSON)
  6338. result, _ := json.Marshal(respJSON)
  6339. fmt.Println(result)
  6340. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6341. utils.ErrorLog("解析失败:%v", err)
  6342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6343. }
  6344. if result3263.Infcode != "0" {
  6345. c.ServeSuccessJSON(map[string]interface{}{
  6346. "failed_code": -10,
  6347. "msg": result3263.ErrMsg,
  6348. })
  6349. return
  6350. } else {
  6351. c.ServeSuccessJSON(map[string]interface{}{
  6352. "list": result3263.Output,
  6353. })
  6354. return
  6355. }
  6356. }
  6357. func (c *HisApiController) Get3264() {
  6358. admin_user_id, _ := c.GetInt64("admin_user_id")
  6359. startTime := c.GetString("start_time")
  6360. //endTime, _ := c.GetString("end_time")
  6361. times := strings.Split(startTime, "-")
  6362. setl_mon := times[0] + times[1]
  6363. upld_btch := "0"
  6364. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6365. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6366. //solidify_id := []
  6367. var result3263 models.JSResult3263
  6368. data := make(map[string]interface{})
  6369. data["org_name"] = miConfig.OrgName
  6370. data["doctor"] = curRoles.UserName
  6371. data["doctor_name"] = curRoles.UserName
  6372. data["fixmedins_code"] = miConfig.Code
  6373. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6374. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6375. data["secret_key"] = miConfig.SecretKey
  6376. data["url"] = miConfig.Url
  6377. data["ak"] = miConfig.AccessKey
  6378. data["cainfo"] = miConfig.Cainfo
  6379. data["setl_mon"] = setl_mon
  6380. data["stmt_loc"] = "2"
  6381. data["upld_btch"] = upld_btch
  6382. client := &http.Client{}
  6383. bytesData, _ := json.Marshal(data)
  6384. var req3263 *http.Request
  6385. if miConfig.MdtrtareaAdmvs == "320921" {
  6386. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6387. } else {
  6388. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6389. }
  6390. resp, _ := client.Do(req3263)
  6391. defer resp.Body.Close()
  6392. body, ioErr := ioutil.ReadAll(resp.Body)
  6393. if ioErr != nil {
  6394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6396. }
  6397. var respJSON3263 map[string]interface{}
  6398. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6401. }
  6402. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6403. fmt.Println(respJSON3263)
  6404. result, _ := json.Marshal(respJSON3263)
  6405. fmt.Println(result)
  6406. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6407. utils.ErrorLog("解析失败:%v", err)
  6408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6409. }
  6410. var ids []string
  6411. for _, item := range result3263.Output {
  6412. ids = append(ids, item.SolidifyID)
  6413. }
  6414. var empty models.JSResultEmpty
  6415. data2 := make(map[string]interface{})
  6416. data2["org_name"] = miConfig.OrgName
  6417. data2["doctor"] = curRoles.UserName
  6418. data2["doctor_name"] = curRoles.UserName
  6419. data2["fixmedins_code"] = miConfig.Code
  6420. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6421. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6422. data2["secret_key"] = miConfig.SecretKey
  6423. data2["url"] = miConfig.Url
  6424. data2["ak"] = miConfig.AccessKey
  6425. data2["cainfo"] = miConfig.Cainfo
  6426. data2["setl_mon"] = setl_mon
  6427. data2["stmt_loc"] = "2"
  6428. data2["upld_btch"] = upld_btch
  6429. data2["solidify_id"] = ids
  6430. client2 := &http.Client{}
  6431. bytesData2, _ := json.Marshal(data2)
  6432. var req *http.Request
  6433. if miConfig.MdtrtareaAdmvs == "320921" {
  6434. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6435. } else {
  6436. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6437. }
  6438. resp2, _ := client2.Do(req)
  6439. defer resp.Body.Close()
  6440. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6441. if ioErr2 != nil {
  6442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6444. }
  6445. var respJSON map[string]interface{}
  6446. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6449. }
  6450. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6451. fmt.Println(respJSON)
  6452. result2, _ := json.Marshal(respJSON)
  6453. fmt.Println(result2)
  6454. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6455. utils.ErrorLog("解析失败:%v", err)
  6456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6457. }
  6458. if empty.Infcode != "0" {
  6459. c.ServeSuccessJSON(map[string]interface{}{
  6460. "failed_code": -10,
  6461. "msg": empty.ErrMsg,
  6462. })
  6463. return
  6464. } else {
  6465. c.ServeSuccessJSON(map[string]interface{}{
  6466. "msg": "",
  6467. })
  6468. return
  6469. }
  6470. }
  6471. func (c *HisApiController) Get3265() {
  6472. admin_user_id, _ := c.GetInt64("admin_user_id")
  6473. startTime := c.GetString("start_time")
  6474. //endTime, _ := c.GetString("end_time")
  6475. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6476. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6477. times := strings.Split(startTime, "-")
  6478. setl_mon := times[0] + times[1]
  6479. var upld_btch string
  6480. upld_btch = "0"
  6481. //var empty models.JSResultEmpty
  6482. var result3265 models.JSResult3264
  6483. var result3263 models.JSResult3263
  6484. data2 := make(map[string]interface{})
  6485. data2["org_name"] = miConfig.OrgName
  6486. data2["doctor"] = curRoles.UserName
  6487. data2["doctor_name"] = curRoles.UserName
  6488. data2["fixmedins_code"] = miConfig.Code
  6489. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6490. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6491. data2["secret_key"] = miConfig.SecretKey
  6492. data2["url"] = miConfig.Url
  6493. data2["ak"] = miConfig.AccessKey
  6494. data2["cainfo"] = miConfig.Cainfo
  6495. data2["setl_mon"] = setl_mon
  6496. data2["stmt_loc"] = "2"
  6497. data2["upld_btch"] = upld_btch
  6498. client2 := &http.Client{}
  6499. bytesData2, _ := json.Marshal(data2)
  6500. var req3263 *http.Request
  6501. if miConfig.MdtrtareaAdmvs == "320921" {
  6502. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6503. } else {
  6504. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6505. }
  6506. resp2, _ := client2.Do(req3263)
  6507. defer resp2.Body.Close()
  6508. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6509. if ioErr2 != nil {
  6510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6512. }
  6513. var respJSON3263 map[string]interface{}
  6514. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6517. }
  6518. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6519. fmt.Println(respJSON3263)
  6520. result2, _ := json.Marshal(respJSON3263)
  6521. fmt.Println(result2)
  6522. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6523. utils.ErrorLog("解析失败:%v", err)
  6524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6525. }
  6526. var ids []string
  6527. for _, item := range result3263.Output {
  6528. ids = append(ids, item.SolidifyID)
  6529. }
  6530. data := make(map[string]interface{})
  6531. data["org_name"] = miConfig.OrgName
  6532. data["doctor"] = curRoles.UserName
  6533. data["doctor_name"] = curRoles.UserName
  6534. data["fixmedins_code"] = miConfig.Code
  6535. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6536. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6537. data["secret_key"] = miConfig.SecretKey
  6538. data["url"] = miConfig.Url
  6539. data["ak"] = miConfig.AccessKey
  6540. data["cainfo"] = miConfig.Cainfo
  6541. data["setl_mon"] = setl_mon
  6542. data["solidify_id"] = ids
  6543. month := time.Unix(1557042972, 0).Format("1")
  6544. year := time.Now().Format("2006")
  6545. month = time.Now().Format("01")
  6546. day := time.Now().Format("02")
  6547. hour := time.Now().Format("15")
  6548. min := time.Now().Format("04")
  6549. sec := time.Now().Format("05")
  6550. fix_fill_date := year + month + day + hour + min + sec
  6551. data["fix_fill_dept"] = miConfig.OrgName
  6552. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6553. data["fix_fill_psn"] = curRoles.UserName
  6554. data["fix_fill_date"] = fix_fill_date
  6555. data["stmt_loc"] = "2"
  6556. data["upld_btch"] = upld_btch
  6557. client := &http.Client{}
  6558. bytesData, _ := json.Marshal(data)
  6559. var req *http.Request
  6560. if miConfig.MdtrtareaAdmvs == "320921" {
  6561. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6562. } else {
  6563. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6564. }
  6565. resp, _ := client.Do(req)
  6566. defer resp.Body.Close()
  6567. body, ioErr := ioutil.ReadAll(resp.Body)
  6568. if ioErr != nil {
  6569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6571. }
  6572. var respJSON map[string]interface{}
  6573. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6576. }
  6577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6578. fmt.Println(respJSON)
  6579. result, _ := json.Marshal(respJSON)
  6580. fmt.Println(result)
  6581. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6582. utils.ErrorLog("解析失败:%v", err)
  6583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6584. }
  6585. if result3265.Infcode != "0" {
  6586. c.ServeSuccessJSON(map[string]interface{}{
  6587. "failed_code": -10,
  6588. "msg": result3265.ErrMsg,
  6589. })
  6590. return
  6591. } else {
  6592. c.ServeSuccessJSON(map[string]interface{}{
  6593. "info": result3265.Output,
  6594. })
  6595. return
  6596. }
  6597. }
  6598. func (c *HisApiController) Get3266() {
  6599. admin_user_id, _ := c.GetInt64("admin_user_id")
  6600. startTime := c.GetString("start_time")
  6601. //endTime, _ := c.GetString("end_time")
  6602. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6603. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6604. times := strings.Split(startTime, "-")
  6605. stmt_mon := times[0] + times[1]
  6606. var upld_btch string
  6607. //var empty models.JSResultEmpty
  6608. var result3265 models.JSResult3264
  6609. data := make(map[string]interface{})
  6610. data["org_name"] = miConfig.OrgName
  6611. data["doctor"] = curRoles.UserName
  6612. data["doctor_name"] = curRoles.UserName
  6613. data["fixmedins_code"] = miConfig.Code
  6614. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6615. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6616. data["secret_key"] = miConfig.SecretKey
  6617. data["url"] = miConfig.Url
  6618. data["ak"] = miConfig.AccessKey
  6619. data["cainfo"] = miConfig.Cainfo
  6620. data["setl_mon"] = stmt_mon
  6621. month := time.Unix(1557042972, 0).Format("1")
  6622. year := time.Now().Format("2006")
  6623. month = time.Now().Format("01")
  6624. day := time.Now().Format("02")
  6625. hour := time.Now().Format("15")
  6626. min := time.Now().Format("04")
  6627. sec := time.Now().Format("05")
  6628. fix_fill_date := year + month + day + hour + min + sec
  6629. data["fix_fill_dept"] = miConfig.OrgName
  6630. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6631. data["fix_fill_psn"] = curRoles.UserName
  6632. data["fix_fill_date"] = fix_fill_date
  6633. data["stmt_loc"] = "2"
  6634. upld_btch = "0"
  6635. data["upld_btch"] = upld_btch
  6636. client := &http.Client{}
  6637. bytesData, _ := json.Marshal(data)
  6638. var req *http.Request
  6639. if miConfig.MdtrtareaAdmvs == "320921" {
  6640. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6641. } else {
  6642. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6643. }
  6644. resp, _ := client.Do(req)
  6645. defer resp.Body.Close()
  6646. body, ioErr := ioutil.ReadAll(resp.Body)
  6647. if ioErr != nil {
  6648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6650. }
  6651. var respJSON map[string]interface{}
  6652. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6655. }
  6656. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6657. fmt.Println(respJSON)
  6658. result, _ := json.Marshal(respJSON)
  6659. fmt.Println(result)
  6660. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6661. utils.ErrorLog("解析失败:%v", err)
  6662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6663. }
  6664. if result3265.Infcode != "0" {
  6665. c.ServeSuccessJSON(map[string]interface{}{
  6666. "failed_code": -10,
  6667. "msg": result3265.ErrMsg,
  6668. })
  6669. return
  6670. } else {
  6671. c.ServeSuccessJSON(map[string]interface{}{
  6672. "info": result3265.Output,
  6673. })
  6674. return
  6675. }
  6676. }
  6677. func (c *HisApiController) Get3267() {
  6678. admin_user_id, _ := c.GetInt64("admin_user_id")
  6679. startTime := c.GetString("start_time")
  6680. //endTime, _ := c.GetString("end_time")
  6681. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6682. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6683. times := strings.Split(startTime, "-")
  6684. setl_mon := times[0] + times[1]
  6685. var upld_btch string
  6686. //var empty models.JSResultEmpty
  6687. var result3265 models.JSResult3264
  6688. upld_btch = "0"
  6689. data := make(map[string]interface{})
  6690. data["org_name"] = miConfig.OrgName
  6691. data["doctor"] = curRoles.UserName
  6692. data["doctor_name"] = curRoles.UserName
  6693. data["fixmedins_code"] = miConfig.Code
  6694. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6695. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6696. data["secret_key"] = miConfig.SecretKey
  6697. data["url"] = miConfig.Url
  6698. data["ak"] = miConfig.AccessKey
  6699. data["cainfo"] = miConfig.Cainfo
  6700. data["setl_mon"] = setl_mon
  6701. data["stmt_loc"] = "2"
  6702. data["upld_btch"] = upld_btch
  6703. client := &http.Client{}
  6704. bytesData, _ := json.Marshal(data)
  6705. var req *http.Request
  6706. if miConfig.MdtrtareaAdmvs == "320921" {
  6707. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6708. } else {
  6709. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6710. }
  6711. resp, _ := client.Do(req)
  6712. defer resp.Body.Close()
  6713. body, ioErr := ioutil.ReadAll(resp.Body)
  6714. if ioErr != nil {
  6715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6717. }
  6718. var respJSON map[string]interface{}
  6719. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6722. }
  6723. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6724. fmt.Println(respJSON)
  6725. result, _ := json.Marshal(respJSON)
  6726. fmt.Println(result)
  6727. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6728. utils.ErrorLog("解析失败:%v", err)
  6729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6730. }
  6731. if result3265.Infcode != "0" {
  6732. c.ServeSuccessJSON(map[string]interface{}{
  6733. "failed_code": -10,
  6734. "msg": result3265.ErrMsg,
  6735. })
  6736. return
  6737. } else {
  6738. c.ServeSuccessJSON(map[string]interface{}{
  6739. "info": result3265.Output.Data,
  6740. })
  6741. return
  6742. }
  6743. }
  6744. func (c *HisApiController) Get3268() {
  6745. admin_user_id, _ := c.GetInt64("admin_user_id")
  6746. startTime := c.GetString("start_time")
  6747. endTime := c.GetString("end_time")
  6748. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6749. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6750. times := strings.Split(startTime, "-")
  6751. setl_mon := times[0] + times[1]
  6752. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6753. var twos []models.FixMonRecDetailFileInTwo
  6754. var funs []models.FundDetail
  6755. for _, item := range datas {
  6756. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6757. funs = append(funs, fun...)
  6758. }
  6759. var funInfos []models.Fund
  6760. //for _, item := range funs {
  6761. // var rf []models.FundInfo
  6762. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6763. // for _, subitem := range rf {
  6764. // var fund models.Fund
  6765. // fund.FundCode = subitem.FundPayType
  6766. // fund.FundName = subitem.FundPayTypeName
  6767. // fund.FundAmt = subitem.FundPayAmt
  6768. // fund.FundKey = item.FundKey
  6769. // fund.InsuAdmdvs = "555555"
  6770. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6771. // funInfos = append(funInfos, fund)
  6772. // }
  6773. //}
  6774. for _, team := range datas {
  6775. var two models.FixMonRecDetailFileInTwo
  6776. two.SetlDate = time.Now().Format("2006-01-02")
  6777. two.MedType = team.MedType
  6778. two.Insutype = team.Insutype
  6779. two.PsnType = team.PsnType
  6780. two.MedType = team.MedType
  6781. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6782. two.InsuAdmdvs = team.InsuAdmdvs
  6783. two.PsnTime = team.PsnTime
  6784. two.PsnCnt = team.PsnCnt
  6785. two.FundKey = team.FundKey
  6786. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6787. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6788. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6789. two.MedfeeSumAmt = ms
  6790. two.InscpAmt = ia
  6791. two.FundPaySumAmt = fps
  6792. twos = append(twos, two)
  6793. }
  6794. var upld_btch string
  6795. upld_btch = "0"
  6796. var empty models.JSResultEmpty
  6797. data := make(map[string]interface{})
  6798. data["org_name"] = miConfig.OrgName
  6799. data["doctor"] = curRoles.UserName
  6800. data["doctor_name"] = curRoles.UserName
  6801. data["fixmedins_code"] = miConfig.Code
  6802. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6803. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6804. data["secret_key"] = miConfig.SecretKey
  6805. data["url"] = miConfig.Url
  6806. data["ak"] = miConfig.AccessKey
  6807. data["cainfo"] = miConfig.Cainfo
  6808. data["datas"] = twos
  6809. data["fund"] = funInfos
  6810. data["setl_mon"] = setl_mon
  6811. month := time.Unix(1557042972, 0).Format("1")
  6812. year := time.Now().Format("2006")
  6813. month = time.Now().Format("01")
  6814. day := time.Now().Format("02")
  6815. hour := time.Now().Format("15")
  6816. min := time.Now().Format("04")
  6817. sec := time.Now().Format("05")
  6818. fix_fill_date := year + month + day + hour + min + sec
  6819. data["fix_fill_dept"] = miConfig.OrgName
  6820. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6821. data["fix_fill_psn"] = curRoles.UserName
  6822. data["fix_fill_date"] = fix_fill_date
  6823. data["stmt_loc"] = "2"
  6824. data["upld_btch"] = upld_btch
  6825. client := &http.Client{}
  6826. bytesData, _ := json.Marshal(data)
  6827. var req *http.Request
  6828. if miConfig.MdtrtareaAdmvs == "320921" {
  6829. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6830. } else {
  6831. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6832. }
  6833. resp, _ := client.Do(req)
  6834. defer resp.Body.Close()
  6835. body, ioErr := ioutil.ReadAll(resp.Body)
  6836. if ioErr != nil {
  6837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6839. }
  6840. var respJSON map[string]interface{}
  6841. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6844. }
  6845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6846. fmt.Println(respJSON)
  6847. result, _ := json.Marshal(respJSON)
  6848. fmt.Println(result)
  6849. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6850. utils.ErrorLog("解析失败:%v", err)
  6851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6852. }
  6853. if empty.Infcode != "0" {
  6854. c.ServeSuccessJSON(map[string]interface{}{
  6855. "failed_code": -10,
  6856. "msg": empty.ErrMsg,
  6857. })
  6858. return
  6859. } else {
  6860. c.ServeSuccessJSON(map[string]interface{}{
  6861. "msg": "上传成功",
  6862. })
  6863. return
  6864. }
  6865. }
  6866. func (c *HisApiController) Get3269() {
  6867. admin_user_id, _ := c.GetInt64("admin_user_id")
  6868. startTime := c.GetString("start_time")
  6869. //endTime, _ := c.GetString("end_time")
  6870. times := strings.Split(startTime, "-")
  6871. setl_mon := times[0] + times[1]
  6872. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6873. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6874. var result3263 models.JSResult3263
  6875. data := make(map[string]interface{})
  6876. data["org_name"] = miConfig.OrgName
  6877. data["doctor"] = curRoles.UserName
  6878. data["doctor_name"] = curRoles.UserName
  6879. data["fixmedins_code"] = miConfig.Code
  6880. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6881. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6882. data["secret_key"] = miConfig.SecretKey
  6883. data["url"] = miConfig.Url
  6884. data["ak"] = miConfig.AccessKey
  6885. data["cainfo"] = miConfig.Cainfo
  6886. data["setl_mon"] = setl_mon
  6887. data["stmt_loc"] = "2"
  6888. client := &http.Client{}
  6889. bytesData, _ := json.Marshal(data)
  6890. var req *http.Request
  6891. if miConfig.MdtrtareaAdmvs == "320921" {
  6892. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6893. } else {
  6894. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6895. }
  6896. resp, _ := client.Do(req)
  6897. defer resp.Body.Close()
  6898. body, ioErr := ioutil.ReadAll(resp.Body)
  6899. if ioErr != nil {
  6900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6902. }
  6903. var respJSON map[string]interface{}
  6904. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6907. }
  6908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6909. fmt.Println(respJSON)
  6910. result, _ := json.Marshal(respJSON)
  6911. fmt.Println(result)
  6912. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6913. utils.ErrorLog("解析失败:%v", err)
  6914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6915. }
  6916. if result3263.Infcode != "0" {
  6917. c.ServeSuccessJSON(map[string]interface{}{
  6918. "failed_code": -10,
  6919. "msg": result3263.ErrMsg,
  6920. })
  6921. return
  6922. } else {
  6923. c.ServeSuccessJSON(map[string]interface{}{
  6924. "msg": "上传成功",
  6925. })
  6926. return
  6927. }
  6928. }
  6929. func (c *HisApiController) Get3270() {
  6930. admin_user_id, _ := c.GetInt64("admin_user_id")
  6931. startTime := c.GetString("start_time")
  6932. //endTime, _ := c.GetString("end_time")
  6933. times := strings.Split(startTime, "-")
  6934. setl_mon := times[0] + times[1]
  6935. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6936. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6937. var result3263 models.JSResult3263
  6938. data2 := make(map[string]interface{})
  6939. data2["org_name"] = miConfig.OrgName
  6940. data2["doctor"] = curRoles.UserName
  6941. data2["doctor_name"] = curRoles.UserName
  6942. data2["fixmedins_code"] = miConfig.Code
  6943. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6944. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6945. data2["secret_key"] = miConfig.SecretKey
  6946. data2["url"] = miConfig.Url
  6947. data2["ak"] = miConfig.AccessKey
  6948. data2["cainfo"] = miConfig.Cainfo
  6949. data2["setl_mon"] = setl_mon
  6950. data2["stmt_loc"] = "2"
  6951. client2 := &http.Client{}
  6952. bytesData2, _ := json.Marshal(data2)
  6953. var req3263 *http.Request
  6954. if miConfig.MdtrtareaAdmvs == "320921" {
  6955. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6956. } else {
  6957. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6958. }
  6959. resp2, _ := client2.Do(req3263)
  6960. defer resp2.Body.Close()
  6961. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6962. if ioErr2 != nil {
  6963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6965. }
  6966. var respJSON3263 map[string]interface{}
  6967. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6970. }
  6971. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6972. fmt.Println(respJSON3263)
  6973. result2, _ := json.Marshal(respJSON3263)
  6974. fmt.Println(result2)
  6975. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6976. utils.ErrorLog("解析失败:%v", err)
  6977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6978. }
  6979. var ids []string
  6980. for _, item := range result3263.Output {
  6981. ids = append(ids, item.SolidifyID)
  6982. }
  6983. var result3264 models.JSResult3264
  6984. data := make(map[string]interface{})
  6985. data["org_name"] = miConfig.OrgName
  6986. data["doctor"] = curRoles.UserName
  6987. data["doctor_name"] = curRoles.UserName
  6988. data["fixmedins_code"] = miConfig.Code
  6989. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6990. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6991. data["secret_key"] = miConfig.SecretKey
  6992. data["url"] = miConfig.Url
  6993. data["ak"] = miConfig.AccessKey
  6994. data["cainfo"] = miConfig.Cainfo
  6995. data["setl_mon"] = setl_mon
  6996. data["stmt_loc"] = "2"
  6997. data["solidify_id"] = ids
  6998. client := &http.Client{}
  6999. bytesData, _ := json.Marshal(data)
  7000. var req *http.Request
  7001. if miConfig.MdtrtareaAdmvs == "320921" {
  7002. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7003. } else {
  7004. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7005. }
  7006. resp, _ := client.Do(req)
  7007. defer resp.Body.Close()
  7008. body, ioErr := ioutil.ReadAll(resp.Body)
  7009. if ioErr != nil {
  7010. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7012. }
  7013. var respJSON map[string]interface{}
  7014. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7017. }
  7018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7019. fmt.Println(respJSON)
  7020. result, _ := json.Marshal(respJSON)
  7021. fmt.Println(result)
  7022. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7023. utils.ErrorLog("解析失败:%v", err)
  7024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7025. }
  7026. if result3264.Infcode != "0" {
  7027. c.ServeSuccessJSON(map[string]interface{}{
  7028. "failed_code": -10,
  7029. "msg": result3264.ErrMsg,
  7030. })
  7031. return
  7032. } else {
  7033. c.ServeSuccessJSON(map[string]interface{}{
  7034. "info": result3264.Output,
  7035. })
  7036. return
  7037. }
  7038. }
  7039. func (c *HisApiController) Get3271() {
  7040. admin_user_id, _ := c.GetInt64("admin_user_id")
  7041. startTime := c.GetString("start_time")
  7042. //endTime, _ := c.GetString("end_time")
  7043. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7044. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7045. times := strings.Split(startTime, "-")
  7046. setl_mon := times[0] + times[1]
  7047. //var empty models.JSResultEmpty
  7048. var result3265 models.JSResult3264
  7049. var result3263 models.JSResult3263
  7050. data2 := make(map[string]interface{})
  7051. data2["org_name"] = miConfig.OrgName
  7052. data2["doctor"] = curRoles.UserName
  7053. data2["doctor_name"] = curRoles.UserName
  7054. data2["fixmedins_code"] = miConfig.Code
  7055. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7056. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7057. data2["secret_key"] = miConfig.SecretKey
  7058. data2["url"] = miConfig.Url
  7059. data2["ak"] = miConfig.AccessKey
  7060. data2["cainfo"] = miConfig.Cainfo
  7061. data2["setl_mon"] = setl_mon
  7062. data2["stmt_loc"] = "2"
  7063. client2 := &http.Client{}
  7064. bytesData2, _ := json.Marshal(data2)
  7065. var req3263 *http.Request
  7066. if miConfig.MdtrtareaAdmvs == "320921" {
  7067. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7068. } else {
  7069. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7070. }
  7071. resp2, _ := client2.Do(req3263)
  7072. defer resp2.Body.Close()
  7073. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7074. if ioErr2 != nil {
  7075. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7077. }
  7078. var respJSON3263 map[string]interface{}
  7079. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7082. }
  7083. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7084. fmt.Println(respJSON3263)
  7085. result2, _ := json.Marshal(respJSON3263)
  7086. fmt.Println(result2)
  7087. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7088. utils.ErrorLog("解析失败:%v", err)
  7089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7090. }
  7091. var ids []string
  7092. for _, item := range result3263.Output {
  7093. ids = append(ids, item.SolidifyID)
  7094. }
  7095. data := make(map[string]interface{})
  7096. data["org_name"] = miConfig.OrgName
  7097. data["doctor"] = curRoles.UserName
  7098. data["doctor_name"] = curRoles.UserName
  7099. data["fixmedins_code"] = miConfig.Code
  7100. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7101. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7102. data["secret_key"] = miConfig.SecretKey
  7103. data["url"] = miConfig.Url
  7104. data["ak"] = miConfig.AccessKey
  7105. data["cainfo"] = miConfig.Cainfo
  7106. data["setl_mon"] = setl_mon
  7107. data["solidify_id"] = ids
  7108. month := time.Unix(1557042972, 0).Format("1")
  7109. year := time.Now().Format("2006")
  7110. month = time.Now().Format("01")
  7111. day := time.Now().Format("02")
  7112. hour := time.Now().Format("15")
  7113. min := time.Now().Format("04")
  7114. sec := time.Now().Format("05")
  7115. fix_fill_date := year + month + day + hour + min + sec
  7116. data["fix_fill_dept"] = miConfig.OrgName
  7117. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7118. data["fix_fill_psn"] = curRoles.UserName
  7119. data["fix_fill_date"] = fix_fill_date
  7120. data["stmt_loc"] = "2"
  7121. client := &http.Client{}
  7122. bytesData, _ := json.Marshal(data)
  7123. var req *http.Request
  7124. if miConfig.MdtrtareaAdmvs == "320921" {
  7125. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7126. } else {
  7127. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7128. }
  7129. resp, _ := client.Do(req)
  7130. defer resp.Body.Close()
  7131. body, ioErr := ioutil.ReadAll(resp.Body)
  7132. if ioErr != nil {
  7133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7135. }
  7136. var respJSON map[string]interface{}
  7137. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7140. }
  7141. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7142. fmt.Println(respJSON)
  7143. result, _ := json.Marshal(respJSON)
  7144. fmt.Println(result)
  7145. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7146. utils.ErrorLog("解析失败:%v", err)
  7147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7148. }
  7149. if result3265.Infcode != "0" {
  7150. c.ServeSuccessJSON(map[string]interface{}{
  7151. "failed_code": -10,
  7152. "msg": result3265.ErrMsg,
  7153. })
  7154. return
  7155. } else {
  7156. c.ServeSuccessJSON(map[string]interface{}{
  7157. "info": result3265.Output.Data,
  7158. })
  7159. return
  7160. }
  7161. }
  7162. func (c *HisApiController) Get3272() {
  7163. admin_user_id, _ := c.GetInt64("admin_user_id")
  7164. startTime := c.GetString("start_time")
  7165. //endTime, _ := c.GetString("end_time")
  7166. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7167. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7168. times := strings.Split(startTime, "-")
  7169. setl_mon := times[0] + times[1]
  7170. var upld_btch string
  7171. //var empty models.JSResultEmpty
  7172. var result3265 models.JSResult3264
  7173. data := make(map[string]interface{})
  7174. data["org_name"] = miConfig.OrgName
  7175. data["doctor"] = curRoles.UserName
  7176. data["doctor_name"] = curRoles.UserName
  7177. data["fixmedins_code"] = miConfig.Code
  7178. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7179. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7180. data["secret_key"] = miConfig.SecretKey
  7181. data["url"] = miConfig.Url
  7182. data["ak"] = miConfig.AccessKey
  7183. data["cainfo"] = miConfig.Cainfo
  7184. data["setl_mon"] = setl_mon
  7185. month := time.Unix(1557042972, 0).Format("1")
  7186. year := time.Now().Format("2006")
  7187. month = time.Now().Format("01")
  7188. day := time.Now().Format("02")
  7189. hour := time.Now().Format("15")
  7190. min := time.Now().Format("04")
  7191. sec := time.Now().Format("05")
  7192. fix_fill_date := year + month + day + hour + min + sec
  7193. data["fix_fill_dept"] = miConfig.OrgName
  7194. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7195. data["fix_fill_psn"] = curRoles.UserName
  7196. data["fix_fill_date"] = fix_fill_date
  7197. data["stmt_loc"] = "2"
  7198. data["upld_btch"] = upld_btch
  7199. client := &http.Client{}
  7200. bytesData, _ := json.Marshal(data)
  7201. var req *http.Request
  7202. if miConfig.MdtrtareaAdmvs == "320921" {
  7203. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7204. } else {
  7205. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7206. }
  7207. resp, _ := client.Do(req)
  7208. defer resp.Body.Close()
  7209. body, ioErr := ioutil.ReadAll(resp.Body)
  7210. if ioErr != nil {
  7211. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7213. }
  7214. var respJSON map[string]interface{}
  7215. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7218. }
  7219. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7220. fmt.Println(respJSON)
  7221. result, _ := json.Marshal(respJSON)
  7222. fmt.Println(result)
  7223. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7224. utils.ErrorLog("解析失败:%v", err)
  7225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7226. }
  7227. if result3265.Infcode != "0" {
  7228. c.ServeSuccessJSON(map[string]interface{}{
  7229. "failed_code": -10,
  7230. "msg": result3265.ErrMsg,
  7231. })
  7232. return
  7233. } else {
  7234. c.ServeSuccessJSON(map[string]interface{}{
  7235. "info": result3265.Output,
  7236. })
  7237. return
  7238. }
  7239. }
  7240. func (c *HisApiController) Get3273() {
  7241. admin_user_id, _ := c.GetInt64("admin_user_id")
  7242. startTime := c.GetString("start_time")
  7243. //endTime, _ := c.GetString("end_time")
  7244. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7245. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7246. times := strings.Split(startTime, "-")
  7247. setl_mon := times[0] + times[1]
  7248. var result3265 models.JSResult3264
  7249. data := make(map[string]interface{})
  7250. data["org_name"] = miConfig.OrgName
  7251. data["doctor"] = curRoles.UserName
  7252. data["doctor_name"] = curRoles.UserName
  7253. data["fixmedins_code"] = miConfig.Code
  7254. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7255. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7256. data["secret_key"] = miConfig.SecretKey
  7257. data["url"] = miConfig.Url
  7258. data["ak"] = miConfig.AccessKey
  7259. data["cainfo"] = miConfig.Cainfo
  7260. data["setl_mon"] = setl_mon
  7261. data["stmt_loc"] = "2"
  7262. client := &http.Client{}
  7263. bytesData, _ := json.Marshal(data)
  7264. var req *http.Request
  7265. if miConfig.MdtrtareaAdmvs == "320921" {
  7266. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7267. } else {
  7268. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7269. }
  7270. resp, _ := client.Do(req)
  7271. defer resp.Body.Close()
  7272. body, ioErr := ioutil.ReadAll(resp.Body)
  7273. if ioErr != nil {
  7274. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7276. }
  7277. var respJSON map[string]interface{}
  7278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7281. }
  7282. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7283. fmt.Println(respJSON)
  7284. result, _ := json.Marshal(respJSON)
  7285. fmt.Println(result)
  7286. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7287. utils.ErrorLog("解析失败:%v", err)
  7288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7289. }
  7290. if result3265.Infcode != "0" {
  7291. c.ServeSuccessJSON(map[string]interface{}{
  7292. "failed_code": -10,
  7293. "msg": result3265.ErrMsg,
  7294. })
  7295. return
  7296. } else {
  7297. c.ServeSuccessJSON(map[string]interface{}{
  7298. "info": result3265.Output.Data,
  7299. })
  7300. return
  7301. }
  7302. }
  7303. func (c *HisApiController) Get3274() {
  7304. //if miConfig.MdtrtareaAdmvs == "320921" {
  7305. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7306. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7307. // "&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
  7308. //
  7309. //} else {
  7310. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7311. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7312. // "&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
  7313. //
  7314. //}
  7315. }
  7316. func (c *HisApiController) Get3275() {
  7317. //if miConfig.MdtrtareaAdmvs == "320921" {
  7318. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7319. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7320. // "&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
  7321. //
  7322. //} else {
  7323. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7324. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7325. // "&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
  7326. //
  7327. //}
  7328. }
  7329. func (c *HisApiController) Get3276() {
  7330. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7331. //month := c.GetString("month")
  7332. //
  7333. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7334. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7335. //var api string
  7336. //var res Result5301
  7337. //
  7338. //if miConfig.MdtrtareaAdmvs == "320921" {
  7339. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7340. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7341. //} else {
  7342. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7343. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7344. //}
  7345. //
  7346. //resp, requestErr := http.Get(api)
  7347. //if requestErr != nil {
  7348. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7349. // return
  7350. //}
  7351. //
  7352. //body, ioErr := ioutil.ReadAll(resp.Body)
  7353. //if ioErr != nil {
  7354. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7355. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7356. // return
  7357. //}
  7358. //var respJSON map[string]interface{}
  7359. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7360. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7362. // return
  7363. //}
  7364. //
  7365. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7366. //result, _ := json.Marshal(respJSON)
  7367. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7368. // utils.ErrorLog("解析失败:%v", err)
  7369. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7370. // return
  7371. //}
  7372. }
  7373. func (c *HisApiController) Get3277() {
  7374. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7375. //month := c.GetString("month")
  7376. //
  7377. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7378. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7379. //var api string
  7380. //var res Result5301
  7381. //
  7382. //if miConfig.MdtrtareaAdmvs == "320921" {
  7383. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7384. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7385. //} else {
  7386. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7387. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7388. //}
  7389. //
  7390. //resp, requestErr := http.Get(api)
  7391. //if requestErr != nil {
  7392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7393. // return
  7394. //}
  7395. //
  7396. //body, ioErr := ioutil.ReadAll(resp.Body)
  7397. //if ioErr != nil {
  7398. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7399. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7400. // return
  7401. //}
  7402. //var respJSON map[string]interface{}
  7403. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7404. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7405. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7406. // return
  7407. //}
  7408. //
  7409. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7410. //result, _ := json.Marshal(respJSON)
  7411. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7412. // utils.ErrorLog("解析失败:%v", err)
  7413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7414. // return
  7415. //}
  7416. }
  7417. func (c *HisApiController) GetCFYLJG001() {
  7418. admin_user_id, _ := c.GetInt64("admin_user_id")
  7419. patient_id, _ := c.GetInt64("patient_id")
  7420. his_patient_id, _ := c.GetInt64("his_patient_id")
  7421. record_time := c.GetString("record_time")
  7422. admin_user_id = 3626
  7423. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7424. psn, _ := service.GetPsnByPatientId(patient_id)
  7425. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7426. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7427. var cFYLJG001 models.CFYLJG001
  7428. timeLayout := "2006-01-02"
  7429. loc, _ := time.LoadLocation("Local")
  7430. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7431. if err != nil {
  7432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7433. return
  7434. }
  7435. recordDateTime := theTime.Unix()
  7436. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7437. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7438. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7439. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7440. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7441. for _, item := range prescriptions {
  7442. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7443. if his.IdCardType == 1 {
  7444. bas := strings.Split(psn.CardInfo, "|")
  7445. basNumber := bas[1]
  7446. fmt.Println(basNumber)
  7447. card_sn := bas[3]
  7448. card_no := bas[2]
  7449. cFYLJG001.MdtrtCertType = "03"
  7450. cFYLJG001.CardSn = card_sn
  7451. cFYLJG001.MdtrtCertNo = card_no
  7452. cFYLJG001.EcToken = ""
  7453. cFYLJG001.AuthNo = ""
  7454. } else if his.IdCardType == 2 {
  7455. cFYLJG001.MdtrtCertType = "02"
  7456. cFYLJG001.CardSn = ""
  7457. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7458. cFYLJG001.EcToken = ""
  7459. cFYLJG001.AuthNo = ""
  7460. } else if his.IdCardType == 4 {
  7461. cFYLJG001.MdtrtCertType = "01"
  7462. cFYLJG001.CardSn = ""
  7463. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7464. cFYLJG001.EcToken = psn.VerifyNumber
  7465. cFYLJG001.AuthNo = ""
  7466. }
  7467. cFYLJG001.BizTypeCode = "01"
  7468. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7469. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7470. cFYLJG001.RxTypeCode = "1"
  7471. tempTime := time.Unix(item.PreTime, 0)
  7472. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7473. cFYLJG001.PrscTime = timeFormatOne
  7474. var count float64
  7475. if item.Type == 1 {
  7476. for _, sumItem := range item.HisDoctorAdviceInfo {
  7477. count = count + sumItem.PrescribingNumber
  7478. }
  7479. }
  7480. cFYLJG001.RxDrugCnt = count
  7481. cFYLJG001.ValiDays = "5"
  7482. ts := time.Unix(item.PreTime, 0)
  7483. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7484. tempTime3 := time.Unix(record_time2, 0)
  7485. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7486. cFYLJG001.ValiEndTime = timeFormat3
  7487. cFYLJG001.RxCotnFlag = "0"
  7488. for _, subItem := range item.HisDoctorAdviceInfo {
  7489. var drug models.RxDrug
  7490. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7491. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7492. drug.RxItemTypeCode = "11"
  7493. drug.DrugDosform = "乳膏剂" //TODO
  7494. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7495. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7496. }
  7497. drug.MedcWayDscr = subItem.DeliveryWay
  7498. tempTime2 := time.Unix(subItem.StartTime, 0)
  7499. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7500. drug.MedcBegntime = timeFormatTwo
  7501. if subItem.Day > 0 {
  7502. ts := time.Unix(subItem.StartTime, 0)
  7503. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7504. tempTime4 := time.Unix(record_time, 0)
  7505. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7506. drug.MedcEndtime = timeFormat5
  7507. } else {
  7508. tempTime2 := time.Unix(subItem.StartTime, 0)
  7509. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7510. drug.MedcEndtime = timeFormatTwo
  7511. }
  7512. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7513. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7514. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7515. drug.DrugCnt = subItem.PrescribingNumber
  7516. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7517. drug.DrugGenname = subItem.AdviceName
  7518. drug.MedcWayCodg = subItem.DeliveryWay
  7519. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7520. drug.SinDoscnt = subItem.SingleDose
  7521. drug.SinDosunt = subItem.SingleDoseUnit
  7522. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7523. drug.UsedFrquName = subItem.ExecutionFrequency
  7524. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7525. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7526. drug.HospApprFlag = "1"
  7527. cFYLJG001.List = append(cFYLJG001.List, drug)
  7528. }
  7529. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7530. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7531. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7532. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7533. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7534. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7535. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7536. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7537. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7538. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7539. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7540. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7541. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7542. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7543. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7544. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7545. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7546. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7547. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7548. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7549. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7550. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7551. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7552. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7553. tempTime2 := time.Now().Unix()
  7554. tempTime6 := time.Unix(tempTime2, 0)
  7555. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7556. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7557. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7558. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7559. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7560. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7561. //memo := make(map[string]interface{})
  7562. //inputData := make(map[string]interface{}, 0)
  7563. //type MyData struct {
  7564. // Insutype string `json:"insutype"`
  7565. //}
  7566. //
  7567. // data := MyData{
  7568. // Insutype: his.Insutype,
  7569. //}
  7570. //
  7571. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7572. var config []*models.HisXtDiagnoseConfig
  7573. for _, item := range diagnosis_ids {
  7574. id, _ := strconv.ParseInt(item, 10, 64)
  7575. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7576. config = append(config, &diagnosisConfig)
  7577. }
  7578. for index, subitem := range config {
  7579. if index == 0 {
  7580. var dia models.DiseInfo
  7581. dia.DiagType = "1"
  7582. dia.MaindiagFlag = "1"
  7583. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7584. dia.DiagCode = subitem.CountryCode
  7585. dia.DiagName = subitem.ClassName
  7586. dia.DiagDept = "肾内科"
  7587. dia.DiagDrNo = doctor.DoctorNumber
  7588. dia.DiagDrName = doctor.UserName
  7589. tempTime3 := time.Unix(item.PreTime, 0)
  7590. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7591. dia.DiagTime = timeFormatTwo
  7592. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7593. } else {
  7594. var dia models.DiseInfo
  7595. dia.DiagType = "1"
  7596. dia.MaindiagFlag = "0"
  7597. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7598. dia.DiagCode = subitem.CountryCode
  7599. dia.DiagName = subitem.ClassName
  7600. dia.DiagDept = "肾内科"
  7601. dia.DiagDrNo = doctor.DoctorNumber
  7602. dia.DiagDrName = doctor.UserName
  7603. tempTime3 := time.Unix(item.PreTime, 0)
  7604. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7605. dia.DiagTime = timeFormatTwo
  7606. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7607. }
  7608. }
  7609. if miConfig.MdtrtareaAdmvs == "340699" {
  7610. result, request := service.GetAHCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7611. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7612. } else {
  7613. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7614. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7615. }
  7616. var res ResultCFYLJG001
  7617. var respJSON2 map[string]interface{}
  7618. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7621. return
  7622. }
  7623. userJSONBytes2, _ := json.Marshal(respJSON2)
  7624. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7625. utils.ErrorLog("解析失败:%v", err)
  7626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7627. return
  7628. }
  7629. if res.Infcode == -1 {
  7630. c.ServeSuccessJSON(map[string]interface{}{
  7631. "failed_code": -10,
  7632. "msg": res.ErrMsg,
  7633. })
  7634. return
  7635. } else {
  7636. var flow models.HisPrescriptionFlow
  7637. flow.Ctime = time.Now().Unix()
  7638. flow.SignDigest = ""
  7639. flow.RxTraceCode = res.Output.RxTraceCode
  7640. flow.HiRxno = res.Output.HiRxno
  7641. flow.MID = his.Number
  7642. flow.Status = 1
  7643. flow.DCode = doctor_info.DoctorNumber
  7644. flow.OriginalRxFile = ""
  7645. flow.OriginalValue = ""
  7646. flow.SignCertDn = ""
  7647. flow.UserOrgId = 10454
  7648. flow.SignCertSn = ""
  7649. flow.Mtime = time.Now().Unix()
  7650. service.Createflow(&flow)
  7651. c.ServeSuccessJSON(map[string]interface{}{
  7652. "msg": "上传成功",
  7653. })
  7654. }
  7655. }
  7656. }
  7657. func (c *HisApiController) GetCFYLJG002() {
  7658. admin_user_id, _ := c.GetInt64("admin_user_id")
  7659. his_patient_id, _ := c.GetInt64("his_patient_id")
  7660. record_time := c.GetString("record_time")
  7661. admin_user_id = 3626
  7662. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7663. //id, _ := c.GetInt64("id")
  7664. admin_user_id = 3626
  7665. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7666. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7667. flow, _ := service.Getflowtwo(his.Number)
  7668. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7669. //record_time := c.GetString("record_time")
  7670. patient_id, _ := c.GetInt64("patient_id")
  7671. //patient_id = 23834
  7672. //record_time = "2023-09-18"
  7673. timeLayout := "2006-01-02"
  7674. loc, _ := time.LoadLocation("Local")
  7675. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7676. if err != nil {
  7677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7678. return
  7679. }
  7680. recordDateTime := theTime.Unix()
  7681. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7682. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7683. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7684. dept, _ := service.GetDepartMentDetail(info.Departments)
  7685. inputData := make(map[string]interface{})
  7686. inputData["rxTraceCode"] = flow.RxTraceCode
  7687. inputData["hiRxno"] = flow.HiRxno
  7688. inputData["mdtrtId"] = flow.MID
  7689. inputData["patnName"] = his.PsnName
  7690. inputData["psnCertType"] = his.PsnCertType
  7691. inputData["certno"] = his.Certno
  7692. inputData["fixmedinsName"] = miConfig.OrgName
  7693. inputData["fixmedinsCode"] = miConfig.Code
  7694. inputData["drCode"] = doctor_info.DoctorNumber
  7695. inputData["prscDrName"] = doctor_info.UserName
  7696. inputData["pharDeptName"] = dept.Name
  7697. inputData["pharDeptCode"] = dept.Number
  7698. inputData["pharProfttlCodg"] = dept.Name
  7699. inputData["pharProfttlName"] = ""
  7700. inputData["pharCode"] = "HY440309002107"
  7701. inputData["pharCertType"] = "01"
  7702. inputData["pharCertno"] = "430482199408260023"
  7703. inputData["pharName"] = "彭斯遥"
  7704. inputData["pharPracCertNo"] = ""
  7705. tempTime2 := time.Unix(info.Ctime, 0)
  7706. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7707. inputData["pharChkTime"] = timeFormatTwo
  7708. bytesData, _ := json.Marshal(inputData)
  7709. fmt.Println(string(bytesData))
  7710. encoded := base64.StdEncoding.EncodeToString(bytesData)
  7711. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7712. if err != nil {
  7713. fmt.Println("Error reading PDF file:", err)
  7714. return
  7715. }
  7716. // 将 PDF 文件内容进行 Base64 编码
  7717. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7718. fmt.Println(err)
  7719. if miConfig.MdtrtareaAdmvs == "340699" {
  7720. result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7721. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7722. } else {
  7723. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7724. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7725. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7726. }
  7727. var res2 Result002
  7728. var respJSON2 map[string]interface{}
  7729. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7732. return
  7733. }
  7734. userJSONBytes2, _ := json.Marshal(respJSON2)
  7735. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7736. utils.ErrorLog("解析失败:%v", err)
  7737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7738. return
  7739. }
  7740. if res2.Infcode == 0 {
  7741. flow.Ctime = time.Now().Unix()
  7742. flow.SignDigest = res2.Output.SignDigest
  7743. flow.RxFile = res2.Output.RxFile
  7744. flow.MID = his.Number
  7745. flow.Status = 1
  7746. flow.DCode = doctor_info.DoctorNumber
  7747. flow.OriginalRxFile = rx_encoded
  7748. flow.OriginalValue = encoded
  7749. flow.SignCertDn = res2.Output.SignCertDn
  7750. flow.SignCertSn = res2.Output.SignCertSn
  7751. flow.Mtime = time.Now().Unix()
  7752. service.Saveflow(flow)
  7753. c.ServeSuccessJSON(map[string]interface{}{
  7754. "msg": "预签名成功",
  7755. })
  7756. } else {
  7757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7758. return
  7759. }
  7760. }
  7761. func (c *HisApiController) GetCFYLJG003() {
  7762. admin_user_id, _ := c.GetInt64("admin_user_id")
  7763. his_patient_id, _ := c.GetInt64("his_patient_id")
  7764. record_time := c.GetString("record_time")
  7765. admin_user_id = 3626
  7766. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7767. //id, _ := c.GetInt64("id")
  7768. admin_user_id = 3626
  7769. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7770. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7771. flow, _ := service.Getflowtwo(his.Number)
  7772. //id = 3
  7773. patient_id, _ := c.GetInt64("patient_id")
  7774. //patient_id = 23834
  7775. //record_time = "2023-09-18"
  7776. timeLayout := "2006-01-02"
  7777. loc, _ := time.LoadLocation("Local")
  7778. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7779. if err != nil {
  7780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7781. return
  7782. }
  7783. recordDateTime := theTime.Unix()
  7784. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7785. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7786. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7787. dept, _ := service.GetDepartMentDetail(info.Departments)
  7788. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7789. var cFYLJG003 models.CFYLJG003
  7790. cFYLJG003.RxTraceCode = flow.RxTraceCode
  7791. cFYLJG003.HiRxno = flow.HiRxno
  7792. cFYLJG003.MdtrtID = flow.MID
  7793. cFYLJG003.PatnName = his.Name
  7794. cFYLJG003.Certno = his.Certno
  7795. cFYLJG003.FixmedinsName = miConfig.OrgName
  7796. cFYLJG003.FixmedinsCode = miConfig.Code
  7797. cFYLJG003.DrCode = doctor_info.DoctorNumber
  7798. cFYLJG003.PrscDrName = doctor_info.UserName
  7799. cFYLJG003.PharDeptName = dept.Name
  7800. cFYLJG003.PharDeptCode = dept.Number
  7801. cFYLJG003.PharCode = "HY440309002107"
  7802. cFYLJG003.PharCertType = "01"
  7803. cFYLJG003.PharCertno = "430482199408260023"
  7804. cFYLJG003.PharName = "彭斯遥"
  7805. cFYLJG003.PsnCertType = "01"
  7806. cFYLJG003.RxFile = flow.RxFile
  7807. cFYLJG003.SignDigest = flow.SignDigest
  7808. cFYLJG003.FixmedinsCode = miConfig.Code
  7809. cFYLJG003.PsnCertType = "01"
  7810. cFYLJG003.PharProfttlCodg = dept.Name
  7811. //inputData["pharProfttlCodg"] =dept.Name
  7812. tempTime2 := time.Unix(info.Ctime, 0)
  7813. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7814. cFYLJG003.PharChkTime = timeFormatTwo
  7815. if miConfig.MdtrtareaAdmvs == "340699" {
  7816. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7817. result, request := service.GetAHCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7818. saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  7819. } else {
  7820. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7821. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7822. }
  7823. var res ResultCFYLJG003
  7824. var respJSON2 map[string]interface{}
  7825. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7828. return
  7829. }
  7830. userJSONBytes2, _ := json.Marshal(respJSON2)
  7831. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7832. utils.ErrorLog("解析失败:%v", err)
  7833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7834. return
  7835. }
  7836. if res.Infcode == -1 {
  7837. c.ServeSuccessJSON(map[string]interface{}{
  7838. "failed_code": -10,
  7839. "msg": res.ErrMsg,
  7840. })
  7841. return
  7842. } else {
  7843. c.ServeSuccessJSON(map[string]interface{}{
  7844. "info": res.Output,
  7845. })
  7846. }
  7847. }
  7848. func (c *HisApiController) GetCFYLJG004() {
  7849. admin_user_id, _ := c.GetInt64("admin_user_id")
  7850. his_patient_id, _ := c.GetInt64("his_patient_id")
  7851. record_time := c.GetString("record_time")
  7852. admin_user_id = 3626
  7853. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7854. //id, _ := c.GetInt64("id")
  7855. admin_user_id = 3626
  7856. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7857. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7858. flow, _ := service.Getflowtwo(his.Number)
  7859. //id = 3
  7860. patient_id, _ := c.GetInt64("patient_id")
  7861. //patient_id = 23834
  7862. //record_time = "2023-09-18"
  7863. timeLayout := "2006-01-02"
  7864. loc, _ := time.LoadLocation("Local")
  7865. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7866. if err != nil {
  7867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7868. return
  7869. }
  7870. recordDateTime := theTime.Unix()
  7871. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7872. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7873. var cFYLJG004 models.CFYLJG004
  7874. cFYLJG004.HiRxno = flow.HiRxno
  7875. cFYLJG004.FixmedinsCode = miConfig.Code
  7876. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7877. cFYLJG004.UndoDrCertType = "01"
  7878. cFYLJG004.UndoRea = "撤销处方"
  7879. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7880. cFYLJG004.UndoDrName = doctor_info.UserName
  7881. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7882. if miConfig.MdtrtareaAdmvs == "340699" {
  7883. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7884. result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7885. saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  7886. } else {
  7887. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7888. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7889. }
  7890. var res ResultCFYLJG004
  7891. var respJSON2 map[string]interface{}
  7892. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7895. return
  7896. }
  7897. userJSONBytes2, _ := json.Marshal(respJSON2)
  7898. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7899. utils.ErrorLog("解析失败:%v", err)
  7900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7901. return
  7902. }
  7903. if res.Infcode == -1 {
  7904. c.ServeSuccessJSON(map[string]interface{}{
  7905. "failed_code": -10,
  7906. "msg": res.ErrMsg,
  7907. })
  7908. return
  7909. } else {
  7910. flow.Status = 0
  7911. service.Saveflow(flow)
  7912. c.ServeSuccessJSON(map[string]interface{}{
  7913. "msg": "撤销成功",
  7914. })
  7915. return
  7916. }
  7917. }
  7918. func (c *HisApiController) GetCFYLJG005() {
  7919. admin_user_id, _ := c.GetInt64("admin_user_id")
  7920. his_patient_id, _ := c.GetInt64("his_patient_id")
  7921. //record_time := c.GetString("record_time")
  7922. admin_user_id = 3626
  7923. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7924. //id, _ := c.GetInt64("id")
  7925. admin_user_id = 3626
  7926. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7927. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7928. flow, _ := service.Getflowtwo(his.Number)
  7929. //id = 3
  7930. var cFYLJG005 models.CFYLJG005
  7931. //patient_id, _ := c.GetInt64("patient_id")
  7932. cFYLJG005.HiRxno = flow.HiRxno
  7933. cFYLJG005.MdtrtID = flow.MID
  7934. cFYLJG005.EcToken = ""
  7935. cFYLJG005.PsnName = his.Name
  7936. cFYLJG005.PsnCertType = "01"
  7937. cFYLJG005.Certno = his.IdCardNo
  7938. if miConfig.MdtrtareaAdmvs == "340699" {
  7939. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7940. result, request := service.GetAHCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7941. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7942. } else {
  7943. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7944. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7945. }
  7946. var res ResultCFYLJG005
  7947. var respJSON2 map[string]interface{}
  7948. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7949. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7951. return
  7952. }
  7953. userJSONBytes2, _ := json.Marshal(respJSON2)
  7954. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7955. utils.ErrorLog("解析失败:%v", err)
  7956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7957. return
  7958. }
  7959. if res.Infcode == -1 {
  7960. c.ServeSuccessJSON(map[string]interface{}{
  7961. "failed_code": -10,
  7962. "msg": res.ErrMsg,
  7963. })
  7964. return
  7965. } else {
  7966. c.ServeSuccessJSON(map[string]interface{}{
  7967. "info": res.Output,
  7968. })
  7969. return
  7970. }
  7971. }
  7972. func (c *HisApiController) GetCFYLJG006() {
  7973. admin_user_id, _ := c.GetInt64("admin_user_id")
  7974. his_patient_id, _ := c.GetInt64("his_patient_id")
  7975. admin_user_id = 3626
  7976. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7977. //id, _ := c.GetInt64("id")
  7978. admin_user_id = 3626
  7979. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7980. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7981. flow, _ := service.Getflowtwo(his.Number)
  7982. //id = 3
  7983. patient_id, _ := c.GetInt64("patient_id")
  7984. var cFYLJG006 models.CFYLJG006
  7985. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7986. cFYLJG006.HiRxno = flow.HiRxno
  7987. cFYLJG006.MdtrtID = flow.MID
  7988. cFYLJG006.PsnName = patient.Name
  7989. cFYLJG006.PsnCertType = "01"
  7990. cFYLJG006.Certno = patient.IdCardNo
  7991. if miConfig.MdtrtareaAdmvs == "340699" {
  7992. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7993. result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  7994. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  7995. } else {
  7996. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  7997. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  7998. }
  7999. var res ResultCFYLJG006
  8000. var respJSON2 map[string]interface{}
  8001. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8002. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8004. return
  8005. }
  8006. userJSONBytes2, _ := json.Marshal(respJSON2)
  8007. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8008. utils.ErrorLog("解析失败:%v", err)
  8009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8010. return
  8011. }
  8012. if res.Infcode == -1 {
  8013. c.ServeSuccessJSON(map[string]interface{}{
  8014. "failed_code": -10,
  8015. "msg": res.ErrMsg,
  8016. })
  8017. return
  8018. } else {
  8019. c.ServeSuccessJSON(map[string]interface{}{
  8020. "info": res.Output,
  8021. })
  8022. return
  8023. }
  8024. }
  8025. func (c *HisApiController) GetCFYLJG007() {
  8026. admin_user_id, _ := c.GetInt64("admin_user_id")
  8027. his_patient_id, _ := c.GetInt64("his_patient_id")
  8028. admin_user_id = 3626
  8029. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8030. //id, _ := c.GetInt64("id")
  8031. admin_user_id = 3626
  8032. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8033. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8034. flow, _ := service.Getflowtwo(his.Number)
  8035. //id = 3
  8036. patient_id, _ := c.GetInt64("patient_id")
  8037. var cFYLJG007 models.CFYLJG007
  8038. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8039. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8040. cFYLJG007.HiRxno = flow.HiRxno
  8041. cFYLJG007.MdtrtID = flow.MID
  8042. cFYLJG007.PsnNo = his.PsnNo
  8043. cFYLJG007.PsnCertType = "01"
  8044. cFYLJG007.Certno = patient.IdCardNo
  8045. cFYLJG007.PsnName = patient.Name
  8046. if miConfig.MdtrtareaAdmvs == "340699" {
  8047. result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8048. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8049. } else {
  8050. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8051. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8052. }
  8053. var res ResultCFYLJG007
  8054. var respJSON2 map[string]interface{}
  8055. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8058. return
  8059. }
  8060. userJSONBytes2, _ := json.Marshal(respJSON2)
  8061. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8062. utils.ErrorLog("解析失败:%v", err)
  8063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8064. return
  8065. }
  8066. if res.Infcode == -1 {
  8067. c.ServeSuccessJSON(map[string]interface{}{
  8068. "failed_code": -10,
  8069. "msg": res.ErrMsg,
  8070. })
  8071. return
  8072. } else {
  8073. c.ServeSuccessJSON(map[string]interface{}{
  8074. "info": res,
  8075. })
  8076. return
  8077. }
  8078. }
  8079. func (c *HisApiController) GetCFYLJG008() {
  8080. admin_user_id, _ := c.GetInt64("admin_user_id")
  8081. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8082. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8083. var cFYLJG008 models.CFYLJG008
  8084. //id, _ := c.GetInt64("id")
  8085. patient_id, _ := c.GetInt64("patient_id")
  8086. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8087. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8088. //id = 3
  8089. //flow, _ := service.Getflow(id)
  8090. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8091. //
  8092. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8093. //patient_id, _ := c.GetInt64("patient_id")
  8094. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8095. record_time := c.GetString("record_time")
  8096. admin_user_id = 3626
  8097. patient_id = 19424
  8098. //his_patient_id = 263947
  8099. record_time = "2023-08-29"
  8100. timeLayout := "2006-01-02"
  8101. loc, _ := time.LoadLocation("Local")
  8102. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8103. if err != nil {
  8104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8105. return
  8106. }
  8107. recordDateTime := theTime.Unix()
  8108. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8109. cFYLJG008.FixmedinsName = ""
  8110. cFYLJG008.Lat = ""
  8111. cFYLJG008.Lng = ""
  8112. cFYLJG008.OrderType = "1"
  8113. cFYLJG008.PoolareaNo = ""
  8114. cFYLJG008.Lng = ""
  8115. cFYLJG008.PageNum = 1
  8116. cFYLJG008.PageSize = 10
  8117. var MPI models.MedinsProdInvChgDDTO
  8118. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8119. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8120. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8121. if miConfig.MdtrtareaAdmvs == "340699" {
  8122. result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8123. saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8124. } else {
  8125. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8126. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8127. var res ResultCFYLJG008
  8128. var respJSON2 map[string]interface{}
  8129. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8132. return
  8133. }
  8134. userJSONBytes2, _ := json.Marshal(respJSON2)
  8135. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8136. utils.ErrorLog("解析失败:%v", err)
  8137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8138. return
  8139. }
  8140. if res.Infcode == -1 {
  8141. c.ServeSuccessJSON(map[string]interface{}{
  8142. "failed_code": -10,
  8143. "msg": res.ErrMsg,
  8144. })
  8145. return
  8146. } else {
  8147. c.ServeSuccessJSON(map[string]interface{}{
  8148. "info": res.Output,
  8149. })
  8150. return
  8151. }
  8152. }
  8153. }
  8154. func (c *HisApiController) GetBL4201A() {
  8155. order_id, _ := c.GetInt64("order_id")
  8156. admin_user_id, _ := c.GetInt64("admin_user_id")
  8157. order, _ := service.GetHisOrderByIDTwo(order_id)
  8158. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8159. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8160. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8161. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8162. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8163. department, _ := service.GetDepartMentDetail(his.Departments)
  8164. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8165. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8166. if order.ID == 0 {
  8167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8168. return
  8169. }
  8170. var struct4201A models.Struct4201A
  8171. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8172. for _, items := range order_info {
  8173. memo := make(map[string]interface{})
  8174. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8175. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8176. fsiOPFLD.MedType = "14"
  8177. fsiOPFLD.BkkpSn = items.FeedetlSn
  8178. fsiOPFLD.FixmedinsCode = miConfig.Code
  8179. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8180. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8181. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8182. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8183. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8184. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8185. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8186. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8187. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8188. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8189. fsiOPFLD.BilgDeptName = department.Name
  8190. fsiOPFLD.BilgDeptCodg = department.Number
  8191. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8192. fsiOPFLD.BilgDrName = doctor.UserName
  8193. fsiOPFLD.MedChrgitmType = "09"
  8194. memo["hosp_appr_flag"] = "1"
  8195. memo["invoice_no"] = order.MdtrtId
  8196. memo["memo"] = "自费"
  8197. bytesData, _ := json.Marshal(memo)
  8198. fsiOPFLD.Memo = string(bytesData)
  8199. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8200. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8201. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8202. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8203. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8204. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8205. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8206. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8207. fsiOPFLD.BilgDeptName = department.Name
  8208. fsiOPFLD.BilgDeptCodg = department.Number
  8209. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8210. fsiOPFLD.BilgDrName = doctor.UserName
  8211. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8212. case 0:
  8213. break
  8214. case 1:
  8215. fsiOPFLD.MedChrgitmType = "14"
  8216. break
  8217. case 2:
  8218. fsiOPFLD.MedChrgitmType = "05"
  8219. break
  8220. case 3:
  8221. fsiOPFLD.MedChrgitmType = "03"
  8222. break
  8223. case 4:
  8224. fsiOPFLD.MedChrgitmType = "03"
  8225. break
  8226. case 5:
  8227. fsiOPFLD.MedChrgitmType = "08"
  8228. break
  8229. case 6:
  8230. fsiOPFLD.MedChrgitmType = "14"
  8231. break
  8232. case 7:
  8233. fsiOPFLD.MedChrgitmType = "14"
  8234. break
  8235. case 8:
  8236. fsiOPFLD.MedChrgitmType = "03"
  8237. break
  8238. case 9:
  8239. fsiOPFLD.MedChrgitmType = "14"
  8240. break
  8241. case 10:
  8242. fsiOPFLD.MedChrgitmType = "14"
  8243. break
  8244. case 11:
  8245. fsiOPFLD.MedChrgitmType = "06"
  8246. break
  8247. case 12:
  8248. fsiOPFLD.MedChrgitmType = "12"
  8249. break
  8250. case 13:
  8251. fsiOPFLD.MedChrgitmType = "01"
  8252. break
  8253. case 14:
  8254. fsiOPFLD.MedChrgitmType = "04"
  8255. break
  8256. case 15:
  8257. fsiOPFLD.MedChrgitmType = "14"
  8258. break
  8259. }
  8260. memo["hosp_appr_flag"] = "1"
  8261. memo["invoice_no"] = order.MdtrtId
  8262. memo["memo"] = "自费"
  8263. bytesData, _ := json.Marshal(memo)
  8264. fsiOPFLD.Memo = string(bytesData)
  8265. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8266. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8267. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8268. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8269. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8270. fsiOPFLD.BilgDeptName = department.Name
  8271. fsiOPFLD.BilgDeptCodg = department.Number
  8272. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8273. fsiOPFLD.BilgDrName = doctor.UserName
  8274. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8275. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8276. fsiOPFLD.MedChrgitmType = "08"
  8277. memo["hosp_appr_flag"] = "1"
  8278. memo["invoice_no"] = order.MdtrtId
  8279. memo["memo"] = "自费"
  8280. bytesData, _ := json.Marshal(memo)
  8281. fsiOPFLD.Memo = string(bytesData)
  8282. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8283. }
  8284. }
  8285. }
  8286. for _, items := range order_info_two {
  8287. memo := make(map[string]interface{})
  8288. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8289. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8290. fsiOPFLD.MedType = "14"
  8291. fsiOPFLD.BkkpSn = items.FeedetlSn
  8292. fsiOPFLD.FixmedinsCode = miConfig.Code
  8293. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8294. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8295. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8296. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8297. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8298. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8299. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8300. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8301. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8302. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8303. fsiOPFLD.BilgDeptName = department.Name
  8304. fsiOPFLD.BilgDeptCodg = department.Number
  8305. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8306. fsiOPFLD.BilgDrName = doctor.UserName
  8307. fsiOPFLD.MedChrgitmType = "09"
  8308. memo["hosp_appr_flag"] = "1"
  8309. memo["invoice_no"] = order.MdtrtId
  8310. memo["memo"] = "自费"
  8311. bytesData, _ := json.Marshal(memo)
  8312. fsiOPFLD.Memo = string(bytesData)
  8313. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8314. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8315. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8316. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8317. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8318. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8319. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8320. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8321. fsiOPFLD.BilgDeptName = department.Name
  8322. fsiOPFLD.BilgDeptCodg = department.Number
  8323. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8324. fsiOPFLD.BilgDrName = doctor.UserName
  8325. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8326. case 0:
  8327. break
  8328. case 1:
  8329. fsiOPFLD.MedChrgitmType = "14"
  8330. break
  8331. case 2:
  8332. fsiOPFLD.MedChrgitmType = "05"
  8333. break
  8334. case 3:
  8335. fsiOPFLD.MedChrgitmType = "03"
  8336. break
  8337. case 4:
  8338. fsiOPFLD.MedChrgitmType = "03"
  8339. break
  8340. case 5:
  8341. fsiOPFLD.MedChrgitmType = "08"
  8342. break
  8343. case 6:
  8344. fsiOPFLD.MedChrgitmType = "14"
  8345. break
  8346. case 7:
  8347. fsiOPFLD.MedChrgitmType = "14"
  8348. break
  8349. case 8:
  8350. fsiOPFLD.MedChrgitmType = "03"
  8351. break
  8352. case 9:
  8353. fsiOPFLD.MedChrgitmType = "14"
  8354. break
  8355. case 10:
  8356. fsiOPFLD.MedChrgitmType = "14"
  8357. break
  8358. case 11:
  8359. fsiOPFLD.MedChrgitmType = "06"
  8360. break
  8361. case 12:
  8362. fsiOPFLD.MedChrgitmType = "12"
  8363. break
  8364. case 13:
  8365. fsiOPFLD.MedChrgitmType = "01"
  8366. break
  8367. case 14:
  8368. fsiOPFLD.MedChrgitmType = "04"
  8369. break
  8370. case 15:
  8371. fsiOPFLD.MedChrgitmType = "14"
  8372. break
  8373. }
  8374. memo["hosp_appr_flag"] = "1"
  8375. memo["invoice_no"] = order.MdtrtId
  8376. memo["memo"] = "自费"
  8377. bytesData, _ := json.Marshal(memo)
  8378. fsiOPFLD.Memo = string(bytesData)
  8379. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8380. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8381. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8382. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8383. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8384. fsiOPFLD.BilgDeptName = department.Name
  8385. fsiOPFLD.BilgDeptCodg = department.Number
  8386. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8387. fsiOPFLD.BilgDrName = doctor.UserName
  8388. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8389. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8390. fsiOPFLD.MedChrgitmType = "08"
  8391. memo["hosp_appr_flag"] = "1"
  8392. memo["invoice_no"] = order.MdtrtId
  8393. memo["memo"] = "自费"
  8394. bytesData, _ := json.Marshal(memo)
  8395. fsiOPFLD.Memo = string(bytesData)
  8396. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8397. }
  8398. }
  8399. }
  8400. fmt.Println(fsiOPFLDs)
  8401. struct4201A.Fopfd = fsiOPFLDs
  8402. fmt.Println(struct4201A.Fopfd)
  8403. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8404. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8405. var res2 ResultSix
  8406. var respJSON2 map[string]interface{}
  8407. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8408. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8410. return
  8411. }
  8412. userJSONBytes2, _ := json.Marshal(respJSON2)
  8413. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8414. utils.ErrorLog("解析失败:%v", err)
  8415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8416. return
  8417. }
  8418. if res2.Infcode != 0 {
  8419. c.ServeSuccessJSON(map[string]interface{}{
  8420. "failed_code": -10,
  8421. "msg": res2.ErrMsg,
  8422. })
  8423. return
  8424. } else {
  8425. order.IsUploadOrderInfo = 1
  8426. service.UpdateOrder(order)
  8427. c.ServeSuccessJSON(map[string]interface{}{
  8428. "msg": "上传成功",
  8429. })
  8430. }
  8431. }
  8432. func (c *HisApiController) Get2505() {
  8433. admin_user_id, _ := c.GetInt64("admin_user_id")
  8434. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  8435. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8436. 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)
  8437. }
  8438. func (c *HisApiController) Get4201A() {
  8439. order_id, _ := c.GetInt64("order_id")
  8440. admin_user_id, _ := c.GetInt64("admin_user_id")
  8441. order, _ := service.GetHisOrderByIDTwo(order_id)
  8442. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8443. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8444. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8445. //order_info = append(order_info, order_info_two...)
  8446. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8447. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8448. department, _ := service.GetDepartMentDetail(his.Departments)
  8449. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8450. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8451. if order.ID == 0 {
  8452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8453. return
  8454. }
  8455. var struct4201A models.Struct4201A
  8456. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8457. for _, items := range order_info {
  8458. memo := make(map[string]interface{})
  8459. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8460. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8461. fsiOPFLD.MedType = "14"
  8462. fsiOPFLD.BkkpSn = items.FeedetlSn
  8463. fsiOPFLD.FixmedinsCode = miConfig.Code
  8464. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8465. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8466. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8467. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8468. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8469. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8470. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8471. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8472. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8473. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8474. fsiOPFLD.BilgDeptName = department.Name
  8475. fsiOPFLD.BilgDeptCodg = department.Number
  8476. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8477. fsiOPFLD.BilgDrName = doctor.UserName
  8478. fsiOPFLD.MedChrgitmType = "09"
  8479. memo["hosp_appr_flag"] = "1"
  8480. memo["invoice_no"] = order.MdtrtId
  8481. memo["memo"] = "自费"
  8482. bytesData, _ := json.Marshal(memo)
  8483. fsiOPFLD.Memo = string(bytesData)
  8484. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8485. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8486. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8487. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8488. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8489. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8490. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8491. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8492. fsiOPFLD.BilgDeptName = department.Name
  8493. fsiOPFLD.BilgDeptCodg = department.Number
  8494. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8495. fsiOPFLD.BilgDrName = doctor.UserName
  8496. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8497. case 0:
  8498. break
  8499. case 1:
  8500. fsiOPFLD.MedChrgitmType = "14"
  8501. break
  8502. case 2:
  8503. fsiOPFLD.MedChrgitmType = "05"
  8504. break
  8505. case 3:
  8506. fsiOPFLD.MedChrgitmType = "03"
  8507. break
  8508. case 4:
  8509. fsiOPFLD.MedChrgitmType = "03"
  8510. break
  8511. case 5:
  8512. fsiOPFLD.MedChrgitmType = "08"
  8513. break
  8514. case 6:
  8515. fsiOPFLD.MedChrgitmType = "14"
  8516. break
  8517. case 7:
  8518. fsiOPFLD.MedChrgitmType = "14"
  8519. break
  8520. case 8:
  8521. fsiOPFLD.MedChrgitmType = "03"
  8522. break
  8523. case 9:
  8524. fsiOPFLD.MedChrgitmType = "14"
  8525. break
  8526. case 10:
  8527. fsiOPFLD.MedChrgitmType = "14"
  8528. break
  8529. case 11:
  8530. fsiOPFLD.MedChrgitmType = "06"
  8531. break
  8532. case 12:
  8533. fsiOPFLD.MedChrgitmType = "12"
  8534. break
  8535. case 13:
  8536. fsiOPFLD.MedChrgitmType = "01"
  8537. break
  8538. case 14:
  8539. fsiOPFLD.MedChrgitmType = "04"
  8540. break
  8541. case 15:
  8542. fsiOPFLD.MedChrgitmType = "14"
  8543. break
  8544. }
  8545. memo["hosp_appr_flag"] = "1"
  8546. memo["invoice_no"] = order.MdtrtId
  8547. memo["memo"] = "自费"
  8548. bytesData, _ := json.Marshal(memo)
  8549. fsiOPFLD.Memo = string(bytesData)
  8550. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8551. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8552. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8553. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8554. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8555. fsiOPFLD.BilgDeptName = department.Name
  8556. fsiOPFLD.BilgDeptCodg = department.Number
  8557. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8558. fsiOPFLD.BilgDrName = doctor.UserName
  8559. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8560. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8561. fsiOPFLD.MedChrgitmType = "08"
  8562. memo["hosp_appr_flag"] = "1"
  8563. memo["invoice_no"] = order.MdtrtId
  8564. memo["memo"] = "自费"
  8565. bytesData, _ := json.Marshal(memo)
  8566. fsiOPFLD.Memo = string(bytesData)
  8567. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8568. }
  8569. }
  8570. }
  8571. for _, items := range order_info_two {
  8572. memo := make(map[string]interface{})
  8573. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8574. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8575. fsiOPFLD.MedType = "14"
  8576. fsiOPFLD.BkkpSn = items.FeedetlSn
  8577. fsiOPFLD.FixmedinsCode = miConfig.Code
  8578. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8579. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8580. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8581. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8582. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8583. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8584. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8585. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8586. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8587. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8588. fsiOPFLD.BilgDeptName = department.Name
  8589. fsiOPFLD.BilgDeptCodg = department.Number
  8590. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8591. fsiOPFLD.BilgDrName = doctor.UserName
  8592. fsiOPFLD.MedChrgitmType = "09"
  8593. memo["hosp_appr_flag"] = "1"
  8594. memo["invoice_no"] = order.MdtrtId
  8595. memo["memo"] = "自费"
  8596. bytesData, _ := json.Marshal(memo)
  8597. fsiOPFLD.Memo = string(bytesData)
  8598. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8599. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8600. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8601. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8602. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8603. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8604. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8605. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8606. fsiOPFLD.BilgDeptName = department.Name
  8607. fsiOPFLD.BilgDeptCodg = department.Number
  8608. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8609. fsiOPFLD.BilgDrName = doctor.UserName
  8610. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8611. case 0:
  8612. break
  8613. case 1:
  8614. fsiOPFLD.MedChrgitmType = "14"
  8615. break
  8616. case 2:
  8617. fsiOPFLD.MedChrgitmType = "05"
  8618. break
  8619. case 3:
  8620. fsiOPFLD.MedChrgitmType = "03"
  8621. break
  8622. case 4:
  8623. fsiOPFLD.MedChrgitmType = "03"
  8624. break
  8625. case 5:
  8626. fsiOPFLD.MedChrgitmType = "08"
  8627. break
  8628. case 6:
  8629. fsiOPFLD.MedChrgitmType = "14"
  8630. break
  8631. case 7:
  8632. fsiOPFLD.MedChrgitmType = "14"
  8633. break
  8634. case 8:
  8635. fsiOPFLD.MedChrgitmType = "03"
  8636. break
  8637. case 9:
  8638. fsiOPFLD.MedChrgitmType = "14"
  8639. break
  8640. case 10:
  8641. fsiOPFLD.MedChrgitmType = "14"
  8642. break
  8643. case 11:
  8644. fsiOPFLD.MedChrgitmType = "06"
  8645. break
  8646. case 12:
  8647. fsiOPFLD.MedChrgitmType = "12"
  8648. break
  8649. case 13:
  8650. fsiOPFLD.MedChrgitmType = "01"
  8651. break
  8652. case 14:
  8653. fsiOPFLD.MedChrgitmType = "04"
  8654. break
  8655. case 15:
  8656. fsiOPFLD.MedChrgitmType = "14"
  8657. break
  8658. }
  8659. memo["hosp_appr_flag"] = "1"
  8660. memo["invoice_no"] = order.MdtrtId
  8661. memo["memo"] = "自费"
  8662. bytesData, _ := json.Marshal(memo)
  8663. fsiOPFLD.Memo = string(bytesData)
  8664. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8665. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8666. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8667. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8668. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8669. fsiOPFLD.BilgDeptName = department.Name
  8670. fsiOPFLD.BilgDeptCodg = department.Number
  8671. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8672. fsiOPFLD.BilgDrName = doctor.UserName
  8673. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8674. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8675. fsiOPFLD.MedChrgitmType = "08"
  8676. memo["hosp_appr_flag"] = "1"
  8677. memo["invoice_no"] = order.MdtrtId
  8678. memo["memo"] = "自费"
  8679. bytesData, _ := json.Marshal(memo)
  8680. fsiOPFLD.Memo = string(bytesData)
  8681. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8682. }
  8683. }
  8684. }
  8685. fmt.Println(fsiOPFLDs)
  8686. struct4201A.Fopfd = fsiOPFLDs
  8687. fmt.Println(struct4201A.Fopfd)
  8688. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8689. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8690. var res2 ResultSix
  8691. var respJSON2 map[string]interface{}
  8692. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8695. return
  8696. }
  8697. userJSONBytes2, _ := json.Marshal(respJSON2)
  8698. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8699. utils.ErrorLog("解析失败:%v", err)
  8700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8701. return
  8702. }
  8703. if res2.Infcode != 0 {
  8704. c.ServeSuccessJSON(map[string]interface{}{
  8705. "failed_code": -10,
  8706. "msg": res2.ErrMsg,
  8707. })
  8708. return
  8709. } else {
  8710. order.IsUploadOrderInfo = 1
  8711. service.UpdateOrder(order)
  8712. c.ServeSuccessJSON(map[string]interface{}{
  8713. "msg": "上传成功",
  8714. })
  8715. }
  8716. }
  8717. func (c *HisApiController) Get4202() {
  8718. order_id, _ := c.GetInt64("order_id")
  8719. admin_user_id, _ := c.GetInt64("admin_user_id")
  8720. order, _ := service.GetHisOrderByIDTwo(order_id)
  8721. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8722. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8723. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8724. if order.ID == 0 {
  8725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8726. return
  8727. }
  8728. var struct4202 models.Struct4202
  8729. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8730. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8731. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8732. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8733. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8734. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8735. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8736. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8737. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8738. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8739. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8740. var config []*models.HisXtDiagnoseConfig
  8741. for _, item := range diagnosis_ids {
  8742. id, _ := strconv.ParseInt(item, 10, 64)
  8743. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8744. config = append(config, &diagnosisConfig)
  8745. }
  8746. var tempDiaginfos []models.OwnPayPatnDiagListD
  8747. for index, item := range config {
  8748. if index == 0 {
  8749. var tempDiaginfo models.OwnPayPatnDiagListD
  8750. tempDiaginfo.InoutDiagType = "1"
  8751. tempDiaginfo.DiagCode = item.CountryCode
  8752. tempDiaginfo.DiagName = item.CountryContentName
  8753. tempDiaginfo.DiagType = "1"
  8754. tempDiaginfo.DiagSrtNo = "1"
  8755. tempDiaginfo.MaindiagFlag = "1"
  8756. tempDiaginfo.ValiFlag = "1"
  8757. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8758. } else {
  8759. var tempDiaginfo models.OwnPayPatnDiagListD
  8760. tempDiaginfo.DiagCode = item.CountryCode
  8761. tempDiaginfo.DiagName = item.CountryContentName
  8762. tempDiaginfo.DiagType = "2"
  8763. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8764. tempDiaginfo.MaindiagFlag = "0"
  8765. tempDiaginfo.ValiFlag = "1"
  8766. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8767. }
  8768. }
  8769. struct4202.ODiagListD = tempDiaginfos
  8770. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8771. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8772. var res2 ResultSix
  8773. var respJSON2 map[string]interface{}
  8774. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8777. return
  8778. }
  8779. userJSONBytes2, _ := json.Marshal(respJSON2)
  8780. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8781. utils.ErrorLog("解析失败:%v", err)
  8782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8783. return
  8784. }
  8785. if res2.Infcode != 0 {
  8786. c.ServeSuccessJSON(map[string]interface{}{
  8787. "failed_code": -10,
  8788. "msg": res2.ErrMsg,
  8789. })
  8790. return
  8791. } else {
  8792. order.IsUploadDiagnose = 1
  8793. service.UpdateOrder(order)
  8794. c.ServeSuccessJSON(map[string]interface{}{
  8795. "msg": "上传成功",
  8796. })
  8797. }
  8798. }
  8799. func (c *HisApiController) Get4203() {
  8800. admin_user_id, _ := c.GetInt64("admin_user_id")
  8801. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8802. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8803. order_id, _ := c.GetInt64("order_id")
  8804. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8805. number := ""
  8806. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8807. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8808. if his.ID == 0 {
  8809. number = hospital.Number
  8810. } else {
  8811. number = his.Number
  8812. }
  8813. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8814. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8815. var res2 ResultSix
  8816. var respJSON2 map[string]interface{}
  8817. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8820. return
  8821. }
  8822. userJSONBytes2, _ := json.Marshal(respJSON2)
  8823. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8824. utils.ErrorLog("解析失败:%v", err)
  8825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8826. return
  8827. }
  8828. if res2.Infcode != 0 {
  8829. c.ServeSuccessJSON(map[string]interface{}{
  8830. "failed_code": -10,
  8831. "msg": res2.ErrMsg,
  8832. })
  8833. return
  8834. } else {
  8835. order.IsUploadSuccess = 1
  8836. service.UpdateOrderTwo(order)
  8837. c.ServeSuccessJSON(map[string]interface{}{
  8838. "msg": "上传成功",
  8839. })
  8840. }
  8841. }
  8842. func (c *HisApiController) Get4205() {
  8843. order_id, _ := c.GetInt64("order_id")
  8844. admin_user_id, _ := c.GetInt64("admin_user_id")
  8845. fapiao_code := c.GetString("fapiao_code")
  8846. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8847. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8848. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8849. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8850. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8851. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8852. //order_info = append(order_info, order_info_two...)
  8853. department, _ := service.GetDepartMentDetail(his.Departments)
  8854. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8855. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8856. if order.ID == 0 {
  8857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8858. return
  8859. }
  8860. var struct4201A models.Struct4201A
  8861. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8862. for _, items := range order_info {
  8863. memo := make(map[string]interface{})
  8864. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8865. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8866. fsiOPFLD.MedType = pre.MedType
  8867. fsiOPFLD.FixmedinsCode = miConfig.Code
  8868. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8869. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8870. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8871. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8872. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8873. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8874. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8875. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8876. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8877. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8878. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8879. fsiOPFLD.BilgDeptName = department.Name
  8880. fsiOPFLD.BilgDeptCodg = department.Number
  8881. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8882. fsiOPFLD.BilgDrName = doctor.UserName
  8883. fsiOPFLD.MedChrgitmType = "09"
  8884. memo["hosp_appr_flag"] = "1"
  8885. memo["invoice_no"] = fapiao_code
  8886. memo["memo"] = "自费"
  8887. bytesData, _ := json.Marshal(memo)
  8888. fsiOPFLD.Memo = string(bytesData)
  8889. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8890. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8891. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8892. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8893. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8894. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8895. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8896. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8897. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8898. fsiOPFLD.BilgDeptName = department.Name
  8899. fsiOPFLD.BilgDeptCodg = department.Number
  8900. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8901. fsiOPFLD.BilgDrName = doctor.UserName
  8902. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8903. case 0:
  8904. break
  8905. case 1:
  8906. fsiOPFLD.MedChrgitmType = "14"
  8907. break
  8908. case 2:
  8909. fsiOPFLD.MedChrgitmType = "05"
  8910. break
  8911. case 3:
  8912. fsiOPFLD.MedChrgitmType = "03"
  8913. break
  8914. case 4:
  8915. fsiOPFLD.MedChrgitmType = "03"
  8916. break
  8917. case 5:
  8918. fsiOPFLD.MedChrgitmType = "08"
  8919. break
  8920. case 6:
  8921. fsiOPFLD.MedChrgitmType = "14"
  8922. break
  8923. case 7:
  8924. fsiOPFLD.MedChrgitmType = "14"
  8925. break
  8926. case 8:
  8927. fsiOPFLD.MedChrgitmType = "03"
  8928. break
  8929. case 9:
  8930. fsiOPFLD.MedChrgitmType = "14"
  8931. break
  8932. case 10:
  8933. fsiOPFLD.MedChrgitmType = "14"
  8934. break
  8935. case 11:
  8936. fsiOPFLD.MedChrgitmType = "06"
  8937. break
  8938. case 12:
  8939. fsiOPFLD.MedChrgitmType = "12"
  8940. break
  8941. case 13:
  8942. fsiOPFLD.MedChrgitmType = "01"
  8943. break
  8944. case 14:
  8945. fsiOPFLD.MedChrgitmType = "04"
  8946. break
  8947. case 15:
  8948. fsiOPFLD.MedChrgitmType = "14"
  8949. break
  8950. }
  8951. memo["hosp_appr_flag"] = "1"
  8952. memo["invoice_no"] = fapiao_code
  8953. memo["memo"] = "自费"
  8954. bytesData, _ := json.Marshal(memo)
  8955. fsiOPFLD.Memo = string(bytesData)
  8956. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8957. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8958. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8959. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8960. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8961. fsiOPFLD.BilgDeptName = department.Name
  8962. fsiOPFLD.BilgDeptCodg = department.Number
  8963. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8964. fsiOPFLD.BilgDrName = doctor.UserName
  8965. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8966. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8967. fsiOPFLD.MedChrgitmType = "08"
  8968. memo["hosp_appr_flag"] = "1"
  8969. memo["invoice_no"] = fapiao_code
  8970. memo["memo"] = "自费"
  8971. bytesData, _ := json.Marshal(memo)
  8972. fsiOPFLD.Memo = string(bytesData)
  8973. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8974. }
  8975. }
  8976. }
  8977. for _, items := range order_info_two {
  8978. memo := make(map[string]interface{})
  8979. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8980. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8981. fsiOPFLD.MedType = pre.MedType
  8982. fsiOPFLD.BkkpSn = items.FeedetlSn
  8983. fsiOPFLD.FixmedinsCode = miConfig.Code
  8984. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8985. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8986. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8987. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8988. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8989. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8990. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8991. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8992. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8993. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8994. fsiOPFLD.BilgDeptName = department.Name
  8995. fsiOPFLD.BilgDeptCodg = department.Number
  8996. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8997. fsiOPFLD.BilgDrName = doctor.UserName
  8998. fsiOPFLD.MedChrgitmType = "09"
  8999. memo["hosp_appr_flag"] = "1"
  9000. memo["invoice_no"] = fapiao_code
  9001. memo["memo"] = "自费"
  9002. bytesData, _ := json.Marshal(memo)
  9003. fsiOPFLD.Memo = string(bytesData)
  9004. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9005. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9006. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9007. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9008. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9009. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9010. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9011. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9012. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9013. fsiOPFLD.BilgDeptName = department.Name
  9014. fsiOPFLD.BilgDeptCodg = department.Number
  9015. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9016. fsiOPFLD.BilgDrName = doctor.UserName
  9017. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9018. case 0:
  9019. break
  9020. case 1:
  9021. fsiOPFLD.MedChrgitmType = "14"
  9022. break
  9023. case 2:
  9024. fsiOPFLD.MedChrgitmType = "05"
  9025. break
  9026. case 3:
  9027. fsiOPFLD.MedChrgitmType = "03"
  9028. break
  9029. case 4:
  9030. fsiOPFLD.MedChrgitmType = "03"
  9031. break
  9032. case 5:
  9033. fsiOPFLD.MedChrgitmType = "08"
  9034. break
  9035. case 6:
  9036. fsiOPFLD.MedChrgitmType = "14"
  9037. break
  9038. case 7:
  9039. fsiOPFLD.MedChrgitmType = "14"
  9040. break
  9041. case 8:
  9042. fsiOPFLD.MedChrgitmType = "03"
  9043. break
  9044. case 9:
  9045. fsiOPFLD.MedChrgitmType = "14"
  9046. break
  9047. case 10:
  9048. fsiOPFLD.MedChrgitmType = "14"
  9049. break
  9050. case 11:
  9051. fsiOPFLD.MedChrgitmType = "06"
  9052. break
  9053. case 12:
  9054. fsiOPFLD.MedChrgitmType = "12"
  9055. break
  9056. case 13:
  9057. fsiOPFLD.MedChrgitmType = "01"
  9058. break
  9059. case 14:
  9060. fsiOPFLD.MedChrgitmType = "04"
  9061. break
  9062. case 15:
  9063. fsiOPFLD.MedChrgitmType = "14"
  9064. break
  9065. }
  9066. memo["hosp_appr_flag"] = "1"
  9067. memo["invoice_no"] = fapiao_code
  9068. memo["memo"] = "自费"
  9069. bytesData, _ := json.Marshal(memo)
  9070. fsiOPFLD.Memo = string(bytesData)
  9071. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9072. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9073. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9074. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9075. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9076. fsiOPFLD.BilgDeptName = department.Name
  9077. fsiOPFLD.BilgDeptCodg = department.Number
  9078. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9079. fsiOPFLD.BilgDrName = doctor.UserName
  9080. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9081. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9082. fsiOPFLD.MedChrgitmType = "08"
  9083. memo["hosp_appr_flag"] = "1"
  9084. memo["invoice_no"] = fapiao_code
  9085. memo["memo"] = "自费"
  9086. bytesData, _ := json.Marshal(memo)
  9087. fsiOPFLD.Memo = string(bytesData)
  9088. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9089. }
  9090. }
  9091. }
  9092. fmt.Println(fsiOPFLDs)
  9093. struct4201A.Fopfd = fsiOPFLDs
  9094. fmt.Println(struct4201A.Fopfd)
  9095. var struct4202 models.Struct4202
  9096. timeLayout := "2006-01-02 15:04:05"
  9097. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9098. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9099. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9100. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9101. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9102. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9103. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9104. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9105. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9106. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9107. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9108. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9109. var config []*models.HisXtDiagnoseConfig
  9110. for _, item := range diagnosis_ids {
  9111. id, _ := strconv.ParseInt(item, 10, 64)
  9112. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9113. config = append(config, &diagnosisConfig)
  9114. }
  9115. var tempDiaginfos []models.OwnPayPatnDiagListD
  9116. for index, item := range config {
  9117. if index == 0 {
  9118. var tempDiaginfo models.OwnPayPatnDiagListD
  9119. tempDiaginfo.InoutDiagType = "1"
  9120. tempDiaginfo.DiagCode = item.CountryCode
  9121. tempDiaginfo.DiagName = item.CountryContentName
  9122. tempDiaginfo.DiagType = "1"
  9123. tempDiaginfo.DiagSrtNo = "1"
  9124. tempDiaginfo.MaindiagFlag = "1"
  9125. tempDiaginfo.ValiFlag = "1"
  9126. tempDiaginfo.DiagDrName = doctor.UserName
  9127. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9128. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9129. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9130. } else {
  9131. var tempDiaginfo models.OwnPayPatnDiagListD
  9132. tempDiaginfo.DiagCode = item.CountryCode
  9133. tempDiaginfo.DiagName = item.CountryContentName
  9134. tempDiaginfo.DiagType = "2"
  9135. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9136. tempDiaginfo.MaindiagFlag = "0"
  9137. tempDiaginfo.ValiFlag = "1"
  9138. tempDiaginfo.DiagDrName = doctor.UserName
  9139. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9140. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9141. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9142. }
  9143. }
  9144. struct4202.ODiagListD = tempDiaginfos
  9145. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9146. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9147. var res2 ResultSix
  9148. var respJSON2 map[string]interface{}
  9149. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9152. return
  9153. }
  9154. userJSONBytes2, _ := json.Marshal(respJSON2)
  9155. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9156. utils.ErrorLog("解析失败:%v", err)
  9157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9158. return
  9159. }
  9160. if res2.Infcode != 0 {
  9161. c.ServeSuccessJSON(map[string]interface{}{
  9162. "failed_code": -10,
  9163. "msg": res2.ErrMsg,
  9164. })
  9165. return
  9166. } else {
  9167. order.IsUploadDiagnose = 1
  9168. order.IsUploadOrderInfo = 1
  9169. service.UpdateOrderTwo(order)
  9170. c.ServeSuccessJSON(map[string]interface{}{
  9171. "msg": "上传成功",
  9172. })
  9173. }
  9174. }
  9175. func (c *HisApiController) Get4207() {
  9176. admin_user_id, _ := c.GetInt64("admin_user_id")
  9177. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9178. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9179. order_id, _ := c.GetInt64("order_id")
  9180. order, _ := service.GetHisOrderByIDTwo(order_id)
  9181. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9182. var struct4207 models.Struct4207
  9183. struct4207.PageNum = "1"
  9184. struct4207.PageSize = "1000"
  9185. struct4207.FixmedinsCode = miConfig.Code
  9186. struct4207.FixmedinsMdtrtID = order.Number
  9187. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9188. saveLog(result, requestLog, "4207", "查询")
  9189. var res2 ResultSix
  9190. var respJSON2 map[string]interface{}
  9191. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9194. return
  9195. }
  9196. userJSONBytes2, _ := json.Marshal(respJSON2)
  9197. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9198. utils.ErrorLog("解析失败:%v", err)
  9199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9200. return
  9201. }
  9202. if res2.Infcode != 0 {
  9203. c.ServeSuccessJSON(map[string]interface{}{
  9204. "failed_code": -10,
  9205. "msg": res2.ErrMsg,
  9206. })
  9207. return
  9208. } else {
  9209. c.ServeSuccessJSON(map[string]interface{}{
  9210. "msg": "查询成功",
  9211. })
  9212. }
  9213. }
  9214. func (c *HisApiController) Get4208() {
  9215. admin_user_id, _ := c.GetInt64("admin_user_id")
  9216. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9217. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9218. order_id, _ := c.GetInt64("order_id")
  9219. order, _ := service.GetHisOrderByIDTwo(order_id)
  9220. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9221. var struct4208 models.Struct4208
  9222. struct4208.PageNum = "1"
  9223. struct4208.PageSize = "1000"
  9224. struct4208.PsnCertType = "01"
  9225. struct4208.Certno = his.Certno
  9226. struct4208.MedType = order.MedType
  9227. struct4208.PsnName = his.Name
  9228. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9229. saveLog(result, requestLog, "4208", "查询")
  9230. var res2 ResultSix
  9231. var respJSON2 map[string]interface{}
  9232. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9233. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9235. return
  9236. }
  9237. userJSONBytes2, _ := json.Marshal(respJSON2)
  9238. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9239. utils.ErrorLog("解析失败:%v", err)
  9240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9241. return
  9242. }
  9243. if res2.Infcode != 0 {
  9244. c.ServeSuccessJSON(map[string]interface{}{
  9245. "failed_code": -10,
  9246. "msg": res2.ErrMsg,
  9247. })
  9248. return
  9249. } else {
  9250. c.ServeSuccessJSON(map[string]interface{}{
  9251. "msg": "查询成功",
  9252. })
  9253. }
  9254. }
  9255. func (c *HisApiController) Get4209() {
  9256. admin_user_id, _ := c.GetInt64("admin_user_id")
  9257. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9258. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9259. order_id, _ := c.GetInt64("order_id")
  9260. order, _ := service.GetHisOrderByIDTwo(order_id)
  9261. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9262. var struct4209 models.Struct4209
  9263. struct4209.FixmedinsMdtrtID = order.Number
  9264. struct4209.FixmedinsCode = miConfig.Code
  9265. struct4209.PageSize = "1000"
  9266. struct4209.PageNum = "1"
  9267. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9268. saveLog(result, requestLog, "4209", "查询")
  9269. var res2 ResultSix
  9270. var respJSON2 map[string]interface{}
  9271. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9274. return
  9275. }
  9276. userJSONBytes2, _ := json.Marshal(respJSON2)
  9277. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9278. utils.ErrorLog("解析失败:%v", err)
  9279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9280. return
  9281. }
  9282. if res2.Infcode != 0 {
  9283. c.ServeSuccessJSON(map[string]interface{}{
  9284. "failed_code": -10,
  9285. "msg": res2.ErrMsg,
  9286. })
  9287. return
  9288. } else {
  9289. c.ServeSuccessJSON(map[string]interface{}{
  9290. "msg": "查询成功",
  9291. })
  9292. }
  9293. }
  9294. type Result3101 struct {
  9295. Infcode string `json:"infcode"`
  9296. InfRefmsgid string `json:"inf_refmsgid"`
  9297. RefmsgTime string `json:"refmsg_time"`
  9298. RespondTime string `json:"respond_time"`
  9299. Enctype string `json:"enctype"`
  9300. Signtype string `json:"signtype"`
  9301. ErrMsg string `json:"err_msg"`
  9302. Output struct {
  9303. Result []struct {
  9304. JudgeResultDetailDtos []struct {
  9305. VolaItemType string `json:"vola_item_type"`
  9306. MdtrtID string `json:"mdtrt_id"`
  9307. JrdID string `json:"jrd_id"`
  9308. PatnID string `json:"patn_id"`
  9309. RxID string `json:"rx_id"`
  9310. VolaAmt interface{} `json:"vola_amt"`
  9311. } `json:"judge_result_detail_dtos"`
  9312. RuleID string `json:"rule_id"`
  9313. VolaEvid string `json:"vola_evid"`
  9314. MdtrtID string `json:"mdtrt_id"`
  9315. RuleName string `json:"rule_name"`
  9316. VolaAmtStas string `json:"vola_amt_stas"`
  9317. JrID string `json:"jr_id"`
  9318. PatnID string `json:"patn_id"`
  9319. SevDeg string `json:"sev_deg"`
  9320. VolaAmt float64 `json:"vola_amt"`
  9321. VolaBhvrType string `json:"vola_bhvr_type"`
  9322. VolaCont string `json:"vola_cont"`
  9323. } `json:"result"`
  9324. } `json:"output"`
  9325. }
  9326. type Resultgd3101 struct {
  9327. Infcode int64 `json:"infcode"`
  9328. InfRefmsgid string `json:"inf_refmsgid"`
  9329. RefmsgTime string `json:"refmsg_time"`
  9330. RespondTime string `json:"respond_time"`
  9331. Enctype string `json:"enctype"`
  9332. Signtype string `json:"signtype"`
  9333. ErrMsg string `json:"err_msg"`
  9334. Output struct {
  9335. Result []struct {
  9336. JudgeResultDetailDtos []struct {
  9337. VolaItemType string `json:"vola_item_type"`
  9338. MdtrtID string `json:"mdtrt_id"`
  9339. JrdID string `json:"jrd_id"`
  9340. PatnID string `json:"patn_id"`
  9341. RxID string `json:"rx_id"`
  9342. VolaAmt interface{} `json:"vola_amt"`
  9343. } `json:"judge_result_detail_dtos"`
  9344. RuleID string `json:"rule_id"`
  9345. VolaEvid string `json:"vola_evid"`
  9346. MdtrtID string `json:"mdtrt_id"`
  9347. RuleName string `json:"rule_name"`
  9348. VolaAmtStas string `json:"vola_amt_stas"`
  9349. JrID string `json:"jr_id"`
  9350. PatnID string `json:"patn_id"`
  9351. SevDeg string `json:"sev_deg"`
  9352. VolaAmt float64 `json:"vola_amt"`
  9353. VolaBhvrType string `json:"vola_bhvr_type"`
  9354. VolaCont string `json:"vola_cont"`
  9355. } `json:"result"`
  9356. } `json:"output"`
  9357. }
  9358. func (c *HisApiController) ReadEleToken() {
  9359. admin_user_id, _ := c.GetInt64("admin_user_id")
  9360. his_patient_id, _ := c.GetInt64("his_patient_id")
  9361. adminUser := c.GetAdminUserInfo()
  9362. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9363. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9364. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9365. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9366. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9367. if len(tokens) > 0 {
  9368. c.ServeSuccessJSON(map[string]interface{}{
  9369. "msg": "读取成功",
  9370. })
  9371. } else {
  9372. c.ServeSuccessJSON(map[string]interface{}{
  9373. "failed_code": -10,
  9374. "msg": "读取失败",
  9375. })
  9376. }
  9377. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9378. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9379. if len(tokens) > 0 {
  9380. c.ServeSuccessJSON(map[string]interface{}{
  9381. "msg": "读取成功",
  9382. })
  9383. } else {
  9384. c.ServeSuccessJSON(map[string]interface{}{
  9385. "failed_code": -10,
  9386. "msg": "读取失败",
  9387. })
  9388. }
  9389. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9390. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9391. if len(tokens) > 0 {
  9392. c.ServeSuccessJSON(map[string]interface{}{
  9393. "msg": "读取成功",
  9394. })
  9395. } else {
  9396. c.ServeSuccessJSON(map[string]interface{}{
  9397. "failed_code": -10,
  9398. "msg": "读取失败",
  9399. })
  9400. }
  9401. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9402. var api string
  9403. 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 +
  9404. "&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"
  9405. resp, requestErr := http.Get(api)
  9406. if requestErr != nil {
  9407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9408. }
  9409. body, ioErr := ioutil.ReadAll(resp.Body)
  9410. if ioErr != nil {
  9411. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9413. }
  9414. var respJSON map[string]interface{}
  9415. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9418. return
  9419. }
  9420. var status string
  9421. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9422. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9423. var token string
  9424. var res ResultTwo //1101结果
  9425. var res10265 ResultTwo10265 //1101结果
  9426. if status == "0" { //读卡成功
  9427. var card_info string //卡信息
  9428. var busi_card_info string
  9429. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9430. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9431. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9432. fmt.Println(card_info)
  9433. fmt.Println(busi_card_info)
  9434. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9435. result, _ := json.Marshal(respJSON)
  9436. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9437. utils.ErrorLog("解析失败:%v", err)
  9438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9439. return
  9440. }
  9441. res.ErrMsg = res10265.ErrMsg
  9442. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9443. res.Infcode = infocode
  9444. res.Output = res10265.Output
  9445. res.InfRefmsgid = res10265.InfRefmsgid
  9446. if res.Infcode == 0 {
  9447. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9448. if err == gorm.ErrRecordNotFound {
  9449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9450. return
  9451. } else if err != nil {
  9452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9453. return
  9454. } else {
  9455. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9456. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9457. infoStr := string(Iinfos)
  9458. idetinfoStr := string(Idetinfos)
  9459. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9460. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9461. psn := &models.HisPsn{
  9462. PsnNo: res.Output.Baseinfo.PsnNo,
  9463. PatientId: patient.ID,
  9464. Certno: res.Output.Baseinfo.Certno,
  9465. Gend: res.Output.Baseinfo.Gend,
  9466. Naty: res.Output.Baseinfo.Naty,
  9467. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9468. PsnName: res.Output.Baseinfo.PsnName,
  9469. Age: float64(age),
  9470. Brdy: b,
  9471. Idetinfo: idetinfoStr,
  9472. Insuinfo: infoStr,
  9473. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9474. CardInfo: card_info,
  9475. VerifyNumber: token,
  9476. IdCardType: 4,
  9477. }
  9478. var rf []*ResultFive
  9479. json.Unmarshal([]byte(infoStr), &rf)
  9480. var insutypes []*ResultFive
  9481. var insutype string
  9482. var is390 int = 0
  9483. var is310 int = 0
  9484. for _, item := range rf {
  9485. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9486. insutypes = append(insutypes, item)
  9487. }
  9488. }
  9489. if len(insutypes) == 1 {
  9490. insutype = insutypes[0].Insutype
  9491. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9492. } else {
  9493. for _, i := range insutypes {
  9494. if i.Insutype == "390" {
  9495. is390 = 1
  9496. }
  9497. if i.Insutype == "310" {
  9498. is310 = 1
  9499. }
  9500. }
  9501. }
  9502. if is390 == 1 {
  9503. insutype = "390"
  9504. }
  9505. if is310 == 1 {
  9506. insutype = "310"
  9507. }
  9508. if len(insutypes) == 0 {
  9509. insutype = "310"
  9510. }
  9511. service.CreateHisPsn(psn)
  9512. c.ServeSuccessJSON(map[string]interface{}{
  9513. "patient": patient,
  9514. "number": token,
  9515. "insutype": insutype,
  9516. })
  9517. }
  9518. } else {
  9519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9520. return
  9521. }
  9522. } else { //读卡失败
  9523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9524. return
  9525. }
  9526. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9527. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9528. if len(errMsg) == 0 {
  9529. type ELeData struct {
  9530. Data struct {
  9531. IdNo string `json:"idNo"`
  9532. IdType string `json:"idType"`
  9533. UserName string `json:"userName"`
  9534. EcToken string `json:"ecToken"`
  9535. InsuOrg string `json:"insuOrg"`
  9536. Gender string `json:"gender"`
  9537. Birthday string `json:"birthday"`
  9538. Nationality string `json:"nationality"`
  9539. Email string `json:"email"`
  9540. Extra string `json:"extra"`
  9541. } `json:"data"`
  9542. Code int `json:"code"`
  9543. Message string `json:"message"`
  9544. }
  9545. var ele ELeData
  9546. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9547. if err != nil {
  9548. utils.ErrorLog("解析失败:%v", err)
  9549. }
  9550. token := ele.Data.EcToken
  9551. if len(token) > 0 {
  9552. psn := &models.HisPsn{
  9553. PsnNo: his.PsnNo,
  9554. Age: 0,
  9555. PatientId: his.PatientId,
  9556. Certno: his.Certno,
  9557. Brdy: his.Brdy,
  9558. Gend: his.Gend,
  9559. Naty: his.Naty,
  9560. PsnCertType: his.PsnCertType,
  9561. PsnName: his.PsnName,
  9562. Idetinfo: his.Idetinfo,
  9563. Insuinfo: his.Iinfo,
  9564. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9565. CardInfo: outPutInfo,
  9566. VerifyNumber: token,
  9567. }
  9568. service.CreateHisPsn(psn)
  9569. }
  9570. if len(token) > 0 {
  9571. c.ServeSuccessJSON(map[string]interface{}{
  9572. "msg": "读取成功",
  9573. })
  9574. } else {
  9575. c.ServeSuccessJSON(map[string]interface{}{
  9576. "failed_code": -10,
  9577. "msg": "读取失败",
  9578. })
  9579. }
  9580. }
  9581. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9582. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9583. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9584. type ELeData struct {
  9585. Data struct {
  9586. IdNo string `json:"idNo"`
  9587. IdType string `json:"idType"`
  9588. UserName string `json:"userName"`
  9589. EcToken string `json:"ecToken"`
  9590. InsuOrg string `json:"insuOrg"`
  9591. Gender string `json:"gender"`
  9592. Birthday string `json:"birthday"`
  9593. Nationality string `json:"nationality"`
  9594. Email string `json:"email"`
  9595. Extra string `json:"extra"`
  9596. } `json:"data"`
  9597. Code int `json:"code"`
  9598. Message string `json:"message"`
  9599. }
  9600. var ele ELeData
  9601. err := json.Unmarshal([]byte(result), &ele)
  9602. if err != nil {
  9603. utils.ErrorLog("解析失败:%v", err)
  9604. }
  9605. token := ele.Data.EcToken
  9606. token = Remove0000(token)
  9607. fmt.Println(ele.Data.UserName)
  9608. 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)
  9609. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9610. var res ResultTwo
  9611. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9612. utils.ErrorLog("解析失败:%v", err)
  9613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9614. return
  9615. }
  9616. if res.Infcode == 0 {
  9617. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9618. if err == gorm.ErrRecordNotFound {
  9619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9620. return
  9621. } else if err != nil {
  9622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9623. return
  9624. } else {
  9625. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9626. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9627. infoStr := string(Iinfos)
  9628. idetinfoStr := string(Idetinfos)
  9629. psn := &models.HisPsn{
  9630. PsnNo: res.Output.Baseinfo.PsnNo,
  9631. PatientId: patient.ID,
  9632. Certno: res.Output.Baseinfo.Certno,
  9633. Gend: res.Output.Baseinfo.Gend,
  9634. Naty: res.Output.Baseinfo.Naty,
  9635. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9636. PsnName: res.Output.Baseinfo.PsnName,
  9637. Idetinfo: idetinfoStr,
  9638. Insuinfo: infoStr,
  9639. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9640. CardInfo: "",
  9641. VerifyNumber: token,
  9642. }
  9643. service.CreateHisPsn(psn)
  9644. c.ServeSuccessJSON(map[string]interface{}{
  9645. "patient": patient,
  9646. "number": token,
  9647. })
  9648. }
  9649. } else {
  9650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9651. return
  9652. }
  9653. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9654. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9655. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9656. type ELeData struct {
  9657. Data struct {
  9658. IdNo string `json:"idNo"`
  9659. IdType string `json:"idType"`
  9660. UserName string `json:"userName"`
  9661. EcToken string `json:"ecToken"`
  9662. InsuOrg string `json:"insuOrg"`
  9663. Gender string `json:"gender"`
  9664. Birthday string `json:"birthday"`
  9665. Nationality string `json:"nationality"`
  9666. Email string `json:"email"`
  9667. Extra string `json:"extra"`
  9668. } `json:"data"`
  9669. Code int `json:"code"`
  9670. Message string `json:"message"`
  9671. }
  9672. var ele ELeData
  9673. err := json.Unmarshal([]byte(result), &ele)
  9674. if err != nil {
  9675. utils.ErrorLog("解析失败:%v", err)
  9676. }
  9677. token := ele.Data.EcToken
  9678. token = Remove0000(token)
  9679. fmt.Println(ele.Data.UserName)
  9680. 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)
  9681. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9682. var res ResultTwo
  9683. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9684. utils.ErrorLog("解析失败:%v", err)
  9685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9686. return
  9687. }
  9688. if res.Infcode == 0 {
  9689. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9690. if err == gorm.ErrRecordNotFound {
  9691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9692. return
  9693. } else if err != nil {
  9694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9695. return
  9696. } else {
  9697. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9698. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9699. infoStr := string(Iinfos)
  9700. idetinfoStr := string(Idetinfos)
  9701. psn := &models.HisPsn{
  9702. PsnNo: res.Output.Baseinfo.PsnNo,
  9703. PatientId: patient.ID,
  9704. Certno: res.Output.Baseinfo.Certno,
  9705. Gend: res.Output.Baseinfo.Gend,
  9706. Naty: res.Output.Baseinfo.Naty,
  9707. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9708. PsnName: res.Output.Baseinfo.PsnName,
  9709. Idetinfo: idetinfoStr,
  9710. Insuinfo: infoStr,
  9711. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9712. CardInfo: "",
  9713. VerifyNumber: token,
  9714. }
  9715. service.CreateHisPsn(psn)
  9716. c.ServeSuccessJSON(map[string]interface{}{
  9717. "patient": patient,
  9718. "number": token,
  9719. })
  9720. }
  9721. } else {
  9722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9723. return
  9724. }
  9725. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9726. //if initFlag == 0 {
  9727. //c.TestGetJiangXiBasBaseInit()
  9728. //}
  9729. //if initEleFlag == 0 {
  9730. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9731. //}
  9732. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9733. utils.ErrorLog("解析失败:%v", json_result)
  9734. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9735. type ELeData struct {
  9736. Data struct {
  9737. IdNo string `json:"idNo"`
  9738. IdType string `json:"idType"`
  9739. UserName string `json:"userName"`
  9740. EcToken string `json:"ecToken"`
  9741. InsuOrg string `json:"insuOrg"`
  9742. Gender string `json:"gender"`
  9743. Birthday string `json:"birthday"`
  9744. Nationality string `json:"nationality"`
  9745. Email string `json:"email"`
  9746. Extra string `json:"extra"`
  9747. } `json:"data"`
  9748. Code int `json:"code"`
  9749. Message string `json:"message"`
  9750. }
  9751. var ele ELeData
  9752. err := json.Unmarshal([]byte(json_result), &ele)
  9753. if err != nil {
  9754. utils.ErrorLog("解析失败:%v", err)
  9755. }
  9756. token := ele.Data.EcToken
  9757. token = Remove0000(token)
  9758. //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)
  9759. 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)
  9760. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9761. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9762. var res ResultTwo
  9763. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9764. utils.ErrorLog("解析失败:%v", err)
  9765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9766. return
  9767. }
  9768. if res.Infcode == 0 {
  9769. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9770. if err == gorm.ErrRecordNotFound {
  9771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9772. return
  9773. } else if err != nil {
  9774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9775. return
  9776. } else {
  9777. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9778. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9779. infoStr := string(Iinfos)
  9780. idetinfoStr := string(Idetinfos)
  9781. psn := &models.HisPsn{
  9782. PsnNo: res.Output.Baseinfo.PsnNo,
  9783. PatientId: patient.ID,
  9784. Certno: res.Output.Baseinfo.Certno,
  9785. Gend: res.Output.Baseinfo.Gend,
  9786. Naty: res.Output.Baseinfo.Naty,
  9787. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9788. PsnName: res.Output.Baseinfo.PsnName,
  9789. Idetinfo: idetinfoStr,
  9790. Insuinfo: infoStr,
  9791. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9792. CardInfo: "",
  9793. VerifyNumber: token,
  9794. InsuplcAdmdvs: ele.Data.InsuOrg,
  9795. }
  9796. service.CreateHisPsn(psn)
  9797. c.ServeSuccessJSON(map[string]interface{}{
  9798. "patient": patient,
  9799. "number": token,
  9800. })
  9801. }
  9802. } else {
  9803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9804. return
  9805. }
  9806. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9807. res := c.GetoleInfo()
  9808. if res.Infcode == 0 {
  9809. var result string
  9810. if res.Output.MdtrtCertType == "01" {
  9811. 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)
  9812. } else if res.Output.MdtrtCertType == "02" {
  9813. 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)
  9814. } else if res.Output.MdtrtCertType == "03" {
  9815. 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)
  9816. }
  9817. var dat map[string]interface{}
  9818. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9819. fmt.Println(dat)
  9820. } else {
  9821. fmt.Println(err)
  9822. }
  9823. userJSONBytes, _ := json.Marshal(dat)
  9824. var res2 ResultTwo
  9825. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9826. utils.ErrorLog("解析失败:%v", err)
  9827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9828. return
  9829. }
  9830. if res2.Infcode == 0 {
  9831. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9832. if err == gorm.ErrRecordNotFound {
  9833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9834. return
  9835. } else if err != nil {
  9836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9837. return
  9838. } else {
  9839. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9840. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9841. infoStr := string(Iinfos)
  9842. idetinfoStr := string(Idetinfos)
  9843. var rf []*ResultFive
  9844. json.Unmarshal([]byte(infoStr), &rf)
  9845. var insutypes []*ResultFive
  9846. var insutype string
  9847. var is390 int = 0
  9848. var is310 int = 0
  9849. //var insuplc_admdvs string
  9850. for _, item := range rf {
  9851. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9852. insutypes = append(insutypes, item)
  9853. }
  9854. }
  9855. if len(insutypes) == 1 {
  9856. insutype = insutypes[0].Insutype
  9857. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9858. } else {
  9859. for _, i := range insutypes {
  9860. if i.Insutype == "390" {
  9861. is390 = 1
  9862. }
  9863. if i.Insutype == "310" {
  9864. is310 = 1
  9865. }
  9866. }
  9867. }
  9868. if is390 == 1 {
  9869. insutype = "390"
  9870. }
  9871. if is310 == 1 {
  9872. insutype = "310"
  9873. }
  9874. if len(insutypes) == 0 {
  9875. insutype = "310"
  9876. }
  9877. psn := &models.HisPsn{
  9878. PsnNo: res2.Output.Baseinfo.PsnNo,
  9879. PatientId: patient.ID,
  9880. Certno: res2.Output.Baseinfo.Certno,
  9881. Gend: res2.Output.Baseinfo.Gend,
  9882. Naty: res2.Output.Baseinfo.Naty,
  9883. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9884. PsnName: res2.Output.Baseinfo.PsnName,
  9885. Idetinfo: idetinfoStr,
  9886. Insuinfo: infoStr,
  9887. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9888. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9889. VerifyNumber: res.Output.EcToken,
  9890. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9891. }
  9892. service.CreateHisPsn(psn)
  9893. c.ServeSuccessJSON(map[string]interface{}{
  9894. "patient": patient,
  9895. "number": res.Output.CardNo,
  9896. "insutype": insutype,
  9897. })
  9898. }
  9899. } else {
  9900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9901. return
  9902. }
  9903. } else {
  9904. c.ServeSuccessJSON(map[string]interface{}{
  9905. "failed_code": -10,
  9906. "msg": res.ErrMsg,
  9907. })
  9908. }
  9909. } else {
  9910. //if initFlag == 0 {
  9911. // c.TestGetBasBaseInit()
  9912. //}
  9913. //token := c.GetEleBaseInfo()
  9914. //token = Remove0000(token)
  9915. type ELeData struct {
  9916. Code string `json:"code"`
  9917. Data struct {
  9918. Aac002 string `json:"aac002"`
  9919. Aaz500 string `json:"aaz500"`
  9920. ActCardNo string `json:"actCardNo"`
  9921. Bab520 string `json:"bab520"`
  9922. Bkz543 string `json:"bkz543"`
  9923. BusinessType string `json:"businessType"`
  9924. CertfCodg string `json:"certfCodg"`
  9925. EcIndexNo string `json:"ecIndexNo"`
  9926. EcToken string `json:"ecToken"`
  9927. ID0000 string `json:"id0000"`
  9928. IDNo string `json:"idNo"`
  9929. IDType string `json:"idType"`
  9930. Idcode string `json:"idcode"`
  9931. IdentityToken string `json:"identity_token"`
  9932. InsuOrg string `json:"insuOrg"`
  9933. OfficeID string `json:"officeId"`
  9934. OfficeName string `json:"officeName"`
  9935. OperatorID string `json:"operatorId"`
  9936. OperatorName string `json:"operatorName"`
  9937. OrgID string `json:"orgId"`
  9938. UserName string `json:"userName"`
  9939. } `json:"data"`
  9940. Infno interface{} `json:"infno"`
  9941. Message string `json:"message"`
  9942. OrgID string `json:"orgId"`
  9943. TransType string `json:"transType"`
  9944. }
  9945. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9946. fmt.Println(result)
  9947. outPutInfo := Remove0000(result)
  9948. fmt.Println(outPutInfo)
  9949. var ele ELeData
  9950. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9951. if err != nil {
  9952. utils.ErrorLog("解析失败:%v", err)
  9953. }
  9954. token := ele.Data.EcToken
  9955. var result2 string
  9956. var requestLog2 string
  9957. if len(token) > 0 {
  9958. if strings.Contains(ele.Data.IDNo, "HKG") {
  9959. 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)
  9960. } else {
  9961. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  9962. }
  9963. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9964. var res ResultTwo
  9965. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9966. utils.ErrorLog("解析失败:%v", err)
  9967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9968. return
  9969. }
  9970. if res.Infcode == 0 {
  9971. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9972. if err == gorm.ErrRecordNotFound {
  9973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9974. return
  9975. } else if err != nil {
  9976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9977. return
  9978. } else {
  9979. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9980. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9981. infoStr := string(Iinfos)
  9982. idetinfoStr := string(Idetinfos)
  9983. psn := &models.HisPsn{
  9984. PsnNo: res.Output.Baseinfo.PsnNo,
  9985. PatientId: patient.ID,
  9986. Certno: res.Output.Baseinfo.Certno,
  9987. Gend: res.Output.Baseinfo.Gend,
  9988. Naty: res.Output.Baseinfo.Naty,
  9989. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9990. PsnName: res.Output.Baseinfo.PsnName,
  9991. Idetinfo: idetinfoStr,
  9992. Insuinfo: infoStr,
  9993. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9994. CardInfo: "",
  9995. VerifyNumber: token,
  9996. }
  9997. service.CreateHisPsn(psn)
  9998. c.ServeSuccessJSON(map[string]interface{}{
  9999. "msg": "读取成功",
  10000. })
  10001. }
  10002. } else {
  10003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10004. return
  10005. }
  10006. } else {
  10007. c.ServeSuccessJSON(map[string]interface{}{
  10008. "failed_code": -10,
  10009. "msg": "读取失败",
  10010. })
  10011. }
  10012. }
  10013. }
  10014. func (c *HisApiController) ReadEleFace() {
  10015. admin_user_id, _ := c.GetInt64("admin_user_id")
  10016. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10017. adminUser := c.GetAdminUserInfo()
  10018. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10019. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10020. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10021. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10022. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10023. if len(tokens) > 0 {
  10024. c.ServeSuccessJSON(map[string]interface{}{
  10025. "msg": "读取成功",
  10026. })
  10027. } else {
  10028. c.ServeSuccessJSON(map[string]interface{}{
  10029. "failed_code": -10,
  10030. "msg": "读取失败",
  10031. })
  10032. }
  10033. }
  10034. }
  10035. func (c *HisApiController) Get9001() {
  10036. adminUser := c.GetAdminUserInfo()
  10037. admin_user_id, _ := c.GetInt64("admin_user_id")
  10038. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10039. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10040. if miConfig.MdtrtareaAdmvs == "350500" {
  10041. service.GetFjAuthorizationInfo(miConfig.Code)
  10042. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10043. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10044. var dat map[string]interface{}
  10045. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10046. fmt.Println(dat)
  10047. } else {
  10048. fmt.Println(err)
  10049. }
  10050. userJSONBytes, _ := json.Marshal(dat)
  10051. var res models.Result9001
  10052. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10053. utils.ErrorLog("解析失败:%v", err)
  10054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10055. return
  10056. }
  10057. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10058. fmt.Println(miConfig.SecretKey)
  10059. var res models.Result9001Two
  10060. 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 +
  10061. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10062. resp, requestErr := http.Get(api)
  10063. if requestErr != nil {
  10064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10065. return
  10066. }
  10067. body, ioErr := ioutil.ReadAll(resp.Body)
  10068. if ioErr != nil {
  10069. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10071. return
  10072. }
  10073. var respJSON map[string]interface{}
  10074. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10077. return
  10078. }
  10079. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10080. if status == "0" {
  10081. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10082. c.ServeSuccessJSON(map[string]interface{}{
  10083. "failed_code": -10,
  10084. "msg": err_msg,
  10085. })
  10086. return
  10087. }
  10088. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10089. result, _ := json.Marshal(respJSON)
  10090. fmt.Println("log")
  10091. fmt.Println(string(result))
  10092. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10093. utils.ErrorLog("解析失败:%v", err)
  10094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10095. return
  10096. }
  10097. if res.Infcode == 0 {
  10098. sign := models.HisSignIn{
  10099. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10100. SignNo: res.Output.Signinoutb.SignNo,
  10101. SignTime: "",
  10102. Ctime: time.Now().Unix(),
  10103. Mtime: time.Now().Unix(),
  10104. Status: 1,
  10105. InputLog: "",
  10106. OutputLog: "",
  10107. FixmedinsCode: miConfig.Code,
  10108. }
  10109. err := service.CreateSignIn(&sign)
  10110. if err == nil {
  10111. c.ServeSuccessJSON(map[string]interface{}{
  10112. "msg": "签到成功",
  10113. })
  10114. }
  10115. } else {
  10116. c.ServeSuccessJSON(map[string]interface{}{
  10117. "failed_code": -10,
  10118. "msg": res.ErrMsg,
  10119. })
  10120. return
  10121. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10122. //return
  10123. }
  10124. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10125. fmt.Println(miConfig.SecretKey)
  10126. var res models.Result9001Two
  10127. 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 +
  10128. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10129. resp, requestErr := http.Get(api)
  10130. if requestErr != nil {
  10131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10132. return
  10133. }
  10134. body, ioErr := ioutil.ReadAll(resp.Body)
  10135. if ioErr != nil {
  10136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10138. return
  10139. }
  10140. var respJSON map[string]interface{}
  10141. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10144. return
  10145. }
  10146. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10147. if status == "0" {
  10148. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10149. c.ServeSuccessJSON(map[string]interface{}{
  10150. "failed_code": -10,
  10151. "msg": err_msg,
  10152. })
  10153. return
  10154. }
  10155. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10156. result, _ := json.Marshal(respJSON)
  10157. fmt.Println("log")
  10158. fmt.Println(string(result))
  10159. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10160. utils.ErrorLog("解析失败:%v", err)
  10161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10162. return
  10163. }
  10164. if res.Infcode == 0 {
  10165. sign := models.HisSignIn{
  10166. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10167. SignNo: res.Output.Signinoutb.SignNo,
  10168. SignTime: "",
  10169. Ctime: time.Now().Unix(),
  10170. Mtime: time.Now().Unix(),
  10171. Status: 1,
  10172. InputLog: "",
  10173. OutputLog: "",
  10174. FixmedinsCode: miConfig.Code,
  10175. }
  10176. err := service.CreateSignIn(&sign)
  10177. if err == nil {
  10178. c.ServeSuccessJSON(map[string]interface{}{
  10179. "msg": "签到成功",
  10180. })
  10181. }
  10182. } else {
  10183. c.ServeSuccessJSON(map[string]interface{}{
  10184. "failed_code": -10,
  10185. "msg": res.ErrMsg,
  10186. })
  10187. return
  10188. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10189. //return
  10190. }
  10191. } else {
  10192. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10193. var dat map[string]interface{}
  10194. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10195. fmt.Println(dat)
  10196. } else {
  10197. fmt.Println(err)
  10198. }
  10199. userJSONBytes, _ := json.Marshal(dat)
  10200. var res models.Result9001
  10201. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10202. utils.ErrorLog("解析失败:%v", err)
  10203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10204. return
  10205. }
  10206. if res.Infcode == 0 {
  10207. sign := models.HisSignIn{
  10208. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10209. SignNo: res.Output.Signinoutb.SignNo,
  10210. SignTime: res.Output.Signinoutb.SignTime,
  10211. Ctime: time.Now().Unix(),
  10212. Mtime: time.Now().Unix(),
  10213. Status: 1,
  10214. InputLog: "",
  10215. OutputLog: "",
  10216. FixmedinsCode: miConfig.Code,
  10217. }
  10218. err := service.CreateSignIn(&sign)
  10219. if err == nil {
  10220. c.ServeSuccessJSON(map[string]interface{}{
  10221. "msg": "签到成功",
  10222. })
  10223. }
  10224. }
  10225. }
  10226. }
  10227. 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) {
  10228. var res Result3101
  10229. adminUser := c.GetAdminUserInfo()
  10230. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10231. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10232. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10233. //record_time := c.GetString("record_time")
  10234. //trig_scen := c.GetString("trig_scen")
  10235. timeLayout := "2006-01-02"
  10236. loc, _ := time.LoadLocation("Local")
  10237. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10238. if err != nil {
  10239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10240. return res
  10241. }
  10242. recordDateTime := theTime.Unix()
  10243. var patientPrescription models.HisPrescriptionInfo
  10244. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10245. //if patientPrescription.ID == 0 {
  10246. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10247. //}
  10248. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10249. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10250. //
  10251. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10252. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10253. var pp models.PublicParams
  10254. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10255. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10256. pp.FixmedinsName = miConfig.OrgName
  10257. pp.FixmedinsCode = miConfig.Code
  10258. pp.RequestUrl = miConfig.Url
  10259. pp.Cainfo = miConfig.Cainfo
  10260. pp.SecretKey = miConfig.SecretKey
  10261. pp.AccessKey = miConfig.AccessKey
  10262. pp.OpterName = roles.UserName
  10263. var config []*models.HisXtDiagnoseConfig
  10264. for _, item := range diagnosis_ids {
  10265. id, _ := strconv.ParseInt(item, 10, 64)
  10266. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10267. config = append(config, &diagnosisConfig)
  10268. }
  10269. var pd models.PatientDtos
  10270. pd.PatnID = his.PsnNo
  10271. pd.PatnName = his.Name
  10272. pd.Gend = his.Gend
  10273. pd.Brdy = his.Brdy
  10274. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10275. pd.CurrMdtrtID = his.Number
  10276. var fed models.FsiEncounterDtos
  10277. fed.MdtrtID = his.Number
  10278. fed.MedinsID = miConfig.Code
  10279. fed.MedinsName = miConfig.OrgName
  10280. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10281. fed.MedMdtrtType = "1"
  10282. fed.MedinsType = "1"
  10283. fed.MedinsLv = "11"
  10284. tm := time.Unix(his.RecordDate, 0)
  10285. s_tm := tm.Format("2006-01-02 15:04:05")
  10286. fed.AdmDate = s_tm
  10287. fed.DscgDate = s_tm
  10288. fed.DscgMainDiseCodg = config[0].CountryCode
  10289. fed.DscgMainDiseName = config[0].CountryContentName
  10290. //诊断信息
  10291. var fdds []*models.FsiDiagnoseDtos
  10292. for index, item := range config {
  10293. if index == 0 {
  10294. var fdd models.FsiDiagnoseDtos
  10295. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10296. fdd.InoutDiseType = "1"
  10297. fdd.MaindiseFlag = "1"
  10298. fdd.DiseDate = s_tm
  10299. fdd.DiasSrtNo = "1"
  10300. fdd.DiseName = item.CountryContentName
  10301. fdd.DiseCodg = item.CountryCode
  10302. fdds = append(fdds, &fdd)
  10303. } else {
  10304. var fdd models.FsiDiagnoseDtos
  10305. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10306. fdd.InoutDiseType = "1"
  10307. fdd.MaindiseFlag = "1"
  10308. fdd.DiseDate = s_tm
  10309. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10310. fdd.DiseName = item.CountryContentName
  10311. fdd.DiseCodg = item.CountryCode
  10312. fdds = append(fdds, &fdd)
  10313. }
  10314. }
  10315. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10316. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10317. fed.AdmDeptName = de.Name
  10318. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10319. fed.DscgDeptName = de.Name
  10320. fed.MedMdtrtType = "1"
  10321. fed.MedType = "11"
  10322. //if his.Insutype == "390" {
  10323. // fed.MedType = "1402"
  10324. //} else {
  10325. // fed.MedType = "9933"
  10326. //}
  10327. var orders []*models.FsiOrderDtos
  10328. if trig_scen == "2" {
  10329. //处方医嘱信息
  10330. for _, item := range prescriptions {
  10331. for _, subItem := range item.HisDoctorAdviceInfo {
  10332. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10333. var order models.FsiOrderDtos
  10334. order.RxID = strconv.FormatInt(item.ID, 10)
  10335. order.Rxno = strconv.FormatInt(item.ID, 10)
  10336. order.LongDrordFlag = "0"
  10337. order.HilistType = "1"
  10338. order.ChrgType = "1"
  10339. order.DrordBhvr = "-"
  10340. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10341. order.HosplistName = subItem.BaseDrugLib.DrugName
  10342. order.HilistLv = "1"
  10343. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10344. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10345. order.HosplistName = subItem.BaseDrugLib.DrugName
  10346. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10347. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10348. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10349. order.OwnpayAmt = ""
  10350. order.SelfpayAmt = ""
  10351. order.Spec = ""
  10352. order.SpecUnt = ""
  10353. order.DrordBegnDate = s_tm
  10354. order.DrordStopDate = ""
  10355. order.DrordDrCodg = doctor_info.DoctorNumber
  10356. order.DrordDeptName = department.Name
  10357. order.DrordDeptCodg = department.Number
  10358. order.DrordDrName = doctor_info.UserName
  10359. order.DrordDrProfttl = "234"
  10360. order.CurrDrordFlag = "1"
  10361. orders = append(orders, &order)
  10362. }
  10363. }
  10364. for _, subItem := range item.HisPrescriptionProject {
  10365. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10366. var order models.FsiOrderDtos
  10367. order.RxID = strconv.FormatInt(item.ID, 10)
  10368. order.Rxno = strconv.FormatInt(item.ID, 10)
  10369. order.LongDrordFlag = "0"
  10370. order.HilistType = "1"
  10371. order.ChrgType = "1"
  10372. order.DrordBhvr = "-"
  10373. order.HilistCode = subItem.HisProject.MedicalCode
  10374. order.HosplistName = subItem.HisProject.ProjectName
  10375. order.HilistLv = "1"
  10376. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10377. order.HosplistCode = subItem.HisProject.MedicalCode
  10378. order.HosplistName = subItem.HisProject.ProjectName
  10379. order.Cnt = subItem.Count
  10380. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10381. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10382. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10383. order.OwnpayAmt = ""
  10384. order.SelfpayAmt = ""
  10385. order.Spec = ""
  10386. order.SpecUnt = ""
  10387. order.DrordBegnDate = s_tm
  10388. order.DrordStopDate = ""
  10389. order.DrordDrCodg = doctor_info.DoctorNumber
  10390. order.DrordDeptName = department.Name
  10391. order.DrordDeptCodg = department.Number
  10392. order.DrordDrName = doctor_info.UserName
  10393. order.DrordDrProfttl = "234"
  10394. order.CurrDrordFlag = "1"
  10395. orders = append(orders, &order)
  10396. }
  10397. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10398. var order models.FsiOrderDtos
  10399. order.RxID = strconv.FormatInt(item.ID, 10)
  10400. order.Rxno = strconv.FormatInt(item.ID, 10)
  10401. order.LongDrordFlag = "0"
  10402. order.HilistType = "1"
  10403. order.ChrgType = "1"
  10404. order.DrordBhvr = "-"
  10405. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10406. order.HosplistName = subItem.GoodInfo.GoodName
  10407. order.HilistLv = "1"
  10408. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10409. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10410. order.HosplistName = subItem.GoodInfo.GoodName
  10411. order.Cnt = subItem.Count
  10412. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10413. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10414. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10415. order.OwnpayAmt = ""
  10416. order.SelfpayAmt = ""
  10417. order.Spec = ""
  10418. order.SpecUnt = ""
  10419. order.DrordBegnDate = s_tm
  10420. order.DrordStopDate = ""
  10421. order.DrordDrCodg = doctor_info.DoctorNumber
  10422. order.DrordDeptName = department.Name
  10423. order.DrordDeptCodg = department.Number
  10424. order.DrordDrName = doctor_info.UserName
  10425. order.DrordDrProfttl = "234"
  10426. order.CurrDrordFlag = "1"
  10427. orders = append(orders, &order)
  10428. }
  10429. }
  10430. }
  10431. //处方医嘱信息
  10432. }
  10433. fed.MatnStas = "0"
  10434. fed.MedfeeSumamt = "0"
  10435. fed.OwnpayAmt = "0"
  10436. fed.SelfpayAmt = "0"
  10437. fed.AcctPayamt = "0"
  10438. fed.MaAmt = "0"
  10439. fed.HifpPayamt = "0"
  10440. fed.SetlTotlnum = "1"
  10441. fed.Insutype = his.Insutype
  10442. fed.ReimFlag = "0"
  10443. fed.OutSetlFlag = "0"
  10444. var fopd []*models.FsiOperationDtosData
  10445. data := make(map[string]interface{})
  10446. data["fed"] = fed
  10447. data["fdd"] = fdds
  10448. data["fod"] = orders
  10449. data["pd"] = pd
  10450. data["pp"] = pp
  10451. data["fopd"] = fopd
  10452. data["trig_scen"] = trig_scen
  10453. fmt.Println(data)
  10454. fmt.Println(fed)
  10455. fmt.Println(fdds)
  10456. fmt.Println(orders)
  10457. fmt.Println(pd)
  10458. fmt.Println(pp)
  10459. fmt.Println(fopd)
  10460. client := &http.Client{}
  10461. bytesData, _ := json.Marshal(data)
  10462. var req *http.Request
  10463. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10464. if miConfig.MdtrtareaAdmvs == "320921" {
  10465. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10466. } else {
  10467. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10468. }
  10469. resp, _ := client.Do(req)
  10470. defer resp.Body.Close()
  10471. body, ioErr := ioutil.ReadAll(resp.Body)
  10472. if ioErr != nil {
  10473. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10475. return res
  10476. }
  10477. var respJSON map[string]interface{}
  10478. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10479. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10481. return res
  10482. }
  10483. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10484. fmt.Println(respJSON)
  10485. result, _ := json.Marshal(respJSON)
  10486. fmt.Println(result)
  10487. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10488. utils.ErrorLog("解析失败:%v", err)
  10489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10490. return res
  10491. }
  10492. return res
  10493. } else {
  10494. //if miConfig.MdtrtareaAdmvs == "441202" {
  10495. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10496. saveLog(output, input, "3101", "事前")
  10497. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10498. utils.ErrorLog("解析失败:%v", err)
  10499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10500. return
  10501. }
  10502. return res
  10503. //}
  10504. }
  10505. }
  10506. 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) {
  10507. adminUser := c.GetAdminUserInfo()
  10508. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10509. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10510. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10511. //record_time := c.GetString("record_time")
  10512. //trig_scen := c.GetString("trig_scen")
  10513. timeLayout := "2006-01-02"
  10514. loc, _ := time.LoadLocation("Local")
  10515. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10516. if err != nil {
  10517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10518. return res
  10519. }
  10520. recordDateTime := theTime.Unix()
  10521. var patientPrescription models.HisPrescriptionInfo
  10522. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10523. if patientPrescription.ID == 0 {
  10524. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10525. }
  10526. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10527. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10528. //
  10529. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10530. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10531. var pp models.PublicParams
  10532. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10533. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10534. pp.FixmedinsName = miConfig.OrgName
  10535. pp.FixmedinsCode = miConfig.Code
  10536. pp.RequestUrl = miConfig.Url
  10537. pp.Cainfo = miConfig.Cainfo
  10538. pp.SecretKey = miConfig.SecretKey
  10539. pp.AccessKey = miConfig.AccessKey
  10540. pp.OpterName = roles.UserName
  10541. var config []*models.HisXtDiagnoseConfig
  10542. for _, item := range diagnosis_ids {
  10543. id, _ := strconv.ParseInt(item, 10, 64)
  10544. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10545. config = append(config, &diagnosisConfig)
  10546. }
  10547. var pd models.PatientDtos
  10548. pd.PatnID = his.PsnNo
  10549. pd.PatnName = his.Name
  10550. pd.Gend = his.Gend
  10551. pd.Brdy = his.Brdy
  10552. pd.Poolarea = his.InsuplcAdmdvs
  10553. pd.CurrMdtrtID = his.Number
  10554. var fed models.FsiEncounterDtos
  10555. fed.MdtrtID = his.Number
  10556. fed.MedinsID = miConfig.Code
  10557. fed.MedinsName = miConfig.OrgName
  10558. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10559. fed.MedMdtrtType = "1"
  10560. fed.MedinsType = "1"
  10561. fed.MedinsLv = "11"
  10562. tm := time.Unix(his.RecordDate, 0)
  10563. s_tm := tm.Format("2006-01-02 15:04:05")
  10564. fed.AdmDate = s_tm
  10565. fed.DscgDate = s_tm
  10566. fed.DscgMainDiseCodg = config[0].CountryCode
  10567. fed.DscgMainDiseName = config[0].CountryContentName
  10568. //诊断信息
  10569. var fdds []*models.FsiDiagnoseDtos
  10570. for index, item := range config {
  10571. if index == 0 {
  10572. var fdd models.FsiDiagnoseDtos
  10573. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10574. fdd.InoutDiseType = "1"
  10575. fdd.MaindiseFlag = "1"
  10576. fdd.DiseDate = s_tm
  10577. fdd.DiasSrtNo = "1"
  10578. fdd.DiseName = item.CountryContentName
  10579. fdd.DiseCodg = item.CountryCode
  10580. fdds = append(fdds, &fdd)
  10581. } else {
  10582. var fdd models.FsiDiagnoseDtos
  10583. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10584. fdd.InoutDiseType = "1"
  10585. fdd.MaindiseFlag = "1"
  10586. fdd.DiseDate = s_tm
  10587. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10588. fdd.DiseName = item.CountryContentName
  10589. fdd.DiseCodg = item.CountryCode
  10590. fdds = append(fdds, &fdd)
  10591. }
  10592. }
  10593. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10594. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10595. fed.AdmDeptName = department.Name
  10596. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10597. fed.DscgDeptName = department.Name
  10598. fed.MedMdtrtType = "1"
  10599. fed.MedType = "11"
  10600. //if his.Insutype == "390" {
  10601. // fed.MedType = "1402"
  10602. //} else {
  10603. // fed.MedType = "9933"
  10604. //}
  10605. var orders []*models.FsiOrderDtos
  10606. if trig_scen == "2" {
  10607. //处方医嘱信息
  10608. for _, item := range prescriptions {
  10609. for _, subItem := range item.HisDoctorAdviceInfo {
  10610. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10611. var order models.FsiOrderDtos
  10612. order.RxID = strconv.FormatInt(item.ID, 10)
  10613. order.Rxno = strconv.FormatInt(item.ID, 10)
  10614. order.LongDrordFlag = "0"
  10615. order.HilistType = "1"
  10616. order.ChrgType = "1"
  10617. order.DrordBhvr = "-"
  10618. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10619. order.HosplistName = subItem.BaseDrugLib.DrugName
  10620. order.HilistLv = "1"
  10621. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10622. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10623. order.HosplistName = subItem.BaseDrugLib.DrugName
  10624. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10625. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10626. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10627. order.OwnpayAmt = ""
  10628. order.SelfpayAmt = ""
  10629. order.Spec = ""
  10630. order.SpecUnt = ""
  10631. order.DrordBegnDate = s_tm
  10632. order.DrordStopDate = ""
  10633. order.DrordDrCodg = doctor_info.DoctorNumber
  10634. order.DrordDeptName = department.Name
  10635. order.DrordDeptCodg = department.Number
  10636. order.DrordDrName = doctor_info.UserName
  10637. order.DrordDrProfttl = "234"
  10638. order.CurrDrordFlag = "1"
  10639. orders = append(orders, &order)
  10640. }
  10641. }
  10642. for _, subItem := range item.HisPrescriptionProject {
  10643. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10644. var order models.FsiOrderDtos
  10645. order.RxID = strconv.FormatInt(item.ID, 10)
  10646. order.Rxno = strconv.FormatInt(item.ID, 10)
  10647. order.LongDrordFlag = "0"
  10648. order.HilistType = "1"
  10649. order.ChrgType = "1"
  10650. order.DrordBhvr = "-"
  10651. order.HilistCode = subItem.HisProject.MedicalCode
  10652. order.HosplistName = subItem.HisProject.ProjectName
  10653. order.HilistLv = "1"
  10654. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10655. order.HosplistCode = subItem.HisProject.MedicalCode
  10656. order.HosplistName = subItem.HisProject.ProjectName
  10657. order.Cnt = subItem.Count
  10658. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10659. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10660. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10661. order.OwnpayAmt = ""
  10662. order.SelfpayAmt = ""
  10663. order.Spec = ""
  10664. order.SpecUnt = ""
  10665. order.DrordBegnDate = s_tm
  10666. order.DrordStopDate = ""
  10667. order.DrordDrCodg = doctor_info.DoctorNumber
  10668. order.DrordDeptName = department.Name
  10669. order.DrordDeptCodg = department.Number
  10670. order.DrordDrName = doctor_info.UserName
  10671. order.DrordDrProfttl = "234"
  10672. order.CurrDrordFlag = "1"
  10673. orders = append(orders, &order)
  10674. }
  10675. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10676. var order models.FsiOrderDtos
  10677. order.RxID = strconv.FormatInt(item.ID, 10)
  10678. order.Rxno = strconv.FormatInt(item.ID, 10)
  10679. order.LongDrordFlag = "0"
  10680. order.HilistType = "1"
  10681. order.ChrgType = "1"
  10682. order.DrordBhvr = "-"
  10683. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10684. order.HosplistName = subItem.GoodInfo.GoodName
  10685. order.HilistLv = "1"
  10686. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10687. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10688. order.HosplistName = subItem.GoodInfo.GoodName
  10689. order.Cnt = subItem.Count
  10690. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10691. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10692. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10693. order.OwnpayAmt = ""
  10694. order.SelfpayAmt = ""
  10695. order.Spec = ""
  10696. order.SpecUnt = ""
  10697. order.DrordBegnDate = s_tm
  10698. order.DrordStopDate = ""
  10699. order.DrordDrCodg = doctor_info.DoctorNumber
  10700. order.DrordDeptName = department.Name
  10701. order.DrordDeptCodg = department.Number
  10702. order.DrordDrName = doctor_info.UserName
  10703. order.DrordDrProfttl = "234"
  10704. order.CurrDrordFlag = "1"
  10705. orders = append(orders, &order)
  10706. }
  10707. }
  10708. }
  10709. //处方医嘱信息
  10710. }
  10711. fed.MatnStas = "0"
  10712. fed.MedfeeSumamt = "0"
  10713. fed.OwnpayAmt = "0"
  10714. fed.SelfpayAmt = "0"
  10715. fed.AcctPayamt = "0"
  10716. fed.MaAmt = "0"
  10717. fed.HifpPayamt = "0"
  10718. fed.SetlTotlnum = "1"
  10719. fed.Insutype = his.Insutype
  10720. fed.ReimFlag = "0"
  10721. fed.OutSetlFlag = "0"
  10722. var fopd []*models.FsiOperationDtosData
  10723. data := make(map[string]interface{})
  10724. data["fed"] = fed
  10725. data["fdd"] = fdds
  10726. data["fod"] = orders
  10727. data["pd"] = pd
  10728. data["pp"] = pp
  10729. data["fopd"] = fopd
  10730. data["trig_scen"] = trig_scen
  10731. fmt.Println(data)
  10732. fmt.Println(fed)
  10733. fmt.Println(fdds)
  10734. fmt.Println(orders)
  10735. fmt.Println(pd)
  10736. fmt.Println(pp)
  10737. fmt.Println(fopd)
  10738. client := &http.Client{}
  10739. bytesData, _ := json.Marshal(data)
  10740. var req *http.Request
  10741. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10742. if miConfig.MdtrtareaAdmvs == "320921" {
  10743. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10744. } else {
  10745. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10746. }
  10747. resp, _ := client.Do(req)
  10748. defer resp.Body.Close()
  10749. body, ioErr := ioutil.ReadAll(resp.Body)
  10750. if ioErr != nil {
  10751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10753. return res
  10754. }
  10755. var respJSON map[string]interface{}
  10756. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10759. return res
  10760. }
  10761. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10762. fmt.Println(respJSON)
  10763. result, _ := json.Marshal(respJSON)
  10764. fmt.Println(result)
  10765. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10766. utils.ErrorLog("解析失败:%v", err)
  10767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10768. return res
  10769. }
  10770. return res
  10771. } else {
  10772. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10773. saveLog(output, input, "3101", "事前")
  10774. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10775. utils.ErrorLog("解析失败:%v", err)
  10776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10777. return
  10778. }
  10779. return res
  10780. }
  10781. return res
  10782. }
  10783. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10784. ////patient_id, _ := c.GetInt64("patient_id")
  10785. //order_id, _ := c.GetInt64("order_id")
  10786. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10787. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10788. //trig_scen := c.GetString("trig_scen")
  10789. adminUser := c.GetAdminUserInfo()
  10790. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10791. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10792. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10793. record_time := c.GetString("record_time")
  10794. order, _ := service.GetHisOrderByID(order_id)
  10795. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10796. timeLayout := "2006-01-02"
  10797. loc, _ := time.LoadLocation("Local")
  10798. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10799. if err != nil {
  10800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10801. return
  10802. }
  10803. recordDateTime := theTime.Unix()
  10804. var patientPrescription models.HisPrescriptionInfo
  10805. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10806. if patientPrescription.ID == 0 {
  10807. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10808. }
  10809. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10810. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10811. //
  10812. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10813. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10814. var pp models.PublicParams
  10815. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10816. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10817. pp.FixmedinsName = miConfig.OrgName
  10818. pp.FixmedinsCode = miConfig.Code
  10819. pp.RequestUrl = miConfig.Url
  10820. pp.Cainfo = miConfig.Cainfo
  10821. pp.SecretKey = miConfig.SecretKey
  10822. pp.AccessKey = miConfig.AccessKey
  10823. pp.OpterName = roles.UserName
  10824. var config []*models.HisXtDiagnoseConfig
  10825. for _, item := range diagnosis_ids {
  10826. id, _ := strconv.ParseInt(item, 10, 64)
  10827. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10828. config = append(config, &diagnosisConfig)
  10829. }
  10830. var pd models.PatientDtos
  10831. pd.PatnID = his.PsnNo
  10832. pd.PatnName = his.Name
  10833. pd.Gend = his.Gend
  10834. pd.Brdy = psn_info.Brdy
  10835. pd.Poolarea = his.InsuplcAdmdvs
  10836. pd.CurrMdtrtID = his.Number
  10837. var fed models.FsiEncounterDtos
  10838. fed.MdtrtID = his.Number
  10839. fed.MedinsID = miConfig.Code
  10840. fed.MedinsName = miConfig.OrgName
  10841. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10842. fed.MedMdtrtType = "1"
  10843. fed.MedinsType = "1"
  10844. fed.MedinsLv = "11"
  10845. tm := time.Unix(his.RecordDate, 0)
  10846. s_tm := tm.Format("2006-01-02 15:04:05")
  10847. fed.AdmDate = s_tm
  10848. fed.DscgDate = s_tm
  10849. fed.DscgMainDiseCodg = config[0].CountryCode
  10850. fed.DscgMainDiseName = config[0].CountryContentName
  10851. //诊断信息
  10852. var fdds []*models.FsiDiagnoseDtos
  10853. for index, item := range config {
  10854. if index == 0 {
  10855. var fdd models.FsiDiagnoseDtos
  10856. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10857. fdd.InoutDiseType = "1"
  10858. fdd.MaindiseFlag = "1"
  10859. fdd.DiseDate = s_tm
  10860. fdd.DiasSrtNo = "1"
  10861. fdd.DiseName = item.CountryContentName
  10862. fdd.DiseCodg = item.CountryCode
  10863. fdds = append(fdds, &fdd)
  10864. } else {
  10865. var fdd models.FsiDiagnoseDtos
  10866. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10867. fdd.InoutDiseType = "1"
  10868. fdd.MaindiseFlag = "1"
  10869. fdd.DiseDate = s_tm
  10870. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10871. fdd.DiseName = item.CountryContentName
  10872. fdd.DiseCodg = item.CountryCode
  10873. fdds = append(fdds, &fdd)
  10874. }
  10875. }
  10876. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10877. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10878. fed.AdmDeptName = department.Name
  10879. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10880. fed.DscgDeptName = department.Name
  10881. fed.MedType = order.MedType
  10882. //处方医嘱信息
  10883. var orders []*models.FsiOrderDtos
  10884. //for _, item := range prescriptions {
  10885. // for _, subItem := range item.HisDoctorAdviceInfo {
  10886. // var order models.FsiOrderDtos
  10887. // order.RxID = strconv.FormatInt(item.ID, 10)
  10888. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10889. // order.LongDrordFlag = "0"
  10890. // order.HilistType = "1"
  10891. // order.ChrgType = "1"
  10892. // order.DrordBhvr = "-"
  10893. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10894. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10895. // order.HilistLv = "1"
  10896. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10897. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10898. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10899. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10900. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10901. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10902. // order.OwnpayAmt = ""
  10903. // order.SelfpayAmt = ""
  10904. // order.Spec = ""
  10905. // order.SpecUnt = ""
  10906. // order.DrordBegnDate = s_tm
  10907. // order.DrordStopDate = ""
  10908. // order.DrordDrCodg = "1"
  10909. // order.DrordDeptName = department.Name
  10910. // order.DrordDrCodg = "1"
  10911. // order.DrordDrName = doctor_info.UserName
  10912. // order.DrordDrProfttl = ""
  10913. // order.CurrDrordFlag = "1"
  10914. // orders = append(orders, &order)
  10915. // }
  10916. // for _, subItem := range item.HisPrescriptionProject {
  10917. // if subItem.Type == 2 {
  10918. // var order models.FsiOrderDtos
  10919. // order.RxID = strconv.FormatInt(item.ID, 10)
  10920. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10921. // order.LongDrordFlag = "0"
  10922. // order.HilistType = "1"
  10923. // order.ChrgType = "1"
  10924. // order.DrordBhvr = "-"
  10925. // order.HilistCode = subItem.HisProject.MedicalCode
  10926. // order.HosplistName = subItem.HisProject.ProjectName
  10927. // order.HilistLv = "1"
  10928. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10929. // order.HosplistCode = subItem.HisProject.MedicalCode
  10930. // order.HosplistName = subItem.HisProject.ProjectName
  10931. // order.Cnt = subItem.Count
  10932. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10933. //
  10934. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10935. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10936. // order.OwnpayAmt = ""
  10937. // order.SelfpayAmt = ""
  10938. // order.Spec = ""
  10939. // order.SpecUnt = ""
  10940. // order.DrordBegnDate = s_tm
  10941. // order.DrordStopDate = ""
  10942. // order.DrordDrCodg = "1"
  10943. // order.DrordDeptName = department.Name
  10944. // order.DrordDrCodg = "1"
  10945. // order.DrordDrName = doctor_info.UserName
  10946. // order.DrordDrProfttl = ""
  10947. // order.CurrDrordFlag = "1"
  10948. // orders = append(orders, &order)
  10949. //
  10950. // }
  10951. // if subItem.Type == 3 {
  10952. //
  10953. // var order models.FsiOrderDtos
  10954. // order.RxID = strconv.FormatInt(item.ID, 10)
  10955. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10956. // order.LongDrordFlag = "0"
  10957. // order.HilistType = "1"
  10958. // order.ChrgType = "1"
  10959. // order.DrordBhvr = "-"
  10960. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10961. // order.HosplistName = subItem.GoodInfo.GoodName
  10962. // order.HilistLv = "1"
  10963. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10964. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10965. // order.HosplistName = subItem.GoodInfo.GoodName
  10966. // order.Cnt = subItem.Count
  10967. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10968. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10969. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10970. // order.OwnpayAmt = ""
  10971. // order.SelfpayAmt = ""
  10972. // order.Spec = ""
  10973. // order.SpecUnt = ""
  10974. // order.DrordBegnDate = s_tm
  10975. // order.DrordStopDate = ""
  10976. // order.DrordDrCodg = "1"
  10977. // order.DrordDeptName = department.Name
  10978. // order.DrordDrCodg = "1"
  10979. // order.DrordDrName = doctor_info.UserName
  10980. // order.DrordDrProfttl = ""
  10981. // order.CurrDrordFlag = "1"
  10982. // orders = append(orders, &order)
  10983. //
  10984. // }
  10985. // }
  10986. //}
  10987. for _, item := range prescriptions {
  10988. for _, subItem := range item.HisDoctorAdviceInfo {
  10989. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10990. var order models.FsiOrderDtos
  10991. order.RxID = strconv.FormatInt(item.ID, 10)
  10992. order.Rxno = strconv.FormatInt(item.ID, 10)
  10993. order.LongDrordFlag = "0"
  10994. order.HilistType = "1"
  10995. order.ChrgType = "1"
  10996. order.DrordBhvr = "-"
  10997. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10998. order.HosplistName = subItem.BaseDrugLib.DrugName
  10999. order.HilistLv = "1"
  11000. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11001. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11002. order.HosplistName = subItem.BaseDrugLib.DrugName
  11003. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11004. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11005. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11006. order.OwnpayAmt = ""
  11007. order.SelfpayAmt = ""
  11008. order.Spec = ""
  11009. order.SpecUnt = ""
  11010. order.DrordBegnDate = s_tm
  11011. order.DrordStopDate = ""
  11012. order.DrordDrCodg = doctor_info.DoctorNumber
  11013. order.DrordDeptName = department.Name
  11014. order.DrordDeptCodg = department.Number
  11015. order.DrordDrName = doctor_info.UserName
  11016. order.DrordDrProfttl = "234"
  11017. order.CurrDrordFlag = "1"
  11018. orders = append(orders, &order)
  11019. }
  11020. }
  11021. for _, subItem := range item.HisPrescriptionProject {
  11022. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11023. var order models.FsiOrderDtos
  11024. order.RxID = strconv.FormatInt(item.ID, 10)
  11025. order.Rxno = strconv.FormatInt(item.ID, 10)
  11026. order.LongDrordFlag = "0"
  11027. order.HilistType = "1"
  11028. order.ChrgType = "1"
  11029. order.DrordBhvr = "-"
  11030. order.HilistCode = subItem.HisProject.MedicalCode
  11031. order.HosplistName = subItem.HisProject.ProjectName
  11032. order.HilistLv = "1"
  11033. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11034. order.HosplistCode = subItem.HisProject.MedicalCode
  11035. order.HosplistName = subItem.HisProject.ProjectName
  11036. order.Cnt = subItem.Count
  11037. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11038. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11039. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11040. order.OwnpayAmt = ""
  11041. order.SelfpayAmt = ""
  11042. order.Spec = ""
  11043. order.SpecUnt = ""
  11044. order.DrordBegnDate = s_tm
  11045. order.DrordStopDate = ""
  11046. order.DrordDrCodg = doctor_info.DoctorNumber
  11047. order.DrordDeptName = department.Name
  11048. order.DrordDeptCodg = department.Number
  11049. order.DrordDrName = doctor_info.UserName
  11050. order.DrordDrProfttl = "234"
  11051. order.CurrDrordFlag = "1"
  11052. orders = append(orders, &order)
  11053. }
  11054. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11055. var order models.FsiOrderDtos
  11056. order.RxID = strconv.FormatInt(item.ID, 10)
  11057. order.Rxno = strconv.FormatInt(item.ID, 10)
  11058. order.LongDrordFlag = "0"
  11059. order.HilistType = "1"
  11060. order.ChrgType = "1"
  11061. order.DrordBhvr = "0"
  11062. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11063. order.HosplistName = subItem.GoodInfo.GoodName
  11064. order.HilistLv = "1"
  11065. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11066. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11067. order.HosplistName = subItem.GoodInfo.GoodName
  11068. order.Cnt = subItem.Count
  11069. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11070. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11071. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11072. order.OwnpayAmt = ""
  11073. order.SelfpayAmt = ""
  11074. order.Spec = ""
  11075. order.SpecUnt = ""
  11076. order.DrordBegnDate = s_tm
  11077. order.DrordStopDate = ""
  11078. order.DrordDrCodg = doctor_info.DoctorNumber
  11079. order.DrordDeptName = department.Name
  11080. order.DrordDeptCodg = department.Number
  11081. order.DrordDrName = doctor_info.UserName
  11082. order.DrordDrProfttl = "234"
  11083. order.CurrDrordFlag = "1"
  11084. orders = append(orders, &order)
  11085. }
  11086. }
  11087. }
  11088. //处方医嘱信息
  11089. fed.MatnStas = "0"
  11090. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11091. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11092. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11093. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11094. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11095. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11096. fed.SetlTotlnum = "1"
  11097. fed.Insutype = his.Insutype
  11098. fed.ReimFlag = "0"
  11099. fed.OutSetlFlag = "0"
  11100. var fopd []*models.FsiOperationDtosData
  11101. data := make(map[string]interface{})
  11102. data["fed"] = fed
  11103. data["fdd"] = fdds
  11104. data["fod"] = orders
  11105. data["pd"] = pd
  11106. data["pp"] = pp
  11107. data["fopd"] = fopd
  11108. data["trig_scen"] = trig_scen
  11109. client := &http.Client{}
  11110. bytesData, _ := json.Marshal(data)
  11111. var req *http.Request
  11112. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11113. if miConfig.MdtrtareaAdmvs == "320921" {
  11114. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11115. } else {
  11116. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11117. }
  11118. resp, _ := client.Do(req)
  11119. defer resp.Body.Close()
  11120. body, ioErr := ioutil.ReadAll(resp.Body)
  11121. if ioErr != nil {
  11122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11124. return res
  11125. }
  11126. var respJSON map[string]interface{}
  11127. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11130. return res
  11131. }
  11132. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11133. result, _ := json.Marshal(respJSON)
  11134. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11135. utils.ErrorLog("解析失败:%v", err)
  11136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11137. return res
  11138. }
  11139. return res
  11140. } else {
  11141. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11142. saveLog(output, input, "3102", "事中")
  11143. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11144. utils.ErrorLog("解析失败:%v", err)
  11145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11146. return
  11147. }
  11148. return res
  11149. }
  11150. return res
  11151. }
  11152. 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) {
  11153. var res Resultgd3101
  11154. adminUser := c.GetAdminUserInfo()
  11155. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11156. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11157. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11158. //record_time := c.GetString("record_time")
  11159. //trig_scen := c.GetString("trig_scen")
  11160. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11161. //psn_info, _ := service.GetPatientId(patient_id)
  11162. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11163. timeLayout := "2006-01-02"
  11164. loc, _ := time.LoadLocation("Local")
  11165. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11166. if err != nil {
  11167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11168. return res
  11169. }
  11170. recordDateTime := theTime.Unix()
  11171. var patientPrescription models.HisPrescriptionInfo
  11172. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11173. //if patientPrescription.ID == 0 {
  11174. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11175. //}
  11176. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11177. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11178. //
  11179. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11180. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11181. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11182. var pp models.PublicParams
  11183. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11184. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11185. pp.FixmedinsName = miConfig.OrgName
  11186. pp.FixmedinsCode = miConfig.Code
  11187. pp.RequestUrl = miConfig.Url
  11188. pp.Cainfo = miConfig.Cainfo
  11189. pp.SecretKey = miConfig.SecretKey
  11190. pp.AccessKey = miConfig.AccessKey
  11191. pp.OpterName = roles.UserName
  11192. var config []*models.HisXtDiagnoseConfig
  11193. for _, item := range diagnosis_ids {
  11194. id, _ := strconv.ParseInt(item, 10, 64)
  11195. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11196. config = append(config, &diagnosisConfig)
  11197. }
  11198. var pd models.PatientDtos
  11199. pd.PatnID = his.PsnNo
  11200. pd.PatnName = his.Name
  11201. pd.Gend = his.Gend
  11202. pd.Brdy = str
  11203. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11204. pd.CurrMdtrtID = his.Number
  11205. var fed models.FsiEncounterDtos
  11206. fed.MdtrtID = his.Number
  11207. fed.MedinsID = miConfig.Code
  11208. fed.MedinsName = miConfig.OrgName
  11209. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11210. fed.MedMdtrtType = "1"
  11211. fed.MedinsType = "1"
  11212. fed.MedinsLv = "11"
  11213. tm := time.Unix(his.RecordDate, 0)
  11214. s_tm := tm.Format("2006-01-02 15:04:05")
  11215. fed.AdmDate = s_tm
  11216. fed.DscgDate = s_tm
  11217. fed.DscgMainDiseCodg = config[0].CountryCode
  11218. fed.DscgMainDiseName = config[0].CountryContentName
  11219. //诊断信息
  11220. var fdds []*models.FsiDiagnoseDtos
  11221. for index, item := range config {
  11222. if index == 0 {
  11223. var fdd models.FsiDiagnoseDtos
  11224. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11225. fdd.InoutDiseType = "1"
  11226. fdd.MaindiseFlag = "1"
  11227. fdd.DiseDate = s_tm
  11228. fdd.DiasSrtNo = "1"
  11229. fdd.DiseName = item.CountryContentName
  11230. fdd.DiseCodg = item.CountryCode
  11231. fdds = append(fdds, &fdd)
  11232. } else {
  11233. var fdd models.FsiDiagnoseDtos
  11234. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11235. fdd.InoutDiseType = "1"
  11236. fdd.MaindiseFlag = "1"
  11237. fdd.DiseDate = s_tm
  11238. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11239. fdd.DiseName = item.CountryContentName
  11240. fdd.DiseCodg = item.CountryCode
  11241. fdds = append(fdds, &fdd)
  11242. }
  11243. }
  11244. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11245. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11246. fed.AdmDeptName = de.Name
  11247. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11248. fed.DscgDeptName = de.Name
  11249. fed.MedMdtrtType = "1"
  11250. fed.MedType = "11"
  11251. //if his.Insutype == "390" {
  11252. // fed.MedType = "1402"
  11253. //} else {
  11254. // fed.MedType = "9933"
  11255. //}
  11256. var orders []*models.FsiOrderDtos
  11257. if trig_scen == "2" {
  11258. //处方医嘱信息
  11259. for _, item := range prescriptions {
  11260. for _, subItem := range item.HisDoctorAdviceInfo {
  11261. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11262. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11263. var order models.FsiOrderDtos
  11264. order.RxID = strconv.FormatInt(item.ID, 10)
  11265. order.Rxno = strconv.FormatInt(item.ID, 10)
  11266. order.LongDrordFlag = "0"
  11267. order.HilistType = "1"
  11268. order.ChrgType = "1"
  11269. order.DrordBhvr = "0"
  11270. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11271. order.HosplistName = subItem.BaseDrugLib.DrugName
  11272. order.HilistLv = "1"
  11273. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11274. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11275. order.HosplistName = subItem.BaseDrugLib.DrugName
  11276. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11277. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11278. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11279. order.OwnpayAmt = ""
  11280. order.SelfpayAmt = ""
  11281. order.Spec = spec
  11282. order.SpecUnt = subItem.PrescribingNumberUnit
  11283. order.DrordBegnDate = s_tm
  11284. order.DrordStopDate = ""
  11285. order.DrordDrCodg = doctor_info.DoctorNumber
  11286. order.DrordDeptName = department.Name
  11287. order.DrordDeptCodg = department.Number
  11288. order.DrordDrName = doctor_info.UserName
  11289. order.DrordDrProfttl = "234"
  11290. order.CurrDrordFlag = "1"
  11291. orders = append(orders, &order)
  11292. }
  11293. }
  11294. for _, subItem := range item.HisPrescriptionProject {
  11295. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11296. var order models.FsiOrderDtos
  11297. order.RxID = strconv.FormatInt(item.ID, 10)
  11298. order.Rxno = strconv.FormatInt(item.ID, 10)
  11299. order.LongDrordFlag = "0"
  11300. order.HilistType = "1"
  11301. order.ChrgType = "1"
  11302. order.DrordBhvr = "0"
  11303. order.HilistCode = subItem.HisProject.MedicalCode
  11304. order.HosplistName = subItem.HisProject.ProjectName
  11305. order.HilistLv = "1"
  11306. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11307. order.HosplistCode = subItem.HisProject.MedicalCode
  11308. order.HosplistName = subItem.HisProject.ProjectName
  11309. order.Cnt = subItem.Count
  11310. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11311. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11312. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11313. order.OwnpayAmt = ""
  11314. order.SelfpayAmt = ""
  11315. order.Spec = subItem.Unit
  11316. order.SpecUnt = subItem.Unit
  11317. order.DrordBegnDate = s_tm
  11318. order.DrordStopDate = ""
  11319. order.DrordDrCodg = doctor_info.DoctorNumber
  11320. order.DrordDeptName = department.Name
  11321. order.DrordDeptCodg = department.Number
  11322. order.DrordDrName = doctor_info.UserName
  11323. order.DrordDrProfttl = "234"
  11324. order.CurrDrordFlag = "1"
  11325. orders = append(orders, &order)
  11326. }
  11327. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11328. var order models.FsiOrderDtos
  11329. order.RxID = strconv.FormatInt(item.ID, 10)
  11330. order.Rxno = strconv.FormatInt(item.ID, 10)
  11331. order.LongDrordFlag = "0"
  11332. order.HilistType = "1"
  11333. order.ChrgType = "1"
  11334. order.DrordBhvr = "0"
  11335. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11336. order.HosplistName = subItem.GoodInfo.GoodName
  11337. order.HilistLv = "1"
  11338. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11339. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11340. order.HosplistName = subItem.GoodInfo.GoodName
  11341. order.Cnt = subItem.Count
  11342. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11343. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11344. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11345. order.OwnpayAmt = ""
  11346. order.SelfpayAmt = ""
  11347. order.Spec = subItem.GoodInfo.SpecificationName
  11348. order.SpecUnt = subItem.Unit
  11349. order.DrordBegnDate = s_tm
  11350. order.DrordStopDate = ""
  11351. order.DrordDrCodg = doctor_info.DoctorNumber
  11352. order.DrordDeptName = department.Name
  11353. order.DrordDeptCodg = department.Number
  11354. order.DrordDrName = doctor_info.UserName
  11355. order.DrordDrProfttl = "234"
  11356. order.CurrDrordFlag = "1"
  11357. orders = append(orders, &order)
  11358. }
  11359. }
  11360. }
  11361. //处方医嘱信息
  11362. }
  11363. fed.MatnStas = "0"
  11364. fed.MedfeeSumamt = "0"
  11365. fed.OwnpayAmt = "0"
  11366. fed.SelfpayAmt = "0"
  11367. fed.AcctPayamt = "0"
  11368. fed.MaAmt = "0"
  11369. fed.HifpPayamt = "0"
  11370. fed.SetlTotlnum = "1"
  11371. fed.Insutype = his.Insutype
  11372. fed.ReimFlag = "0"
  11373. fed.OutSetlFlag = "0"
  11374. var fopd []*models.FsiOperationDtosData
  11375. data := make(map[string]interface{})
  11376. data["fed"] = fed
  11377. data["fdd"] = fdds
  11378. data["fod"] = orders
  11379. data["pd"] = pd
  11380. data["pp"] = pp
  11381. data["fopd"] = fopd
  11382. data["trig_scen"] = trig_scen
  11383. fmt.Println(data)
  11384. fmt.Println(fed)
  11385. fmt.Println(fdds)
  11386. fmt.Println(orders)
  11387. fmt.Println(pd)
  11388. fmt.Println(pp)
  11389. fmt.Println(fopd)
  11390. client := &http.Client{}
  11391. bytesData, _ := json.Marshal(data)
  11392. var req *http.Request
  11393. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11394. if miConfig.MdtrtareaAdmvs == "320921" {
  11395. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11396. } else {
  11397. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11398. }
  11399. resp, _ := client.Do(req)
  11400. defer resp.Body.Close()
  11401. body, ioErr := ioutil.ReadAll(resp.Body)
  11402. if ioErr != nil {
  11403. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11405. return res
  11406. }
  11407. var respJSON map[string]interface{}
  11408. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11411. return res
  11412. }
  11413. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11414. fmt.Println(respJSON)
  11415. result, _ := json.Marshal(respJSON)
  11416. fmt.Println(result)
  11417. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11418. utils.ErrorLog("解析失败:%v", err)
  11419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11420. return res
  11421. }
  11422. return res
  11423. } else {
  11424. //if miConfig.MdtrtareaAdmvs == "441202" {
  11425. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11426. saveLog(output, input, "3101", "事前")
  11427. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11428. utils.ErrorLog("解析失败:%v", err)
  11429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11430. return
  11431. }
  11432. return res
  11433. //}
  11434. }
  11435. }
  11436. 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) {
  11437. adminUser := c.GetAdminUserInfo()
  11438. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11439. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11440. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11441. //record_time := c.GetString("record_time")
  11442. //trig_scen := c.GetString("trig_scen")
  11443. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11444. timeLayout := "2006-01-02"
  11445. loc, _ := time.LoadLocation("Local")
  11446. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11447. if err != nil {
  11448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11449. return res
  11450. }
  11451. recordDateTime := theTime.Unix()
  11452. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11453. var patientPrescription models.HisPrescriptionInfo
  11454. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11455. if patientPrescription.ID == 0 {
  11456. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11457. }
  11458. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11459. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11460. //
  11461. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11462. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11463. var pp models.PublicParams
  11464. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11465. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11466. pp.FixmedinsName = miConfig.OrgName
  11467. pp.FixmedinsCode = miConfig.Code
  11468. pp.RequestUrl = miConfig.Url
  11469. pp.Cainfo = miConfig.Cainfo
  11470. pp.SecretKey = miConfig.SecretKey
  11471. pp.AccessKey = miConfig.AccessKey
  11472. pp.OpterName = roles.UserName
  11473. var config []*models.HisXtDiagnoseConfig
  11474. for _, item := range diagnosis_ids {
  11475. id, _ := strconv.ParseInt(item, 10, 64)
  11476. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11477. config = append(config, &diagnosisConfig)
  11478. }
  11479. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11480. var pd models.PatientDtos
  11481. pd.PatnID = his.PsnNo
  11482. pd.PatnName = his.Name
  11483. pd.Gend = his.Gend
  11484. pd.Brdy = str
  11485. pd.Poolarea = his.InsuplcAdmdvs
  11486. pd.CurrMdtrtID = his.Number
  11487. var fed models.FsiEncounterDtos
  11488. fed.MdtrtID = his.Number
  11489. fed.MedinsID = miConfig.Code
  11490. fed.MedinsName = miConfig.OrgName
  11491. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11492. fed.MedMdtrtType = "1"
  11493. fed.MedinsType = "1"
  11494. fed.MedinsLv = "11"
  11495. tm := time.Unix(his.RecordDate, 0)
  11496. s_tm := tm.Format("2006-01-02 15:04:05")
  11497. fed.AdmDate = s_tm
  11498. fed.DscgDate = s_tm
  11499. fed.DscgMainDiseCodg = config[0].CountryCode
  11500. fed.DscgMainDiseName = config[0].CountryContentName
  11501. //诊断信息
  11502. var fdds []*models.FsiDiagnoseDtos
  11503. for index, item := range config {
  11504. if index == 0 {
  11505. var fdd models.FsiDiagnoseDtos
  11506. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11507. fdd.InoutDiseType = "1"
  11508. fdd.MaindiseFlag = "1"
  11509. fdd.DiseDate = s_tm
  11510. fdd.DiasSrtNo = "1"
  11511. fdd.DiseName = item.CountryContentName
  11512. fdd.DiseCodg = item.CountryCode
  11513. fdds = append(fdds, &fdd)
  11514. } else {
  11515. var fdd models.FsiDiagnoseDtos
  11516. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11517. fdd.InoutDiseType = "1"
  11518. fdd.MaindiseFlag = "1"
  11519. fdd.DiseDate = s_tm
  11520. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11521. fdd.DiseName = item.CountryContentName
  11522. fdd.DiseCodg = item.CountryCode
  11523. fdds = append(fdds, &fdd)
  11524. }
  11525. }
  11526. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11527. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11528. fed.AdmDeptName = department.Name
  11529. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11530. fed.DscgDeptName = department.Name
  11531. fed.MedMdtrtType = "1"
  11532. fed.MedType = "11"
  11533. //if his.Insutype == "390" {
  11534. // fed.MedType = "1402"
  11535. //} else {
  11536. // fed.MedType = "9933"
  11537. //}
  11538. var orders []*models.FsiOrderDtos
  11539. if trig_scen == "2" {
  11540. //处方医嘱信息
  11541. for _, item := range prescriptions {
  11542. for _, subItem := range item.HisDoctorAdviceInfo {
  11543. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11544. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11545. var order models.FsiOrderDtos
  11546. order.RxID = strconv.FormatInt(item.ID, 10)
  11547. order.Rxno = strconv.FormatInt(item.ID, 10)
  11548. order.LongDrordFlag = "0"
  11549. order.HilistType = "1"
  11550. order.ChrgType = "1"
  11551. order.DrordBhvr = "0"
  11552. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11553. order.HosplistName = subItem.BaseDrugLib.DrugName
  11554. order.HilistLv = "1"
  11555. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11556. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11557. order.HosplistName = subItem.BaseDrugLib.DrugName
  11558. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11559. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11560. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11561. order.OwnpayAmt = ""
  11562. order.SelfpayAmt = ""
  11563. order.Spec = spec
  11564. order.SpecUnt = subItem.PrescribingNumberUnit
  11565. order.DrordBegnDate = s_tm
  11566. order.DrordStopDate = ""
  11567. order.DrordDrCodg = doctor_info.DoctorNumber
  11568. order.DrordDeptName = department.Name
  11569. order.DrordDeptCodg = department.Number
  11570. order.DrordDrName = doctor_info.UserName
  11571. order.DrordDrProfttl = "234"
  11572. order.CurrDrordFlag = "1"
  11573. orders = append(orders, &order)
  11574. }
  11575. }
  11576. for _, subItem := range item.HisPrescriptionProject {
  11577. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11578. var order models.FsiOrderDtos
  11579. order.RxID = strconv.FormatInt(item.ID, 10)
  11580. order.Rxno = strconv.FormatInt(item.ID, 10)
  11581. order.LongDrordFlag = "0"
  11582. order.HilistType = "1"
  11583. order.ChrgType = "1"
  11584. order.DrordBhvr = "0"
  11585. order.HilistCode = subItem.HisProject.MedicalCode
  11586. order.HosplistName = subItem.HisProject.ProjectName
  11587. order.HilistLv = "1"
  11588. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11589. order.HosplistCode = subItem.HisProject.MedicalCode
  11590. order.HosplistName = subItem.HisProject.ProjectName
  11591. order.Cnt = subItem.Count
  11592. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11593. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11594. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11595. order.OwnpayAmt = ""
  11596. order.SelfpayAmt = ""
  11597. order.Spec = subItem.Unit
  11598. order.SpecUnt = subItem.Unit
  11599. order.DrordBegnDate = s_tm
  11600. order.DrordStopDate = ""
  11601. order.DrordDrCodg = doctor_info.DoctorNumber
  11602. order.DrordDeptName = department.Name
  11603. order.DrordDeptCodg = department.Number
  11604. order.DrordDrName = doctor_info.UserName
  11605. order.DrordDrProfttl = "234"
  11606. order.CurrDrordFlag = "1"
  11607. orders = append(orders, &order)
  11608. }
  11609. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11610. var order models.FsiOrderDtos
  11611. order.RxID = strconv.FormatInt(item.ID, 10)
  11612. order.Rxno = strconv.FormatInt(item.ID, 10)
  11613. order.LongDrordFlag = "0"
  11614. order.HilistType = "1"
  11615. order.ChrgType = "1"
  11616. order.DrordBhvr = "0"
  11617. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11618. order.HosplistName = subItem.GoodInfo.GoodName
  11619. order.HilistLv = "1"
  11620. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11621. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11622. order.HosplistName = subItem.GoodInfo.GoodName
  11623. order.Cnt = subItem.Count
  11624. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11625. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11626. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11627. order.OwnpayAmt = ""
  11628. order.SelfpayAmt = ""
  11629. order.Spec = subItem.GoodInfo.SpecificationName
  11630. order.SpecUnt = subItem.Unit
  11631. order.DrordBegnDate = s_tm
  11632. order.DrordStopDate = ""
  11633. order.DrordDrCodg = doctor_info.DoctorNumber
  11634. order.DrordDeptName = department.Name
  11635. order.DrordDeptCodg = department.Number
  11636. order.DrordDrName = doctor_info.UserName
  11637. order.DrordDrProfttl = "234"
  11638. order.CurrDrordFlag = "1"
  11639. orders = append(orders, &order)
  11640. }
  11641. }
  11642. }
  11643. //处方医嘱信息
  11644. }
  11645. fed.MatnStas = "0"
  11646. fed.MedfeeSumamt = "0"
  11647. fed.OwnpayAmt = "0"
  11648. fed.SelfpayAmt = "0"
  11649. fed.AcctPayamt = "0"
  11650. fed.MaAmt = "0"
  11651. fed.HifpPayamt = "0"
  11652. fed.SetlTotlnum = "1"
  11653. fed.Insutype = his.Insutype
  11654. fed.ReimFlag = "0"
  11655. fed.OutSetlFlag = "0"
  11656. var fopd []*models.FsiOperationDtosData
  11657. data := make(map[string]interface{})
  11658. data["fed"] = fed
  11659. data["fdd"] = fdds
  11660. data["fod"] = orders
  11661. data["pd"] = pd
  11662. data["pp"] = pp
  11663. data["fopd"] = fopd
  11664. data["trig_scen"] = trig_scen
  11665. fmt.Println(data)
  11666. fmt.Println(fed)
  11667. fmt.Println(fdds)
  11668. fmt.Println(orders)
  11669. fmt.Println(pd)
  11670. fmt.Println(pp)
  11671. fmt.Println(fopd)
  11672. client := &http.Client{}
  11673. bytesData, _ := json.Marshal(data)
  11674. var req *http.Request
  11675. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11676. if miConfig.MdtrtareaAdmvs == "320921" {
  11677. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11678. } else {
  11679. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11680. }
  11681. resp, _ := client.Do(req)
  11682. defer resp.Body.Close()
  11683. body, ioErr := ioutil.ReadAll(resp.Body)
  11684. if ioErr != nil {
  11685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11687. return res
  11688. }
  11689. var respJSON map[string]interface{}
  11690. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11693. return res
  11694. }
  11695. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11696. fmt.Println(respJSON)
  11697. result, _ := json.Marshal(respJSON)
  11698. fmt.Println(result)
  11699. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11700. utils.ErrorLog("解析失败:%v", err)
  11701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11702. return res
  11703. }
  11704. return res
  11705. } else {
  11706. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11707. saveLog(output, input, "3101", "事前")
  11708. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11709. utils.ErrorLog("解析失败:%v", err)
  11710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11711. return
  11712. }
  11713. return res
  11714. }
  11715. return res
  11716. }
  11717. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11718. ////patient_id, _ := c.GetInt64("patient_id")
  11719. //order_id, _ := c.GetInt64("order_id")
  11720. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11721. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11722. //trig_scen := c.GetString("trig_scen")
  11723. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11724. //utils.ErrorLog("解析失败:%v", psn_info)
  11725. adminUser := c.GetAdminUserInfo()
  11726. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11727. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11728. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11729. record_time := c.GetString("record_time")
  11730. order, _ := service.GetHisOrderByID(order_id)
  11731. timeLayout := "2006-01-02"
  11732. loc, _ := time.LoadLocation("Local")
  11733. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11734. if err != nil {
  11735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11736. return
  11737. }
  11738. recordDateTime := theTime.Unix()
  11739. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11740. var patientPrescription models.HisPrescriptionInfo
  11741. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11742. if patientPrescription.ID == 0 {
  11743. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11744. }
  11745. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11746. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11747. //
  11748. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11749. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11750. var pp models.PublicParams
  11751. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11752. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11753. pp.FixmedinsName = miConfig.OrgName
  11754. pp.FixmedinsCode = miConfig.Code
  11755. pp.RequestUrl = miConfig.Url
  11756. pp.Cainfo = miConfig.Cainfo
  11757. pp.SecretKey = miConfig.SecretKey
  11758. pp.AccessKey = miConfig.AccessKey
  11759. pp.OpterName = roles.UserName
  11760. var config []*models.HisXtDiagnoseConfig
  11761. for _, item := range diagnosis_ids {
  11762. id, _ := strconv.ParseInt(item, 10, 64)
  11763. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11764. config = append(config, &diagnosisConfig)
  11765. }
  11766. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11767. var pd models.PatientDtos
  11768. pd.PatnID = his.PsnNo
  11769. pd.PatnName = his.Name
  11770. pd.Gend = his.Gend
  11771. pd.Brdy = str
  11772. pd.Poolarea = his.InsuplcAdmdvs
  11773. pd.CurrMdtrtID = his.Number
  11774. var fed models.FsiEncounterDtos
  11775. fed.MdtrtID = his.Number
  11776. fed.MedinsID = miConfig.Code
  11777. fed.MedinsName = miConfig.OrgName
  11778. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11779. fed.MedMdtrtType = "1"
  11780. fed.MedinsType = "1"
  11781. fed.MedinsLv = "11"
  11782. tm := time.Unix(his.RecordDate, 0)
  11783. s_tm := tm.Format("2006-01-02 15:04:05")
  11784. fed.AdmDate = s_tm
  11785. fed.DscgDate = s_tm
  11786. fed.DscgMainDiseCodg = config[0].CountryCode
  11787. fed.DscgMainDiseName = config[0].CountryContentName
  11788. //诊断信息
  11789. var fdds []*models.FsiDiagnoseDtos
  11790. for index, item := range config {
  11791. if index == 0 {
  11792. var fdd models.FsiDiagnoseDtos
  11793. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11794. fdd.InoutDiseType = "1"
  11795. fdd.MaindiseFlag = "1"
  11796. fdd.DiseDate = s_tm
  11797. fdd.DiasSrtNo = "1"
  11798. fdd.DiseName = item.CountryContentName
  11799. fdd.DiseCodg = item.CountryCode
  11800. fdds = append(fdds, &fdd)
  11801. } else {
  11802. var fdd models.FsiDiagnoseDtos
  11803. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11804. fdd.InoutDiseType = "1"
  11805. fdd.MaindiseFlag = "1"
  11806. fdd.DiseDate = s_tm
  11807. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11808. fdd.DiseName = item.CountryContentName
  11809. fdd.DiseCodg = item.CountryCode
  11810. fdds = append(fdds, &fdd)
  11811. }
  11812. }
  11813. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11814. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11815. fed.AdmDeptName = department.Name
  11816. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11817. fed.DscgDeptName = department.Name
  11818. fed.MedType = order.MedType
  11819. //处方医嘱信息
  11820. var orders []*models.FsiOrderDtos
  11821. //for _, item := range prescriptions {
  11822. // for _, subItem := range item.HisDoctorAdviceInfo {
  11823. // var order models.FsiOrderDtos
  11824. // order.RxID = strconv.FormatInt(item.ID, 10)
  11825. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11826. // order.LongDrordFlag = "0"
  11827. // order.HilistType = "1"
  11828. // order.ChrgType = "1"
  11829. // order.DrordBhvr = "-"
  11830. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11831. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11832. // order.HilistLv = "1"
  11833. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11834. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11835. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11836. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11837. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11838. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11839. // order.OwnpayAmt = ""
  11840. // order.SelfpayAmt = ""
  11841. // order.Spec = ""
  11842. // order.SpecUnt = ""
  11843. // order.DrordBegnDate = s_tm
  11844. // order.DrordStopDate = ""
  11845. // order.DrordDrCodg = "1"
  11846. // order.DrordDeptName = department.Name
  11847. // order.DrordDrCodg = "1"
  11848. // order.DrordDrName = doctor_info.UserName
  11849. // order.DrordDrProfttl = ""
  11850. // order.CurrDrordFlag = "1"
  11851. // orders = append(orders, &order)
  11852. // }
  11853. // for _, subItem := range item.HisPrescriptionProject {
  11854. // if subItem.Type == 2 {
  11855. // var order models.FsiOrderDtos
  11856. // order.RxID = strconv.FormatInt(item.ID, 10)
  11857. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11858. // order.LongDrordFlag = "0"
  11859. // order.HilistType = "1"
  11860. // order.ChrgType = "1"
  11861. // order.DrordBhvr = "-"
  11862. // order.HilistCode = subItem.HisProject.MedicalCode
  11863. // order.HosplistName = subItem.HisProject.ProjectName
  11864. // order.HilistLv = "1"
  11865. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11866. // order.HosplistCode = subItem.HisProject.MedicalCode
  11867. // order.HosplistName = subItem.HisProject.ProjectName
  11868. // order.Cnt = subItem.Count
  11869. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11870. //
  11871. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11872. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11873. // order.OwnpayAmt = ""
  11874. // order.SelfpayAmt = ""
  11875. // order.Spec = ""
  11876. // order.SpecUnt = ""
  11877. // order.DrordBegnDate = s_tm
  11878. // order.DrordStopDate = ""
  11879. // order.DrordDrCodg = "1"
  11880. // order.DrordDeptName = department.Name
  11881. // order.DrordDrCodg = "1"
  11882. // order.DrordDrName = doctor_info.UserName
  11883. // order.DrordDrProfttl = ""
  11884. // order.CurrDrordFlag = "1"
  11885. // orders = append(orders, &order)
  11886. //
  11887. // }
  11888. // if subItem.Type == 3 {
  11889. //
  11890. // var order models.FsiOrderDtos
  11891. // order.RxID = strconv.FormatInt(item.ID, 10)
  11892. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11893. // order.LongDrordFlag = "0"
  11894. // order.HilistType = "1"
  11895. // order.ChrgType = "1"
  11896. // order.DrordBhvr = "-"
  11897. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11898. // order.HosplistName = subItem.GoodInfo.GoodName
  11899. // order.HilistLv = "1"
  11900. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11901. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11902. // order.HosplistName = subItem.GoodInfo.GoodName
  11903. // order.Cnt = subItem.Count
  11904. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11905. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11906. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11907. // order.OwnpayAmt = ""
  11908. // order.SelfpayAmt = ""
  11909. // order.Spec = ""
  11910. // order.SpecUnt = ""
  11911. // order.DrordBegnDate = s_tm
  11912. // order.DrordStopDate = ""
  11913. // order.DrordDrCodg = "1"
  11914. // order.DrordDeptName = department.Name
  11915. // order.DrordDrCodg = "1"
  11916. // order.DrordDrName = doctor_info.UserName
  11917. // order.DrordDrProfttl = ""
  11918. // order.CurrDrordFlag = "1"
  11919. // orders = append(orders, &order)
  11920. //
  11921. // }
  11922. // }
  11923. //}
  11924. for _, item := range prescriptions {
  11925. for _, subItem := range item.HisDoctorAdviceInfo {
  11926. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11927. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11928. var order models.FsiOrderDtos
  11929. order.RxID = strconv.FormatInt(item.ID, 10)
  11930. order.Rxno = strconv.FormatInt(item.ID, 10)
  11931. order.LongDrordFlag = "0"
  11932. order.HilistType = "1"
  11933. order.ChrgType = "1"
  11934. order.DrordBhvr = "0"
  11935. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11936. order.HosplistName = subItem.BaseDrugLib.DrugName
  11937. order.HilistLv = "1"
  11938. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11939. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11940. order.HosplistName = subItem.BaseDrugLib.DrugName
  11941. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11942. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11943. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11944. order.OwnpayAmt = ""
  11945. order.SelfpayAmt = ""
  11946. order.Spec = spec
  11947. order.SpecUnt = subItem.PrescribingNumberUnit
  11948. order.DrordBegnDate = s_tm
  11949. order.DrordStopDate = ""
  11950. order.DrordDrCodg = doctor_info.DoctorNumber
  11951. order.DrordDeptName = department.Name
  11952. order.DrordDeptCodg = department.Number
  11953. order.DrordDrName = doctor_info.UserName
  11954. order.DrordDrProfttl = "234"
  11955. order.CurrDrordFlag = "1"
  11956. orders = append(orders, &order)
  11957. }
  11958. }
  11959. for _, subItem := range item.HisPrescriptionProject {
  11960. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11961. var order models.FsiOrderDtos
  11962. order.RxID = strconv.FormatInt(item.ID, 10)
  11963. order.Rxno = strconv.FormatInt(item.ID, 10)
  11964. order.LongDrordFlag = "0"
  11965. order.HilistType = "1"
  11966. order.ChrgType = "1"
  11967. order.DrordBhvr = "0"
  11968. order.HilistCode = subItem.HisProject.MedicalCode
  11969. order.HosplistName = subItem.HisProject.ProjectName
  11970. order.HilistLv = "1"
  11971. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11972. order.HosplistCode = subItem.HisProject.MedicalCode
  11973. order.HosplistName = subItem.HisProject.ProjectName
  11974. order.Cnt = subItem.Count
  11975. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11976. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11977. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11978. order.OwnpayAmt = ""
  11979. order.SelfpayAmt = ""
  11980. order.Spec = subItem.Unit
  11981. order.SpecUnt = subItem.Unit
  11982. order.DrordBegnDate = s_tm
  11983. order.DrordStopDate = ""
  11984. order.DrordDrCodg = doctor_info.DoctorNumber
  11985. order.DrordDeptName = department.Name
  11986. order.DrordDeptCodg = department.Number
  11987. order.DrordDrName = doctor_info.UserName
  11988. order.DrordDrProfttl = "234"
  11989. order.CurrDrordFlag = "1"
  11990. orders = append(orders, &order)
  11991. }
  11992. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11993. var order models.FsiOrderDtos
  11994. order.RxID = strconv.FormatInt(item.ID, 10)
  11995. order.Rxno = strconv.FormatInt(item.ID, 10)
  11996. order.LongDrordFlag = "0"
  11997. order.HilistType = "1"
  11998. order.ChrgType = "1"
  11999. order.DrordBhvr = "0"
  12000. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12001. order.HosplistName = subItem.GoodInfo.GoodName
  12002. order.HilistLv = "1"
  12003. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12004. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12005. order.HosplistName = subItem.GoodInfo.GoodName
  12006. order.Cnt = subItem.Count
  12007. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12008. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12009. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12010. order.OwnpayAmt = ""
  12011. order.SelfpayAmt = ""
  12012. order.Spec = subItem.GoodInfo.SpecificationName
  12013. order.SpecUnt = subItem.Unit
  12014. order.DrordBegnDate = s_tm
  12015. order.DrordStopDate = ""
  12016. order.DrordDrCodg = doctor_info.DoctorNumber
  12017. order.DrordDeptName = department.Name
  12018. order.DrordDeptCodg = department.Number
  12019. order.DrordDrName = doctor_info.UserName
  12020. order.DrordDrProfttl = "234"
  12021. order.CurrDrordFlag = "1"
  12022. orders = append(orders, &order)
  12023. }
  12024. }
  12025. }
  12026. //处方医嘱信息
  12027. fed.MatnStas = "0"
  12028. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12029. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12030. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12031. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12032. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12033. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12034. fed.SetlTotlnum = "1"
  12035. fed.Insutype = his.Insutype
  12036. fed.ReimFlag = "0"
  12037. fed.OutSetlFlag = "0"
  12038. var fopd []*models.FsiOperationDtosData
  12039. data := make(map[string]interface{})
  12040. data["fed"] = fed
  12041. data["fdd"] = fdds
  12042. data["fod"] = orders
  12043. data["pd"] = pd
  12044. data["pp"] = pp
  12045. data["fopd"] = fopd
  12046. data["trig_scen"] = trig_scen
  12047. client := &http.Client{}
  12048. bytesData, _ := json.Marshal(data)
  12049. var req *http.Request
  12050. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12051. if miConfig.MdtrtareaAdmvs == "320921" {
  12052. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12053. } else {
  12054. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12055. }
  12056. resp, _ := client.Do(req)
  12057. defer resp.Body.Close()
  12058. body, ioErr := ioutil.ReadAll(resp.Body)
  12059. if ioErr != nil {
  12060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12062. return res
  12063. }
  12064. var respJSON map[string]interface{}
  12065. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12068. return res
  12069. }
  12070. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12071. result, _ := json.Marshal(respJSON)
  12072. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12073. utils.ErrorLog("解析失败:%v", err)
  12074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12075. return res
  12076. }
  12077. return res
  12078. } else {
  12079. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12080. saveLog(output, input, "3102", "事中")
  12081. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12082. utils.ErrorLog("解析失败:%v", err)
  12083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12084. return
  12085. }
  12086. return res
  12087. }
  12088. return res
  12089. }
  12090. func (c *HisApiController) Check() {
  12091. psn_no := c.GetString("psn_no")
  12092. in := c.GetString("in")
  12093. mt := c.GetString("mt")
  12094. baseParams := models.BaseParams{
  12095. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12096. FixmedinsCode: "H15049901371",
  12097. InsuplcAdmdvs: "150499",
  12098. MdtrtareaAdmvs: "150499",
  12099. OrgName: "赤峰费森血液透析中心",
  12100. Doctor: "1111",
  12101. }
  12102. service.Gdyb2001(baseParams, psn_no, in, mt)
  12103. }
  12104. func (c *HisApiController) GetPsnNcdsInfo() {
  12105. admin_user_id, _ := c.GetInt64("admin_user_id")
  12106. patient_id, _ := c.GetInt64("patient_id")
  12107. //id, _ := c.GetInt64("id")
  12108. adminUser := c.GetAdminUserInfo()
  12109. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12110. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12111. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12112. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12113. //psn_record, _ := service.GetP(id)
  12114. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12115. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12116. //
  12117. //if psn_record.ID == 0 {
  12118. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12119. // return
  12120. //}
  12121. var res Result5301
  12122. var res10265 Result5301For10265
  12123. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12124. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12125. var api string
  12126. if miConfig.MdtrtareaAdmvs == "320921" {
  12127. 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 +
  12128. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12129. } else {
  12130. 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 +
  12131. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12132. }
  12133. resp, requestErr := http.Get(api)
  12134. if requestErr != nil {
  12135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12136. return
  12137. }
  12138. body, ioErr := ioutil.ReadAll(resp.Body)
  12139. if ioErr != nil {
  12140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12142. return
  12143. }
  12144. var respJSON map[string]interface{}
  12145. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12148. return
  12149. }
  12150. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12151. result, _ := json.Marshal(respJSON)
  12152. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12153. utils.ErrorLog("解析失败:%v", err)
  12154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12155. return
  12156. }
  12157. res.ErrMsg = res10265.ErrMsg
  12158. res.Output = res10265.Output
  12159. res.InfRefmsgid = res10265.InfRefmsgid
  12160. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12161. res.Infcode = infocode
  12162. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12163. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12164. var api string
  12165. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12166. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12167. resp, requestErr := http.Get(api)
  12168. if requestErr != nil {
  12169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12170. return
  12171. }
  12172. body, ioErr := ioutil.ReadAll(resp.Body)
  12173. if ioErr != nil {
  12174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12176. return
  12177. }
  12178. var respJSON map[string]interface{}
  12179. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12182. return
  12183. }
  12184. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12185. if status == "0" {
  12186. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12187. c.ServeSuccessJSON(map[string]interface{}{
  12188. "failed_code": -10,
  12189. "msg": err_msg,
  12190. })
  12191. return
  12192. }
  12193. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12194. result, _ := json.Marshal(respJSON)
  12195. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12196. utils.ErrorLog("解析失败:%v", err)
  12197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12198. return
  12199. }
  12200. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12201. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12202. var api string
  12203. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12204. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12205. resp, requestErr := http.Get(api)
  12206. if requestErr != nil {
  12207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12208. return
  12209. }
  12210. body, ioErr := ioutil.ReadAll(resp.Body)
  12211. if ioErr != nil {
  12212. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12214. return
  12215. }
  12216. var respJSON map[string]interface{}
  12217. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12220. return
  12221. }
  12222. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12223. if status == "0" {
  12224. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12225. c.ServeSuccessJSON(map[string]interface{}{
  12226. "failed_code": -10,
  12227. "msg": err_msg,
  12228. })
  12229. return
  12230. }
  12231. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12232. result, _ := json.Marshal(respJSON)
  12233. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12234. utils.ErrorLog("解析失败:%v", err)
  12235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12236. return
  12237. }
  12238. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12239. p, _ := service.GetHisPatientById(patient_id)
  12240. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12241. var dat map[string]interface{}
  12242. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12243. fmt.Println(dat)
  12244. } else {
  12245. fmt.Println(err)
  12246. }
  12247. userJSONBytes, _ := json.Marshal(dat)
  12248. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12249. utils.ErrorLog("解析失败:%v", err)
  12250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12251. return
  12252. }
  12253. } else if miConfig.MdtrtareaAdmvs == "361025" {
  12254. p, _ := service.GetHisPatientById(patient_id)
  12255. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12256. var dat map[string]interface{}
  12257. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12258. fmt.Println(dat)
  12259. } else {
  12260. fmt.Println(err)
  12261. }
  12262. userJSONBytes, _ := json.Marshal(dat)
  12263. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12264. utils.ErrorLog("解析失败:%v", err)
  12265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12266. return
  12267. }
  12268. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12269. p, _ := service.GetHisPatientById(patient_id)
  12270. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12271. var dat map[string]interface{}
  12272. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12273. fmt.Println(dat)
  12274. } else {
  12275. fmt.Println(err)
  12276. }
  12277. userJSONBytes, _ := json.Marshal(dat)
  12278. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12279. utils.ErrorLog("解析失败:%v", err)
  12280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12281. return
  12282. }
  12283. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12284. p, _ := service.GetHisPatientById(patient_id)
  12285. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12286. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12287. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12288. resp, requestErr := http.Get(api)
  12289. if requestErr != nil {
  12290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12291. return
  12292. }
  12293. body, ioErr := ioutil.ReadAll(resp.Body)
  12294. if ioErr != nil {
  12295. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12297. return
  12298. }
  12299. var respJSON map[string]interface{}
  12300. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12301. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12303. return
  12304. }
  12305. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12306. result, _ := json.Marshal(respJSON)
  12307. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12308. utils.ErrorLog("解析失败:%v", err)
  12309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12310. return
  12311. }
  12312. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12313. p, _ := service.GetHisPatientById(patient_id)
  12314. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12315. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12316. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12317. resp, requestErr := http.Get(api)
  12318. if requestErr != nil {
  12319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12320. return
  12321. }
  12322. body, ioErr := ioutil.ReadAll(resp.Body)
  12323. if ioErr != nil {
  12324. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12326. return
  12327. }
  12328. var respJSON map[string]interface{}
  12329. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12332. return
  12333. }
  12334. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12335. result, _ := json.Marshal(respJSON)
  12336. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12337. utils.ErrorLog("解析失败:%v", err)
  12338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12339. return
  12340. }
  12341. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12342. p, _ := service.GetHisPatientById(patient_id)
  12343. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12344. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12345. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12346. resp, requestErr := http.Get(api)
  12347. if requestErr != nil {
  12348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12349. return
  12350. }
  12351. body, ioErr := ioutil.ReadAll(resp.Body)
  12352. if ioErr != nil {
  12353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12355. return
  12356. }
  12357. var respJSON map[string]interface{}
  12358. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12361. return
  12362. }
  12363. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12364. result, _ := json.Marshal(respJSON)
  12365. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12366. utils.ErrorLog("解析失败:%v", err)
  12367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12368. return
  12369. }
  12370. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12371. p, _ := service.GetHisPatientById(patient_id)
  12372. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12373. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12374. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12375. resp, requestErr := http.Get(api)
  12376. if requestErr != nil {
  12377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12378. return
  12379. }
  12380. body, ioErr := ioutil.ReadAll(resp.Body)
  12381. if ioErr != nil {
  12382. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12384. return
  12385. }
  12386. var respJSON map[string]interface{}
  12387. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12388. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12390. return
  12391. }
  12392. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12393. result, _ := json.Marshal(respJSON)
  12394. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12395. utils.ErrorLog("解析失败:%v", err)
  12396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12397. return
  12398. }
  12399. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12400. p, _ := service.GetHisPatientById(patient_id)
  12401. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12402. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12403. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12404. resp, requestErr := http.Get(api)
  12405. if requestErr != nil {
  12406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12407. return
  12408. }
  12409. body, ioErr := ioutil.ReadAll(resp.Body)
  12410. if ioErr != nil {
  12411. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12413. return
  12414. }
  12415. var respJSON map[string]interface{}
  12416. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12419. return
  12420. }
  12421. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12422. result, _ := json.Marshal(respJSON)
  12423. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12424. utils.ErrorLog("解析失败:%v", err)
  12425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12426. return
  12427. }
  12428. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12429. p, _ := service.GetHisPatientById(patient_id)
  12430. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12431. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12432. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12433. resp, requestErr := http.Get(api)
  12434. if requestErr != nil {
  12435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12436. return
  12437. }
  12438. body, ioErr := ioutil.ReadAll(resp.Body)
  12439. if ioErr != nil {
  12440. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12442. return
  12443. }
  12444. var respJSON map[string]interface{}
  12445. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12448. return
  12449. }
  12450. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12451. result, _ := json.Marshal(respJSON)
  12452. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12453. utils.ErrorLog("解析失败:%v", err)
  12454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12455. return
  12456. }
  12457. } else {
  12458. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12459. var dat map[string]interface{}
  12460. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12461. fmt.Println(dat)
  12462. } else {
  12463. fmt.Println(err)
  12464. }
  12465. userJSONBytes, _ := json.Marshal(dat)
  12466. if miConfig.Code == "H15049901371" {
  12467. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12468. utils.ErrorLog("解析失败:%v", err)
  12469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12470. return
  12471. }
  12472. res.InfRefmsgid = res10265.InfRefmsgid
  12473. res.Output = res10265.Output
  12474. res.ErrMsg = res10265.ErrMsg
  12475. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12476. res.Infcode = infocode
  12477. } else {
  12478. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12479. utils.ErrorLog("解析失败:%v", err)
  12480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12481. return
  12482. }
  12483. }
  12484. }
  12485. if res.Infcode == 0 {
  12486. c.ServeSuccessJSON(map[string]interface{}{
  12487. "result": res.Output.Result,
  12488. })
  12489. }
  12490. }
  12491. func (c *HisApiController) CheckInsutype() {
  12492. his_patient_id, _ := c.GetInt64("his_patient_id")
  12493. admin_user_id, _ := c.GetInt64("admin_user_id")
  12494. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12495. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12496. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12497. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12498. var dat map[string]interface{}
  12499. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12500. fmt.Println(dat)
  12501. } else {
  12502. fmt.Println(err)
  12503. }
  12504. userJSONBytes, _ := json.Marshal(dat)
  12505. var res Result90100
  12506. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12507. utils.ErrorLog("解析失败:%v", err)
  12508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12509. return
  12510. }
  12511. if res.Infcode != 0 {
  12512. c.ServeSuccessJSON(map[string]interface{}{
  12513. "failed_code": -10,
  12514. "msg": res.ErrMsg,
  12515. })
  12516. return
  12517. } else {
  12518. fmt.Println(res)
  12519. }
  12520. }
  12521. func (c *HisApiController) CheckCardPWD() {
  12522. card_pwd := c.GetString("card_pwd")
  12523. his_patient_id, _ := c.GetInt64("his_patient_id")
  12524. admin_user_id, _ := c.GetInt64("admin_user_id")
  12525. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12526. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12527. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12528. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12529. bas := strings.Split(psn.CardInfo, "|")
  12530. basNumber := bas[2]
  12531. if psn.InsuplcAdmdvs[:4] == "4403" {
  12532. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12533. var dat map[string]interface{}
  12534. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12535. fmt.Println(dat)
  12536. } else {
  12537. fmt.Println(err)
  12538. }
  12539. userJSONBytes, _ := json.Marshal(dat)
  12540. var res Result90991
  12541. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12542. utils.ErrorLog("解析失败:%v", err)
  12543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12544. return
  12545. }
  12546. if res.Infcode != 0 {
  12547. c.ServeSuccessJSON(map[string]interface{}{
  12548. "failed_code": -10,
  12549. "msg": res.ErrMsg,
  12550. })
  12551. return
  12552. } else {
  12553. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12554. var msg string
  12555. switch res.Output.Result.CardStat {
  12556. case "00":
  12557. msg = "未激活"
  12558. break
  12559. case "10":
  12560. msg = "激活"
  12561. break
  12562. case "20":
  12563. msg = "窗口挂失"
  12564. break
  12565. case "21":
  12566. msg = "电话挂失"
  12567. break
  12568. case "22":
  12569. msg = "单位网上申报挂失"
  12570. break
  12571. case "23":
  12572. msg = "保健办挂失"
  12573. break
  12574. case "24":
  12575. msg = "个人网上挂失"
  12576. break
  12577. case "25":
  12578. msg = "网上服务大厅挂失"
  12579. break
  12580. case "30":
  12581. msg = "注销"
  12582. break
  12583. case "40":
  12584. msg = "回收"
  12585. break
  12586. case "99":
  12587. msg = "制卡中(无效卡)"
  12588. break
  12589. }
  12590. c.ServeSuccessJSON(map[string]interface{}{
  12591. "failed_code": -10,
  12592. "msg": msg,
  12593. })
  12594. return
  12595. } else {
  12596. c.ServeSuccessJSON(map[string]interface{}{
  12597. "msg": "校验成功",
  12598. })
  12599. return
  12600. }
  12601. }
  12602. } else {
  12603. c.ServeSuccessJSON(map[string]interface{}{
  12604. "msg": "校验成功",
  12605. })
  12606. return
  12607. }
  12608. }
  12609. func (c *HisApiController) CheckCardPWDTwo() {
  12610. //card_pwd := c.GetString("card_pwd")
  12611. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12612. admin_user_id, _ := c.GetInt64("admin_user_id")
  12613. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12614. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12615. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12616. var dat map[string]interface{}
  12617. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12618. fmt.Println(dat)
  12619. } else {
  12620. fmt.Println(err)
  12621. }
  12622. userJSONBytes, _ := json.Marshal(dat)
  12623. var res Result90991
  12624. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12625. utils.ErrorLog("解析失败:%v", err)
  12626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12627. return
  12628. }
  12629. if res.Infcode != 0 {
  12630. c.ServeSuccessJSON(map[string]interface{}{
  12631. "failed_code": -10,
  12632. "msg": res.ErrMsg,
  12633. })
  12634. return
  12635. } else {
  12636. if res.Output.Result.SscnoCheckStat == "0" {
  12637. var msg string
  12638. switch res.Output.Result.CardStat {
  12639. case "00":
  12640. msg = "未激活"
  12641. break
  12642. case "10":
  12643. msg = "激活"
  12644. break
  12645. case "20":
  12646. msg = "窗口挂失"
  12647. break
  12648. case "21":
  12649. msg = "电话挂失"
  12650. break
  12651. case "22":
  12652. msg = "单位网上申报挂失"
  12653. break
  12654. case "23":
  12655. msg = "保健办挂失"
  12656. break
  12657. case "24":
  12658. msg = "个人网上挂失"
  12659. break
  12660. case "25":
  12661. msg = "网上服务大厅挂失"
  12662. break
  12663. case "30":
  12664. msg = "注销"
  12665. break
  12666. case "40":
  12667. msg = "回收"
  12668. break
  12669. case "99":
  12670. msg = "制卡中(无效卡)"
  12671. break
  12672. }
  12673. c.ServeSuccessJSON(map[string]interface{}{
  12674. "failed_code": -10,
  12675. "msg": msg,
  12676. })
  12677. return
  12678. } else {
  12679. c.ServeSuccessJSON(map[string]interface{}{
  12680. "msg": "校验成功",
  12681. })
  12682. return
  12683. }
  12684. }
  12685. }
  12686. type ELeCertData struct {
  12687. Data struct {
  12688. Extra string `json:"extra"`
  12689. IDNo string `json:"idNo"`
  12690. IDType string `json:"idType"`
  12691. EcToken string `json:"ecToken"`
  12692. InsuOrg string `json:"insuOrg"`
  12693. UserName string `json:"userName"`
  12694. EcIndexNo string `json:"ecIndexNo"`
  12695. Gender string `json:"gender"`
  12696. Birthday string `json:"birthday"`
  12697. Nationality string `json:"nationality"`
  12698. Email string `json:"email"`
  12699. } `json:"OutData"`
  12700. }
  12701. func (c *HisApiController) ReadCard() {
  12702. id_card_type, _ := c.GetInt64("id_card_type")
  12703. admin_user_id, _ := c.GetInt64("admin_user_id")
  12704. certificates, _ := c.GetInt64("certificates")
  12705. //
  12706. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12707. id_card_no := c.GetString("id_card_no")
  12708. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12709. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12710. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12711. switch id_card_type {
  12712. case 1:
  12713. if miConfig.MdtrtareaAdmvs == "421300" {
  12714. var res ResultTwo
  12715. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12716. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12717. "&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)
  12718. resp, requestErr := http.Get(api)
  12719. if requestErr != nil {
  12720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12721. return
  12722. }
  12723. body, ioErr := ioutil.ReadAll(resp.Body)
  12724. if ioErr != nil {
  12725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12727. return
  12728. }
  12729. var respJSON map[string]interface{}
  12730. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12733. return
  12734. }
  12735. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12736. result, _ := json.Marshal(respJSON)
  12737. fmt.Println("log")
  12738. fmt.Println(string(result))
  12739. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12740. utils.ErrorLog("解析失败:%v", err)
  12741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12742. return
  12743. }
  12744. if res.Infcode == 0 {
  12745. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12746. if err == gorm.ErrRecordNotFound {
  12747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12748. return
  12749. } else if err != nil {
  12750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12751. return
  12752. } else {
  12753. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12754. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12755. infoStr := string(Iinfos)
  12756. idetinfoStr := string(Idetinfos)
  12757. var rf []*ResultFive
  12758. json.Unmarshal([]byte(infoStr), &rf)
  12759. var insutypes []*ResultFive
  12760. var insutype string
  12761. var is390 int = 0
  12762. var is310 int = 0
  12763. for _, item := range rf {
  12764. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12765. insutypes = append(insutypes, item)
  12766. }
  12767. }
  12768. if len(insutypes) == 1 {
  12769. insutype = insutypes[0].Insutype
  12770. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12771. } else {
  12772. for _, i := range insutypes {
  12773. if i.Insutype == "390" {
  12774. is390 = 1
  12775. }
  12776. if i.Insutype == "310" {
  12777. is310 = 1
  12778. }
  12779. }
  12780. }
  12781. if is390 == 1 {
  12782. insutype = "390"
  12783. }
  12784. if is310 == 1 {
  12785. insutype = "310"
  12786. }
  12787. if len(insutypes) == 0 {
  12788. insutype = "390"
  12789. }
  12790. var insuplc_admdvs string
  12791. for _, item := range rf {
  12792. if item.Insutype == insutype {
  12793. insuplc_admdvs = item.InsuplcAdmdvs
  12794. }
  12795. }
  12796. if strings.Contains(insuplc_admdvs, "4213") {
  12797. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12798. }
  12799. psn := &models.HisPsn{
  12800. PsnNo: res.Output.Baseinfo.PsnNo,
  12801. PatientId: patient.ID,
  12802. Certno: res.Output.Baseinfo.Certno,
  12803. Gend: res.Output.Baseinfo.Gend,
  12804. Naty: res.Output.Baseinfo.Naty,
  12805. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12806. PsnName: res.Output.Baseinfo.PsnName,
  12807. Idetinfo: idetinfoStr,
  12808. Insuinfo: infoStr,
  12809. InsuplcAdmdvs: insuplc_admdvs,
  12810. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12811. }
  12812. service.CreateHisPsn(psn)
  12813. c.ServeSuccessJSON(map[string]interface{}{
  12814. "patient": patient,
  12815. "number": res.Output.Baseinfo.Certno,
  12816. })
  12817. }
  12818. } else {
  12819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12820. return
  12821. }
  12822. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12823. var res ResultTwo
  12824. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12825. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12826. "&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)
  12827. resp, requestErr := http.Get(api)
  12828. if requestErr != nil {
  12829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12830. return
  12831. }
  12832. body, ioErr := ioutil.ReadAll(resp.Body)
  12833. if ioErr != nil {
  12834. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12836. return
  12837. }
  12838. var respJSON map[string]interface{}
  12839. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12842. return
  12843. }
  12844. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12845. result, _ := json.Marshal(respJSON)
  12846. fmt.Println("log")
  12847. fmt.Println(string(result))
  12848. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12849. utils.ErrorLog("解析失败:%v", err)
  12850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12851. return
  12852. }
  12853. if res.Infcode == 0 {
  12854. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12855. if err == gorm.ErrRecordNotFound {
  12856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12857. return
  12858. } else if err != nil {
  12859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12860. return
  12861. } else {
  12862. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12863. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12864. infoStr := string(Iinfos)
  12865. idetinfoStr := string(Idetinfos)
  12866. psn := &models.HisPsn{
  12867. PsnNo: res.Output.Baseinfo.PsnNo,
  12868. PatientId: patient.ID,
  12869. Certno: res.Output.Baseinfo.Certno,
  12870. Gend: res.Output.Baseinfo.Gend,
  12871. Naty: res.Output.Baseinfo.Naty,
  12872. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12873. PsnName: res.Output.Baseinfo.PsnName,
  12874. Idetinfo: idetinfoStr,
  12875. Insuinfo: infoStr,
  12876. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12877. }
  12878. service.CreateHisPsn(psn)
  12879. var rf []*ResultFive
  12880. json.Unmarshal([]byte(infoStr), &rf)
  12881. var insutypes []*ResultFive
  12882. var insutype string
  12883. var is390 int = 0
  12884. var is310 int = 0
  12885. for _, item := range rf {
  12886. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12887. insutypes = append(insutypes, item)
  12888. }
  12889. }
  12890. if len(insutypes) == 1 {
  12891. insutype = insutypes[0].Insutype
  12892. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12893. } else {
  12894. for _, i := range insutypes {
  12895. if i.Insutype == "390" {
  12896. is390 = 1
  12897. }
  12898. if i.Insutype == "310" {
  12899. is310 = 1
  12900. }
  12901. }
  12902. }
  12903. if is390 == 1 {
  12904. insutype = "390"
  12905. }
  12906. if is310 == 1 {
  12907. insutype = "310"
  12908. }
  12909. if len(insutypes) == 0 {
  12910. insutype = "310"
  12911. }
  12912. c.ServeSuccessJSON(map[string]interface{}{
  12913. "patient": patient,
  12914. "number": res.Output.Baseinfo.Certno,
  12915. "insutype": insutype,
  12916. })
  12917. }
  12918. } else {
  12919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12920. return
  12921. }
  12922. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12923. var res ResultTwo
  12924. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12925. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12926. "&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)
  12927. resp, requestErr := http.Get(api)
  12928. if requestErr != nil {
  12929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12930. return
  12931. }
  12932. body, ioErr := ioutil.ReadAll(resp.Body)
  12933. if ioErr != nil {
  12934. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12936. return
  12937. }
  12938. var respJSON map[string]interface{}
  12939. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12942. return
  12943. }
  12944. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12945. result, _ := json.Marshal(respJSON)
  12946. fmt.Println("log")
  12947. fmt.Println(string(result))
  12948. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12949. utils.ErrorLog("解析失败:%v", err)
  12950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12951. return
  12952. }
  12953. if res.Infcode == 0 {
  12954. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12955. if err == gorm.ErrRecordNotFound {
  12956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12957. return
  12958. } else if err != nil {
  12959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12960. return
  12961. } else {
  12962. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12963. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12964. infoStr := string(Iinfos)
  12965. idetinfoStr := string(Idetinfos)
  12966. var rf []*ResultFive
  12967. json.Unmarshal([]byte(infoStr), &rf)
  12968. var insutypes []*ResultFive
  12969. var insutype string
  12970. var is390 int = 0
  12971. var is310 int = 0
  12972. for _, item := range rf {
  12973. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12974. insutypes = append(insutypes, item)
  12975. }
  12976. }
  12977. if len(insutypes) == 1 {
  12978. insutype = insutypes[0].Insutype
  12979. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12980. } else {
  12981. for _, i := range insutypes {
  12982. if i.Insutype == "390" {
  12983. is390 = 1
  12984. }
  12985. if i.Insutype == "310" {
  12986. is310 = 1
  12987. }
  12988. }
  12989. }
  12990. if is390 == 1 {
  12991. insutype = "390"
  12992. }
  12993. if is310 == 1 {
  12994. insutype = "310"
  12995. }
  12996. if len(insutypes) == 0 {
  12997. insutype = "390"
  12998. }
  12999. var insuplc_admdvs string
  13000. for _, item := range rf {
  13001. if item.Insutype == insutype {
  13002. insuplc_admdvs = item.InsuplcAdmdvs
  13003. }
  13004. }
  13005. psn := &models.HisPsn{
  13006. PsnNo: res.Output.Baseinfo.PsnNo,
  13007. PatientId: patient.ID,
  13008. Certno: res.Output.Baseinfo.Certno,
  13009. Gend: res.Output.Baseinfo.Gend,
  13010. Naty: res.Output.Baseinfo.Naty,
  13011. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13012. PsnName: res.Output.Baseinfo.PsnName,
  13013. Idetinfo: idetinfoStr,
  13014. Insuinfo: infoStr,
  13015. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13016. InsuplcAdmdvs: insuplc_admdvs,
  13017. }
  13018. service.CreateHisPsn(psn)
  13019. for _, item := range rf {
  13020. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13021. insutypes = append(insutypes, item)
  13022. }
  13023. }
  13024. if len(insutypes) == 1 {
  13025. insutype = insutypes[0].Insutype
  13026. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13027. } else {
  13028. for _, i := range insutypes {
  13029. if i.Insutype == "390" {
  13030. is390 = 1
  13031. }
  13032. if i.Insutype == "310" {
  13033. is310 = 1
  13034. }
  13035. }
  13036. }
  13037. if is390 == 1 {
  13038. insutype = "390"
  13039. }
  13040. if is310 == 1 {
  13041. insutype = "310"
  13042. }
  13043. if len(insutypes) == 0 {
  13044. insutype = "310"
  13045. }
  13046. c.ServeSuccessJSON(map[string]interface{}{
  13047. "patient": patient,
  13048. "number": res.Output.Baseinfo.Certno,
  13049. "insutype": insutype,
  13050. })
  13051. }
  13052. } else {
  13053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13054. return
  13055. }
  13056. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13057. var res ResultTwo
  13058. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13059. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13060. "&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)
  13061. resp, requestErr := http.Get(api)
  13062. if requestErr != nil {
  13063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13064. return
  13065. }
  13066. body, ioErr := ioutil.ReadAll(resp.Body)
  13067. if ioErr != nil {
  13068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13070. return
  13071. }
  13072. var respJSON map[string]interface{}
  13073. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13076. return
  13077. }
  13078. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13079. result, _ := json.Marshal(respJSON)
  13080. fmt.Println("log")
  13081. fmt.Println(string(result))
  13082. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13083. utils.ErrorLog("解析失败:%v", err)
  13084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13085. return
  13086. }
  13087. if res.Infcode == 0 {
  13088. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13089. if err == gorm.ErrRecordNotFound {
  13090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13091. return
  13092. } else if err != nil {
  13093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13094. return
  13095. } else {
  13096. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13097. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13098. infoStr := string(Iinfos)
  13099. idetinfoStr := string(Idetinfos)
  13100. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13101. psn := &models.HisPsn{
  13102. PsnNo: res.Output.Baseinfo.PsnNo,
  13103. PatientId: patient.ID,
  13104. Certno: res.Output.Baseinfo.Certno,
  13105. Brdy: b,
  13106. Age: float64(age),
  13107. Gend: res.Output.Baseinfo.Gend,
  13108. Naty: res.Output.Baseinfo.Naty,
  13109. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13110. PsnName: res.Output.Baseinfo.PsnName,
  13111. Idetinfo: idetinfoStr,
  13112. Insuinfo: infoStr,
  13113. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13114. }
  13115. service.CreateHisPsn(psn)
  13116. var rf []*ResultFive
  13117. json.Unmarshal([]byte(infoStr), &rf)
  13118. var insutypes []*ResultFive
  13119. var insutype string
  13120. var is390 int = 0
  13121. var is310 int = 0
  13122. for _, item := range rf {
  13123. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13124. insutypes = append(insutypes, item)
  13125. }
  13126. }
  13127. if len(insutypes) == 1 {
  13128. insutype = insutypes[0].Insutype
  13129. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13130. } else {
  13131. for _, i := range insutypes {
  13132. if i.Insutype == "390" {
  13133. is390 = 1
  13134. }
  13135. if i.Insutype == "310" {
  13136. is310 = 1
  13137. }
  13138. }
  13139. }
  13140. if is390 == 1 {
  13141. insutype = "390"
  13142. }
  13143. if is310 == 1 {
  13144. insutype = "310"
  13145. }
  13146. if len(insutypes) == 0 {
  13147. insutype = "310"
  13148. }
  13149. c.ServeSuccessJSON(map[string]interface{}{
  13150. "patient": patient,
  13151. "number": res.Output.Baseinfo.Certno,
  13152. "insutype": insutype,
  13153. })
  13154. }
  13155. } else {
  13156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13157. return
  13158. }
  13159. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13160. var api string
  13161. if miConfig.MdtrtareaAdmvs == "320921" {
  13162. 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 +
  13163. "&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
  13164. fmt.Println(api)
  13165. } else {
  13166. 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 +
  13167. "&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)
  13168. }
  13169. resp, requestErr := http.Get(api)
  13170. if requestErr != nil {
  13171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13172. return
  13173. }
  13174. body, ioErr := ioutil.ReadAll(resp.Body)
  13175. if ioErr != nil {
  13176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13178. return
  13179. }
  13180. var respJSON map[string]interface{}
  13181. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13184. return
  13185. }
  13186. var status string
  13187. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13188. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13189. //console.log()
  13190. fmt.Println("type===")
  13191. fmt.Println(card_type)
  13192. var token string
  13193. var res ResultTwo //1101结果
  13194. var res10265 ResultTwo10265 //1101结果
  13195. var card_info string //卡信息
  13196. var busi_card_info string
  13197. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13198. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13199. if status == "0" { //读卡成功
  13200. if card_type == "1" {
  13201. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13202. result, _ := json.Marshal(respJSON)
  13203. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13204. utils.ErrorLog("解析失败:%v", err)
  13205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13206. return
  13207. }
  13208. res.ErrMsg = res10265.ErrMsg
  13209. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13210. res.Infcode = infocode
  13211. res.Output = res10265.Output
  13212. res.InfRefmsgid = res10265.InfRefmsgid
  13213. } else {
  13214. //var card_info string //卡信息
  13215. //var busi_card_info string
  13216. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13217. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13218. //fmt.Println(card_info)
  13219. //fmt.Println(busi_card_info)
  13220. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13221. result, _ := json.Marshal(respJSON)
  13222. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13223. utils.ErrorLog("解析失败:%v", err)
  13224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13225. return
  13226. }
  13227. res.ErrMsg = res10265.ErrMsg
  13228. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13229. res.Infcode = infocode
  13230. res.Output = res10265.Output
  13231. res.InfRefmsgid = res10265.InfRefmsgid
  13232. }
  13233. if res.Infcode == 0 {
  13234. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13235. if err == gorm.ErrRecordNotFound {
  13236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13237. return
  13238. } else if err != nil {
  13239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13240. return
  13241. } else {
  13242. if card_type == "1" {
  13243. bas := strings.Split(card_info, "|")
  13244. basNumber := bas[2]
  13245. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13246. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13247. infoStr := string(Iinfos)
  13248. idetinfoStr := string(Idetinfos)
  13249. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13250. psn := &models.HisPsn{
  13251. PsnNo: res.Output.Baseinfo.PsnNo,
  13252. PatientId: patient.ID,
  13253. Certno: res.Output.Baseinfo.Certno,
  13254. Brdy: b,
  13255. Age: float64(age),
  13256. Gend: res.Output.Baseinfo.Gend,
  13257. Naty: res.Output.Baseinfo.Naty,
  13258. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13259. PsnName: res.Output.Baseinfo.PsnName,
  13260. Idetinfo: idetinfoStr,
  13261. Insuinfo: infoStr,
  13262. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13263. CardInfo: card_info,
  13264. VerifyNumber: busi_card_info,
  13265. }
  13266. service.CreateHisPsn(psn)
  13267. var rf []*ResultFive
  13268. json.Unmarshal([]byte(infoStr), &rf)
  13269. var insutypes []*ResultFive
  13270. var insutype string
  13271. var is390 int = 0
  13272. var is310 int = 0
  13273. for _, item := range rf {
  13274. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13275. insutypes = append(insutypes, item)
  13276. }
  13277. }
  13278. if len(insutypes) == 1 {
  13279. insutype = insutypes[0].Insutype
  13280. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13281. } else {
  13282. for _, i := range insutypes {
  13283. if i.Insutype == "390" {
  13284. is390 = 1
  13285. }
  13286. if i.Insutype == "310" {
  13287. is310 = 1
  13288. }
  13289. }
  13290. }
  13291. if is390 == 1 {
  13292. insutype = "390"
  13293. }
  13294. if is310 == 1 {
  13295. insutype = "310"
  13296. }
  13297. if len(insutypes) == 0 {
  13298. insutype = "310"
  13299. }
  13300. c.ServeSuccessJSON(map[string]interface{}{
  13301. "patient": patient,
  13302. "number": basNumber,
  13303. "insutype": insutype,
  13304. })
  13305. } else {
  13306. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13307. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13308. infoStr := string(Iinfos)
  13309. idetinfoStr := string(Idetinfos)
  13310. psn := &models.HisPsn{
  13311. PsnNo: res.Output.Baseinfo.PsnNo,
  13312. PatientId: patient.ID,
  13313. Certno: res.Output.Baseinfo.Certno,
  13314. Gend: res.Output.Baseinfo.Gend,
  13315. Naty: res.Output.Baseinfo.Naty,
  13316. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13317. PsnName: res.Output.Baseinfo.PsnName,
  13318. Idetinfo: idetinfoStr,
  13319. Insuinfo: infoStr,
  13320. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13321. CardInfo: card_info,
  13322. VerifyNumber: token,
  13323. }
  13324. service.CreateHisPsn(psn)
  13325. c.ServeSuccessJSON(map[string]interface{}{
  13326. "patient": patient,
  13327. "number": token,
  13328. })
  13329. }
  13330. }
  13331. } else {
  13332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13333. return
  13334. }
  13335. } else { //读卡失败
  13336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13337. return
  13338. }
  13339. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13340. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13341. cardnum = DeleteExtraSpaceTwo(cardnum)
  13342. cardCode = DeleteExtraSpaceTwo(cardCode)
  13343. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13344. name = DeleteExtraSpaceTwo(name)
  13345. errmsg = DeleteExtraSpaceTwo(errmsg)
  13346. cardnum = Remove0000(cardnum)
  13347. cardCode = Remove0000(cardCode)
  13348. id_card_no = Remove0000(id_card_no)
  13349. name = Remove0000(name)
  13350. errmsg = Remove0000(errmsg)
  13351. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13352. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13353. //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)
  13354. //fmt.Println(result2)
  13355. //fmt.Println(requestLog2)
  13356. //fmt.Println(errMsgLog2)
  13357. 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)
  13358. saveLog(result, requestLog, "1101", "获取人员信息")
  13359. fmt.Println(errMsgLog)
  13360. if len(errMsgLog) > 0 {
  13361. } else {
  13362. var dat map[string]interface{}
  13363. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13364. fmt.Println(dat)
  13365. } else {
  13366. fmt.Println(err)
  13367. }
  13368. userJSONBytes, _ := json.Marshal(dat)
  13369. var res ResultTwo
  13370. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13371. utils.ErrorLog("解析失败:%v", err)
  13372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13373. return
  13374. }
  13375. res.ErrMsg = errMsgLog
  13376. if res.Infcode == 0 {
  13377. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13378. if err == gorm.ErrRecordNotFound {
  13379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13380. return
  13381. } else if err != nil {
  13382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13383. return
  13384. } else {
  13385. fmt.Println(res)
  13386. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13387. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13388. infoStr := string(Iinfos)
  13389. idetinfoStr := string(Idetinfos)
  13390. var rf []*ResultFive
  13391. json.Unmarshal([]byte(infoStr), &rf)
  13392. var insutypes []*ResultFive
  13393. var insutype string
  13394. var is390 int = 0
  13395. var is310 int = 0
  13396. for _, item := range rf {
  13397. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13398. insutypes = append(insutypes, item)
  13399. }
  13400. }
  13401. if len(insutypes) == 1 {
  13402. insutype = insutypes[0].Insutype
  13403. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13404. } else {
  13405. for _, i := range insutypes {
  13406. if i.Insutype == "390" {
  13407. is390 = 1
  13408. }
  13409. if i.Insutype == "310" {
  13410. is310 = 1
  13411. }
  13412. }
  13413. }
  13414. if is390 == 1 {
  13415. insutype = "390"
  13416. }
  13417. if is310 == 1 {
  13418. insutype = "310"
  13419. }
  13420. if len(insutypes) == 0 {
  13421. insutype = "390"
  13422. }
  13423. var insuplc_admdvs string
  13424. for _, item := range rf {
  13425. if item.Insutype == insutype {
  13426. insuplc_admdvs = item.InsuplcAdmdvs
  13427. }
  13428. }
  13429. psn := &models.HisPsn{
  13430. PsnNo: res.Output.Baseinfo.PsnNo,
  13431. PatientId: patient.ID,
  13432. Certno: res.Output.Baseinfo.Certno,
  13433. Gend: res.Output.Baseinfo.Gend,
  13434. Naty: res.Output.Baseinfo.Naty,
  13435. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13436. PsnName: res.Output.Baseinfo.PsnName,
  13437. Idetinfo: idetinfoStr,
  13438. Insuinfo: infoStr,
  13439. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13440. CardInfo: basStr,
  13441. VerifyNumber: "",
  13442. InsuplcAdmdvs: insuplc_admdvs,
  13443. }
  13444. service.CreateHisPsn(psn)
  13445. c.ServeSuccessJSON(map[string]interface{}{
  13446. "patient": patient,
  13447. "number": cardnum,
  13448. "insutype": insutype,
  13449. })
  13450. }
  13451. } else {
  13452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13453. return
  13454. }
  13455. }
  13456. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13457. fmt.Println(initFlag)
  13458. fmt.Println("initFlag")
  13459. if initFlag == 0 {
  13460. c.TestGetJiangXiBasBaseInit()
  13461. }
  13462. basStr := c.GetBasBaseInfo()
  13463. if len(basStr) == 0 {
  13464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13465. return
  13466. }
  13467. fmt.Println(basStr)
  13468. bas := strings.Split(basStr, "|")
  13469. basNumber := bas[1]
  13470. fmt.Println(basNumber)
  13471. card_sn := bas[3]
  13472. fmt.Println(card_sn)
  13473. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13474. 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)
  13475. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13476. var dat map[string]interface{}
  13477. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13478. fmt.Println(dat)
  13479. } else {
  13480. fmt.Println(err)
  13481. }
  13482. userJSONBytes, _ := json.Marshal(dat)
  13483. var res ResultTwo
  13484. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13485. utils.ErrorLog("解析失败:%v", err)
  13486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13487. return
  13488. }
  13489. if res.Infcode == 0 {
  13490. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13491. if err == gorm.ErrRecordNotFound {
  13492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13493. return
  13494. } else if err != nil {
  13495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13496. return
  13497. } else {
  13498. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13499. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13500. infoStr := string(Iinfos)
  13501. idetinfoStr := string(Idetinfos)
  13502. var rf []*ResultFive
  13503. json.Unmarshal([]byte(infoStr), &rf)
  13504. var insutypes []*ResultFive
  13505. var insutype string
  13506. var is390 int = 0
  13507. var is310 int = 0
  13508. var insuplc_admdvs string
  13509. for _, item := range rf {
  13510. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13511. insutypes = append(insutypes, item)
  13512. }
  13513. }
  13514. if len(insutypes) == 1 {
  13515. insutype = insutypes[0].Insutype
  13516. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13517. } else {
  13518. for _, i := range insutypes {
  13519. if i.Insutype == "390" {
  13520. is390 = 1
  13521. }
  13522. if i.Insutype == "310" {
  13523. is310 = 1
  13524. }
  13525. }
  13526. }
  13527. if is390 == 1 {
  13528. insutype = "390"
  13529. }
  13530. if is310 == 1 {
  13531. insutype = "310"
  13532. }
  13533. if len(insutypes) == 0 {
  13534. insutype = "310"
  13535. }
  13536. for _, item := range rf {
  13537. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13538. insuplc_admdvs = item.InsuplcAdmdvs
  13539. }
  13540. }
  13541. psn := &models.HisPsn{
  13542. PsnNo: res.Output.Baseinfo.PsnNo,
  13543. PatientId: patient.ID,
  13544. Certno: res.Output.Baseinfo.Certno,
  13545. Gend: res.Output.Baseinfo.Gend,
  13546. Naty: res.Output.Baseinfo.Naty,
  13547. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13548. PsnName: res.Output.Baseinfo.PsnName,
  13549. Idetinfo: idetinfoStr,
  13550. Insuinfo: infoStr,
  13551. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13552. CardInfo: basStr,
  13553. InsuplcAdmdvs: insuplc_admdvs,
  13554. VerifyNumber: "",
  13555. }
  13556. service.CreateHisPsn(psn)
  13557. c.ServeSuccessJSON(map[string]interface{}{
  13558. "patient": patient,
  13559. "number": basNumber,
  13560. "insutype": insutype,
  13561. })
  13562. }
  13563. } else {
  13564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13565. return
  13566. }
  13567. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13568. basStr := c.GetBasBaseInfo22222()
  13569. fmt.Println(basStr)
  13570. if len(basStr) == 0 {
  13571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13572. return
  13573. }
  13574. fmt.Println(basStr)
  13575. bas := strings.Split(basStr, "|")
  13576. basNumber := bas[2] //卡号
  13577. card_sn := bas[3] //
  13578. id_card_No := bas[1] //卡号
  13579. fmt.Println(basNumber)
  13580. fmt.Println(card_sn)
  13581. fmt.Println(id_card_No)
  13582. var patient service.Patients
  13583. if len(id_card_No) == 0 {
  13584. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13585. } else {
  13586. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13587. }
  13588. result, _ := service.Jxyb1101bycard(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, patient.Name, patient.IdCardNo)
  13589. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13590. var dat map[string]interface{}
  13591. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13592. fmt.Println(dat)
  13593. } else {
  13594. fmt.Println(err)
  13595. }
  13596. userJSONBytes, _ := json.Marshal(dat)
  13597. var res ResultTwo
  13598. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13599. utils.ErrorLog("解析失败:%v", err)
  13600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13601. return
  13602. }
  13603. if res.Infcode == 0 {
  13604. var pateint2 service.Patients
  13605. var err error
  13606. if len(id_card_No) == 0 {
  13607. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13608. } else {
  13609. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13610. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13611. }
  13612. if err == gorm.ErrRecordNotFound {
  13613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13614. return
  13615. } else if err != nil {
  13616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13617. return
  13618. } else {
  13619. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13620. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13621. infoStr := string(Iinfos)
  13622. idetinfoStr := string(Idetinfos)
  13623. var rf []*ResultFive
  13624. json.Unmarshal([]byte(infoStr), &rf)
  13625. var insutypes []*ResultFive
  13626. var insutype string
  13627. var is390 int = 0
  13628. var is310 int = 0
  13629. var insuplc_admdvs string
  13630. for _, item := range rf {
  13631. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13632. insutypes = append(insutypes, item)
  13633. }
  13634. }
  13635. if len(insutypes) == 1 {
  13636. insutype = insutypes[0].Insutype
  13637. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13638. } else {
  13639. for _, i := range insutypes {
  13640. if i.Insutype == "390" {
  13641. is390 = 1
  13642. }
  13643. if i.Insutype == "310" {
  13644. is310 = 1
  13645. }
  13646. }
  13647. }
  13648. if is390 == 1 {
  13649. insutype = "390"
  13650. }
  13651. if is310 == 1 {
  13652. insutype = "310"
  13653. }
  13654. if len(insutypes) == 0 {
  13655. insutype = "310"
  13656. }
  13657. for _, item := range rf {
  13658. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13659. insuplc_admdvs = item.InsuplcAdmdvs
  13660. }
  13661. }
  13662. psn := &models.HisPsn{
  13663. PsnNo: res.Output.Baseinfo.PsnNo,
  13664. PatientId: pateint2.ID,
  13665. Certno: res.Output.Baseinfo.Certno,
  13666. Gend: res.Output.Baseinfo.Gend,
  13667. Naty: res.Output.Baseinfo.Naty,
  13668. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13669. PsnName: res.Output.Baseinfo.PsnName,
  13670. Idetinfo: idetinfoStr,
  13671. Insuinfo: infoStr,
  13672. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13673. CardInfo: basStr,
  13674. InsuplcAdmdvs: insuplc_admdvs,
  13675. VerifyNumber: "",
  13676. }
  13677. service.CreateHisPsn(psn)
  13678. c.ServeSuccessJSON(map[string]interface{}{
  13679. "patient": patient,
  13680. "number": basNumber,
  13681. "insutype": insutype,
  13682. })
  13683. }
  13684. } else {
  13685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13686. return
  13687. }
  13688. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13689. fmt.Println(initFlag)
  13690. fmt.Println("initFlag")
  13691. if initFlag == 0 {
  13692. c.TestGetHnBasBaseInit()
  13693. }
  13694. basStr := c.GetBasBaseInfo()
  13695. if len(basStr) == 0 {
  13696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13697. return
  13698. }
  13699. fmt.Println(basStr)
  13700. bas := strings.Split(basStr, "|")
  13701. basNumber := bas[1]
  13702. fmt.Println(basNumber)
  13703. card_sn := bas[3]
  13704. card_no := bas[2]
  13705. fmt.Println(card_sn)
  13706. name := bas[4]
  13707. name = ConvertToString(name, "gbk", "utf-8")
  13708. 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)
  13709. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13710. var dat map[string]interface{}
  13711. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13712. fmt.Println(dat)
  13713. } else {
  13714. fmt.Println(err)
  13715. }
  13716. userJSONBytes, _ := json.Marshal(dat)
  13717. var res ResultTwo
  13718. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13719. utils.ErrorLog("解析失败:%v", err)
  13720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13721. return
  13722. }
  13723. if res.Infcode == 0 {
  13724. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13725. if err == gorm.ErrRecordNotFound {
  13726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13727. return
  13728. } else if err != nil {
  13729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13730. return
  13731. } else {
  13732. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13733. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13734. infoStr := string(Iinfos)
  13735. idetinfoStr := string(Idetinfos)
  13736. psn := &models.HisPsn{
  13737. PsnNo: res.Output.Baseinfo.PsnNo,
  13738. PatientId: patient.ID,
  13739. Certno: res.Output.Baseinfo.Certno,
  13740. Gend: res.Output.Baseinfo.Gend,
  13741. Naty: res.Output.Baseinfo.Naty,
  13742. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13743. PsnName: res.Output.Baseinfo.PsnName,
  13744. Idetinfo: idetinfoStr,
  13745. Insuinfo: infoStr,
  13746. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13747. CardInfo: basStr,
  13748. VerifyNumber: "",
  13749. }
  13750. service.CreateHisPsn(psn)
  13751. var rf []*ResultFive
  13752. json.Unmarshal([]byte(infoStr), &rf)
  13753. var insutypes []*ResultFive
  13754. var insutype string
  13755. var is390 int = 0
  13756. var is310 int = 0
  13757. for _, item := range rf {
  13758. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13759. insutypes = append(insutypes, item)
  13760. }
  13761. }
  13762. if len(insutypes) == 1 {
  13763. insutype = insutypes[0].Insutype
  13764. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13765. } else {
  13766. for _, i := range insutypes {
  13767. if i.Insutype == "390" {
  13768. is390 = 1
  13769. }
  13770. if i.Insutype == "310" {
  13771. is310 = 1
  13772. }
  13773. }
  13774. }
  13775. if is390 == 1 {
  13776. insutype = "390"
  13777. }
  13778. if is310 == 1 {
  13779. insutype = "310"
  13780. }
  13781. if len(insutypes) == 0 {
  13782. insutype = "310"
  13783. }
  13784. c.ServeSuccessJSON(map[string]interface{}{
  13785. "patient": patient,
  13786. "number": basNumber,
  13787. "insutype": insutype,
  13788. })
  13789. }
  13790. } else {
  13791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13792. return
  13793. }
  13794. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13795. var api string
  13796. 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 +
  13797. "&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
  13798. fmt.Println(api)
  13799. resp, requestErr := http.Get(api)
  13800. if requestErr != nil {
  13801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13802. return
  13803. }
  13804. body, ioErr := ioutil.ReadAll(resp.Body)
  13805. if ioErr != nil {
  13806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13808. return
  13809. }
  13810. var respJSON map[string]interface{}
  13811. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13814. return
  13815. }
  13816. var res ResultTwo //1101结果
  13817. var res10265 ResultTwo10265 //1101结果
  13818. var card_info string //卡信息
  13819. token := respJSON["data"].(map[string]interface{})["token"].(string)
  13820. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13821. result, _ := json.Marshal(respJSON)
  13822. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13823. utils.ErrorLog("解析失败:%v", err)
  13824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13825. return
  13826. }
  13827. res.ErrMsg = res10265.ErrMsg
  13828. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13829. res.Infcode = infocode
  13830. res.Output = res10265.Output
  13831. res.InfRefmsgid = res10265.InfRefmsgid
  13832. if res.Infcode == 0 {
  13833. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13834. if err == gorm.ErrRecordNotFound {
  13835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13836. return
  13837. } else if err != nil {
  13838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13839. return
  13840. } else {
  13841. bas := strings.Split(card_info, "|")
  13842. basNumber := bas[2]
  13843. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13844. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13845. infoStr := string(Iinfos)
  13846. idetinfoStr := string(Idetinfos)
  13847. psn := &models.HisPsn{
  13848. PsnNo: res.Output.Baseinfo.PsnNo,
  13849. PatientId: patient.ID,
  13850. Certno: res.Output.Baseinfo.Certno,
  13851. Gend: res.Output.Baseinfo.Gend,
  13852. Naty: res.Output.Baseinfo.Naty,
  13853. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13854. PsnName: res.Output.Baseinfo.PsnName,
  13855. Idetinfo: idetinfoStr,
  13856. Insuinfo: infoStr,
  13857. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13858. CardInfo: card_info,
  13859. VerifyNumber: token,
  13860. }
  13861. service.CreateHisPsn(psn)
  13862. var rf []*ResultFive
  13863. json.Unmarshal([]byte(infoStr), &rf)
  13864. var insutypes []*ResultFive
  13865. var insutype string
  13866. var is390 int = 0
  13867. var is310 int = 0
  13868. for _, item := range rf {
  13869. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13870. insutypes = append(insutypes, item)
  13871. }
  13872. }
  13873. if len(insutypes) == 1 {
  13874. insutype = insutypes[0].Insutype
  13875. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13876. } else {
  13877. for _, i := range insutypes {
  13878. if i.Insutype == "390" {
  13879. is390 = 1
  13880. }
  13881. if i.Insutype == "310" {
  13882. is310 = 1
  13883. }
  13884. }
  13885. }
  13886. if is390 == 1 {
  13887. insutype = "390"
  13888. }
  13889. if is310 == 1 {
  13890. insutype = "310"
  13891. }
  13892. if len(insutypes) == 0 {
  13893. insutype = "310"
  13894. }
  13895. c.ServeSuccessJSON(map[string]interface{}{
  13896. "patient": patient,
  13897. "number": basNumber,
  13898. "insutype": insutype,
  13899. })
  13900. }
  13901. } else {
  13902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13903. return
  13904. }
  13905. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13906. res := c.GetoleInfo()
  13907. if res.Infcode == 0 {
  13908. var result string
  13909. if res.Output.MdtrtCertType == "01" {
  13910. 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)
  13911. } else if res.Output.MdtrtCertType == "02" {
  13912. 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)
  13913. } else if res.Output.MdtrtCertType == "03" {
  13914. 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)
  13915. }
  13916. var dat map[string]interface{}
  13917. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13918. fmt.Println(dat)
  13919. } else {
  13920. fmt.Println(err)
  13921. }
  13922. userJSONBytes, _ := json.Marshal(dat)
  13923. var res2 ResultTwo
  13924. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13925. utils.ErrorLog("解析失败:%v", err)
  13926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13927. return
  13928. }
  13929. if res2.Infcode == 0 {
  13930. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13931. if err == gorm.ErrRecordNotFound {
  13932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13933. return
  13934. } else if err != nil {
  13935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13936. return
  13937. } else {
  13938. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13939. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13940. infoStr := string(Iinfos)
  13941. idetinfoStr := string(Idetinfos)
  13942. var rf []*ResultFive
  13943. json.Unmarshal([]byte(infoStr), &rf)
  13944. var insutypes []*ResultFive
  13945. var insutype string
  13946. var is390 int = 0
  13947. var is310 int = 0
  13948. //var insuplc_admdvs string
  13949. for _, item := range rf {
  13950. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13951. insutypes = append(insutypes, item)
  13952. }
  13953. }
  13954. if len(insutypes) == 1 {
  13955. insutype = insutypes[0].Insutype
  13956. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13957. } else {
  13958. for _, i := range insutypes {
  13959. if i.Insutype == "390" {
  13960. is390 = 1
  13961. }
  13962. if i.Insutype == "310" {
  13963. is310 = 1
  13964. }
  13965. }
  13966. }
  13967. if is390 == 1 {
  13968. insutype = "390"
  13969. }
  13970. if is310 == 1 {
  13971. insutype = "310"
  13972. }
  13973. if len(insutypes) == 0 {
  13974. insutype = "310"
  13975. }
  13976. psn := &models.HisPsn{
  13977. PsnNo: res2.Output.Baseinfo.PsnNo,
  13978. PatientId: patient.ID,
  13979. Certno: res2.Output.Baseinfo.Certno,
  13980. Gend: res2.Output.Baseinfo.Gend,
  13981. Naty: res2.Output.Baseinfo.Naty,
  13982. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  13983. PsnName: res2.Output.Baseinfo.PsnName,
  13984. Idetinfo: idetinfoStr,
  13985. Insuinfo: infoStr,
  13986. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13987. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  13988. VerifyNumber: res.Output.EcToken,
  13989. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  13990. }
  13991. if res.Output.MdtrtCertType == "01" {
  13992. psn.VerifyNumber = res.Output.EcToken
  13993. //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)
  13994. } else if res.Output.MdtrtCertType == "02" {
  13995. psn.VerifyNumber = res.Output.MdtrtCertNo
  13996. //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)
  13997. } else if res.Output.MdtrtCertType == "03" {
  13998. psn.VerifyNumber = res.Output.MdtrtCertNo
  13999. //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)
  14000. }
  14001. var balc float64
  14002. for _, item := range rf {
  14003. if item.Insutype == insutype {
  14004. balc = item.Balc
  14005. }
  14006. }
  14007. service.CreateHisPsn(psn)
  14008. c.ServeSuccessJSON(map[string]interface{}{
  14009. "patient": patient,
  14010. "number": res.Output.CardNo,
  14011. "insutype": insutype,
  14012. "blac": balc,
  14013. "desc": idetinfoStr,
  14014. })
  14015. }
  14016. } else {
  14017. c.ServeSuccessJSON(map[string]interface{}{
  14018. "failed_code": -10,
  14019. "msg": res2.ErrMsg,
  14020. })
  14021. }
  14022. } else {
  14023. c.ServeSuccessJSON(map[string]interface{}{
  14024. "failed_code": -10,
  14025. "msg": res.ErrMsg,
  14026. })
  14027. }
  14028. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14029. var api string
  14030. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14031. "&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
  14032. fmt.Println(api)
  14033. resp, requestErr := http.Get(api)
  14034. if requestErr != nil {
  14035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14036. return
  14037. }
  14038. body, ioErr := ioutil.ReadAll(resp.Body)
  14039. if ioErr != nil {
  14040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14042. return
  14043. }
  14044. var respJSON map[string]interface{}
  14045. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14048. return
  14049. }
  14050. var status string
  14051. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14052. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14053. //console.log()
  14054. fmt.Println("type===")
  14055. fmt.Println(card_type)
  14056. var token string
  14057. var res ResultTwo //1101结果
  14058. //var res10265 ResultTwoesultTwo10265 //1101结果
  14059. var card_info string //卡信息
  14060. var busi_card_info string
  14061. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14062. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14063. if status == "0" { //读卡成功
  14064. if card_type == "1" {
  14065. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14066. result, _ := json.Marshal(respJSON)
  14067. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14068. utils.ErrorLog("解析失败:%v", err)
  14069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14070. return
  14071. }
  14072. } else {
  14073. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14074. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14075. result, _ := json.Marshal(respJSON)
  14076. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14077. utils.ErrorLog("解析失败:%v", err)
  14078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14079. return
  14080. }
  14081. }
  14082. if res.Infcode == 0 {
  14083. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14084. if err == gorm.ErrRecordNotFound {
  14085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14086. return
  14087. } else if err != nil {
  14088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14089. return
  14090. } else {
  14091. if card_type == "1" {
  14092. bas := strings.Split(card_info, "|")
  14093. basNumber := bas[2]
  14094. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14095. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14096. infoStr := string(Iinfos)
  14097. idetinfoStr := string(Idetinfos)
  14098. psn := &models.HisPsn{
  14099. PsnNo: res.Output.Baseinfo.PsnNo,
  14100. PatientId: patient.ID,
  14101. Certno: res.Output.Baseinfo.Certno,
  14102. Gend: res.Output.Baseinfo.Gend,
  14103. Naty: res.Output.Baseinfo.Naty,
  14104. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14105. PsnName: res.Output.Baseinfo.PsnName,
  14106. Idetinfo: idetinfoStr,
  14107. Insuinfo: infoStr,
  14108. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14109. CardInfo: card_info,
  14110. VerifyNumber: busi_card_info,
  14111. }
  14112. service.CreateHisPsn(psn)
  14113. var rf []*ResultFive
  14114. json.Unmarshal([]byte(infoStr), &rf)
  14115. var insutypes []*ResultFive
  14116. var insutype string
  14117. var is390 int = 0
  14118. var is310 int = 0
  14119. for _, item := range rf {
  14120. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14121. insutypes = append(insutypes, item)
  14122. }
  14123. }
  14124. if len(insutypes) == 1 {
  14125. insutype = insutypes[0].Insutype
  14126. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14127. } else {
  14128. for _, i := range insutypes {
  14129. if i.Insutype == "390" {
  14130. is390 = 1
  14131. }
  14132. if i.Insutype == "310" {
  14133. is310 = 1
  14134. }
  14135. }
  14136. }
  14137. if is390 == 1 {
  14138. insutype = "390"
  14139. }
  14140. if is310 == 1 {
  14141. insutype = "310"
  14142. }
  14143. if len(insutypes) == 0 {
  14144. insutype = "310"
  14145. }
  14146. c.ServeSuccessJSON(map[string]interface{}{
  14147. "patient": patient,
  14148. "number": basNumber,
  14149. "insutype": insutype,
  14150. })
  14151. } else {
  14152. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14153. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14154. infoStr := string(Iinfos)
  14155. idetinfoStr := string(Idetinfos)
  14156. psn := &models.HisPsn{
  14157. PsnNo: res.Output.Baseinfo.PsnNo,
  14158. PatientId: patient.ID,
  14159. Certno: res.Output.Baseinfo.Certno,
  14160. Gend: res.Output.Baseinfo.Gend,
  14161. Naty: res.Output.Baseinfo.Naty,
  14162. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14163. PsnName: res.Output.Baseinfo.PsnName,
  14164. Idetinfo: idetinfoStr,
  14165. Insuinfo: infoStr,
  14166. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14167. CardInfo: card_info,
  14168. VerifyNumber: token,
  14169. }
  14170. service.CreateHisPsn(psn)
  14171. c.ServeSuccessJSON(map[string]interface{}{
  14172. "patient": patient,
  14173. "number": token,
  14174. })
  14175. }
  14176. }
  14177. } else {
  14178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14179. return
  14180. }
  14181. } else { //读卡失败
  14182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14183. return
  14184. }
  14185. } else if miConfig.MdtrtareaAdmvs == "340699" {
  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. fmt.Println(api)
  14190. resp, requestErr := http.Get(api)
  14191. if requestErr != nil {
  14192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14193. return
  14194. }
  14195. body, ioErr := ioutil.ReadAll(resp.Body)
  14196. if ioErr != nil {
  14197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14199. return
  14200. }
  14201. var respJSON map[string]interface{}
  14202. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14205. return
  14206. }
  14207. var status string
  14208. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14209. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14210. //console.log()
  14211. fmt.Println("type===")
  14212. fmt.Println(card_type)
  14213. var token string
  14214. var res ResultTwo //1101结果
  14215. //var res10265 ResultTwoesultTwo10265 //1101结果
  14216. var card_info string //卡信息
  14217. //var busi_card_info string
  14218. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14219. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14220. if status == "0" { //读卡成功
  14221. if card_type == "1" {
  14222. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14223. result, _ := json.Marshal(respJSON)
  14224. fmt.Println(result)
  14225. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14226. utils.ErrorLog("解析失败:%v", err)
  14227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14228. return
  14229. }
  14230. fmt.Println(res)
  14231. } else {
  14232. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14233. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14234. result, _ := json.Marshal(respJSON)
  14235. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14236. utils.ErrorLog("解析失败:%v", err)
  14237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14238. return
  14239. }
  14240. }
  14241. if res.Infcode == 0 {
  14242. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14243. if err == gorm.ErrRecordNotFound {
  14244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14245. return
  14246. } else if err != nil {
  14247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14248. return
  14249. } else {
  14250. if card_type == "1" {
  14251. bas := strings.Split(card_info, "|")
  14252. basNumber := bas[2]
  14253. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14254. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14255. infoStr := string(Iinfos)
  14256. idetinfoStr := string(Idetinfos)
  14257. psn := &models.HisPsn{
  14258. PsnNo: res.Output.Baseinfo.PsnNo,
  14259. PatientId: patient.ID,
  14260. Certno: res.Output.Baseinfo.Certno,
  14261. Gend: res.Output.Baseinfo.Gend,
  14262. Naty: res.Output.Baseinfo.Naty,
  14263. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14264. PsnName: res.Output.Baseinfo.PsnName,
  14265. Idetinfo: idetinfoStr,
  14266. Insuinfo: infoStr,
  14267. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14268. CardInfo: card_info,
  14269. //VerifyNumber: busi_card_info,
  14270. }
  14271. service.CreateHisPsn(psn)
  14272. var rf []*ResultFive
  14273. json.Unmarshal([]byte(infoStr), &rf)
  14274. var insutypes []*ResultFive
  14275. var insutype string
  14276. var is390 int = 0
  14277. var is310 int = 0
  14278. for _, item := range rf {
  14279. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14280. insutypes = append(insutypes, item)
  14281. }
  14282. }
  14283. if len(insutypes) == 1 {
  14284. insutype = insutypes[0].Insutype
  14285. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14286. } else {
  14287. for _, i := range insutypes {
  14288. if i.Insutype == "390" {
  14289. is390 = 1
  14290. }
  14291. if i.Insutype == "310" {
  14292. is310 = 1
  14293. }
  14294. }
  14295. }
  14296. if is390 == 1 {
  14297. insutype = "390"
  14298. }
  14299. if is310 == 1 {
  14300. insutype = "310"
  14301. }
  14302. if len(insutypes) == 0 {
  14303. insutype = "310"
  14304. }
  14305. c.ServeSuccessJSON(map[string]interface{}{
  14306. "patient": patient,
  14307. "number": basNumber,
  14308. "insutype": insutype,
  14309. })
  14310. } else {
  14311. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14312. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14313. infoStr := string(Iinfos)
  14314. idetinfoStr := string(Idetinfos)
  14315. psn := &models.HisPsn{
  14316. PsnNo: res.Output.Baseinfo.PsnNo,
  14317. PatientId: patient.ID,
  14318. Certno: res.Output.Baseinfo.Certno,
  14319. Gend: res.Output.Baseinfo.Gend,
  14320. Naty: res.Output.Baseinfo.Naty,
  14321. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14322. PsnName: res.Output.Baseinfo.PsnName,
  14323. Idetinfo: idetinfoStr,
  14324. Insuinfo: infoStr,
  14325. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14326. CardInfo: card_info,
  14327. VerifyNumber: token,
  14328. }
  14329. service.CreateHisPsn(psn)
  14330. c.ServeSuccessJSON(map[string]interface{}{
  14331. "patient": patient,
  14332. "number": token,
  14333. })
  14334. }
  14335. }
  14336. } else {
  14337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14338. return
  14339. }
  14340. } else { //读卡失败
  14341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14342. return
  14343. }
  14344. } else {
  14345. if initFlag == 0 {
  14346. c.TestGetBasBaseInit()
  14347. }
  14348. basStr := c.GetBasBaseInfo()
  14349. if len(basStr) == 0 {
  14350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14351. return
  14352. }
  14353. fmt.Println(basStr)
  14354. bas := strings.Split(basStr, "|")
  14355. basNumber := bas[1]
  14356. fmt.Println(basNumber)
  14357. card_sn := bas[3]
  14358. fmt.Println(card_sn)
  14359. cardNumber := bas[2]
  14360. fmt.Println(cardNumber)
  14361. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14362. var result string
  14363. if bas[0][:2] == "44" {
  14364. 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)
  14365. } else {
  14366. 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)
  14367. }
  14368. var dat map[string]interface{}
  14369. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14370. fmt.Println(dat)
  14371. } else {
  14372. fmt.Println(err)
  14373. }
  14374. userJSONBytes, _ := json.Marshal(dat)
  14375. var res ResultTwo
  14376. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14377. utils.ErrorLog("解析失败:%v", err)
  14378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14379. return
  14380. }
  14381. if res.Infcode == 0 {
  14382. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14383. if err == gorm.ErrRecordNotFound {
  14384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14385. return
  14386. } else if err != nil {
  14387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14388. return
  14389. } else {
  14390. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14391. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14392. infoStr := string(Iinfos)
  14393. idetinfoStr := string(Idetinfos)
  14394. var rf []*ResultFive
  14395. json.Unmarshal([]byte(infoStr), &rf)
  14396. var insutypes []*ResultFive
  14397. var insutype string
  14398. var is390 int = 0
  14399. var is310 int = 0
  14400. var insuplc_admdvs string
  14401. for _, item := range rf {
  14402. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14403. insutypes = append(insutypes, item)
  14404. }
  14405. }
  14406. if len(insutypes) == 1 {
  14407. insutype = insutypes[0].Insutype
  14408. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14409. } else {
  14410. for _, i := range insutypes {
  14411. if i.Insutype == "390" {
  14412. is390 = 1
  14413. }
  14414. if i.Insutype == "310" {
  14415. is310 = 1
  14416. }
  14417. }
  14418. }
  14419. if is390 == 1 {
  14420. insutype = "390"
  14421. }
  14422. if is310 == 1 {
  14423. insutype = "310"
  14424. }
  14425. if len(insutypes) == 0 {
  14426. insutype = "310"
  14427. }
  14428. for _, item := range rf {
  14429. if item.Insutype == insutype {
  14430. insuplc_admdvs = item.InsuplcAdmdvs
  14431. }
  14432. }
  14433. psn := &models.HisPsn{
  14434. PsnNo: res.Output.Baseinfo.PsnNo,
  14435. PatientId: patient.ID,
  14436. Certno: res.Output.Baseinfo.Certno,
  14437. Gend: res.Output.Baseinfo.Gend,
  14438. Naty: res.Output.Baseinfo.Naty,
  14439. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14440. PsnName: res.Output.Baseinfo.PsnName,
  14441. Idetinfo: idetinfoStr,
  14442. Insuinfo: infoStr,
  14443. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14444. CardInfo: basStr,
  14445. VerifyNumber: "",
  14446. InsuplcAdmdvs: insuplc_admdvs,
  14447. }
  14448. service.CreateHisPsn(psn)
  14449. c.ServeSuccessJSON(map[string]interface{}{
  14450. "patient": patient,
  14451. "number": basNumber,
  14452. })
  14453. }
  14454. } else {
  14455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14456. return
  14457. }
  14458. break
  14459. }
  14460. case 2:
  14461. if miConfig.MdtrtareaAdmvs == "430800" {
  14462. if initFlag == 0 {
  14463. c.TestGetHnBasBaseInit()
  14464. }
  14465. SFZStr := c.GetSFZBaseInfo()
  14466. if len(SFZStr) == 0 {
  14467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14468. return
  14469. }
  14470. fmt.Println(SFZStr)
  14471. id_card_str := strings.Split(SFZStr, "^")
  14472. card_no := id_card_str[0]
  14473. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14474. //name := id_card_str[1]
  14475. //name = ConvertToString(name, "gbk", "utf-8")
  14476. 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)
  14477. var dat map[string]interface{}
  14478. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14479. fmt.Println(dat)
  14480. } else {
  14481. fmt.Println(err)
  14482. }
  14483. userJSONBytes, _ := json.Marshal(dat)
  14484. var res ResultTwo
  14485. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14486. utils.ErrorLog("解析失败:%v", err)
  14487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14488. return
  14489. }
  14490. if res.Infcode == 0 {
  14491. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14492. if err == gorm.ErrRecordNotFound {
  14493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14494. return
  14495. } else if err != nil {
  14496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14497. return
  14498. } else {
  14499. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14500. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14501. infoStr := string(Iinfos)
  14502. idetinfoStr := string(Idetinfos)
  14503. var rf []*ResultFive
  14504. json.Unmarshal([]byte(infoStr), &rf)
  14505. var insutypes []*ResultFive
  14506. var insutype string
  14507. var is390 int = 0
  14508. var is310 int = 0
  14509. for _, item := range rf {
  14510. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14511. insutypes = append(insutypes, item)
  14512. }
  14513. }
  14514. if len(insutypes) == 1 {
  14515. insutype = insutypes[0].Insutype
  14516. } else {
  14517. for _, i := range insutypes {
  14518. if i.Insutype == "390" {
  14519. is390 = 1
  14520. }
  14521. if i.Insutype == "310" {
  14522. is310 = 1
  14523. }
  14524. }
  14525. }
  14526. if is390 == 1 {
  14527. insutype = "390"
  14528. }
  14529. if is310 == 1 {
  14530. insutype = "310"
  14531. }
  14532. if len(insutypes) == 0 {
  14533. insutype = "310"
  14534. }
  14535. var InsuplcAdmdvs string
  14536. for _, item := range rf {
  14537. if item.Insutype == insutype {
  14538. InsuplcAdmdvs = item.InsuplcAdmdvs
  14539. }
  14540. }
  14541. psn := &models.HisPsn{
  14542. PsnNo: res.Output.Baseinfo.PsnNo,
  14543. PatientId: patient.ID,
  14544. Certno: res.Output.Baseinfo.Certno,
  14545. Gend: res.Output.Baseinfo.Gend,
  14546. Naty: res.Output.Baseinfo.Naty,
  14547. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14548. PsnName: res.Output.Baseinfo.PsnName,
  14549. Idetinfo: idetinfoStr,
  14550. Insuinfo: infoStr,
  14551. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14552. CardInfo: SFZStr,
  14553. VerifyNumber: "",
  14554. InsuplcAdmdvs: InsuplcAdmdvs,
  14555. }
  14556. service.CreateHisPsn(psn)
  14557. c.ServeSuccessJSON(map[string]interface{}{
  14558. "patient": patient,
  14559. "number": card_no,
  14560. "insutype": insutype,
  14561. })
  14562. }
  14563. } else {
  14564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14565. return
  14566. }
  14567. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14568. var res ResultTwo
  14569. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14570. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14571. "&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)
  14572. resp, requestErr := http.Get(api)
  14573. if requestErr != nil {
  14574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14575. return
  14576. }
  14577. body, ioErr := ioutil.ReadAll(resp.Body)
  14578. if ioErr != nil {
  14579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14581. return
  14582. }
  14583. var respJSON map[string]interface{}
  14584. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14587. return
  14588. }
  14589. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14590. result, _ := json.Marshal(respJSON)
  14591. fmt.Println("log")
  14592. fmt.Println(string(result))
  14593. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14594. utils.ErrorLog("解析失败:%v", err)
  14595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14596. return
  14597. }
  14598. if res.Infcode == 0 {
  14599. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14600. if err == gorm.ErrRecordNotFound {
  14601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14602. return
  14603. } else if err != nil {
  14604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14605. return
  14606. } else {
  14607. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14608. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14609. infoStr := string(Iinfos)
  14610. idetinfoStr := string(Idetinfos)
  14611. psn := &models.HisPsn{
  14612. PsnNo: res.Output.Baseinfo.PsnNo,
  14613. PatientId: patient.ID,
  14614. Certno: res.Output.Baseinfo.Certno,
  14615. Gend: res.Output.Baseinfo.Gend,
  14616. Naty: res.Output.Baseinfo.Naty,
  14617. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14618. PsnName: res.Output.Baseinfo.PsnName,
  14619. Idetinfo: idetinfoStr,
  14620. Insuinfo: infoStr,
  14621. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14622. }
  14623. service.CreateHisPsn(psn)
  14624. c.ServeSuccessJSON(map[string]interface{}{
  14625. "patient": patient,
  14626. "number": res.Output.Baseinfo.Certno,
  14627. })
  14628. }
  14629. } else {
  14630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14631. return
  14632. }
  14633. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14634. var res ResultTwo
  14635. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14636. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14637. "&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)
  14638. resp, requestErr := http.Get(api)
  14639. if requestErr != nil {
  14640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14641. return
  14642. }
  14643. body, ioErr := ioutil.ReadAll(resp.Body)
  14644. if ioErr != nil {
  14645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14647. return
  14648. }
  14649. var respJSON map[string]interface{}
  14650. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14653. return
  14654. }
  14655. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14656. result, _ := json.Marshal(respJSON)
  14657. fmt.Println("log")
  14658. fmt.Println(string(result))
  14659. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14660. utils.ErrorLog("解析失败:%v", err)
  14661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14662. return
  14663. }
  14664. if res.Infcode == 0 {
  14665. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14666. if err == gorm.ErrRecordNotFound {
  14667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14668. return
  14669. } else if err != nil {
  14670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14671. return
  14672. } else {
  14673. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14674. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14675. infoStr := string(Iinfos)
  14676. idetinfoStr := string(Idetinfos)
  14677. psn := &models.HisPsn{
  14678. PsnNo: res.Output.Baseinfo.PsnNo,
  14679. PatientId: patient.ID,
  14680. Certno: res.Output.Baseinfo.Certno,
  14681. Gend: res.Output.Baseinfo.Gend,
  14682. Naty: res.Output.Baseinfo.Naty,
  14683. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14684. PsnName: res.Output.Baseinfo.PsnName,
  14685. Idetinfo: idetinfoStr,
  14686. Insuinfo: infoStr,
  14687. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14688. }
  14689. service.CreateHisPsn(psn)
  14690. c.ServeSuccessJSON(map[string]interface{}{
  14691. "patient": patient,
  14692. "number": res.Output.Baseinfo.Certno,
  14693. })
  14694. }
  14695. } else {
  14696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14697. return
  14698. }
  14699. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14700. var res ResultTwo
  14701. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14702. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14703. "&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)
  14704. resp, requestErr := http.Get(api)
  14705. if requestErr != nil {
  14706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14707. return
  14708. }
  14709. body, ioErr := ioutil.ReadAll(resp.Body)
  14710. if ioErr != nil {
  14711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14713. return
  14714. }
  14715. var respJSON map[string]interface{}
  14716. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14719. return
  14720. }
  14721. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14722. result, _ := json.Marshal(respJSON)
  14723. fmt.Println("log")
  14724. fmt.Println(string(result))
  14725. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14726. utils.ErrorLog("解析失败:%v", err)
  14727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14728. return
  14729. }
  14730. if res.Infcode == 0 {
  14731. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14732. if err == gorm.ErrRecordNotFound {
  14733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14734. return
  14735. } else if err != nil {
  14736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14737. return
  14738. } else {
  14739. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14740. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14741. infoStr := string(Iinfos)
  14742. idetinfoStr := string(Idetinfos)
  14743. var rf []*ResultFive
  14744. json.Unmarshal([]byte(infoStr), &rf)
  14745. var insutypes []*ResultFive
  14746. var insutype string
  14747. var is390 int = 0
  14748. var is310 int = 0
  14749. for _, item := range rf {
  14750. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14751. insutypes = append(insutypes, item)
  14752. }
  14753. }
  14754. if len(insutypes) == 1 {
  14755. insutype = insutypes[0].Insutype
  14756. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14757. } else {
  14758. for _, i := range insutypes {
  14759. if i.Insutype == "390" {
  14760. is390 = 1
  14761. }
  14762. if i.Insutype == "310" {
  14763. is310 = 1
  14764. }
  14765. }
  14766. }
  14767. if is390 == 1 {
  14768. insutype = "390"
  14769. }
  14770. if is310 == 1 {
  14771. insutype = "310"
  14772. }
  14773. if len(insutypes) == 0 {
  14774. insutype = "390"
  14775. }
  14776. var insuplc_admdvs string
  14777. for _, item := range rf {
  14778. if item.Insutype == insutype {
  14779. insuplc_admdvs = item.InsuplcAdmdvs
  14780. }
  14781. }
  14782. psn := &models.HisPsn{
  14783. PsnNo: res.Output.Baseinfo.PsnNo,
  14784. PatientId: patient.ID,
  14785. Certno: res.Output.Baseinfo.Certno,
  14786. Gend: res.Output.Baseinfo.Gend,
  14787. Naty: res.Output.Baseinfo.Naty,
  14788. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14789. PsnName: res.Output.Baseinfo.PsnName,
  14790. Idetinfo: idetinfoStr,
  14791. Insuinfo: infoStr,
  14792. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14793. InsuplcAdmdvs: insuplc_admdvs,
  14794. }
  14795. service.CreateHisPsn(psn)
  14796. c.ServeSuccessJSON(map[string]interface{}{
  14797. "patient": patient,
  14798. "number": res.Output.Baseinfo.Certno,
  14799. })
  14800. }
  14801. } else {
  14802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14803. return
  14804. }
  14805. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14806. res := c.GetoleInfo()
  14807. if res.Infcode == 0 {
  14808. var result string
  14809. if res.Output.MdtrtCertType == "01" {
  14810. 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)
  14811. } else if res.Output.MdtrtCertType == "02" {
  14812. 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)
  14813. } else if res.Output.MdtrtCertType == "03" {
  14814. 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)
  14815. }
  14816. var dat map[string]interface{}
  14817. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14818. fmt.Println(dat)
  14819. } else {
  14820. fmt.Println(err)
  14821. }
  14822. userJSONBytes, _ := json.Marshal(dat)
  14823. var res2 ResultTwo
  14824. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14825. utils.ErrorLog("解析失败:%v", err)
  14826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14827. return
  14828. }
  14829. if res2.Infcode == 0 {
  14830. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14831. if err == gorm.ErrRecordNotFound {
  14832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14833. return
  14834. } else if err != nil {
  14835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14836. return
  14837. } else {
  14838. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14839. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14840. infoStr := string(Iinfos)
  14841. idetinfoStr := string(Idetinfos)
  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. //var insuplc_admdvs string
  14849. for _, item := range rf {
  14850. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14851. insutypes = append(insutypes, item)
  14852. }
  14853. }
  14854. if len(insutypes) == 1 {
  14855. insutype = insutypes[0].Insutype
  14856. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14857. } else {
  14858. for _, i := range insutypes {
  14859. if i.Insutype == "390" {
  14860. is390 = 1
  14861. }
  14862. if i.Insutype == "310" {
  14863. is310 = 1
  14864. }
  14865. }
  14866. }
  14867. if is390 == 1 {
  14868. insutype = "390"
  14869. }
  14870. if is310 == 1 {
  14871. insutype = "310"
  14872. }
  14873. if len(insutypes) == 0 {
  14874. insutype = "310"
  14875. }
  14876. psn := &models.HisPsn{
  14877. PsnNo: res2.Output.Baseinfo.PsnNo,
  14878. PatientId: patient.ID,
  14879. //Brdy: res2.Output.Baseinfo.Brdy,
  14880. Certno: res2.Output.Baseinfo.Certno,
  14881. Gend: res2.Output.Baseinfo.Gend,
  14882. Naty: res2.Output.Baseinfo.Naty,
  14883. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14884. PsnName: res2.Output.Baseinfo.PsnName,
  14885. Idetinfo: idetinfoStr,
  14886. Insuinfo: infoStr,
  14887. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14888. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14889. VerifyNumber: res.Output.EcToken,
  14890. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14891. }
  14892. service.CreateHisPsn(psn)
  14893. var balc float64
  14894. for _, item := range rf {
  14895. if item.Insutype == insutype {
  14896. balc = item.Balc
  14897. }
  14898. }
  14899. c.ServeSuccessJSON(map[string]interface{}{
  14900. "patient": patient,
  14901. "number": res.Output.CardNo,
  14902. "insutype": insutype,
  14903. "blac": balc,
  14904. "desc": idetinfoStr,
  14905. })
  14906. }
  14907. } else {
  14908. c.ServeSuccessJSON(map[string]interface{}{
  14909. "failed_code": -10,
  14910. "msg": res2.ErrMsg,
  14911. })
  14912. }
  14913. } else {
  14914. c.ServeSuccessJSON(map[string]interface{}{
  14915. "failed_code": -10,
  14916. "msg": res.ErrMsg,
  14917. })
  14918. }
  14919. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14920. var insuplc_admdvs string
  14921. if len(patient.InsuplcAdmdvs) > 0 {
  14922. insuplc_admdvs = patient.InsuplcAdmdvs
  14923. } else {
  14924. if len(insuplc_admdvs_str) > 0 {
  14925. insuplc_admdvs = insuplc_admdvs_str
  14926. } else {
  14927. insuplc_admdvs = miConfig.InsuplcAdmdvs
  14928. }
  14929. }
  14930. //请求内网数据
  14931. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  14932. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14933. "&insuplc_admdvs=" + insuplc_admdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&name=" + patient.Name + "&token=" + ""
  14934. resp, requestErr := http.Get(api)
  14935. if requestErr != nil {
  14936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14937. return
  14938. }
  14939. body, ioErr := ioutil.ReadAll(resp.Body)
  14940. if ioErr != nil {
  14941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14943. return
  14944. }
  14945. var respJSON map[string]interface{}
  14946. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14949. return
  14950. }
  14951. status := respJSON["data"].(map[string]interface{})["status"].(string)
  14952. if status == "0" {
  14953. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  14954. c.ServeSuccessJSON(map[string]interface{}{
  14955. "failed_code": -10,
  14956. "msg": err_msg,
  14957. })
  14958. return
  14959. }
  14960. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14961. var res ResultTwo
  14962. result, _ := json.Marshal(respJSON)
  14963. fmt.Println("log")
  14964. fmt.Println(string(result))
  14965. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14966. utils.ErrorLog("解析失败:%v", err)
  14967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14968. return
  14969. }
  14970. if res.Infcode == 0 {
  14971. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14972. if err == gorm.ErrRecordNotFound {
  14973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14974. return
  14975. } else if err != nil {
  14976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14977. return
  14978. } else {
  14979. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14980. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14981. infoStr := string(Iinfos)
  14982. idetinfoStr := string(Idetinfos)
  14983. psn := &models.HisPsn{
  14984. PsnNo: res.Output.Baseinfo.PsnNo,
  14985. PatientId: patient.ID,
  14986. Certno: res.Output.Baseinfo.Certno,
  14987. Gend: res.Output.Baseinfo.Gend,
  14988. Naty: res.Output.Baseinfo.Naty,
  14989. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14990. PsnName: res.Output.Baseinfo.PsnName,
  14991. Idetinfo: idetinfoStr,
  14992. Insuinfo: infoStr,
  14993. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14994. }
  14995. service.CreateHisPsn(psn)
  14996. var rf []*ResultFive
  14997. json.Unmarshal([]byte(infoStr), &rf)
  14998. var insutypes []*ResultFive
  14999. var is390 int = 0
  15000. var is310 int = 0
  15001. var insutype string
  15002. for _, item := range rf {
  15003. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15004. insutypes = append(insutypes, item)
  15005. }
  15006. }
  15007. if len(insutypes) == 1 {
  15008. insutype = insutypes[0].Insutype
  15009. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15010. } else {
  15011. for _, i := range insutypes {
  15012. if i.Insutype == "390" {
  15013. is390 = 1
  15014. }
  15015. if i.Insutype == "310" {
  15016. is310 = 1
  15017. }
  15018. }
  15019. }
  15020. if is390 == 1 {
  15021. insutype = "390"
  15022. }
  15023. if is310 == 1 {
  15024. insutype = "310"
  15025. }
  15026. if len(insutypes) == 0 {
  15027. insutype = "390"
  15028. }
  15029. c.ServeSuccessJSON(map[string]interface{}{
  15030. "patient": patient,
  15031. "insutype": insutype,
  15032. "number": res.Output.Baseinfo.Certno,
  15033. "info": res,
  15034. })
  15035. }
  15036. } else {
  15037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15038. return
  15039. }
  15040. } else {
  15041. SFZStr := c.GetSFZBaseInfo()
  15042. id_card_str := strings.Split(SFZStr, "^")
  15043. id_card_number := id_card_str[0]
  15044. card_sn := ""
  15045. 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)
  15046. var dat map[string]interface{}
  15047. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15048. fmt.Println(dat)
  15049. } else {
  15050. fmt.Println(err)
  15051. }
  15052. userJSONBytes, _ := json.Marshal(dat)
  15053. var res ResultTwo
  15054. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15055. utils.ErrorLog("解析失败:%v", err)
  15056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15057. return
  15058. }
  15059. if res.Infcode == 0 {
  15060. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  15061. if err == gorm.ErrRecordNotFound {
  15062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15063. return
  15064. } else if err != nil {
  15065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15066. return
  15067. } else {
  15068. c.ServeSuccessJSON(map[string]interface{}{
  15069. "patient": patient,
  15070. "number": id_card_number,
  15071. })
  15072. }
  15073. } else {
  15074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15075. return
  15076. }
  15077. }
  15078. break
  15079. case 3:
  15080. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15081. var api string
  15082. if miConfig.MdtrtareaAdmvs == "320921" {
  15083. 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 +
  15084. "&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
  15085. fmt.Println(api)
  15086. } else {
  15087. 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 +
  15088. "&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)
  15089. }
  15090. resp, requestErr := http.Get(api)
  15091. if requestErr != nil {
  15092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15093. return
  15094. }
  15095. body, ioErr := ioutil.ReadAll(resp.Body)
  15096. if ioErr != nil {
  15097. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15099. return
  15100. }
  15101. var respJSON map[string]interface{}
  15102. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15105. return
  15106. }
  15107. var status string
  15108. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15109. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15110. var token string
  15111. var res ResultTwo //1101结果
  15112. var res10265 ResultTwo10265 //1101结果
  15113. var card_info string //卡信息
  15114. var busi_card_info string
  15115. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15116. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15117. if status == "0" { //读卡成功
  15118. if card_type == "1" {
  15119. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15120. result, _ := json.Marshal(respJSON)
  15121. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15122. utils.ErrorLog("解析失败:%v", err)
  15123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15124. return
  15125. }
  15126. res.ErrMsg = res10265.ErrMsg
  15127. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15128. res.Infcode = infocode
  15129. res.Output = res10265.Output
  15130. res.InfRefmsgid = res10265.InfRefmsgid
  15131. } else {
  15132. //var card_info string //卡信息
  15133. //var busi_card_info string
  15134. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15135. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15136. //fmt.Println(card_info)
  15137. //fmt.Println(busi_card_info)
  15138. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15139. result, _ := json.Marshal(respJSON)
  15140. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15141. utils.ErrorLog("解析失败:%v", err)
  15142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15143. return
  15144. }
  15145. res.ErrMsg = res10265.ErrMsg
  15146. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15147. res.Infcode = infocode
  15148. res.Output = res10265.Output
  15149. res.InfRefmsgid = res10265.InfRefmsgid
  15150. }
  15151. if res.Infcode == 0 {
  15152. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15153. if err == gorm.ErrRecordNotFound {
  15154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15155. return
  15156. } else if err != nil {
  15157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15158. return
  15159. } else {
  15160. if card_type == "1" {
  15161. bas := strings.Split(card_info, "|")
  15162. basNumber := bas[2]
  15163. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15164. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15165. infoStr := string(Iinfos)
  15166. idetinfoStr := string(Idetinfos)
  15167. psn := &models.HisPsn{
  15168. PsnNo: res.Output.Baseinfo.PsnNo,
  15169. PatientId: patient.ID,
  15170. Certno: res.Output.Baseinfo.Certno,
  15171. //Brdy: res.Output.Baseinfo.Brdy,
  15172. Gend: res.Output.Baseinfo.Gend,
  15173. Naty: res.Output.Baseinfo.Naty,
  15174. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15175. PsnName: res.Output.Baseinfo.PsnName,
  15176. Idetinfo: idetinfoStr,
  15177. Insuinfo: infoStr,
  15178. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15179. CardInfo: card_info,
  15180. VerifyNumber: busi_card_info,
  15181. }
  15182. service.CreateHisPsn(psn)
  15183. c.ServeSuccessJSON(map[string]interface{}{
  15184. "patient": patient,
  15185. "number": basNumber,
  15186. })
  15187. } else {
  15188. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15189. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15190. infoStr := string(Iinfos)
  15191. idetinfoStr := string(Idetinfos)
  15192. psn := &models.HisPsn{
  15193. PsnNo: res.Output.Baseinfo.PsnNo,
  15194. PatientId: patient.ID,
  15195. Certno: res.Output.Baseinfo.Certno,
  15196. Gend: res.Output.Baseinfo.Gend,
  15197. Naty: res.Output.Baseinfo.Naty,
  15198. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15199. PsnName: res.Output.Baseinfo.PsnName,
  15200. Idetinfo: idetinfoStr,
  15201. Insuinfo: infoStr,
  15202. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15203. CardInfo: card_info,
  15204. VerifyNumber: token,
  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. }
  15247. } else {
  15248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15249. return
  15250. }
  15251. } else { //读卡失败
  15252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15253. return
  15254. }
  15255. }
  15256. break
  15257. case 4:
  15258. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15259. var api string
  15260. if miConfig.MdtrtareaAdmvs == "320921" {
  15261. 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 +
  15262. "&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
  15263. fmt.Println(api)
  15264. } else {
  15265. 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 +
  15266. "&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)
  15267. }
  15268. resp, requestErr := http.Get(api)
  15269. if requestErr != nil {
  15270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15271. return
  15272. }
  15273. body, ioErr := ioutil.ReadAll(resp.Body)
  15274. if ioErr != nil {
  15275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15277. return
  15278. }
  15279. var respJSON map[string]interface{}
  15280. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15281. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15283. return
  15284. }
  15285. var status string
  15286. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15287. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15288. var token string
  15289. var res ResultTwo //1101结果
  15290. var res10265 ResultTwo10265 //1101结果
  15291. if status == "0" { //读卡成功
  15292. var card_info string //卡信息
  15293. var busi_card_info string
  15294. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15295. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15296. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15297. fmt.Println(card_info)
  15298. fmt.Println(busi_card_info)
  15299. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15300. result, _ := json.Marshal(respJSON)
  15301. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15302. utils.ErrorLog("解析失败:%v", err)
  15303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15304. return
  15305. }
  15306. res.ErrMsg = res10265.ErrMsg
  15307. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15308. res.Infcode = infocode
  15309. res.Output = res10265.Output
  15310. res.InfRefmsgid = res10265.InfRefmsgid
  15311. if res.Infcode == 0 {
  15312. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15313. if err == gorm.ErrRecordNotFound {
  15314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15315. return
  15316. } else if err != nil {
  15317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15318. return
  15319. } else {
  15320. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15321. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15322. infoStr := string(Iinfos)
  15323. idetinfoStr := string(Idetinfos)
  15324. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15325. psn := &models.HisPsn{
  15326. PsnNo: res.Output.Baseinfo.PsnNo,
  15327. PatientId: patient.ID,
  15328. Certno: res.Output.Baseinfo.Certno,
  15329. Brdy: b,
  15330. Age: float64(age),
  15331. //Brdy: res.Output.Baseinfo.Brdy,
  15332. Gend: res.Output.Baseinfo.Gend,
  15333. Naty: res.Output.Baseinfo.Naty,
  15334. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15335. PsnName: res.Output.Baseinfo.PsnName,
  15336. Idetinfo: idetinfoStr,
  15337. Insuinfo: infoStr,
  15338. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15339. CardInfo: card_info,
  15340. VerifyNumber: token,
  15341. }
  15342. var rf []*ResultFive
  15343. json.Unmarshal([]byte(infoStr), &rf)
  15344. var insutypes []*ResultFive
  15345. var insutype string
  15346. var is390 int = 0
  15347. var is310 int = 0
  15348. for _, item := range rf {
  15349. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15350. insutypes = append(insutypes, item)
  15351. }
  15352. }
  15353. if len(insutypes) == 1 {
  15354. insutype = insutypes[0].Insutype
  15355. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15356. } else {
  15357. for _, i := range insutypes {
  15358. if i.Insutype == "390" {
  15359. is390 = 1
  15360. }
  15361. if i.Insutype == "310" {
  15362. is310 = 1
  15363. }
  15364. }
  15365. }
  15366. if is390 == 1 {
  15367. insutype = "390"
  15368. }
  15369. if is310 == 1 {
  15370. insutype = "310"
  15371. }
  15372. if len(insutypes) == 0 {
  15373. insutype = "310"
  15374. }
  15375. service.CreateHisPsn(psn)
  15376. c.ServeSuccessJSON(map[string]interface{}{
  15377. "patient": patient,
  15378. "number": token,
  15379. "insutype": insutype,
  15380. })
  15381. }
  15382. } else {
  15383. c.ServeSuccessJSON(map[string]interface{}{
  15384. "failed_code": -10,
  15385. "msg": res.ErrMsg,
  15386. })
  15387. }
  15388. } else { //读卡失败
  15389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15390. return
  15391. }
  15392. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15393. var api string
  15394. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15395. "&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
  15396. resp, requestErr := http.Get(api)
  15397. if requestErr != nil {
  15398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15399. return
  15400. }
  15401. body, ioErr := ioutil.ReadAll(resp.Body)
  15402. if ioErr != nil {
  15403. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15405. return
  15406. }
  15407. var respJSON map[string]interface{}
  15408. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15411. return
  15412. }
  15413. var status string
  15414. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15415. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15416. var token string
  15417. var res ResultTwo //1101结果
  15418. if status == "1" { //读卡成功
  15419. var card_info string //卡信息
  15420. var busi_card_info string
  15421. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15422. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15423. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15424. fmt.Println(card_info)
  15425. fmt.Println(busi_card_info)
  15426. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15427. result, _ := json.Marshal(respJSON)
  15428. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15429. utils.ErrorLog("解析失败:%v", err)
  15430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15431. return
  15432. }
  15433. if res.Infcode == 0 {
  15434. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15435. if err == gorm.ErrRecordNotFound {
  15436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15437. return
  15438. } else if err != nil {
  15439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15440. return
  15441. } else {
  15442. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15443. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15444. infoStr := string(Iinfos)
  15445. idetinfoStr := string(Idetinfos)
  15446. psn := &models.HisPsn{
  15447. PsnNo: res.Output.Baseinfo.PsnNo,
  15448. PatientId: patient.ID,
  15449. Certno: res.Output.Baseinfo.Certno,
  15450. Gend: res.Output.Baseinfo.Gend,
  15451. Naty: res.Output.Baseinfo.Naty,
  15452. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15453. PsnName: res.Output.Baseinfo.PsnName,
  15454. Idetinfo: idetinfoStr,
  15455. Insuinfo: infoStr,
  15456. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15457. CardInfo: card_info,
  15458. VerifyNumber: token,
  15459. }
  15460. var rf []*ResultFive
  15461. json.Unmarshal([]byte(infoStr), &rf)
  15462. var insutypes []*ResultFive
  15463. var insutype string
  15464. var is390 int = 0
  15465. var is310 int = 0
  15466. for _, item := range rf {
  15467. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15468. insutypes = append(insutypes, item)
  15469. }
  15470. }
  15471. if len(insutypes) == 1 {
  15472. insutype = insutypes[0].Insutype
  15473. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15474. } else {
  15475. for _, i := range insutypes {
  15476. if i.Insutype == "390" {
  15477. is390 = 1
  15478. }
  15479. if i.Insutype == "310" {
  15480. is310 = 1
  15481. }
  15482. }
  15483. }
  15484. if is390 == 1 {
  15485. insutype = "390"
  15486. }
  15487. if is310 == 1 {
  15488. insutype = "310"
  15489. }
  15490. if len(insutypes) == 0 {
  15491. insutype = "310"
  15492. }
  15493. service.CreateHisPsn(psn)
  15494. c.ServeSuccessJSON(map[string]interface{}{
  15495. "patient": patient,
  15496. "number": token,
  15497. "insutype": insutype,
  15498. })
  15499. }
  15500. } else {
  15501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15502. return
  15503. }
  15504. } else { //读卡失败
  15505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15506. return
  15507. }
  15508. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15509. var api string
  15510. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15511. "&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
  15512. resp, requestErr := http.Get(api)
  15513. if requestErr != nil {
  15514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15515. return
  15516. }
  15517. body, ioErr := ioutil.ReadAll(resp.Body)
  15518. if ioErr != nil {
  15519. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15521. return
  15522. }
  15523. var respJSON map[string]interface{}
  15524. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15527. return
  15528. }
  15529. var status string
  15530. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15531. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15532. var token string
  15533. var res ResultTwo //1101结果
  15534. if status == "1" { //读卡成功
  15535. var card_info string //卡信息
  15536. var busi_card_info string
  15537. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15538. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15539. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15540. fmt.Println(card_info)
  15541. fmt.Println(busi_card_info)
  15542. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15543. result, _ := json.Marshal(respJSON)
  15544. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15545. utils.ErrorLog("解析失败:%v", err)
  15546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15547. return
  15548. }
  15549. if res.Infcode == 0 {
  15550. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15551. if err == gorm.ErrRecordNotFound {
  15552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15553. return
  15554. } else if err != nil {
  15555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15556. return
  15557. } else {
  15558. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15559. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15560. infoStr := string(Iinfos)
  15561. idetinfoStr := string(Idetinfos)
  15562. psn := &models.HisPsn{
  15563. PsnNo: res.Output.Baseinfo.PsnNo,
  15564. PatientId: patient.ID,
  15565. Certno: res.Output.Baseinfo.Certno,
  15566. Gend: res.Output.Baseinfo.Gend,
  15567. Naty: res.Output.Baseinfo.Naty,
  15568. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15569. PsnName: res.Output.Baseinfo.PsnName,
  15570. Idetinfo: idetinfoStr,
  15571. Insuinfo: infoStr,
  15572. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15573. CardInfo: card_info,
  15574. VerifyNumber: token,
  15575. }
  15576. var rf []*ResultFive
  15577. json.Unmarshal([]byte(infoStr), &rf)
  15578. var insutypes []*ResultFive
  15579. var insutype string
  15580. var is390 int = 0
  15581. var is310 int = 0
  15582. for _, item := range rf {
  15583. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15584. insutypes = append(insutypes, item)
  15585. }
  15586. }
  15587. if len(insutypes) == 1 {
  15588. insutype = insutypes[0].Insutype
  15589. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15590. } else {
  15591. for _, i := range insutypes {
  15592. if i.Insutype == "390" {
  15593. is390 = 1
  15594. }
  15595. if i.Insutype == "310" {
  15596. is310 = 1
  15597. }
  15598. }
  15599. }
  15600. if is390 == 1 {
  15601. insutype = "390"
  15602. }
  15603. if is310 == 1 {
  15604. insutype = "310"
  15605. }
  15606. if len(insutypes) == 0 {
  15607. insutype = "310"
  15608. }
  15609. service.CreateHisPsn(psn)
  15610. c.ServeSuccessJSON(map[string]interface{}{
  15611. "patient": patient,
  15612. "number": token,
  15613. "insutype": insutype,
  15614. })
  15615. }
  15616. } else {
  15617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15618. return
  15619. }
  15620. } else { //读卡失败
  15621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15622. return
  15623. }
  15624. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15625. //idNo := c.GetString("idNo")
  15626. //userName := c.GetString("userName")
  15627. //ecToken := c.GetString("ecToken")
  15628. //insuOrg := c.GetString("insuOrg")
  15629. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15630. utils.ErrorLog("解析失败:%v", json_result)
  15631. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15632. type ELeData struct {
  15633. Data struct {
  15634. IdNo string `json:"idNo"`
  15635. IdType string `json:"idType"`
  15636. UserName string `json:"userName"`
  15637. EcToken string `json:"ecToken"`
  15638. InsuOrg string `json:"insuOrg"`
  15639. Gender string `json:"gender"`
  15640. Birthday string `json:"birthday"`
  15641. Nationality string `json:"nationality"`
  15642. Email string `json:"email"`
  15643. Extra string `json:"extra"`
  15644. } `json:"data"`
  15645. Code int `json:"code"`
  15646. Message string `json:"message"`
  15647. }
  15648. var ele ELeData
  15649. err := json.Unmarshal([]byte(json_result), &ele)
  15650. if err != nil {
  15651. utils.ErrorLog("解析失败:%v", err)
  15652. }
  15653. token := ele.Data.EcToken
  15654. token = Remove0000(token)
  15655. 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)
  15656. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15657. var res ResultTwo
  15658. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15659. utils.ErrorLog("解析失败:%v", err)
  15660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15661. return
  15662. }
  15663. if res.Infcode == 0 {
  15664. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15665. if err == gorm.ErrRecordNotFound {
  15666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15667. return
  15668. } else if err != nil {
  15669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15670. return
  15671. } else {
  15672. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15673. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15674. infoStr := string(Iinfos)
  15675. idetinfoStr := string(Idetinfos)
  15676. psn := &models.HisPsn{
  15677. PsnNo: res.Output.Baseinfo.PsnNo,
  15678. PatientId: patient.ID,
  15679. Certno: res.Output.Baseinfo.Certno,
  15680. Gend: res.Output.Baseinfo.Gend,
  15681. Naty: res.Output.Baseinfo.Naty,
  15682. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15683. PsnName: res.Output.Baseinfo.PsnName,
  15684. Idetinfo: idetinfoStr,
  15685. Insuinfo: infoStr,
  15686. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15687. CardInfo: "",
  15688. Stage: "1",
  15689. VerifyNumber: token,
  15690. InsuplcAdmdvs: ele.Data.InsuOrg,
  15691. }
  15692. service.CreateHisPsn(psn)
  15693. var rf []*ResultFive
  15694. json.Unmarshal([]byte(infoStr), &rf)
  15695. var insutypes []*ResultFive
  15696. var insutype string
  15697. var is390 int = 0
  15698. var is310 int = 0
  15699. for _, item := range rf {
  15700. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15701. insutypes = append(insutypes, item)
  15702. }
  15703. }
  15704. if len(insutypes) == 1 {
  15705. insutype = insutypes[0].Insutype
  15706. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15707. } else {
  15708. for _, i := range insutypes {
  15709. if i.Insutype == "390" {
  15710. is390 = 1
  15711. }
  15712. if i.Insutype == "310" {
  15713. is310 = 1
  15714. }
  15715. }
  15716. }
  15717. if is390 == 1 {
  15718. insutype = "390"
  15719. }
  15720. if is310 == 1 {
  15721. insutype = "310"
  15722. }
  15723. if len(insutypes) == 0 {
  15724. insutype = "310"
  15725. }
  15726. c.ServeSuccessJSON(map[string]interface{}{
  15727. "patient": patient,
  15728. "number": token,
  15729. "insutype": insutype,
  15730. })
  15731. }
  15732. } else {
  15733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15734. return
  15735. }
  15736. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15737. //if initFlag == 0 {
  15738. //c.TestGetJiangXiBasBaseInit()
  15739. //}
  15740. //if initEleFlag == 0 {
  15741. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15742. //}
  15743. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15744. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15745. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15746. type ELeData struct {
  15747. Data struct {
  15748. IdNo string `json:"idNo"`
  15749. IdType string `json:"idType"`
  15750. UserName string `json:"userName"`
  15751. EcToken string `json:"ecToken"`
  15752. InsuOrg string `json:"insuOrg"`
  15753. Gender string `json:"gender"`
  15754. Birthday string `json:"birthday"`
  15755. Nationality string `json:"nationality"`
  15756. Email string `json:"email"`
  15757. Extra string `json:"extra"`
  15758. } `json:"data"`
  15759. Code int `json:"code"`
  15760. Message string `json:"message"`
  15761. }
  15762. var ele ELeData
  15763. err := json.Unmarshal([]byte(result), &ele)
  15764. if err != nil {
  15765. utils.ErrorLog("解析失败:%v", err)
  15766. }
  15767. token := ele.Data.EcToken
  15768. token = Remove0000(token)
  15769. 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)
  15770. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15771. var res ResultTwo
  15772. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15773. utils.ErrorLog("解析失败:%v", err)
  15774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15775. return
  15776. }
  15777. if res.Infcode == 0 {
  15778. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15779. if err == gorm.ErrRecordNotFound {
  15780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15781. return
  15782. } else if err != nil {
  15783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15784. return
  15785. } else {
  15786. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15787. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15788. infoStr := string(Iinfos)
  15789. idetinfoStr := string(Idetinfos)
  15790. psn := &models.HisPsn{
  15791. PsnNo: res.Output.Baseinfo.PsnNo,
  15792. PatientId: patient.ID,
  15793. Certno: res.Output.Baseinfo.Certno,
  15794. Gend: res.Output.Baseinfo.Gend,
  15795. Naty: res.Output.Baseinfo.Naty,
  15796. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15797. PsnName: res.Output.Baseinfo.PsnName,
  15798. Idetinfo: idetinfoStr,
  15799. Insuinfo: infoStr,
  15800. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15801. CardInfo: "",
  15802. VerifyNumber: token,
  15803. InsuplcAdmdvs: ele.Data.InsuOrg,
  15804. }
  15805. service.CreateHisPsn(psn)
  15806. var rf []*ResultFive
  15807. json.Unmarshal([]byte(infoStr), &rf)
  15808. var insutypes []*ResultFive
  15809. var insutype string
  15810. var is390 int = 0
  15811. var is310 int = 0
  15812. for _, item := range rf {
  15813. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15814. insutypes = append(insutypes, item)
  15815. }
  15816. }
  15817. if len(insutypes) == 1 {
  15818. insutype = insutypes[0].Insutype
  15819. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15820. } else {
  15821. for _, i := range insutypes {
  15822. if i.Insutype == "390" {
  15823. is390 = 1
  15824. }
  15825. if i.Insutype == "310" {
  15826. is310 = 1
  15827. }
  15828. }
  15829. }
  15830. if is390 == 1 {
  15831. insutype = "390"
  15832. }
  15833. if is310 == 1 {
  15834. insutype = "310"
  15835. }
  15836. if len(insutypes) == 0 {
  15837. insutype = "310"
  15838. }
  15839. c.ServeSuccessJSON(map[string]interface{}{
  15840. "patient": patient,
  15841. "number": token,
  15842. "insutype": insutype,
  15843. })
  15844. }
  15845. } else {
  15846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15847. return
  15848. }
  15849. } else if miConfig.MdtrtareaAdmvs == "361025" {
  15850. //if initFlag == 0 {
  15851. //c.TestGetJiangXiBasBaseInit()
  15852. //}
  15853. //if initEleFlag == 0 {
  15854. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15855. //}
  15856. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15857. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15858. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15859. type ELeData struct {
  15860. Data struct {
  15861. IdNo string `json:"idNo"`
  15862. IdType string `json:"idType"`
  15863. UserName string `json:"userName"`
  15864. EcToken string `json:"ecToken"`
  15865. InsuOrg string `json:"insuOrg"`
  15866. Gender string `json:"gender"`
  15867. Birthday string `json:"birthday"`
  15868. Nationality string `json:"nationality"`
  15869. Email string `json:"email"`
  15870. Extra string `json:"extra"`
  15871. } `json:"data"`
  15872. Code int `json:"code"`
  15873. Message string `json:"message"`
  15874. }
  15875. var ele ELeData
  15876. err := json.Unmarshal([]byte(result), &ele)
  15877. if err != nil {
  15878. utils.ErrorLog("解析失败:%v", err)
  15879. }
  15880. token := ele.Data.EcToken
  15881. token = Remove0000(token)
  15882. 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)
  15883. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15884. var res ResultTwo
  15885. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15886. utils.ErrorLog("解析失败:%v", err)
  15887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15888. return
  15889. }
  15890. if res.Infcode == 0 {
  15891. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15892. if err == gorm.ErrRecordNotFound {
  15893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15894. return
  15895. } else if err != nil {
  15896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15897. return
  15898. } else {
  15899. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15900. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15901. infoStr := string(Iinfos)
  15902. idetinfoStr := string(Idetinfos)
  15903. psn := &models.HisPsn{
  15904. PsnNo: res.Output.Baseinfo.PsnNo,
  15905. PatientId: patient.ID,
  15906. Certno: res.Output.Baseinfo.Certno,
  15907. Gend: res.Output.Baseinfo.Gend,
  15908. Naty: res.Output.Baseinfo.Naty,
  15909. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15910. PsnName: res.Output.Baseinfo.PsnName,
  15911. Idetinfo: idetinfoStr,
  15912. Insuinfo: infoStr,
  15913. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15914. CardInfo: "",
  15915. VerifyNumber: token,
  15916. InsuplcAdmdvs: ele.Data.InsuOrg,
  15917. }
  15918. service.CreateHisPsn(psn)
  15919. var rf []*ResultFive
  15920. json.Unmarshal([]byte(infoStr), &rf)
  15921. var insutypes []*ResultFive
  15922. var insutype string
  15923. var is390 int = 0
  15924. var is310 int = 0
  15925. for _, item := range rf {
  15926. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15927. insutypes = append(insutypes, item)
  15928. }
  15929. }
  15930. if len(insutypes) == 1 {
  15931. insutype = insutypes[0].Insutype
  15932. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15933. } else {
  15934. for _, i := range insutypes {
  15935. if i.Insutype == "390" {
  15936. is390 = 1
  15937. }
  15938. if i.Insutype == "310" {
  15939. is310 = 1
  15940. }
  15941. }
  15942. }
  15943. if is390 == 1 {
  15944. insutype = "390"
  15945. }
  15946. if is310 == 1 {
  15947. insutype = "310"
  15948. }
  15949. if len(insutypes) == 0 {
  15950. insutype = "310"
  15951. }
  15952. c.ServeSuccessJSON(map[string]interface{}{
  15953. "patient": patient,
  15954. "number": token,
  15955. "insutype": insutype,
  15956. })
  15957. }
  15958. } else {
  15959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15960. return
  15961. }
  15962. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15963. //if initFlag == 0 {
  15964. c.TestGetJiangXiBasBaseInit()
  15965. //}
  15966. //if initEleFlag == 0 {
  15967. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15968. //}
  15969. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15970. type ELeData struct {
  15971. Data struct {
  15972. IdNo string `json:"idNo"`
  15973. IdType string `json:"idType"`
  15974. UserName string `json:"userName"`
  15975. EcToken string `json:"ecToken"`
  15976. InsuOrg string `json:"insuOrg"`
  15977. Gender string `json:"gender"`
  15978. Birthday string `json:"birthday"`
  15979. Nationality string `json:"nationality"`
  15980. Email string `json:"email"`
  15981. Extra string `json:"extra"`
  15982. } `json:"data"`
  15983. Code int `json:"code"`
  15984. Message string `json:"message"`
  15985. }
  15986. var ele ELeData
  15987. err := json.Unmarshal([]byte(json_result), &ele)
  15988. if err != nil {
  15989. utils.ErrorLog("解析失败:%v", err)
  15990. }
  15991. token := ele.Data.EcToken
  15992. token = Remove0000(token)
  15993. 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)
  15994. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15995. var res ResultTwo
  15996. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15997. utils.ErrorLog("解析失败:%v", err)
  15998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15999. return
  16000. }
  16001. if res.Infcode == 0 {
  16002. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16003. if err == gorm.ErrRecordNotFound {
  16004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16005. return
  16006. } else if err != nil {
  16007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16008. return
  16009. } else {
  16010. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16011. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16012. infoStr := string(Iinfos)
  16013. idetinfoStr := string(Idetinfos)
  16014. psn := &models.HisPsn{
  16015. PsnNo: res.Output.Baseinfo.PsnNo,
  16016. PatientId: patient.ID,
  16017. Certno: res.Output.Baseinfo.Certno,
  16018. Gend: res.Output.Baseinfo.Gend,
  16019. Naty: res.Output.Baseinfo.Naty,
  16020. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16021. PsnName: res.Output.Baseinfo.PsnName,
  16022. Idetinfo: idetinfoStr,
  16023. Insuinfo: infoStr,
  16024. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16025. CardInfo: "",
  16026. VerifyNumber: token,
  16027. }
  16028. service.CreateHisPsn(psn)
  16029. var rf []*ResultFive
  16030. json.Unmarshal([]byte(infoStr), &rf)
  16031. var insutypes []*ResultFive
  16032. var insutype string
  16033. var is390 int = 0
  16034. var is310 int = 0
  16035. for _, item := range rf {
  16036. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16037. insutypes = append(insutypes, item)
  16038. }
  16039. }
  16040. if len(insutypes) == 1 {
  16041. insutype = insutypes[0].Insutype
  16042. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16043. } else {
  16044. for _, i := range insutypes {
  16045. if i.Insutype == "390" {
  16046. is390 = 1
  16047. }
  16048. if i.Insutype == "310" {
  16049. is310 = 1
  16050. }
  16051. }
  16052. }
  16053. if is390 == 1 {
  16054. insutype = "390"
  16055. }
  16056. if is310 == 1 {
  16057. insutype = "310"
  16058. }
  16059. if len(insutypes) == 0 {
  16060. insutype = "310"
  16061. }
  16062. c.ServeSuccessJSON(map[string]interface{}{
  16063. "patient": patient,
  16064. "number": token,
  16065. "insutype": insutype,
  16066. })
  16067. }
  16068. } else {
  16069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16070. return
  16071. }
  16072. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16073. type ELeData struct {
  16074. Code string `json:"code"`
  16075. Data struct {
  16076. Aac002 string `json:"aac002"`
  16077. Aaz500 string `json:"aaz500"`
  16078. ActCardNo string `json:"actCardNo"`
  16079. Bab520 string `json:"bab520"`
  16080. Bkz543 string `json:"bkz543"`
  16081. BusinessType string `json:"businessType"`
  16082. CertfCodg string `json:"certfCodg"`
  16083. EcIndexNo string `json:"ecIndexNo"`
  16084. EcToken string `json:"ecToken"`
  16085. ID0000 string `json:"id0000"`
  16086. IDNo string `json:"idNo"`
  16087. IDType string `json:"idType"`
  16088. Idcode string `json:"idcode"`
  16089. IdentityToken string `json:"identity_token"`
  16090. InsuOrg string `json:"insuOrg"`
  16091. OfficeID string `json:"officeId"`
  16092. OfficeName string `json:"officeName"`
  16093. OperatorID string `json:"operatorId"`
  16094. OperatorName string `json:"operatorName"`
  16095. OrgID string `json:"orgId"`
  16096. UserName string `json:"userName"`
  16097. } `json:"data"`
  16098. Infno interface{} `json:"infno"`
  16099. Message string `json:"message"`
  16100. OrgID string `json:"orgId"`
  16101. TransType string `json:"transType"`
  16102. }
  16103. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  16104. outPutInfo = Remove0000(outPutInfo)
  16105. if len(outPutInfo) > 0 {
  16106. var ele ELeData
  16107. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16108. if err != nil {
  16109. utils.ErrorLog("解析失败:%v", err)
  16110. }
  16111. token := ele.Data.EcToken
  16112. fmt.Println(inputInfo)
  16113. fmt.Println(outPutInfo)
  16114. 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)
  16115. saveLog(result, requestLog, "1101", "获取人员信息")
  16116. var dat map[string]interface{}
  16117. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16118. fmt.Println(dat)
  16119. } else {
  16120. fmt.Println(err)
  16121. }
  16122. userJSONBytes, _ := json.Marshal(dat)
  16123. var res ResultTwo
  16124. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16125. utils.ErrorLog("解析失败:%v", err)
  16126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16127. return
  16128. }
  16129. res.ErrMsg = errMsgLog
  16130. if res.Infcode == 0 {
  16131. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16132. if err == gorm.ErrRecordNotFound {
  16133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16134. return
  16135. } else if err != nil {
  16136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16137. return
  16138. } else {
  16139. fmt.Println(res)
  16140. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16141. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16142. infoStr := string(Iinfos)
  16143. idetinfoStr := string(Idetinfos)
  16144. psn := &models.HisPsn{
  16145. PsnNo: res.Output.Baseinfo.PsnNo,
  16146. PatientId: patient.ID,
  16147. Certno: res.Output.Baseinfo.Certno,
  16148. Gend: res.Output.Baseinfo.Gend,
  16149. Naty: res.Output.Baseinfo.Naty,
  16150. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16151. PsnName: res.Output.Baseinfo.PsnName,
  16152. Idetinfo: idetinfoStr,
  16153. Insuinfo: infoStr,
  16154. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16155. CardInfo: outPutInfo,
  16156. VerifyNumber: token,
  16157. InsuplcAdmdvs: ele.Data.InsuOrg,
  16158. }
  16159. service.CreateHisPsn(psn)
  16160. var rf []*ResultFive
  16161. json.Unmarshal([]byte(infoStr), &rf)
  16162. var insutypes []*ResultFive
  16163. var insutype string
  16164. var is390 int = 0
  16165. var is310 int = 0
  16166. for _, item := range rf {
  16167. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16168. insutypes = append(insutypes, item)
  16169. }
  16170. }
  16171. if len(insutypes) == 1 {
  16172. insutype = insutypes[0].Insutype
  16173. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16174. } else {
  16175. for _, i := range insutypes {
  16176. if i.Insutype == "390" {
  16177. is390 = 1
  16178. }
  16179. if i.Insutype == "310" {
  16180. is310 = 1
  16181. }
  16182. }
  16183. }
  16184. if is390 == 1 {
  16185. insutype = "390"
  16186. }
  16187. if is310 == 1 {
  16188. insutype = "310"
  16189. }
  16190. if len(insutypes) == 0 {
  16191. insutype = "310"
  16192. }
  16193. c.ServeSuccessJSON(map[string]interface{}{
  16194. "patient": patient,
  16195. "number": token,
  16196. "insutype": insutype,
  16197. })
  16198. }
  16199. } else {
  16200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16201. return
  16202. }
  16203. }
  16204. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16205. var api string
  16206. 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 +
  16207. "&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
  16208. resp, requestErr := http.Get(api)
  16209. if requestErr != nil {
  16210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16211. return
  16212. }
  16213. body, ioErr := ioutil.ReadAll(resp.Body)
  16214. if ioErr != nil {
  16215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16217. return
  16218. }
  16219. var respJSON map[string]interface{}
  16220. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16223. return
  16224. }
  16225. var status string
  16226. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16227. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16228. var token string
  16229. var res ResultTwo //1101结果
  16230. var res10265 ResultTwo10265 //1101结果
  16231. if status == "0" { //读卡成功
  16232. var card_info string //卡信息
  16233. var busi_card_info string
  16234. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16235. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16236. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16237. fmt.Println(card_info)
  16238. fmt.Println(busi_card_info)
  16239. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16240. result, _ := json.Marshal(respJSON)
  16241. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16242. utils.ErrorLog("解析失败:%v", err)
  16243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16244. return
  16245. }
  16246. res.ErrMsg = res10265.ErrMsg
  16247. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16248. res.Infcode = infocode
  16249. res.Output = res10265.Output
  16250. res.InfRefmsgid = res10265.InfRefmsgid
  16251. if res.Infcode == 0 {
  16252. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16253. if err == gorm.ErrRecordNotFound {
  16254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16255. return
  16256. } else if err != nil {
  16257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16258. return
  16259. } else {
  16260. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16261. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16262. infoStr := string(Iinfos)
  16263. idetinfoStr := string(Idetinfos)
  16264. psn := &models.HisPsn{
  16265. PsnNo: res.Output.Baseinfo.PsnNo,
  16266. PatientId: patient.ID,
  16267. Certno: res.Output.Baseinfo.Certno,
  16268. Gend: res.Output.Baseinfo.Gend,
  16269. Naty: res.Output.Baseinfo.Naty,
  16270. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16271. PsnName: res.Output.Baseinfo.PsnName,
  16272. Idetinfo: idetinfoStr,
  16273. Insuinfo: infoStr,
  16274. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16275. CardInfo: card_info,
  16276. VerifyNumber: token,
  16277. }
  16278. var rf []*ResultFive
  16279. json.Unmarshal([]byte(infoStr), &rf)
  16280. var insutypes []*ResultFive
  16281. var insutype string
  16282. var is390 int = 0
  16283. var is310 int = 0
  16284. for _, item := range rf {
  16285. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16286. insutypes = append(insutypes, item)
  16287. }
  16288. }
  16289. if len(insutypes) == 1 {
  16290. insutype = insutypes[0].Insutype
  16291. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16292. } else {
  16293. for _, i := range insutypes {
  16294. if i.Insutype == "390" {
  16295. is390 = 1
  16296. }
  16297. if i.Insutype == "310" {
  16298. is310 = 1
  16299. }
  16300. }
  16301. }
  16302. if is390 == 1 {
  16303. insutype = "390"
  16304. }
  16305. if is310 == 1 {
  16306. insutype = "310"
  16307. }
  16308. if len(insutypes) == 0 {
  16309. insutype = "310"
  16310. }
  16311. service.CreateHisPsn(psn)
  16312. c.ServeSuccessJSON(map[string]interface{}{
  16313. "patient": patient,
  16314. "number": token,
  16315. "insutype": insutype,
  16316. })
  16317. }
  16318. } else {
  16319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16320. return
  16321. }
  16322. } else { //读卡失败
  16323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16324. return
  16325. }
  16326. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16327. res := c.GetoleInfo()
  16328. if res.Infcode == 0 {
  16329. var result string
  16330. if res.Output.MdtrtCertType == "01" {
  16331. 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)
  16332. } else if res.Output.MdtrtCertType == "02" {
  16333. 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)
  16334. } else if res.Output.MdtrtCertType == "03" {
  16335. 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)
  16336. }
  16337. var dat map[string]interface{}
  16338. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16339. fmt.Println(dat)
  16340. } else {
  16341. fmt.Println(err)
  16342. }
  16343. userJSONBytes, _ := json.Marshal(dat)
  16344. var res2 ResultTwo
  16345. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16346. utils.ErrorLog("解析失败:%v", err)
  16347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16348. return
  16349. }
  16350. if res2.Infcode == 0 {
  16351. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  16352. if err == gorm.ErrRecordNotFound {
  16353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16354. return
  16355. } else if err != nil {
  16356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16357. return
  16358. } else {
  16359. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  16360. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16361. infoStr := string(Iinfos)
  16362. idetinfoStr := string(Idetinfos)
  16363. var rf []*ResultFive
  16364. json.Unmarshal([]byte(infoStr), &rf)
  16365. var insutypes []*ResultFive
  16366. var insutype string
  16367. var is390 int = 0
  16368. var is310 int = 0
  16369. //var insuplc_admdvs string
  16370. for _, item := range rf {
  16371. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16372. insutypes = append(insutypes, item)
  16373. }
  16374. }
  16375. if len(insutypes) == 1 {
  16376. insutype = insutypes[0].Insutype
  16377. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16378. } else {
  16379. for _, i := range insutypes {
  16380. if i.Insutype == "390" {
  16381. is390 = 1
  16382. }
  16383. if i.Insutype == "310" {
  16384. is310 = 1
  16385. }
  16386. }
  16387. }
  16388. if is390 == 1 {
  16389. insutype = "390"
  16390. }
  16391. if is310 == 1 {
  16392. insutype = "310"
  16393. }
  16394. if len(insutypes) == 0 {
  16395. insutype = "310"
  16396. }
  16397. psn := &models.HisPsn{
  16398. PsnNo: res2.Output.Baseinfo.PsnNo,
  16399. PatientId: patient.ID,
  16400. Certno: res2.Output.Baseinfo.Certno,
  16401. Gend: res2.Output.Baseinfo.Gend,
  16402. Naty: res2.Output.Baseinfo.Naty,
  16403. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16404. PsnName: res2.Output.Baseinfo.PsnName,
  16405. Idetinfo: idetinfoStr,
  16406. Insuinfo: infoStr,
  16407. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16408. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16409. VerifyNumber: res.Output.EcToken,
  16410. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16411. }
  16412. if res.Output.MdtrtCertType == "01" {
  16413. psn.VerifyNumber = res.Output.EcToken
  16414. //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)
  16415. } else if res.Output.MdtrtCertType == "02" {
  16416. psn.VerifyNumber = res.Output.CardNo
  16417. //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)
  16418. } else if res.Output.MdtrtCertType == "03" {
  16419. psn.VerifyNumber = res.Output.MdtrtCertNo
  16420. //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)
  16421. }
  16422. service.CreateHisPsn(psn)
  16423. var balc float64
  16424. for _, item := range rf {
  16425. if item.Insutype == insutype {
  16426. balc = item.Balc
  16427. }
  16428. }
  16429. c.ServeSuccessJSON(map[string]interface{}{
  16430. "patient": patient,
  16431. "number": res.Output.CardNo,
  16432. "insutype": insutype,
  16433. "blac": balc,
  16434. "desc": idetinfoStr,
  16435. })
  16436. }
  16437. } else {
  16438. c.ServeSuccessJSON(map[string]interface{}{
  16439. "failed_code": -10,
  16440. "msg": res2.ErrMsg,
  16441. })
  16442. }
  16443. } else {
  16444. c.ServeSuccessJSON(map[string]interface{}{
  16445. "failed_code": -10,
  16446. "msg": res.ErrMsg,
  16447. })
  16448. }
  16449. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16450. var res ResultTwo
  16451. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16452. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16453. "&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)
  16454. resp, requestErr := http.Get(api)
  16455. if requestErr != nil {
  16456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16457. return
  16458. }
  16459. body, ioErr := ioutil.ReadAll(resp.Body)
  16460. if ioErr != nil {
  16461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16463. return
  16464. }
  16465. var respJSON map[string]interface{}
  16466. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16469. return
  16470. }
  16471. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16472. result, _ := json.Marshal(respJSON)
  16473. fmt.Println("log")
  16474. fmt.Println(string(result))
  16475. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16476. utils.ErrorLog("解析失败:%v", err)
  16477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16478. return
  16479. }
  16480. if res.Infcode == 0 {
  16481. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16482. if err == gorm.ErrRecordNotFound {
  16483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16484. return
  16485. } else if err != nil {
  16486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16487. return
  16488. } else {
  16489. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16490. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16491. infoStr := string(Iinfos)
  16492. idetinfoStr := string(Idetinfos)
  16493. var rf []*ResultFive
  16494. json.Unmarshal([]byte(infoStr), &rf)
  16495. var insutypes []*ResultFive
  16496. var insutype string
  16497. var is390 int = 0
  16498. var is310 int = 0
  16499. for _, item := range rf {
  16500. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16501. insutypes = append(insutypes, item)
  16502. }
  16503. }
  16504. if len(insutypes) == 1 {
  16505. insutype = insutypes[0].Insutype
  16506. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16507. } else {
  16508. for _, i := range insutypes {
  16509. if i.Insutype == "390" {
  16510. is390 = 1
  16511. }
  16512. if i.Insutype == "310" {
  16513. is310 = 1
  16514. }
  16515. }
  16516. }
  16517. if is390 == 1 {
  16518. insutype = "390"
  16519. }
  16520. if is310 == 1 {
  16521. insutype = "310"
  16522. }
  16523. if len(insutypes) == 0 {
  16524. insutype = "390"
  16525. }
  16526. var insuplc_admdvs string
  16527. for _, item := range rf {
  16528. if item.Insutype == insutype {
  16529. insuplc_admdvs = item.InsuplcAdmdvs
  16530. }
  16531. }
  16532. psn := &models.HisPsn{
  16533. PsnNo: res.Output.Baseinfo.PsnNo,
  16534. PatientId: patient.ID,
  16535. Certno: res.Output.Baseinfo.Certno,
  16536. Gend: res.Output.Baseinfo.Gend,
  16537. Naty: res.Output.Baseinfo.Naty,
  16538. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16539. PsnName: res.Output.Baseinfo.PsnName,
  16540. Idetinfo: idetinfoStr,
  16541. Insuinfo: infoStr,
  16542. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16543. InsuplcAdmdvs: insuplc_admdvs,
  16544. }
  16545. service.CreateHisPsn(psn)
  16546. c.ServeSuccessJSON(map[string]interface{}{
  16547. "patient": patient,
  16548. "number": res.Output.Baseinfo.Certno,
  16549. })
  16550. }
  16551. } else {
  16552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16553. return
  16554. }
  16555. } else {
  16556. type ELeData struct {
  16557. Code string `json:"code"`
  16558. Data struct {
  16559. Aac002 string `json:"aac002"`
  16560. Aaz500 string `json:"aaz500"`
  16561. ActCardNo string `json:"actCardNo"`
  16562. Bab520 string `json:"bab520"`
  16563. Bkz543 string `json:"bkz543"`
  16564. BusinessType string `json:"businessType"`
  16565. CertfCodg string `json:"certfCodg"`
  16566. EcIndexNo string `json:"ecIndexNo"`
  16567. EcToken string `json:"ecToken"`
  16568. ID0000 string `json:"id0000"`
  16569. IDNo string `json:"idNo"`
  16570. IDType string `json:"idType"`
  16571. Idcode string `json:"idcode"`
  16572. IdentityToken string `json:"identity_token"`
  16573. InsuOrg string `json:"insuOrg"`
  16574. OfficeID string `json:"officeId"`
  16575. OfficeName string `json:"officeName"`
  16576. OperatorID string `json:"operatorId"`
  16577. OperatorName string `json:"operatorName"`
  16578. OrgID string `json:"orgId"`
  16579. UserName string `json:"userName"`
  16580. } `json:"data"`
  16581. Infno interface{} `json:"infno"`
  16582. Message string `json:"message"`
  16583. OrgID string `json:"orgId"`
  16584. TransType string `json:"transType"`
  16585. }
  16586. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16587. fmt.Println(result)
  16588. outPutInfo := Remove0000(result)
  16589. fmt.Println(outPutInfo)
  16590. if len(outPutInfo) > 0 {
  16591. var ele ELeData
  16592. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16593. if err != nil {
  16594. utils.ErrorLog("解析失败:%v", err)
  16595. }
  16596. token := ele.Data.EcToken
  16597. fmt.Println(outPutInfo)
  16598. 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)
  16599. saveLog(result, requestLog, "1101", "获取人员信息")
  16600. var dat map[string]interface{}
  16601. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16602. fmt.Println(dat)
  16603. } else {
  16604. fmt.Println(err)
  16605. }
  16606. userJSONBytes, _ := json.Marshal(dat)
  16607. var res ResultTwo
  16608. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16609. utils.ErrorLog("解析失败:%v", err)
  16610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16611. return
  16612. }
  16613. if res.Infcode == 0 {
  16614. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16615. if err == gorm.ErrRecordNotFound {
  16616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16617. return
  16618. } else if err != nil {
  16619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16620. return
  16621. } else {
  16622. fmt.Println(res)
  16623. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16624. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16625. infoStr := string(Iinfos)
  16626. idetinfoStr := string(Idetinfos)
  16627. psn := &models.HisPsn{
  16628. PsnNo: res.Output.Baseinfo.PsnNo,
  16629. PatientId: patient.ID,
  16630. Certno: res.Output.Baseinfo.Certno,
  16631. Gend: res.Output.Baseinfo.Gend,
  16632. Naty: res.Output.Baseinfo.Naty,
  16633. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16634. PsnName: res.Output.Baseinfo.PsnName,
  16635. Idetinfo: idetinfoStr,
  16636. Insuinfo: infoStr,
  16637. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16638. CardInfo: outPutInfo,
  16639. VerifyNumber: token,
  16640. InsuplcAdmdvs: ele.Data.InsuOrg,
  16641. }
  16642. service.CreateHisPsn(psn)
  16643. var rf []*ResultFive
  16644. json.Unmarshal([]byte(infoStr), &rf)
  16645. var insutypes []*ResultFive
  16646. var insutype string
  16647. var is390 int = 0
  16648. var is310 int = 0
  16649. for _, item := range rf {
  16650. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16651. insutypes = append(insutypes, item)
  16652. }
  16653. }
  16654. if len(insutypes) == 1 {
  16655. insutype = insutypes[0].Insutype
  16656. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16657. } else {
  16658. for _, i := range insutypes {
  16659. if i.Insutype == "390" {
  16660. is390 = 1
  16661. }
  16662. if i.Insutype == "310" {
  16663. is310 = 1
  16664. }
  16665. }
  16666. }
  16667. if is390 == 1 {
  16668. insutype = "390"
  16669. }
  16670. if is310 == 1 {
  16671. insutype = "310"
  16672. }
  16673. if len(insutypes) == 0 {
  16674. insutype = "310"
  16675. }
  16676. c.ServeSuccessJSON(map[string]interface{}{
  16677. "patient": patient,
  16678. "number": token,
  16679. "insutype": insutype,
  16680. })
  16681. }
  16682. } else {
  16683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16684. return
  16685. }
  16686. }
  16687. //fmt.Println(result)
  16688. //
  16689. //if initFlag == 0 {
  16690. // c.TestGetBasBaseInit()
  16691. //}
  16692. //token := c.GetEleBaseInfo()
  16693. //
  16694. //token = Remove0000(token)
  16695. //
  16696. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  16697. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  16698. ////
  16699. //var res ResultTwo
  16700. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16701. // utils.ErrorLog("解析失败:%v", err)
  16702. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16703. // return
  16704. //}
  16705. //
  16706. //if res.Infcode == 0 {
  16707. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16708. // if err == gorm.ErrRecordNotFound {
  16709. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16710. // return
  16711. // } else if err != nil {
  16712. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16713. // return
  16714. //
  16715. // } else {
  16716. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16717. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16718. // infoStr := string(Iinfos)
  16719. // idetinfoStr := string(Idetinfos)
  16720. //
  16721. //
  16722. //
  16723. //
  16724. // var rf []*ResultFive
  16725. // json.Unmarshal([]byte(infoStr), &rf)
  16726. //
  16727. // var insutypes []*ResultFive
  16728. // var insutype string
  16729. // var is390 int = 0
  16730. // var is310 int = 0
  16731. // var insuplc_admdvs string
  16732. //
  16733. // for _, item := range rf {
  16734. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16735. // insutypes = append(insutypes, item)
  16736. // }
  16737. // }
  16738. //
  16739. // if len(insutypes) == 1 {
  16740. // insutype = insutypes[0].Insutype
  16741. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16742. // } else {
  16743. // for _, i := range insutypes {
  16744. // if i.Insutype == "390" {
  16745. // is390 = 1
  16746. // }
  16747. //
  16748. // if i.Insutype == "310" {
  16749. // is310 = 1
  16750. // }
  16751. // }
  16752. // }
  16753. // if is390 == 1 {
  16754. // insutype = "390"
  16755. // }
  16756. //
  16757. // if is310 == 1 {
  16758. // insutype = "310"
  16759. // }
  16760. // if len(insutypes) == 0 {
  16761. // insutype = "310"
  16762. // }
  16763. // for _, item := range rf {
  16764. // if item.Insutype == insutype {
  16765. // insuplc_admdvs = item.InsuplcAdmdvs
  16766. // }
  16767. // }
  16768. // psn := &models.HisPsn{
  16769. // PsnNo: res.Output.Baseinfo.PsnNo,
  16770. // Age: res.Output.Baseinfo.Age,
  16771. // PatientId: patient.ID,
  16772. // Certno: res.Output.Baseinfo.Certno,
  16773. // Brdy: res.Output.Baseinfo.Brdy,
  16774. // Gend: res.Output.Baseinfo.Gend,
  16775. // Naty: res.Output.Baseinfo.Naty,
  16776. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  16777. // PsnName: res.Output.Baseinfo.PsnName,
  16778. // Idetinfo: idetinfoStr,
  16779. // Insuinfo: infoStr,
  16780. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16781. // CardInfo: "",
  16782. // VerifyNumber: token,
  16783. // InsuplcAdmdvs: insuplc_admdvs,
  16784. // }
  16785. // service.CreateHisPsn(psn)
  16786. //
  16787. // c.ServeSuccessJSON(map[string]interface{}{
  16788. // "patient": patient,
  16789. // "number": token,
  16790. // })
  16791. // }
  16792. //} else {
  16793. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16794. // return
  16795. //}
  16796. }
  16797. break
  16798. case 5:
  16799. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16800. var api string
  16801. if miConfig.MdtrtareaAdmvs == "320921" {
  16802. 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 +
  16803. "&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
  16804. fmt.Println(api)
  16805. } else {
  16806. 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 +
  16807. "&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)
  16808. }
  16809. resp, requestErr := http.Get(api)
  16810. if requestErr != nil {
  16811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16812. return
  16813. }
  16814. body, ioErr := ioutil.ReadAll(resp.Body)
  16815. if ioErr != nil {
  16816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16818. return
  16819. }
  16820. var respJSON map[string]interface{}
  16821. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16824. return
  16825. }
  16826. var status string
  16827. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16828. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16829. var token string
  16830. var res ResultTwo //1101结果
  16831. var res10265 ResultTwo10265 //1101结果
  16832. if status == "0" { //读卡成功
  16833. var card_info string //卡信息
  16834. //var busi_card_info string
  16835. var auth_info string
  16836. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16837. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16838. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16839. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  16840. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16841. result, _ := json.Marshal(respJSON)
  16842. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16843. utils.ErrorLog("解析失败:%v", err)
  16844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16845. return
  16846. }
  16847. res.ErrMsg = res10265.ErrMsg
  16848. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16849. res.Infcode = infocode
  16850. res.Output = res10265.Output
  16851. res.InfRefmsgid = res10265.InfRefmsgid
  16852. if res.Infcode == 0 {
  16853. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16854. if err == gorm.ErrRecordNotFound {
  16855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16856. return
  16857. } else if err != nil {
  16858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16859. return
  16860. } else {
  16861. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16862. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16863. infoStr := string(Iinfos)
  16864. idetinfoStr := string(Idetinfos)
  16865. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16866. psn := &models.HisPsn{
  16867. PsnNo: res.Output.Baseinfo.PsnNo,
  16868. PatientId: patient.ID,
  16869. Certno: res.Output.Baseinfo.Certno,
  16870. Gend: res.Output.Baseinfo.Gend,
  16871. Brdy: b,
  16872. Age: float64(age),
  16873. Naty: res.Output.Baseinfo.Naty,
  16874. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16875. PsnName: res.Output.Baseinfo.PsnName,
  16876. Idetinfo: idetinfoStr,
  16877. Insuinfo: infoStr,
  16878. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16879. CardInfo: card_info,
  16880. VerifyNumber: token,
  16881. AuthInfo: auth_info,
  16882. }
  16883. var rf []*ResultFive
  16884. json.Unmarshal([]byte(infoStr), &rf)
  16885. var insutypes []*ResultFive
  16886. var insutype string
  16887. var is390 int = 0
  16888. var is310 int = 0
  16889. for _, item := range rf {
  16890. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16891. insutypes = append(insutypes, item)
  16892. }
  16893. }
  16894. if len(insutypes) == 1 {
  16895. insutype = insutypes[0].Insutype
  16896. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16897. } else {
  16898. for _, i := range insutypes {
  16899. if i.Insutype == "390" {
  16900. is390 = 1
  16901. }
  16902. if i.Insutype == "310" {
  16903. is310 = 1
  16904. }
  16905. }
  16906. }
  16907. if is390 == 1 {
  16908. insutype = "390"
  16909. }
  16910. if is310 == 1 {
  16911. insutype = "310"
  16912. }
  16913. if len(insutypes) == 0 {
  16914. insutype = "310"
  16915. }
  16916. service.CreateHisPsn(psn)
  16917. c.ServeSuccessJSON(map[string]interface{}{
  16918. "patient": patient,
  16919. "number": token,
  16920. "insutype": insutype,
  16921. })
  16922. }
  16923. } else {
  16924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16925. return
  16926. }
  16927. } else { //读卡失败
  16928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16929. return
  16930. }
  16931. }
  16932. break
  16933. }
  16934. }
  16935. var initFlag int64 = 0
  16936. var initEleFlag int64 = 0
  16937. func (c *HisApiController) TestGetBasBaseInit() {
  16938. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16939. Iinit := DllDef.MustFindProc("Init")
  16940. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16941. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  16942. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  16943. if ret != 0 {
  16944. fmt.Println("SSCard的报错原因:", err)
  16945. fmt.Println("SSCard的运算结果为:", ret)
  16946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16947. return
  16948. }
  16949. result := int(ret)
  16950. fmt.Println("SSCard的运算结果为1:", result)
  16951. initFlag = 1
  16952. return
  16953. }
  16954. func (c *HisApiController) HandleJiangXiReadCard() {
  16955. fmt.Println("~~~~~~")
  16956. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16957. admin_user_id, _ := c.GetInt64("admin_user_id")
  16958. id_card_type, _ := c.GetInt64("id_card_type")
  16959. //certificates, _ := c.GetInt64("certificates")
  16960. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16961. if initFlag == 0 {
  16962. c.TestGetJiangXiBasBaseInit()
  16963. }
  16964. basStr := c.GetBasBaseInfo()
  16965. if len(basStr) == 0 {
  16966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16967. return
  16968. }
  16969. fmt.Println(basStr)
  16970. bas := strings.Split(basStr, "|")
  16971. basNumber := bas[1]
  16972. fmt.Println(basNumber)
  16973. card_sn := bas[3]
  16974. fmt.Println(card_sn)
  16975. 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, "")
  16976. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  16977. var dat map[string]interface{}
  16978. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16979. fmt.Println(dat)
  16980. } else {
  16981. fmt.Println(err)
  16982. }
  16983. userJSONBytes, _ := json.Marshal(dat)
  16984. var res ResultTwo
  16985. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16986. utils.ErrorLog("解析失败:%v", err)
  16987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16988. return
  16989. }
  16990. if res.Infcode == 0 {
  16991. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  16992. if err == gorm.ErrRecordNotFound {
  16993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16994. return
  16995. } else if err != nil {
  16996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16997. return
  16998. } else {
  16999. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17000. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17001. infoStr := string(Iinfos)
  17002. idetinfoStr := string(Idetinfos)
  17003. psn := &models.HisPsn{
  17004. PsnNo: res.Output.Baseinfo.PsnNo,
  17005. PatientId: patient.ID,
  17006. Certno: res.Output.Baseinfo.Certno,
  17007. Gend: res.Output.Baseinfo.Gend,
  17008. Naty: res.Output.Baseinfo.Naty,
  17009. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17010. PsnName: res.Output.Baseinfo.PsnName,
  17011. Idetinfo: idetinfoStr,
  17012. Insuinfo: infoStr,
  17013. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17014. CardInfo: basStr,
  17015. VerifyNumber: "",
  17016. }
  17017. service.CreateHisPsn(psn)
  17018. c.ServeSuccessJSON(map[string]interface{}{
  17019. "patient": patient,
  17020. "number": basNumber,
  17021. })
  17022. }
  17023. } else {
  17024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17025. return
  17026. }
  17027. }
  17028. func (c *HisApiController) TestGetHnBasBaseInit() {
  17029. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17030. Iinit := DllDef.MustFindProc("Init")
  17031. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17032. //http://10.77.211.236/CSB/hsa-fsi-1303
  17033. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  17034. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  17035. // 调用 Init 函数
  17036. 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"))))
  17037. //if ret != 0 {
  17038. fmt.Println("SSCard的报错原因:", err)
  17039. fmt.Println("SSCard的运算结果为:", ret)
  17040. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17041. // return
  17042. //}
  17043. result := int(ret)
  17044. fmt.Println("SSCard的运算结果为1:", result)
  17045. initFlag = 1
  17046. return
  17047. }
  17048. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  17049. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17050. Iinit := DllDef.MustFindProc("Init")
  17051. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17052. //http://10.77.211.236/CSB/hsa-fsi-1303
  17053. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  17054. if ret != 0 {
  17055. fmt.Println("SSCard的报错原因:", err)
  17056. fmt.Println("SSCard的运算结果为:", ret)
  17057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17058. return
  17059. }
  17060. result := int(ret)
  17061. fmt.Println("SSCard的运算结果为1:", result)
  17062. initFlag = 1
  17063. return
  17064. }
  17065. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  17066. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17067. Iinit := DllDef.MustFindProc("Init")
  17068. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17069. //http://10.77.211.236/CSB/hsa-fsi-1303
  17070. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  17071. if ret != 0 {
  17072. fmt.Println("SSCard的报错原因:", err)
  17073. fmt.Println("SSCard的运算结果为:", ret)
  17074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17075. return
  17076. }
  17077. result := int(ret)
  17078. fmt.Println("SSCard的运算结果为1:", result)
  17079. initFlag = 1
  17080. return
  17081. }
  17082. func (c *HisApiController) GetSFZBaseInfo() string {
  17083. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17084. readCard := DllDef.MustFindProc("ReadSFZ")
  17085. if readCard == nil {
  17086. fmt.Println("readcard is nil")
  17087. readCard = DllDef.MustFindProc("ReadSFZ")
  17088. }
  17089. str := make([]byte, 8096)
  17090. str1 := make([]byte, 8096)
  17091. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  17092. fmt.Println(r)
  17093. return Remove0000(string(str))
  17094. }
  17095. func (c *HisApiController) GetEleBaseInfo() string {
  17096. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17097. readCard := DllDef.MustFindProc("GetQRBase")
  17098. fmt.Println(readCard)
  17099. if readCard == nil {
  17100. fmt.Println("readcard is nil")
  17101. readCard = DllDef.MustFindProc("GetQRBase")
  17102. }
  17103. str := make([]byte, 1024)
  17104. str1 := make([]byte, 1024)
  17105. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17106. fmt.Println(ret2)
  17107. fmt.Println(string(str1))
  17108. fmt.Println(string(str))
  17109. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17110. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17111. if ret2 != 0 {
  17112. return ""
  17113. }
  17114. return string(str)
  17115. }
  17116. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17117. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17118. readCard := DllDef.MustFindProc("NationEcTrans")
  17119. fmt.Println(readCard)
  17120. fmt.Println("!!!!!")
  17121. pBusiCardInfo := make([]byte, 2048)
  17122. input := make(map[string]interface{})
  17123. inputData := make(map[string]interface{})
  17124. inputData["orgId"] = code
  17125. inputData["businessType"] = "01101"
  17126. inputData["operatorId"] = "1"
  17127. inputData["operatorName"] = "admin"
  17128. inputData["officeId"] = "001"
  17129. inputData["officeName"] = "血透室"
  17130. inputData["deviceType"] = ""
  17131. input["data"] = inputData
  17132. input["orgId"] = code
  17133. input["transType"] = "ec.query"
  17134. bytesData, _ := json.Marshal(input)
  17135. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17136. fmt.Println(ret2)
  17137. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17138. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17139. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  17140. }
  17141. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17142. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17143. readCard := DllDef.MustFindProc("NationEcTrans")
  17144. fmt.Println(readCard)
  17145. fmt.Println("!!!!!")
  17146. pBusiCardInfo := make([]byte, 2048)
  17147. input := make(map[string]interface{})
  17148. inputData := make(map[string]interface{})
  17149. inputData["orgId"] = code
  17150. inputData["businessType"] = "01101"
  17151. inputData["operatorId"] = "9"
  17152. inputData["operatorName"] = "admin"
  17153. inputData["officeId"] = "001"
  17154. inputData["officeName"] = "血透室"
  17155. inputData["deviceType"] = ""
  17156. input["data"] = inputData
  17157. input["orgId"] = code
  17158. input["transType"] = "ec.query"
  17159. bytesData, _ := json.Marshal(input)
  17160. 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])))
  17161. fmt.Println(ret2)
  17162. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17163. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17164. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17165. }
  17166. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  17167. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17168. readCard := DllDef.MustFindProc("NationEcTrans")
  17169. fmt.Println(readCard)
  17170. fmt.Println("!!!!!")
  17171. pBusiCardInfo := make([]byte, 2048)
  17172. input := make(map[string]interface{})
  17173. inputData := make(map[string]interface{})
  17174. inputData["orgId"] = code
  17175. inputData["businessType"] = "01301"
  17176. inputData["operatorId"] = "9"
  17177. inputData["operatorName"] = "admin"
  17178. inputData["officeId"] = "001"
  17179. inputData["officeName"] = "血透室"
  17180. inputData["deviceType"] = ""
  17181. input["data"] = inputData
  17182. input["orgId"] = code
  17183. input["transType"] = "ec.query"
  17184. bytesData, _ := json.Marshal(input)
  17185. 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])))
  17186. fmt.Println(ret2)
  17187. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17188. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17189. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17190. }
  17191. func GetJxEleBaseInfo(org_id int64) string {
  17192. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17193. readCard := DllDef.MustFindProc("NationEcTrans")
  17194. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17195. if readCard == nil {
  17196. fmt.Println("readcard is nil")
  17197. readCard = DllDef.MustFindProc("NationEcTrans")
  17198. }
  17199. str1 := make([]byte, 1024)
  17200. data := make(map[string]interface{})
  17201. inputData := make(map[string]interface{})
  17202. inputData["orgId"] = miConfig.Code
  17203. inputData["businessType"] = "01101"
  17204. inputData["operatorId"] = "test001"
  17205. inputData["operatorName"] = "cn"
  17206. inputData["officeId"] = "32760"
  17207. inputData["officeName"] = "waike"
  17208. inputData["deviceType"] = ""
  17209. data["data"] = inputData
  17210. data["transType"] = "ec.query"
  17211. data["extra "] = ""
  17212. data["orgId"] = miConfig.Code
  17213. bytesData, _ := json.Marshal(data)
  17214. //bytesData, _ := json.Marshal(data)
  17215. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17216. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17217. fmt.Println(ret2)
  17218. fmt.Println(string(str1))
  17219. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17220. if ret2 != 0 {
  17221. return ""
  17222. }
  17223. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17224. }
  17225. //func GetJxEleBaseInfoTWO(org_id int64) string {
  17226. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  17227. // readCard := DllDef.MustFindProc("NationEcTrans")
  17228. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17229. //
  17230. // if readCard == nil {
  17231. // fmt.Println("readcard is nil")
  17232. // readCard = DllDef.MustFindProc("NationEcTrans")
  17233. // }
  17234. // str1 := make([]byte, 1024)
  17235. //
  17236. // data := make(map[string]interface{})
  17237. //
  17238. // inputData := make(map[string]interface{})
  17239. // inputData["orgId"] = miConfig.Code
  17240. // inputData["businessType"] = "01101"
  17241. // inputData["operatorId"] = "test001"
  17242. // inputData["operatorName"] = "cn"
  17243. // inputData["officeId"] = "32760"
  17244. // inputData["officeName"] = "waike"
  17245. // inputData["deviceType"] = ""
  17246. //
  17247. // data["data"] = inputData
  17248. // data["transType"] = "ec.query"
  17249. // data["extra "] = ""
  17250. // data["orgId"] = miConfig.Code
  17251. // bytesData, _ := json.Marshal(data)
  17252. // //bytesData, _ := json.Marshal(data)
  17253. //
  17254. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17255. //
  17256. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17257. // fmt.Println(ret2)
  17258. // fmt.Println(string(str1))
  17259. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17260. //
  17261. // if ret2 != 0 {
  17262. // return ""
  17263. // }
  17264. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17265. //}
  17266. func GetJxEleBaseInitInfo(org_id int64) string {
  17267. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17268. readCard := DllDef.MustFindProc("NationEcTrans")
  17269. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17270. if readCard == nil {
  17271. fmt.Println("readcard is nil")
  17272. readCard = DllDef.MustFindProc("NationEcTrans")
  17273. }
  17274. str1 := make([]byte, 2048)
  17275. data := make(map[string]interface{})
  17276. inputData := make(map[string]interface{})
  17277. inputData["orgId"] = miConfig.Code
  17278. inputData["businessType"] = "01101"
  17279. inputData["operatorId"] = "1"
  17280. inputData["operatorName"] = "huangchuang"
  17281. inputData["officeId"] = "101"
  17282. inputData["officeName"] = "xuetou"
  17283. inputData["deviceType"] = ""
  17284. data["data"] = inputData
  17285. data["transType"] = "ec.query"
  17286. data["orgId"] = miConfig.Code
  17287. bytesData, _ := json.Marshal(data)
  17288. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17289. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17290. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  17291. fmt.Println(ret2)
  17292. fmt.Println(string(str1))
  17293. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17294. if ret2 != 0 {
  17295. return ""
  17296. }
  17297. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  17298. initEleFlag = 1
  17299. }
  17300. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17301. }
  17302. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  17303. // // 构建命令
  17304. // cmd := exec.Command("python", "b.py")
  17305. //
  17306. // // 执行命令并等待完成
  17307. // output, err := cmd.CombinedOutput()
  17308. // if err != nil {
  17309. // fmt.Println("Error executing Python script:", err)
  17310. // return
  17311. // }
  17312. //
  17313. // // 打印Python脚本的输出
  17314. // fmt.Println(string(output))
  17315. //}
  17316. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  17317. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  17318. readCard := DllDef.MustFindProc("gxyb_call")
  17319. if readCard == nil {
  17320. fmt.Println("readcard is nil")
  17321. readCard = DllDef.MustFindProc("gxyb_call")
  17322. }
  17323. str := make([]byte, 1024)
  17324. str1 := make([]byte, 1024)
  17325. //data := make(map[string]interface{})
  17326. currentTime := time.Now()
  17327. // 格式化时间为 "YYYYMMDDHH24MISS"
  17328. formattedTime := currentTime.Format("20060102150405")
  17329. inputData := make(map[string]interface{})
  17330. inputData2 := make(map[string]interface{})
  17331. inputData["transNo"] = "1401"
  17332. inputData["transType"] = "passwordCheck"
  17333. inputData["timestamp"] = formattedTime
  17334. inputData2["fixmedinsCode"] = code
  17335. inputData2["psnNo"] = ""
  17336. inputData["data"] = inputData2
  17337. jsonBytes, err := json.Marshal(inputData)
  17338. if err != nil {
  17339. fmt.Println("Error encoding map to JSON:", err)
  17340. }
  17341. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17342. fmt.Println(string(str1))
  17343. fmt.Println(string(str))
  17344. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17345. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17346. if ret2 != 0 {
  17347. return ""
  17348. }
  17349. return string(str)
  17350. }
  17351. func (c *HisApiController) GetoleInfo() Response {
  17352. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17353. defer ole.CoUninitialize()
  17354. // Replace with the ProgID or CLSID of your COM object
  17355. progID := "YinHai.XJ.Actual.Interface.New"
  17356. // Create COM object
  17357. unknown, err := oleutil.CreateObject(progID)
  17358. if err != nil {
  17359. fmt.Println("Unable to create COM object:", err)
  17360. }
  17361. defer unknown.Release()
  17362. // Query for the IDispatch interface
  17363. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17364. if err != nil {
  17365. fmt.Println("Unable to get IDispatch interface:", err)
  17366. }
  17367. defer dispatch.Release()
  17368. // Prepare parameters
  17369. transNo := "1401"
  17370. transType := "passwordCheck"
  17371. timestamp := time.Now().Unix()
  17372. fixmedinsCode := "H45072101171"
  17373. psnNo := ""
  17374. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17375. result2 := ""
  17376. // Call COM object's method using the IDispatch interface
  17377. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17378. fmt.Println(resulr)
  17379. fmt.Println(result2)
  17380. if err != nil {
  17381. fmt.Println("调用COM对象方法失败:", err)
  17382. }
  17383. var response Response
  17384. err2 := json.Unmarshal([]byte(result2), &response)
  17385. if err2 != nil {
  17386. fmt.Println("解析JSON失败:", err)
  17387. }
  17388. return response
  17389. }
  17390. func (c *HisApiController) GetBasBaseInfo() string {
  17391. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17392. readCard := DllDef.MustFindProc("ReadCardBas")
  17393. if readCard == nil {
  17394. fmt.Println("readcard is nil")
  17395. readCard = DllDef.MustFindProc("ReadCardBas")
  17396. }
  17397. str := make([]byte, 1024)
  17398. str1 := make([]byte, 1024)
  17399. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17400. fmt.Println(string(str1))
  17401. fmt.Println(string(str))
  17402. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17403. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17404. if ret2 != 0 {
  17405. return ""
  17406. }
  17407. return string(str)
  17408. }
  17409. type Program struct {
  17410. FunctionID string `xml:"function_id"`
  17411. CardInfo string `xml:"cardinfo"`
  17412. User string `xml:"user"`
  17413. }
  17414. func (c *HisApiController) GetBasBaseInfo1111() string {
  17415. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17416. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17417. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17418. if readCard == nil {
  17419. fmt.Println("readcard is nil")
  17420. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17421. }
  17422. if readCard2 == nil {
  17423. fmt.Println("readcard is nil")
  17424. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17425. }
  17426. str := make([]byte, 1024)
  17427. str1 := make([]byte, 1024)
  17428. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17429. str3 := make([]byte, 1024)
  17430. str4 := make([]byte, 1024)
  17431. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17432. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17433. //if err != nil {
  17434. // fmt.Println("Error opening file:", err)
  17435. //}
  17436. //defer file.Close()
  17437. //
  17438. //var lastProgram Program
  17439. //scanner := bufio.NewScanner(file)
  17440. //inProgram := false
  17441. //
  17442. //for scanner.Scan() {
  17443. // line := scanner.Text()
  17444. // if strings.Contains(line, "<program>") {
  17445. // inProgram = true
  17446. // programXML := "<program>"
  17447. // for scanner.Scan() {
  17448. // line = scanner.Text()
  17449. // programXML += line
  17450. // if strings.Contains(line, "</program>") {
  17451. // programXML += "</program>"
  17452. // break
  17453. // }
  17454. // }
  17455. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17456. // // 解析成功,更新最后的 Program
  17457. // }
  17458. // inProgram = false
  17459. // }
  17460. //}
  17461. //
  17462. // fmt.Println("Error reading file:", inProgram)
  17463. //
  17464. //if err := scanner.Err(); err != nil {
  17465. // fmt.Println("Error reading file:", err)
  17466. //}
  17467. // 输出最后一次的 Program
  17468. //fmt.Printf("最后一次的 <program>:\n")
  17469. //fmt.Printf("<program>\n")
  17470. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17471. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17472. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17473. //fmt.Printf("</program>\n")
  17474. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17475. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17476. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17477. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17478. return ConvertToString(string(str), "gbk", "utf-8")
  17479. }
  17480. func (c *HisApiController) GetBasBaseInfo22222() string {
  17481. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17482. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17483. if readCard == nil {
  17484. fmt.Println("readcard is nil")
  17485. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17486. }
  17487. str := make([]byte, 1024)
  17488. str1 := make([]byte, 1024)
  17489. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17490. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17491. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17492. //if err != nil {
  17493. // fmt.Println("Error opening file:", err)
  17494. //}
  17495. //defer file.Close()
  17496. //
  17497. //var lastProgram Program
  17498. //scanner := bufio.NewScanner(file)
  17499. //inProgram := false
  17500. //
  17501. //for scanner.Scan() {
  17502. // line := scanner.Text()
  17503. // if strings.Contains(line, "<program>") {
  17504. // inProgram = true
  17505. // programXML := "<program>"
  17506. // for scanner.Scan() {
  17507. // line = scanner.Text()
  17508. // programXML += line
  17509. // if strings.Contains(line, "</program>") {
  17510. // programXML += "</program>"
  17511. // break
  17512. // }
  17513. // }
  17514. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17515. // // 解析成功,更新最后的 Program
  17516. // }
  17517. // inProgram = false
  17518. // }
  17519. //}
  17520. //
  17521. // fmt.Println("Error reading file:", inProgram)
  17522. //
  17523. //if err := scanner.Err(); err != nil {
  17524. // fmt.Println("Error reading file:", err)
  17525. //}
  17526. // 输出最后一次的 Program
  17527. //fmt.Printf("最后一次的 <program>:\n")
  17528. //fmt.Printf("<program>\n")
  17529. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17530. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17531. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17532. //fmt.Printf("</program>\n")
  17533. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17534. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17535. return ConvertToString(string(str1), "gbk", "utf-8")
  17536. }
  17537. func (c *HisApiController) GetahBasBaseInfo() string {
  17538. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17539. readCard := DllDef.MustFindProc("iReadCardBas")
  17540. if readCard == nil {
  17541. fmt.Println("readcard is nil")
  17542. readCard = DllDef.MustFindProc("iReadCardBas")
  17543. }
  17544. //str := make([]byte, 1024)
  17545. str1 := make([]byte, 1024)
  17546. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17547. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17548. //if err != nil {
  17549. // fmt.Println("Error opening file:", err)
  17550. //}
  17551. //defer file.Close()
  17552. //
  17553. //var lastProgram Program
  17554. //scanner := bufio.NewScanner(file)
  17555. //inProgram := false
  17556. //
  17557. //for scanner.Scan() {
  17558. // line := scanner.Text()
  17559. // if strings.Contains(line, "<program>") {
  17560. // inProgram = true
  17561. // programXML := "<program>"
  17562. // for scanner.Scan() {
  17563. // line = scanner.Text()
  17564. // programXML += line
  17565. // if strings.Contains(line, "</program>") {
  17566. // programXML += "</program>"
  17567. // break
  17568. // }
  17569. // }
  17570. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17571. // // 解析成功,更新最后的 Program
  17572. // }
  17573. // inProgram = false
  17574. // }
  17575. //}
  17576. //
  17577. // fmt.Println("Error reading file:", inProgram)
  17578. //
  17579. //if err := scanner.Err(); err != nil {
  17580. // fmt.Println("Error reading file:", err)
  17581. //}
  17582. // 输出最后一次的 Program
  17583. //fmt.Printf("最后一次的 <program>:\n")
  17584. //fmt.Printf("<program>\n")
  17585. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17586. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17587. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17588. //fmt.Printf("</program>\n")
  17589. fmt.Println(string(str1))
  17590. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17591. if ret2 != 0 {
  17592. return ""
  17593. }
  17594. return string(str1)
  17595. }
  17596. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17597. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17598. readCard := DllDef.MustFindProc("read_cardinfo")
  17599. if readCard == nil {
  17600. fmt.Println("readcard is nil")
  17601. readCard = DllDef.MustFindProc("read_cardinfo")
  17602. }
  17603. str := make([]byte, 1024) //卡号
  17604. str1 := make([]byte, 1024) //卡识别码
  17605. str2 := make([]byte, 1024) //身份证号
  17606. str3 := make([]byte, 1024) //姓名
  17607. str4 := make([]byte, 1024) //错误信息
  17608. 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])))
  17609. fmt.Println(string(str1))
  17610. fmt.Println(string(str))
  17611. fmt.Println(string(str2))
  17612. fmt.Println(string(str3))
  17613. fmt.Println(string(str4))
  17614. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17615. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17616. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17617. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17618. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17619. if ret2 != 0 {
  17620. return "", "", "", "", ""
  17621. }
  17622. return string(str), string(str1), string(str2), string(str3), string(str4)
  17623. }
  17624. type CustomFundPay struct {
  17625. FundPayType string `json:"fund_pay_type"`
  17626. FundPayamt float64 `json:"fund_payamt"`
  17627. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17628. }
  17629. //func (c *HisApiController) GetBatchSettleList() {
  17630. // start_time_str := c.GetString("start_time")
  17631. // //end_time_str := c.GetString("end_time")
  17632. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17633. //
  17634. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17635. //
  17636. // for _, item := range orders {
  17637. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17638. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17639. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17640. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17641. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17642. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17643. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17644. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17645. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17646. //
  17647. // if order.ID == 0 {
  17648. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17649. // return
  17650. // }
  17651. //
  17652. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17653. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17654. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17655. // //fmt.Println(count)
  17656. // //var zero string
  17657. // //number := count + 1
  17658. // //if number >= 1000 {
  17659. // // zero = "0000" + strconv.FormatInt(number, 10)
  17660. // //} else if number >= 10000 {
  17661. // // zero = "000" + strconv.FormatInt(number, 10)
  17662. // //} else if number >= 100000 {
  17663. // // zero = "00" + strconv.FormatInt(number, 10)
  17664. // //} else if number >= 1000000 {
  17665. // // zero = "0" + strconv.FormatInt(number, 10)
  17666. // //} else {
  17667. // // zero = strconv.FormatInt(number, 10)
  17668. // //}
  17669. // //fmt.Println(zero)
  17670. //
  17671. // struct4101 := service.Struct4101{
  17672. // PsnNo: order.PsnNo,
  17673. // MdtrtId: order.MdtrtId,
  17674. // SetlId: order.SetlId,
  17675. // PsnName: order.PsnName,
  17676. // Gend: order.Gend,
  17677. // Brdy: his.Brdy,
  17678. // Age: his.Age,
  17679. // Naty: order.Naty,
  17680. // PatnCertType: "01",
  17681. // Certno: order.Certno,
  17682. // Prfs: "90",
  17683. // ConerName: roles[0].UserName,
  17684. // PatnRlts: "99",
  17685. // ConerAddr: miConfig.OrgName,
  17686. // ConerTel: admin.Mobile,
  17687. // HiType: order.Insutype,
  17688. // Insuplc: miConfig.InsuplcAdmdvs,
  17689. // MaindiagFlag: "1",
  17690. // BillCode: order.SetlId,
  17691. // BillNo: order.SetlId,
  17692. // BizSn: order.Number,
  17693. // PsnSelfPay: order.PsnPartAmt,
  17694. // PsnOwnPay: order.PsnPartAmt,
  17695. // AcctPay: order.AcctPay,
  17696. // PsnCashpay: order.PsnCashPay,
  17697. // HiPaymtd: "1",
  17698. // Hsorg: miConfig.InsuplcAdmdvs,
  17699. // HsorgOpter: miConfig.InsuplcAdmdvs,
  17700. // MedinsFillPsn: curRoles.UserName,
  17701. // MedinsFillDept: miConfig.OrgName,
  17702. // IptMedType: "2",
  17703. // }
  17704. // struct4101.SetlBegnDate = order.SetlTime
  17705. // struct4101.SetlEndDate = order.SetlTime
  17706. // time_arr := strings.Split(order.SetlTime, " ")
  17707. // struct4101.AdmTime = time_arr[0]
  17708. // struct4101.AdmEndTime = time_arr[0]
  17709. //
  17710. // var rf []CustomFundPay
  17711. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  17712. //
  17713. // var tempFunPays []service.CustomStruct
  17714. // for _, item := range rf {
  17715. // var tempFunPay service.CustomStruct
  17716. // tempFunPay.FundPayamt = item.FundPayamt
  17717. // tempFunPay.FundPayType = item.FundPayType
  17718. // tempFunPays = append(tempFunPays, tempFunPay)
  17719. // }
  17720. // struct4101.CustomStruct = tempFunPays
  17721. //
  17722. // var tempDiaginfos []service.DiaginfoStructTwo
  17723. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17724. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17725. //
  17726. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17727. // var config []*models.HisXtDiagnoseConfig
  17728. // for _, item := range diagnosis_ids {
  17729. // id, _ := strconv.ParseInt(item, 10, 64)
  17730. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  17731. // config = append(config, &diagnosisConfig)
  17732. // }
  17733. //
  17734. // for index, item := range config {
  17735. // if index == 0 {
  17736. // var tempDiaginfo service.DiaginfoStructTwo
  17737. // tempDiaginfo.DiagCode = item.CountryCode
  17738. // tempDiaginfo.DiagName = item.CountryContentName
  17739. // tempDiaginfo.DiagType = "1"
  17740. // tempDiaginfo.MaindiagFlag = "1"
  17741. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17742. // } else {
  17743. // var tempDiaginfo service.DiaginfoStructTwo
  17744. // tempDiaginfo.DiagCode = item.CountryCode
  17745. // tempDiaginfo.DiagName = item.CountryContentName
  17746. // tempDiaginfo.DiagType = "1"
  17747. // tempDiaginfo.MaindiagFlag = "0"
  17748. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17749. // }
  17750. // }
  17751. // struct4101.Diseinfo = tempDiaginfos
  17752. //
  17753. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  17754. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17755. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17756. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17757. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17758. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17759. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17760. //
  17761. // var iteminfo service.IteminfoStruct
  17762. //
  17763. // var bedCostTotal float64 = 0 //床位总费
  17764. // var bedCostSelfTotal float64 = 0 //床位自费
  17765. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17766. //
  17767. // var operationCostTotal float64 = 0 //手术费
  17768. // var operationCostSelfTotal float64 = 0 //手术费
  17769. // var operationCostPartSelfTotal float64 = 0 //手术费
  17770. //
  17771. // var otherCostTotal float64 = 0 //其他费用
  17772. // var otherCostSelfTotal float64 = 0 //其他费用
  17773. // var otherCostPartSelfTotal float64 = 0 //其他费用
  17774. //
  17775. // var materialCostTotal float64 = 0 //材料费
  17776. // var materialCostSelfTotal float64 = 0 //材料费
  17777. // var materialCostPartSelfTotal float64 = 0 //材料费
  17778. //
  17779. // var westernMedicineCostTotal float64 = 0 //西药费
  17780. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  17781. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17782. //
  17783. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17784. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17785. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17786. //
  17787. // var checkCostTotal float64 = 0 //检查费
  17788. // var checkCostSelfTotal float64 = 0 //检查费
  17789. // var checkCostPartSelfTotal float64 = 0 //检查费
  17790. //
  17791. // var laboratoryCostTotal float64 = 0 //化验费
  17792. // var laboratoryCostSelfTotal float64 = 0 //化验费
  17793. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17794. //
  17795. // var treatCostTotal float64 = 0 //治疗费用
  17796. // var treatCostSelfTotal float64 = 0 //治疗费用
  17797. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  17798. //
  17799. // decimal.DivisionPrecision = 2
  17800. //
  17801. // var bed_fulamt_ownpay_amt float64 = 0
  17802. // var operation_fulamt_ownpay_amt float64 = 0
  17803. // var other_fulamt_ownpay_amt float64 = 0
  17804. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  17805. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17806. // var check_fulamt_ownpay_amt float64 = 0
  17807. // var material_fulamt_ownpay_amt float64 = 0
  17808. // var laboratory_fulamt_ownpay_amt float64 = 0
  17809. // var treat_fulamt_ownpay_amt float64 = 0
  17810. //
  17811. // var bed_claa_sunmfee float64 = 0
  17812. // var bed_clab_amt float64 = 0
  17813. // var bed_other_amt float64 = 0
  17814. //
  17815. // var operation_claa_sunmfee float64 = 0
  17816. // var operation_clab_amt float64 = 0
  17817. // var operation_other_amt float64 = 0
  17818. //
  17819. // var other_claa_sunmfee float64 = 0
  17820. // var other_clab_amt float64 = 0
  17821. // var other_other_amt float64 = 0
  17822. //
  17823. // var westernMedicine_claa_sunmfee float64 = 0
  17824. // var westernMedicine_clab_amt float64 = 0
  17825. // var westernMedicine_other_amt float64 = 0
  17826. //
  17827. // var chineseTraditional_claa_sunmfee float64 = 0
  17828. // var chineseTraditional_clab_amt float64 = 0
  17829. // var chineseTraditional_other_amt float64 = 0
  17830. //
  17831. // var check_claa_sunmfee float64 = 0
  17832. // var check_clab_amt float64 = 0
  17833. // var check_other_amt float64 = 0
  17834. //
  17835. // var material_claa_sunmfee float64 = 0
  17836. // var material_clab_amt float64 = 0
  17837. // var material_other_amt float64 = 0
  17838. //
  17839. // var laboratory_claa_sunmfee float64 = 0
  17840. // var laboratory_clab_amt float64 = 0
  17841. // var laboratory_other_amt float64 = 0
  17842. //
  17843. // var treat_claa_sunmfee float64 = 0
  17844. // var treat_clab_amt float64 = 0
  17845. // var treat_other_amt float64 = 0
  17846. //
  17847. // for _, item := range order.HisOrderInfo {
  17848. // if item.MedChrgitmType == "01" { //床位费
  17849. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17850. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17851. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17852. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17853. // if item.ChrgitmLv == "1" {
  17854. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17855. // }
  17856. // if item.ChrgitmLv == "2" {
  17857. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17858. //
  17859. // }
  17860. // if item.ChrgitmLv == "3" {
  17861. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17862. // }
  17863. //
  17864. // }
  17865. //
  17866. // if item.MedChrgitmType == "03" { //检查费
  17867. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17868. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17869. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17870. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17871. // if item.ChrgitmLv == "1" {
  17872. //
  17873. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17874. //
  17875. // }
  17876. // if item.ChrgitmLv == "2" {
  17877. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17878. //
  17879. // }
  17880. // if item.ChrgitmLv == "3" {
  17881. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17882. // }
  17883. // }
  17884. //
  17885. // if item.MedChrgitmType == "04" { //化验费
  17886. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17887. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17888. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17889. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17890. // if item.ChrgitmLv == "1" {
  17891. //
  17892. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17893. //
  17894. // }
  17895. // if item.ChrgitmLv == "2" {
  17896. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17897. //
  17898. // }
  17899. // if item.ChrgitmLv == "3" {
  17900. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17901. // }
  17902. // }
  17903. //
  17904. // if item.MedChrgitmType == "05" { //治疗费
  17905. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17906. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17907. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17908. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17909. // if item.ChrgitmLv == "1" {
  17910. //
  17911. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17912. //
  17913. // }
  17914. // if item.ChrgitmLv == "2" {
  17915. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17916. //
  17917. // }
  17918. // if item.ChrgitmLv == "3" {
  17919. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17920. // }
  17921. // }
  17922. //
  17923. // if item.MedChrgitmType == "06" { //手术费
  17924. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17925. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17926. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17927. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17928. //
  17929. // if item.ChrgitmLv == "1" {
  17930. //
  17931. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17932. //
  17933. // }
  17934. // if item.ChrgitmLv == "2" {
  17935. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17936. //
  17937. // }
  17938. // if item.ChrgitmLv == "3" {
  17939. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17940. // }
  17941. // }
  17942. //
  17943. // if item.MedChrgitmType == "08" { //材料费
  17944. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17945. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17946. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17947. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17948. // if item.ChrgitmLv == "1" {
  17949. //
  17950. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17951. //
  17952. // }
  17953. // if item.ChrgitmLv == "2" {
  17954. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17955. //
  17956. // }
  17957. // if item.ChrgitmLv == "3" {
  17958. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17959. // }
  17960. // }
  17961. //
  17962. // if item.MedChrgitmType == "09" { //西药费
  17963. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17964. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17965. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17966. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17967. // if item.ChrgitmLv == "1" {
  17968. //
  17969. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17970. //
  17971. // }
  17972. // if item.ChrgitmLv == "2" {
  17973. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17974. //
  17975. // }
  17976. // if item.ChrgitmLv == "3" {
  17977. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17978. // }
  17979. // }
  17980. //
  17981. // if item.MedChrgitmType == "11" { //中成费
  17982. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17983. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17984. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17985. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17986. // if item.ChrgitmLv == "1" {
  17987. //
  17988. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17989. //
  17990. // }
  17991. // if item.ChrgitmLv == "2" {
  17992. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17993. //
  17994. // }
  17995. // if item.ChrgitmLv == "3" {
  17996. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17997. // }
  17998. // }
  17999. //
  18000. // if item.MedChrgitmType == "14" { //其他费
  18001. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18002. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18003. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18004. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18005. // if item.ChrgitmLv == "1" {
  18006. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18007. //
  18008. // }
  18009. // if item.ChrgitmLv == "2" {
  18010. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18011. //
  18012. // }
  18013. // if item.ChrgitmLv == "3" {
  18014. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18015. // }
  18016. // }
  18017. //
  18018. // }
  18019. //
  18020. // var iteminfoStructs []service.IteminfoStruct
  18021. //
  18022. // if bedCostTotal != 0 {
  18023. // iteminfo.MedChrgitm = "01"
  18024. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18025. // iteminfo.Amt = bedCostTotal
  18026. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  18027. // iteminfo.ClabAmt = bed_clab_amt
  18028. // iteminfo.OthAmt = bed_other_amt
  18029. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18030. // }
  18031. //
  18032. // if checkCostTotal != 0 {
  18033. // iteminfo.MedChrgitm = "03"
  18034. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18035. // iteminfo.Amt = checkCostTotal
  18036. // iteminfo.ClaaSumfee = check_claa_sunmfee
  18037. // iteminfo.ClabAmt = check_clab_amt
  18038. // iteminfo.OthAmt = check_other_amt
  18039. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18040. //
  18041. // }
  18042. //
  18043. // if laboratoryCostTotal != 0 {
  18044. // iteminfo.MedChrgitm = "04"
  18045. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18046. // iteminfo.Amt = laboratoryCostTotal
  18047. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18048. // iteminfo.ClabAmt = laboratory_clab_amt
  18049. // iteminfo.OthAmt = laboratory_other_amt
  18050. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18051. //
  18052. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18053. //
  18054. // }
  18055. //
  18056. // if treatCostTotal != 0 {
  18057. // iteminfo.MedChrgitm = "05"
  18058. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18059. // iteminfo.Amt = treatCostTotal
  18060. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  18061. // iteminfo.ClabAmt = treat_clab_amt
  18062. // iteminfo.OthAmt = treat_other_amt
  18063. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18064. // //(struct4101.IteminfoStruct, iteminfo)
  18065. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18066. // }
  18067. //
  18068. // if operationCostTotal != 0 {
  18069. // iteminfo.MedChrgitm = "06"
  18070. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18071. // iteminfo.Amt = operationCostTotal
  18072. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  18073. // iteminfo.ClabAmt = operation_clab_amt
  18074. // iteminfo.OthAmt = operation_other_amt
  18075. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18076. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18077. // }
  18078. //
  18079. // if materialCostTotal != 0 {
  18080. // iteminfo.MedChrgitm = "08"
  18081. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18082. // iteminfo.Amt = materialCostTotal
  18083. // iteminfo.ClaaSumfee = material_claa_sunmfee
  18084. // iteminfo.ClabAmt = material_clab_amt
  18085. // iteminfo.OthAmt = material_other_amt
  18086. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18087. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18088. // }
  18089. //
  18090. // if westernMedicineCostTotal != 0 {
  18091. // iteminfo.MedChrgitm = "09"
  18092. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18093. // iteminfo.Amt = westernMedicineCostTotal
  18094. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18095. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18096. // iteminfo.OthAmt = westernMedicine_other_amt
  18097. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18098. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18099. //
  18100. // }
  18101. // if chineseTraditionalMedicineCostTotal != 0 {
  18102. // iteminfo.MedChrgitm = "11"
  18103. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18104. // iteminfo.Amt = westernMedicineCostTotal
  18105. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18106. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18107. // iteminfo.OthAmt = westernMedicine_other_amt
  18108. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18109. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18110. //
  18111. // }
  18112. // if otherCostTotal != 0 {
  18113. // iteminfo.MedChrgitm = "14"
  18114. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18115. // iteminfo.Amt = otherCostTotal
  18116. // iteminfo.ClaaSumfee = other_claa_sunmfee
  18117. // iteminfo.ClabAmt = other_clab_amt
  18118. // iteminfo.OthAmt = other_other_amt
  18119. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18120. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18121. //
  18122. // }
  18123. // struct4101.IteminfoStruct = iteminfoStructs
  18124. // struct4101.Ntly = "中国"
  18125. // struct4101.AdmCaty = "A03.06"
  18126. //
  18127. // struct4101.DoctorName = doctor.UserName
  18128. // struct4101.DoctorCode = doctor.DoctorNumber
  18129. //
  18130. // var res ResultSeventeen
  18131. //
  18132. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18133. // struct4101.BillCode = order.Number
  18134. // struct4101.BillNo = order.SetlId
  18135. // var resOther ResultSeventeenOther
  18136. // var pp models.PublicParams
  18137. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18138. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18139. // pp.FixmedinsName = miConfig.OrgName
  18140. // pp.FixmedinsCode = miConfig.Code
  18141. // pp.RequestUrl = miConfig.Url
  18142. // pp.Cainfo = miConfig.Cainfo
  18143. // pp.SecretKey = miConfig.SecretKey
  18144. // pp.AccessKey = miConfig.AccessKey
  18145. // pp.OpterName = curRoles.UserName
  18146. //
  18147. // client := &http.Client{}
  18148. // var req *http.Request
  18149. // data := make(map[string]interface{})
  18150. // data["struct4101"] = struct4101
  18151. // data["pp"] = pp
  18152. // bytesData, _ := json.Marshal(data)
  18153. // if miConfig.MdtrtareaAdmvs == "320921" {
  18154. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18155. // } else {
  18156. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18157. // }
  18158. // resp, _ := client.Do(req)
  18159. // defer resp.Body.Close()
  18160. // body, ioErr := ioutil.ReadAll(resp.Body)
  18161. // if ioErr != nil {
  18162. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18163. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18164. // return
  18165. // }
  18166. // var respJSON map[string]interface{}
  18167. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18168. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18169. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18170. // return
  18171. // }
  18172. //
  18173. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18174. // userJSONBytes, _ := json.Marshal(respJSON)
  18175. // fmt.Println("log")
  18176. // fmt.Println(string(userJSONBytes))
  18177. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18178. // utils.ErrorLog("解析失败:%v", err)
  18179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18180. // return
  18181. // }
  18182. // res.InfRefmsgid = resOther.InfRefmsgid
  18183. // res.Output = resOther.Output
  18184. // res.ErrMsg = resOther.ErrMsg
  18185. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18186. // res.Infcode = infocode
  18187. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  18188. //
  18189. // var pp models.PublicParams
  18190. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18191. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18192. // pp.FixmedinsName = miConfig.OrgName
  18193. // pp.FixmedinsCode = miConfig.Code
  18194. // pp.RequestUrl = miConfig.Url
  18195. // pp.Cainfo = miConfig.Cainfo
  18196. // pp.SecretKey = miConfig.SecretKey
  18197. // pp.AccessKey = miConfig.AccessKey
  18198. // pp.OpterName = curRoles.UserName
  18199. // result, _ := service.Jxyb4101(struct4101, pp)
  18200. // var dat map[string]interface{}
  18201. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18202. // fmt.Println(dat)
  18203. // } else {
  18204. // fmt.Println(err)
  18205. // }
  18206. // userJSONBytes, _ := json.Marshal(dat)
  18207. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18208. // utils.ErrorLog("解析失败:%v", err)
  18209. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18210. // return
  18211. // }
  18212. //
  18213. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  18214. // var pp models.PublicParams
  18215. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18216. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18217. // pp.FixmedinsName = miConfig.OrgName
  18218. // pp.FixmedinsCode = miConfig.Code
  18219. // pp.RequestUrl = miConfig.Url
  18220. // pp.Cainfo = miConfig.Cainfo
  18221. // pp.SecretKey = miConfig.SecretKey
  18222. // pp.AccessKey = miConfig.AccessKey
  18223. // pp.OpterName = curRoles.UserName
  18224. // result, _ := service.Hnyb4101(struct4101, pp)
  18225. // var dat map[string]interface{}
  18226. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18227. // fmt.Println(dat)
  18228. // } else {
  18229. // fmt.Println(err)
  18230. // }
  18231. // userJSONBytes, _ := json.Marshal(dat)
  18232. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18233. // utils.ErrorLog("解析失败:%v", err)
  18234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18235. // return
  18236. // }
  18237. //
  18238. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  18239. // var resOther ResultSeventeenOther
  18240. //
  18241. // var pp models.PublicParams
  18242. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18243. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18244. // pp.FixmedinsName = miConfig.OrgName
  18245. // pp.FixmedinsCode = miConfig.Code
  18246. // pp.RequestUrl = miConfig.Url
  18247. // pp.Cainfo = miConfig.Cainfo
  18248. // pp.SecretKey = miConfig.SecretKey
  18249. // pp.AccessKey = miConfig.AccessKey
  18250. // pp.OpterName = curRoles.UserName
  18251. // client := &http.Client{}
  18252. // var req *http.Request
  18253. // data := make(map[string]interface{})
  18254. // data["struct4101"] = struct4101
  18255. // data["pp"] = pp
  18256. // bytesData, _ := json.Marshal(data)
  18257. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18258. // resp, _ := client.Do(req)
  18259. // defer resp.Body.Close()
  18260. // body, ioErr := ioutil.ReadAll(resp.Body)
  18261. // if ioErr != nil {
  18262. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18263. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18264. // return
  18265. // }
  18266. // var respJSON map[string]interface{}
  18267. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18268. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18269. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18270. // return
  18271. // }
  18272. //
  18273. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18274. // userJSONBytes, _ := json.Marshal(respJSON)
  18275. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18276. // utils.ErrorLog("解析失败:%v", err)
  18277. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18278. // return
  18279. // }
  18280. // res.InfRefmsgid = resOther.InfRefmsgid
  18281. // res.Output = resOther.Output
  18282. // res.ErrMsg = resOther.ErrMsg
  18283. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18284. // res.Infcode = infocode
  18285. //
  18286. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  18287. // var pp models.PublicParams
  18288. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18289. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18290. // pp.FixmedinsName = miConfig.OrgName
  18291. // pp.FixmedinsCode = miConfig.Code
  18292. // pp.RequestUrl = miConfig.Url
  18293. // pp.Cainfo = miConfig.Cainfo
  18294. // pp.SecretKey = miConfig.SecretKey
  18295. // pp.AccessKey = miConfig.AccessKey
  18296. // pp.OpterName = curRoles.UserName
  18297. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18298. // fmt.Println(requestLog)
  18299. // fmt.Println(errMsgLog)
  18300. //
  18301. // saveLog(result, requestLog, "4101a", "上传清单")
  18302. //
  18303. // var dat map[string]interface{}
  18304. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18305. // fmt.Println(dat)
  18306. // } else {
  18307. // fmt.Println(err)
  18308. // }
  18309. // userJSONBytes, _ := json.Marshal(dat)
  18310. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18311. // utils.ErrorLog("解析失败:%v", err)
  18312. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18313. // return
  18314. // }
  18315. //
  18316. // } else {
  18317. //
  18318. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  18319. // var dat map[string]interface{}
  18320. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18321. // fmt.Println(dat)
  18322. // } else {
  18323. // fmt.Println(err)
  18324. // }
  18325. // userJSONBytes, _ := json.Marshal(dat)
  18326. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18327. // utils.ErrorLog("解析失败:%v", err)
  18328. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18329. // return
  18330. // }
  18331. // }
  18332. //
  18333. // if res.Infcode != 0 {
  18334. // adminUser := c.GetAdminUserInfo()
  18335. // errlog := &models.HisOrderError{
  18336. // UserOrgId: adminUser.CurrentOrgId,
  18337. // Ctime: time.Now().Unix(),
  18338. // Mtime: time.Now().Unix(),
  18339. // ErrMsg: res.ErrMsg,
  18340. // Status: 1,
  18341. // PatientId: order.ID,
  18342. // Stage: 10265,
  18343. // }
  18344. // service.CreateErrMsgLog(errlog)
  18345. // continue
  18346. // } else {
  18347. // //order.FaPiaoNumber = zero
  18348. // //order.FaPiaoCode = last_order.FaPiaoCode
  18349. // //service.UpdateOrder(order)
  18350. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18351. // Number: res.Output.SetlListId,
  18352. // Status: 1,
  18353. // Ctime: time.Now().Unix(),
  18354. // Mtime: time.Now().Unix(),
  18355. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18356. // IsUpload: 1,
  18357. // OrderId: order.ID,
  18358. // }
  18359. // service.CreateUploadRecord(hisFundSettleListResult)
  18360. // c.ServeSuccessJSON(map[string]interface{}{
  18361. // "msg": "上传成功",
  18362. // "result": hisFundSettleListResult,
  18363. // })
  18364. // continue
  18365. // }
  18366. // }
  18367. //}
  18368. func (c *HisApiController) GetbatchSettleList() {
  18369. //order_id, _ := c.GetInt64("order_id")
  18370. admin_user_id, _ := c.GetInt64("admin_user_id")
  18371. orders, _ := service.GetAllHisOrderTwo10485()
  18372. for _, item := range orders {
  18373. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18374. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18375. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18376. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18377. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18378. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18379. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18380. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18381. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18382. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18383. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18384. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18385. //fmt.Println(count)
  18386. //var zero string
  18387. //number := count + 1
  18388. //if number >= 1000 {
  18389. // zero = "0000" + strconv.FormatInt(number, 10)
  18390. //} else if number >= 10000 {
  18391. // zero = "000" + strconv.FormatInt(number, 10)
  18392. //} else if number >= 100000 {
  18393. // zero = "00" + strconv.FormatInt(number, 10)
  18394. //} else if number >= 1000000 {
  18395. // zero = "0" + strconv.FormatInt(number, 10)
  18396. //} else {
  18397. // zero = strconv.FormatInt(number, 10)
  18398. //}
  18399. //fmt.Println(zero)
  18400. struct4101 := service.Struct4101{
  18401. PsnNo: order.PsnNo,
  18402. MdtrtId: order.MdtrtId,
  18403. SetlId: order.SetlId,
  18404. PsnName: order.PsnName,
  18405. Gend: order.Gend,
  18406. Brdy: his.Brdy,
  18407. Age: his.Age,
  18408. Naty: order.Naty,
  18409. PatnCertType: "01",
  18410. Certno: order.Certno,
  18411. Prfs: "90",
  18412. ConerName: roles[0].UserName,
  18413. PatnRlts: "99",
  18414. ConerAddr: miConfig.OrgName,
  18415. ConerTel: admin.Mobile,
  18416. HiType: order.Insutype,
  18417. Insuplc: miConfig.InsuplcAdmdvs,
  18418. MaindiagFlag: "1",
  18419. BillCode: order.SetlId,
  18420. BillNo: order.SetlId,
  18421. BizSn: order.Number,
  18422. PsnSelfPay: order.PsnPartAmt,
  18423. PsnOwnPay: order.PsnPartAmt,
  18424. AcctPay: order.AcctPay,
  18425. PsnCashpay: order.PsnCashPay,
  18426. HiPaymtd: "1",
  18427. Hsorg: miConfig.InsuplcAdmdvs,
  18428. HsorgOpter: miConfig.InsuplcAdmdvs,
  18429. MedinsFillPsn: curRoles.UserName,
  18430. MedinsFillDept: miConfig.OrgName,
  18431. IptMedType: "2",
  18432. }
  18433. struct4101.SetlBegnDate = order.SetlTime
  18434. struct4101.SetlEndDate = order.SetlTime
  18435. time_arr := strings.Split(order.SetlTime, " ")
  18436. struct4101.AdmTime = time_arr[0]
  18437. struct4101.AdmEndTime = time_arr[0]
  18438. //var rf []CustomFundPay
  18439. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18440. //
  18441. //var tempFunPays []service.CustomStruct
  18442. //for _, item := range rf {
  18443. // var tempFunPay service.CustomStruct
  18444. // tempFunPay.FundPayamt = item.FundPayamt
  18445. // tempFunPay.FundPayType = item.FundPayType
  18446. // tempFunPays = append(tempFunPays, tempFunPay)
  18447. //}
  18448. //struct4101.CustomStruct = tempFunPays
  18449. var tempDiaginfos []service.DiaginfoStructTwo
  18450. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18451. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18452. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18453. var config []*models.HisXtDiagnoseConfig
  18454. for _, item := range diagnosis_ids {
  18455. id, _ := strconv.ParseInt(item, 10, 64)
  18456. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18457. config = append(config, &diagnosisConfig)
  18458. }
  18459. for index, item := range config {
  18460. if index == 0 {
  18461. var tempDiaginfo service.DiaginfoStructTwo
  18462. tempDiaginfo.DiagCode = item.CountryCode
  18463. tempDiaginfo.DiagName = item.CountryContentName
  18464. tempDiaginfo.DiagType = "1"
  18465. tempDiaginfo.MaindiagFlag = "1"
  18466. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18467. } else {
  18468. var tempDiaginfo service.DiaginfoStructTwo
  18469. tempDiaginfo.DiagCode = item.CountryCode
  18470. tempDiaginfo.DiagName = item.CountryContentName
  18471. tempDiaginfo.DiagType = "1"
  18472. tempDiaginfo.MaindiagFlag = "0"
  18473. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18474. }
  18475. }
  18476. struct4101.Diseinfo = tempDiaginfos
  18477. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18478. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18479. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18480. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18481. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18482. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18483. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18484. var iteminfo service.IteminfoStruct
  18485. var bedCostTotal float64 = 0 //床位总费
  18486. var bedCostSelfTotal float64 = 0 //床位自费
  18487. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18488. var operationCostTotal float64 = 0 //手术费
  18489. var operationCostSelfTotal float64 = 0 //手术费
  18490. var operationCostPartSelfTotal float64 = 0 //手术费
  18491. var otherCostTotal float64 = 0 //其他费用
  18492. var otherCostSelfTotal float64 = 0 //其他费用
  18493. var otherCostPartSelfTotal float64 = 0 //其他费用
  18494. var materialCostTotal float64 = 0 //材料费
  18495. var materialCostSelfTotal float64 = 0 //材料费
  18496. var materialCostPartSelfTotal float64 = 0 //材料费
  18497. var westernMedicineCostTotal float64 = 0 //西药费
  18498. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18499. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18500. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18501. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18502. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18503. var checkCostTotal float64 = 0 //检查费
  18504. var checkCostSelfTotal float64 = 0 //检查费
  18505. var checkCostPartSelfTotal float64 = 0 //检查费
  18506. var laboratoryCostTotal float64 = 0 //化验费
  18507. var laboratoryCostSelfTotal float64 = 0 //化验费
  18508. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18509. var treatCostTotal float64 = 0 //治疗费用
  18510. var treatCostSelfTotal float64 = 0 //治疗费用
  18511. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18512. decimal.DivisionPrecision = 2
  18513. var bed_fulamt_ownpay_amt float64 = 0
  18514. var operation_fulamt_ownpay_amt float64 = 0
  18515. var other_fulamt_ownpay_amt float64 = 0
  18516. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18517. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18518. var check_fulamt_ownpay_amt float64 = 0
  18519. var material_fulamt_ownpay_amt float64 = 0
  18520. var laboratory_fulamt_ownpay_amt float64 = 0
  18521. var treat_fulamt_ownpay_amt float64 = 0
  18522. var bed_claa_sunmfee float64 = 0
  18523. var bed_clab_amt float64 = 0
  18524. var bed_other_amt float64 = 0
  18525. var operation_claa_sunmfee float64 = 0
  18526. var operation_clab_amt float64 = 0
  18527. var operation_other_amt float64 = 0
  18528. var other_claa_sunmfee float64 = 0
  18529. var other_clab_amt float64 = 0
  18530. var other_other_amt float64 = 0
  18531. var westernMedicine_claa_sunmfee float64 = 0
  18532. var westernMedicine_clab_amt float64 = 0
  18533. var westernMedicine_other_amt float64 = 0
  18534. var chineseTraditional_claa_sunmfee float64 = 0
  18535. var chineseTraditional_clab_amt float64 = 0
  18536. var chineseTraditional_other_amt float64 = 0
  18537. var check_claa_sunmfee float64 = 0
  18538. var check_clab_amt float64 = 0
  18539. var check_other_amt float64 = 0
  18540. var material_claa_sunmfee float64 = 0
  18541. var material_clab_amt float64 = 0
  18542. var material_other_amt float64 = 0
  18543. var laboratory_claa_sunmfee float64 = 0
  18544. var laboratory_clab_amt float64 = 0
  18545. var laboratory_other_amt float64 = 0
  18546. var treat_claa_sunmfee float64 = 0
  18547. var treat_clab_amt float64 = 0
  18548. var treat_other_amt float64 = 0
  18549. for _, item := range order.HisOrderInfo {
  18550. if item.MedChrgitmType == "01" { //床位费
  18551. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18552. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18553. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18554. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18555. if item.ChrgitmLv == "1" {
  18556. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18557. }
  18558. if item.ChrgitmLv == "2" {
  18559. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18560. }
  18561. if item.ChrgitmLv == "3" {
  18562. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18563. }
  18564. }
  18565. if item.MedChrgitmType == "03" { //检查费
  18566. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18567. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18568. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18569. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18570. if item.ChrgitmLv == "1" {
  18571. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18572. }
  18573. if item.ChrgitmLv == "2" {
  18574. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18575. }
  18576. if item.ChrgitmLv == "3" {
  18577. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18578. }
  18579. }
  18580. if item.MedChrgitmType == "04" { //化验费
  18581. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18582. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18583. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18584. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18585. if item.ChrgitmLv == "1" {
  18586. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18587. }
  18588. if item.ChrgitmLv == "2" {
  18589. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18590. }
  18591. if item.ChrgitmLv == "3" {
  18592. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18593. }
  18594. }
  18595. if item.MedChrgitmType == "05" { //治疗费
  18596. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18597. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18598. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18599. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18600. if item.ChrgitmLv == "1" {
  18601. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18602. }
  18603. if item.ChrgitmLv == "2" {
  18604. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18605. }
  18606. if item.ChrgitmLv == "3" {
  18607. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18608. }
  18609. }
  18610. if item.MedChrgitmType == "06" { //手术费
  18611. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18612. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18613. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18614. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18615. if item.ChrgitmLv == "1" {
  18616. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18617. }
  18618. if item.ChrgitmLv == "2" {
  18619. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18620. }
  18621. if item.ChrgitmLv == "3" {
  18622. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18623. }
  18624. }
  18625. if item.MedChrgitmType == "08" { //材料费
  18626. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18627. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18628. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18629. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18630. if item.ChrgitmLv == "1" {
  18631. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18632. }
  18633. if item.ChrgitmLv == "2" {
  18634. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18635. }
  18636. if item.ChrgitmLv == "3" {
  18637. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18638. }
  18639. }
  18640. if item.MedChrgitmType == "09" { //西药费
  18641. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18642. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18643. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18644. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18645. if item.ChrgitmLv == "1" {
  18646. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18647. }
  18648. if item.ChrgitmLv == "2" {
  18649. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18650. }
  18651. if item.ChrgitmLv == "3" {
  18652. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18653. }
  18654. }
  18655. if item.MedChrgitmType == "11" { //中成费
  18656. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18657. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18658. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18659. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18660. if item.ChrgitmLv == "1" {
  18661. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18662. }
  18663. if item.ChrgitmLv == "2" {
  18664. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18665. }
  18666. if item.ChrgitmLv == "3" {
  18667. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18668. }
  18669. }
  18670. if item.MedChrgitmType == "14" { //其他费
  18671. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18672. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18673. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18674. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18675. if item.ChrgitmLv == "1" {
  18676. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18677. }
  18678. if item.ChrgitmLv == "2" {
  18679. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18680. }
  18681. if item.ChrgitmLv == "3" {
  18682. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18683. }
  18684. }
  18685. }
  18686. var iteminfoStructs []service.IteminfoStruct
  18687. if bedCostTotal != 0 {
  18688. iteminfo.MedChrgitm = "01"
  18689. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18690. iteminfo.Amt = bedCostTotal
  18691. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18692. iteminfo.ClabAmt = bed_clab_amt
  18693. iteminfo.OthAmt = bed_other_amt
  18694. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18695. }
  18696. if checkCostTotal != 0 {
  18697. iteminfo.MedChrgitm = "03"
  18698. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18699. iteminfo.Amt = checkCostTotal
  18700. iteminfo.ClaaSumfee = check_claa_sunmfee
  18701. iteminfo.ClabAmt = check_clab_amt
  18702. iteminfo.OthAmt = check_other_amt
  18703. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18704. }
  18705. if laboratoryCostTotal != 0 {
  18706. iteminfo.MedChrgitm = "04"
  18707. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18708. iteminfo.Amt = laboratoryCostTotal
  18709. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18710. iteminfo.ClabAmt = laboratory_clab_amt
  18711. iteminfo.OthAmt = laboratory_other_amt
  18712. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18713. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18714. }
  18715. if treatCostTotal != 0 {
  18716. iteminfo.MedChrgitm = "05"
  18717. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18718. iteminfo.Amt = treatCostTotal
  18719. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18720. iteminfo.ClabAmt = treat_clab_amt
  18721. iteminfo.OthAmt = treat_other_amt
  18722. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18723. //(struct4101.IteminfoStruct, iteminfo)
  18724. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18725. }
  18726. if operationCostTotal != 0 {
  18727. iteminfo.MedChrgitm = "06"
  18728. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18729. iteminfo.Amt = operationCostTotal
  18730. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18731. iteminfo.ClabAmt = operation_clab_amt
  18732. iteminfo.OthAmt = operation_other_amt
  18733. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18734. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18735. }
  18736. if materialCostTotal != 0 {
  18737. iteminfo.MedChrgitm = "08"
  18738. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18739. iteminfo.Amt = materialCostTotal
  18740. iteminfo.ClaaSumfee = material_claa_sunmfee
  18741. iteminfo.ClabAmt = material_clab_amt
  18742. iteminfo.OthAmt = material_other_amt
  18743. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18744. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18745. }
  18746. if westernMedicineCostTotal != 0 {
  18747. iteminfo.MedChrgitm = "09"
  18748. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18749. iteminfo.Amt = westernMedicineCostTotal
  18750. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18751. iteminfo.ClabAmt = westernMedicine_clab_amt
  18752. iteminfo.OthAmt = westernMedicine_other_amt
  18753. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18754. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18755. }
  18756. if chineseTraditionalMedicineCostTotal != 0 {
  18757. iteminfo.MedChrgitm = "11"
  18758. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18759. iteminfo.Amt = westernMedicineCostTotal
  18760. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18761. iteminfo.ClabAmt = westernMedicine_clab_amt
  18762. iteminfo.OthAmt = westernMedicine_other_amt
  18763. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18764. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18765. }
  18766. if otherCostTotal != 0 {
  18767. iteminfo.MedChrgitm = "14"
  18768. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18769. iteminfo.Amt = otherCostTotal
  18770. iteminfo.ClaaSumfee = other_claa_sunmfee
  18771. iteminfo.ClabAmt = other_clab_amt
  18772. iteminfo.OthAmt = other_other_amt
  18773. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18774. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18775. }
  18776. struct4101.IteminfoStruct = iteminfoStructs
  18777. struct4101.Ntly = "中国"
  18778. struct4101.AdmCaty = "A03.06"
  18779. struct4101.DoctorName = doctor.UserName
  18780. struct4101.DoctorCode = doctor.DoctorNumber
  18781. var res ResultSeventeen
  18782. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18783. struct4101.BillCode = order.Number
  18784. struct4101.BillNo = order.SetlId
  18785. var resOther ResultSeventeenOther
  18786. var pp models.PublicParams
  18787. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18788. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18789. pp.FixmedinsName = miConfig.OrgName
  18790. pp.FixmedinsCode = miConfig.Code
  18791. pp.RequestUrl = miConfig.Url
  18792. pp.Cainfo = miConfig.Cainfo
  18793. pp.SecretKey = miConfig.SecretKey
  18794. pp.AccessKey = miConfig.AccessKey
  18795. pp.OpterName = curRoles.UserName
  18796. client := &http.Client{}
  18797. var req *http.Request
  18798. data := make(map[string]interface{})
  18799. data["struct4101"] = struct4101
  18800. data["pp"] = pp
  18801. bytesData, _ := json.Marshal(data)
  18802. if miConfig.MdtrtareaAdmvs == "320921" {
  18803. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18804. } else {
  18805. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18806. }
  18807. resp, _ := client.Do(req)
  18808. defer resp.Body.Close()
  18809. body, ioErr := ioutil.ReadAll(resp.Body)
  18810. if ioErr != nil {
  18811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18813. return
  18814. }
  18815. var respJSON map[string]interface{}
  18816. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18819. return
  18820. }
  18821. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18822. userJSONBytes, _ := json.Marshal(respJSON)
  18823. fmt.Println("log")
  18824. fmt.Println(string(userJSONBytes))
  18825. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18826. utils.ErrorLog("解析失败:%v", err)
  18827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18828. return
  18829. }
  18830. res.InfRefmsgid = resOther.InfRefmsgid
  18831. res.Output = resOther.Output
  18832. res.ErrMsg = resOther.ErrMsg
  18833. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18834. res.Infcode = infocode
  18835. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18836. var pp models.PublicParams
  18837. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18838. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18839. pp.FixmedinsName = miConfig.OrgName
  18840. pp.FixmedinsCode = miConfig.Code
  18841. pp.RequestUrl = miConfig.Url
  18842. pp.Cainfo = miConfig.Cainfo
  18843. pp.SecretKey = miConfig.SecretKey
  18844. pp.AccessKey = miConfig.AccessKey
  18845. pp.OpterName = curRoles.UserName
  18846. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18847. result, _ := service.Jxyb4101(struct4101, pp)
  18848. var dat map[string]interface{}
  18849. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18850. fmt.Println(dat)
  18851. } else {
  18852. fmt.Println(err)
  18853. }
  18854. userJSONBytes, _ := json.Marshal(dat)
  18855. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18856. utils.ErrorLog("解析失败:%v", err)
  18857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18858. return
  18859. }
  18860. } else if miConfig.MdtrtareaAdmvs == "361025" {
  18861. var pp models.PublicParams
  18862. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18863. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18864. pp.FixmedinsName = miConfig.OrgName
  18865. pp.FixmedinsCode = miConfig.Code
  18866. pp.RequestUrl = miConfig.Url
  18867. pp.Cainfo = miConfig.Cainfo
  18868. pp.SecretKey = miConfig.SecretKey
  18869. pp.AccessKey = miConfig.AccessKey
  18870. pp.OpterName = curRoles.UserName
  18871. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18872. result, _ := service.Jxyb4101(struct4101, pp)
  18873. var dat map[string]interface{}
  18874. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18875. fmt.Println(dat)
  18876. } else {
  18877. fmt.Println(err)
  18878. }
  18879. userJSONBytes, _ := json.Marshal(dat)
  18880. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18881. utils.ErrorLog("解析失败:%v", err)
  18882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18883. return
  18884. }
  18885. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18886. var pp models.PublicParams
  18887. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18888. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18889. pp.FixmedinsName = miConfig.OrgName
  18890. pp.FixmedinsCode = miConfig.Code
  18891. pp.RequestUrl = miConfig.Url
  18892. pp.Cainfo = miConfig.Cainfo
  18893. pp.SecretKey = miConfig.SecretKey
  18894. pp.AccessKey = miConfig.AccessKey
  18895. pp.OpterName = curRoles.UserName
  18896. result, _ := service.Hnyb4101(struct4101, pp)
  18897. var dat map[string]interface{}
  18898. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18899. fmt.Println(dat)
  18900. } else {
  18901. fmt.Println(err)
  18902. }
  18903. userJSONBytes, _ := json.Marshal(dat)
  18904. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18905. utils.ErrorLog("解析失败:%v", err)
  18906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18907. return
  18908. }
  18909. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18910. var resOther ResultSeventeenOther
  18911. var pp models.PublicParams
  18912. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18913. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18914. pp.FixmedinsName = miConfig.OrgName
  18915. pp.FixmedinsCode = miConfig.Code
  18916. pp.RequestUrl = miConfig.Url
  18917. pp.Cainfo = miConfig.Cainfo
  18918. pp.SecretKey = miConfig.SecretKey
  18919. pp.AccessKey = miConfig.AccessKey
  18920. pp.OpterName = curRoles.UserName
  18921. client := &http.Client{}
  18922. var req *http.Request
  18923. data := make(map[string]interface{})
  18924. data["struct4101"] = struct4101
  18925. data["pp"] = pp
  18926. bytesData, _ := json.Marshal(data)
  18927. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18928. resp, _ := client.Do(req)
  18929. defer resp.Body.Close()
  18930. body, ioErr := ioutil.ReadAll(resp.Body)
  18931. if ioErr != nil {
  18932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18934. return
  18935. }
  18936. var respJSON map[string]interface{}
  18937. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18940. return
  18941. }
  18942. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18943. userJSONBytes, _ := json.Marshal(respJSON)
  18944. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18945. utils.ErrorLog("解析失败:%v", err)
  18946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18947. return
  18948. }
  18949. res.InfRefmsgid = resOther.InfRefmsgid
  18950. res.Output = resOther.Output
  18951. res.ErrMsg = resOther.ErrMsg
  18952. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18953. res.Infcode = infocode
  18954. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18955. var pp models.PublicParams
  18956. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18957. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18958. pp.FixmedinsName = miConfig.OrgName
  18959. pp.FixmedinsCode = miConfig.Code
  18960. pp.RequestUrl = miConfig.Url
  18961. pp.Cainfo = miConfig.Cainfo
  18962. pp.SecretKey = miConfig.SecretKey
  18963. pp.AccessKey = miConfig.AccessKey
  18964. pp.OpterName = curRoles.UserName
  18965. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18966. fmt.Println(requestLog)
  18967. fmt.Println(errMsgLog)
  18968. saveLog(result, requestLog, "4101a", "上传清单")
  18969. var dat map[string]interface{}
  18970. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18971. fmt.Println(dat)
  18972. } else {
  18973. fmt.Println(err)
  18974. }
  18975. userJSONBytes, _ := json.Marshal(dat)
  18976. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18977. utils.ErrorLog("解析失败:%v", err)
  18978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18979. return
  18980. }
  18981. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18982. var pp models.PublicParams
  18983. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18984. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18985. pp.FixmedinsName = miConfig.OrgName
  18986. pp.FixmedinsCode = miConfig.Code
  18987. pp.RequestUrl = miConfig.Url
  18988. pp.Cainfo = miConfig.Cainfo
  18989. pp.SecretKey = miConfig.SecretKey
  18990. pp.AccessKey = miConfig.AccessKey
  18991. pp.OpterName = curRoles.UserName
  18992. client := &http.Client{}
  18993. var req *http.Request
  18994. data := make(map[string]interface{})
  18995. data["struct4101"] = struct4101
  18996. data["pp"] = pp
  18997. bytesData, _ := json.Marshal(data)
  18998. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  18999. resp, _ := client.Do(req)
  19000. defer resp.Body.Close()
  19001. body, ioErr := ioutil.ReadAll(resp.Body)
  19002. if ioErr != nil {
  19003. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19005. return
  19006. }
  19007. var respJSON map[string]interface{}
  19008. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19009. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19011. return
  19012. }
  19013. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19014. userJSONBytes, _ := json.Marshal(respJSON)
  19015. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19016. utils.ErrorLog("解析失败:%v", err)
  19017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19018. return
  19019. }
  19020. } else {
  19021. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19022. var dat map[string]interface{}
  19023. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19024. fmt.Println(dat)
  19025. } else {
  19026. fmt.Println(err)
  19027. }
  19028. userJSONBytes, _ := json.Marshal(dat)
  19029. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19030. utils.ErrorLog("解析失败:%v", err)
  19031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19032. return
  19033. }
  19034. }
  19035. if res.Infcode != 0 {
  19036. errlog := &models.HisOrderError{
  19037. UserOrgId: order.UserOrgId,
  19038. Ctime: time.Now().Unix(),
  19039. Mtime: time.Now().Unix(),
  19040. ErrMsg: res.ErrMsg + "解析失败",
  19041. Status: 1,
  19042. PatientId: order.ID,
  19043. Stage: 10485,
  19044. }
  19045. service.CreateErrMsgLog(errlog)
  19046. continue
  19047. //c.ServeSuccessJSON(map[string]interface{}{
  19048. // "failed_code": -10,
  19049. // "msg": res.ErrMsg,
  19050. //})
  19051. } else {
  19052. //order.FaPiaoNumber = zero
  19053. //order.FaPiaoCode = last_order.FaPiaoCode
  19054. //service.UpdateOrder(order)
  19055. hisFundSettleListResult := &models.HisFundSettleListResult{
  19056. Number: res.Output.SetlListId,
  19057. Status: 1,
  19058. Ctime: time.Now().Unix(),
  19059. Mtime: time.Now().Unix(),
  19060. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19061. IsUpload: 1,
  19062. OrderId: order.ID,
  19063. }
  19064. service.CreateUploadRecord(hisFundSettleListResult)
  19065. continue
  19066. }
  19067. }
  19068. }
  19069. func (c *HisApiController) GetSettleList() {
  19070. order_id, _ := c.GetInt64("order_id")
  19071. admin_user_id, _ := c.GetInt64("admin_user_id")
  19072. order, _ := service.GetHisOrderByIDTwo(order_id)
  19073. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19074. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19075. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19076. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19077. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19078. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19079. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19080. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19081. if order.ID == 0 {
  19082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19083. return
  19084. }
  19085. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19086. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19087. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19088. //fmt.Println(count)
  19089. //var zero string
  19090. //number := count + 1
  19091. //if number >= 1000 {
  19092. // zero = "0000" + strconv.FormatInt(number, 10)
  19093. //} else if number >= 10000 {
  19094. // zero = "000" + strconv.FormatInt(number, 10)
  19095. //} else if number >= 100000 {
  19096. // zero = "00" + strconv.FormatInt(number, 10)
  19097. //} else if number >= 1000000 {
  19098. // zero = "0" + strconv.FormatInt(number, 10)
  19099. //} else {
  19100. // zero = strconv.FormatInt(number, 10)
  19101. //}
  19102. //fmt.Println(zero)
  19103. struct4101 := service.Struct4101{
  19104. PsnNo: order.PsnNo,
  19105. MdtrtId: order.MdtrtId,
  19106. SetlId: order.SetlId,
  19107. PsnName: order.PsnName,
  19108. Gend: order.Gend,
  19109. Brdy: his.Brdy,
  19110. Age: his.Age,
  19111. Naty: order.Naty,
  19112. PatnCertType: "01",
  19113. Certno: order.Certno,
  19114. Prfs: "90",
  19115. ConerName: roles[0].UserName,
  19116. PatnRlts: "99",
  19117. ConerAddr: miConfig.OrgName,
  19118. ConerTel: admin.Mobile,
  19119. HiType: order.Insutype,
  19120. Insuplc: miConfig.InsuplcAdmdvs,
  19121. MaindiagFlag: "1",
  19122. BillCode: order.SetlId,
  19123. BillNo: order.SetlId,
  19124. BizSn: order.Number,
  19125. PsnSelfPay: order.PsnPartAmt,
  19126. PsnOwnPay: order.PsnPartAmt,
  19127. AcctPay: order.AcctPay,
  19128. PsnCashpay: order.PsnCashPay,
  19129. HiPaymtd: "1",
  19130. Hsorg: miConfig.InsuplcAdmdvs,
  19131. HsorgOpter: miConfig.InsuplcAdmdvs,
  19132. MedinsFillPsn: curRoles.UserName,
  19133. MedinsFillDept: miConfig.OrgName,
  19134. IptMedType: "2",
  19135. }
  19136. struct4101.SetlBegnDate = order.SetlTime
  19137. struct4101.SetlEndDate = order.SetlTime
  19138. time_arr := strings.Split(order.SetlTime, " ")
  19139. struct4101.AdmTime = time_arr[0]
  19140. struct4101.AdmEndTime = time_arr[0]
  19141. //
  19142. //var rf []CustomFundPay
  19143. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19144. //
  19145. //var tempFunPays []service.CustomStruct
  19146. //for _, item := range rf {
  19147. // var tempFunPay service.CustomStruct
  19148. // tempFunPay.FundPayamt = item.FundPayamt
  19149. // tempFunPay.FundPayType = item.FundPayType
  19150. // tempFunPays = append(tempFunPays, tempFunPay)
  19151. //}
  19152. //struct4101.CustomStruct = tempFunPays
  19153. var tempDiaginfos []service.DiaginfoStructTwo
  19154. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19155. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19156. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  19157. var config []*models.HisXtDiagnoseConfig
  19158. for _, item := range diagnosis_ids {
  19159. id, _ := strconv.ParseInt(item, 10, 64)
  19160. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19161. config = append(config, &diagnosisConfig)
  19162. }
  19163. if miConfig.Code == "H15049901371" {
  19164. //for _, item := range config {
  19165. // if item.ID == 138 {
  19166. diagnosisConfig, _ := service.FindDiagnoseById(138)
  19167. var tempDiaginfo service.DiaginfoStructTwo
  19168. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  19169. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  19170. tempDiaginfo.DiagType = "1"
  19171. tempDiaginfo.MaindiagFlag = "1"
  19172. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19173. //}
  19174. //}
  19175. for _, item := range config {
  19176. if item.ID != 138 {
  19177. var tempDiaginfo service.DiaginfoStructTwo
  19178. tempDiaginfo.DiagCode = item.CountryCode
  19179. tempDiaginfo.DiagName = item.CountryContentName
  19180. tempDiaginfo.DiagType = "1"
  19181. tempDiaginfo.MaindiagFlag = "0"
  19182. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19183. }
  19184. }
  19185. } else {
  19186. for index, item := range config {
  19187. if index == 0 {
  19188. var tempDiaginfo service.DiaginfoStructTwo
  19189. tempDiaginfo.DiagCode = item.CountryCode
  19190. tempDiaginfo.DiagName = item.CountryContentName
  19191. tempDiaginfo.DiagType = "1"
  19192. tempDiaginfo.MaindiagFlag = "1"
  19193. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19194. } else {
  19195. var tempDiaginfo service.DiaginfoStructTwo
  19196. tempDiaginfo.DiagCode = item.CountryCode
  19197. tempDiaginfo.DiagName = item.CountryContentName
  19198. tempDiaginfo.DiagType = "1"
  19199. tempDiaginfo.MaindiagFlag = "0"
  19200. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19201. }
  19202. }
  19203. }
  19204. struct4101.Diseinfo = tempDiaginfos
  19205. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19206. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19207. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19208. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19209. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19210. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19211. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19212. var iteminfo service.IteminfoStruct
  19213. var bedCostTotal float64 = 0 //床位总费
  19214. var bedCostSelfTotal float64 = 0 //床位自费
  19215. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19216. var operationCostTotal float64 = 0 //手术费
  19217. var operationCostSelfTotal float64 = 0 //手术费
  19218. var operationCostPartSelfTotal float64 = 0 //手术费
  19219. var otherCostTotal float64 = 0 //其他费用
  19220. var otherCostSelfTotal float64 = 0 //其他费用
  19221. var otherCostPartSelfTotal float64 = 0 //其他费用
  19222. var materialCostTotal float64 = 0 //材料费
  19223. var materialCostSelfTotal float64 = 0 //材料费
  19224. var materialCostPartSelfTotal float64 = 0 //材料费
  19225. var westernMedicineCostTotal float64 = 0 //西药费
  19226. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19227. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19228. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19229. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19230. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19231. var checkCostTotal float64 = 0 //检查费
  19232. var checkCostSelfTotal float64 = 0 //检查费
  19233. var checkCostPartSelfTotal float64 = 0 //检查费
  19234. var laboratoryCostTotal float64 = 0 //化验费
  19235. var laboratoryCostSelfTotal float64 = 0 //化验费
  19236. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19237. var treatCostTotal float64 = 0 //治疗费用
  19238. var treatCostSelfTotal float64 = 0 //治疗费用
  19239. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19240. decimal.DivisionPrecision = 2
  19241. var bed_fulamt_ownpay_amt float64 = 0
  19242. var operation_fulamt_ownpay_amt float64 = 0
  19243. var other_fulamt_ownpay_amt float64 = 0
  19244. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19245. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19246. var check_fulamt_ownpay_amt float64 = 0
  19247. var material_fulamt_ownpay_amt float64 = 0
  19248. var laboratory_fulamt_ownpay_amt float64 = 0
  19249. var treat_fulamt_ownpay_amt float64 = 0
  19250. var bed_claa_sunmfee float64 = 0
  19251. var bed_clab_amt float64 = 0
  19252. var bed_other_amt float64 = 0
  19253. var operation_claa_sunmfee float64 = 0
  19254. var operation_clab_amt float64 = 0
  19255. var operation_other_amt float64 = 0
  19256. var other_claa_sunmfee float64 = 0
  19257. var other_clab_amt float64 = 0
  19258. var other_other_amt float64 = 0
  19259. var westernMedicine_claa_sunmfee float64 = 0
  19260. var westernMedicine_clab_amt float64 = 0
  19261. var westernMedicine_other_amt float64 = 0
  19262. var chineseTraditional_claa_sunmfee float64 = 0
  19263. var chineseTraditional_clab_amt float64 = 0
  19264. var chineseTraditional_other_amt float64 = 0
  19265. var check_claa_sunmfee float64 = 0
  19266. var check_clab_amt float64 = 0
  19267. var check_other_amt float64 = 0
  19268. var material_claa_sunmfee float64 = 0
  19269. var material_clab_amt float64 = 0
  19270. var material_other_amt float64 = 0
  19271. var laboratory_claa_sunmfee float64 = 0
  19272. var laboratory_clab_amt float64 = 0
  19273. var laboratory_other_amt float64 = 0
  19274. var treat_claa_sunmfee float64 = 0
  19275. var treat_clab_amt float64 = 0
  19276. var treat_other_amt float64 = 0
  19277. for _, item := range order.HisOrderInfo {
  19278. if item.MedChrgitmType == "01" { //床位费
  19279. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19280. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19281. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19282. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19283. if item.ChrgitmLv == "1" {
  19284. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19285. }
  19286. if item.ChrgitmLv == "2" {
  19287. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19288. }
  19289. if item.ChrgitmLv == "3" {
  19290. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19291. }
  19292. }
  19293. if item.MedChrgitmType == "03" { //检查费
  19294. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19295. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19296. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19297. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19298. if item.ChrgitmLv == "1" {
  19299. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19300. }
  19301. if item.ChrgitmLv == "2" {
  19302. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19303. }
  19304. if item.ChrgitmLv == "3" {
  19305. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19306. }
  19307. }
  19308. if item.MedChrgitmType == "04" { //化验费
  19309. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19310. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19311. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19312. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19313. if item.ChrgitmLv == "1" {
  19314. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19315. }
  19316. if item.ChrgitmLv == "2" {
  19317. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19318. }
  19319. if item.ChrgitmLv == "3" {
  19320. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19321. }
  19322. }
  19323. if item.MedChrgitmType == "05" { //治疗费
  19324. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19325. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19326. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19327. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19328. if item.ChrgitmLv == "1" {
  19329. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19330. }
  19331. if item.ChrgitmLv == "2" {
  19332. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19333. }
  19334. if item.ChrgitmLv == "3" {
  19335. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19336. }
  19337. }
  19338. if item.MedChrgitmType == "06" { //手术费
  19339. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19340. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19341. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19342. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19343. if item.ChrgitmLv == "1" {
  19344. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19345. }
  19346. if item.ChrgitmLv == "2" {
  19347. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19348. }
  19349. if item.ChrgitmLv == "3" {
  19350. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19351. }
  19352. }
  19353. if item.MedChrgitmType == "08" { //材料费
  19354. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19355. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19356. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19357. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19358. if item.ChrgitmLv == "1" {
  19359. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19360. }
  19361. if item.ChrgitmLv == "2" {
  19362. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19363. }
  19364. if item.ChrgitmLv == "3" {
  19365. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19366. }
  19367. }
  19368. if item.MedChrgitmType == "09" { //西药费
  19369. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19370. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19371. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19372. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19373. if item.ChrgitmLv == "1" {
  19374. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19375. }
  19376. if item.ChrgitmLv == "2" {
  19377. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19378. }
  19379. if item.ChrgitmLv == "3" {
  19380. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19381. }
  19382. }
  19383. if item.MedChrgitmType == "11" { //中成费
  19384. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19385. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19386. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19387. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19388. if item.ChrgitmLv == "1" {
  19389. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19390. }
  19391. if item.ChrgitmLv == "2" {
  19392. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19393. }
  19394. if item.ChrgitmLv == "3" {
  19395. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19396. }
  19397. }
  19398. if item.MedChrgitmType == "14" { //其他费
  19399. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19400. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19401. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19402. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19403. if item.ChrgitmLv == "1" {
  19404. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19405. }
  19406. if item.ChrgitmLv == "2" {
  19407. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19408. }
  19409. if item.ChrgitmLv == "3" {
  19410. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19411. }
  19412. }
  19413. }
  19414. var iteminfoStructs []service.IteminfoStruct
  19415. if bedCostTotal != 0 {
  19416. iteminfo.MedChrgitm = "01"
  19417. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19418. iteminfo.Amt = bedCostTotal
  19419. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19420. iteminfo.ClabAmt = bed_clab_amt
  19421. iteminfo.OthAmt = bed_other_amt
  19422. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19423. }
  19424. if checkCostTotal != 0 {
  19425. iteminfo.MedChrgitm = "03"
  19426. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19427. iteminfo.Amt = checkCostTotal
  19428. iteminfo.ClaaSumfee = check_claa_sunmfee
  19429. iteminfo.ClabAmt = check_clab_amt
  19430. iteminfo.OthAmt = check_other_amt
  19431. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19432. }
  19433. if laboratoryCostTotal != 0 {
  19434. iteminfo.MedChrgitm = "04"
  19435. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19436. iteminfo.Amt = laboratoryCostTotal
  19437. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19438. iteminfo.ClabAmt = laboratory_clab_amt
  19439. iteminfo.OthAmt = laboratory_other_amt
  19440. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19441. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19442. }
  19443. if treatCostTotal != 0 {
  19444. iteminfo.MedChrgitm = "05"
  19445. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19446. iteminfo.Amt = treatCostTotal
  19447. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19448. iteminfo.ClabAmt = treat_clab_amt
  19449. iteminfo.OthAmt = treat_other_amt
  19450. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19451. //(struct4101.IteminfoStruct, iteminfo)
  19452. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19453. }
  19454. if operationCostTotal != 0 {
  19455. iteminfo.MedChrgitm = "06"
  19456. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19457. iteminfo.Amt = operationCostTotal
  19458. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19459. iteminfo.ClabAmt = operation_clab_amt
  19460. iteminfo.OthAmt = operation_other_amt
  19461. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19462. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19463. }
  19464. if materialCostTotal != 0 {
  19465. iteminfo.MedChrgitm = "08"
  19466. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19467. iteminfo.Amt = materialCostTotal
  19468. iteminfo.ClaaSumfee = material_claa_sunmfee
  19469. iteminfo.ClabAmt = material_clab_amt
  19470. iteminfo.OthAmt = material_other_amt
  19471. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19472. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19473. }
  19474. if westernMedicineCostTotal != 0 {
  19475. iteminfo.MedChrgitm = "09"
  19476. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19477. iteminfo.Amt = westernMedicineCostTotal
  19478. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19479. iteminfo.ClabAmt = westernMedicine_clab_amt
  19480. iteminfo.OthAmt = westernMedicine_other_amt
  19481. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19482. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19483. }
  19484. if chineseTraditionalMedicineCostTotal != 0 {
  19485. iteminfo.MedChrgitm = "11"
  19486. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19487. iteminfo.Amt = westernMedicineCostTotal
  19488. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19489. iteminfo.ClabAmt = westernMedicine_clab_amt
  19490. iteminfo.OthAmt = westernMedicine_other_amt
  19491. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19492. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19493. }
  19494. if otherCostTotal != 0 {
  19495. iteminfo.MedChrgitm = "14"
  19496. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19497. iteminfo.Amt = otherCostTotal
  19498. iteminfo.ClaaSumfee = other_claa_sunmfee
  19499. iteminfo.ClabAmt = other_clab_amt
  19500. iteminfo.OthAmt = other_other_amt
  19501. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19502. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19503. }
  19504. struct4101.IteminfoStruct = iteminfoStructs
  19505. struct4101.Ntly = "中国"
  19506. struct4101.AdmCaty = "A03.06"
  19507. struct4101.DoctorName = doctor.UserName
  19508. struct4101.DoctorCode = doctor.DoctorNumber
  19509. var res ResultSeventeen
  19510. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19511. struct4101.BillCode = order.Number
  19512. struct4101.BillNo = order.SetlId
  19513. var resOther ResultSeventeenOther
  19514. var pp models.PublicParams
  19515. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19516. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19517. pp.FixmedinsName = miConfig.OrgName
  19518. pp.FixmedinsCode = miConfig.Code
  19519. pp.RequestUrl = miConfig.Url
  19520. pp.Cainfo = miConfig.Cainfo
  19521. pp.SecretKey = miConfig.SecretKey
  19522. pp.AccessKey = miConfig.AccessKey
  19523. pp.OpterName = curRoles.UserName
  19524. client := &http.Client{}
  19525. var req *http.Request
  19526. data := make(map[string]interface{})
  19527. data["struct4101"] = struct4101
  19528. data["pp"] = pp
  19529. bytesData, _ := json.Marshal(data)
  19530. if miConfig.MdtrtareaAdmvs == "320921" {
  19531. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19532. } else {
  19533. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19534. }
  19535. resp, _ := client.Do(req)
  19536. defer resp.Body.Close()
  19537. body, ioErr := ioutil.ReadAll(resp.Body)
  19538. if ioErr != nil {
  19539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19541. return
  19542. }
  19543. var respJSON map[string]interface{}
  19544. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19547. return
  19548. }
  19549. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19550. userJSONBytes, _ := json.Marshal(respJSON)
  19551. fmt.Println("log")
  19552. fmt.Println(string(userJSONBytes))
  19553. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19554. utils.ErrorLog("解析失败:%v", err)
  19555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19556. return
  19557. }
  19558. res.InfRefmsgid = resOther.InfRefmsgid
  19559. res.Output = resOther.Output
  19560. res.ErrMsg = resOther.ErrMsg
  19561. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19562. res.Infcode = infocode
  19563. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19564. var pp models.PublicParams
  19565. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19566. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19567. pp.FixmedinsName = miConfig.OrgName
  19568. pp.FixmedinsCode = miConfig.Code
  19569. pp.RequestUrl = miConfig.Url
  19570. pp.Cainfo = miConfig.Cainfo
  19571. pp.SecretKey = miConfig.SecretKey
  19572. pp.AccessKey = miConfig.AccessKey
  19573. pp.OpterName = curRoles.UserName
  19574. result, _ := service.Jxyb4101(struct4101, pp)
  19575. var dat map[string]interface{}
  19576. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19577. fmt.Println(dat)
  19578. } else {
  19579. fmt.Println(err)
  19580. }
  19581. userJSONBytes, _ := json.Marshal(dat)
  19582. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19583. utils.ErrorLog("解析失败:%v", err)
  19584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19585. return
  19586. }
  19587. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19588. var pp models.PublicParams
  19589. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19590. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19591. pp.FixmedinsName = miConfig.OrgName
  19592. pp.FixmedinsCode = miConfig.Code
  19593. pp.RequestUrl = miConfig.Url
  19594. pp.Cainfo = miConfig.Cainfo
  19595. pp.SecretKey = miConfig.SecretKey
  19596. pp.AccessKey = miConfig.AccessKey
  19597. pp.OpterName = curRoles.UserName
  19598. result, _ := service.Jxyb4101(struct4101, pp)
  19599. var dat map[string]interface{}
  19600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19601. fmt.Println(dat)
  19602. } else {
  19603. fmt.Println(err)
  19604. }
  19605. userJSONBytes, _ := json.Marshal(dat)
  19606. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19607. utils.ErrorLog("解析失败:%v", err)
  19608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19609. return
  19610. }
  19611. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19612. var pp models.PublicParams
  19613. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19614. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19615. pp.FixmedinsName = miConfig.OrgName
  19616. pp.FixmedinsCode = miConfig.Code
  19617. pp.RequestUrl = miConfig.Url
  19618. pp.Cainfo = miConfig.Cainfo
  19619. pp.SecretKey = miConfig.SecretKey
  19620. pp.AccessKey = miConfig.AccessKey
  19621. pp.OpterName = curRoles.UserName
  19622. result, _ := service.Hnyb4101(struct4101, pp)
  19623. var dat map[string]interface{}
  19624. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19625. fmt.Println(dat)
  19626. } else {
  19627. fmt.Println(err)
  19628. }
  19629. userJSONBytes, _ := json.Marshal(dat)
  19630. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19631. utils.ErrorLog("解析失败:%v", err)
  19632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19633. return
  19634. }
  19635. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19636. var resOther ResultSeventeenOther
  19637. var pp models.PublicParams
  19638. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19639. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19640. pp.FixmedinsName = miConfig.OrgName
  19641. pp.FixmedinsCode = miConfig.Code
  19642. pp.RequestUrl = miConfig.Url
  19643. pp.Cainfo = miConfig.Cainfo
  19644. pp.SecretKey = miConfig.SecretKey
  19645. pp.AccessKey = miConfig.AccessKey
  19646. pp.OpterName = curRoles.UserName
  19647. client := &http.Client{}
  19648. var req *http.Request
  19649. data := make(map[string]interface{})
  19650. data["struct4101"] = struct4101
  19651. data["pp"] = pp
  19652. bytesData, _ := json.Marshal(data)
  19653. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19654. resp, _ := client.Do(req)
  19655. defer resp.Body.Close()
  19656. body, ioErr := ioutil.ReadAll(resp.Body)
  19657. if ioErr != nil {
  19658. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19660. return
  19661. }
  19662. var respJSON map[string]interface{}
  19663. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19664. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19666. return
  19667. }
  19668. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19669. userJSONBytes, _ := json.Marshal(respJSON)
  19670. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19671. utils.ErrorLog("解析失败:%v", err)
  19672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19673. return
  19674. }
  19675. res.InfRefmsgid = resOther.InfRefmsgid
  19676. res.Output = resOther.Output
  19677. res.ErrMsg = resOther.ErrMsg
  19678. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19679. res.Infcode = infocode
  19680. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19681. var pp models.PublicParams
  19682. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19683. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19684. pp.FixmedinsName = miConfig.OrgName
  19685. pp.FixmedinsCode = miConfig.Code
  19686. pp.RequestUrl = miConfig.Url
  19687. pp.Cainfo = miConfig.Cainfo
  19688. pp.SecretKey = miConfig.SecretKey
  19689. pp.AccessKey = miConfig.AccessKey
  19690. pp.OpterName = curRoles.UserName
  19691. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19692. fmt.Println(requestLog)
  19693. fmt.Println(errMsgLog)
  19694. saveLog(result, requestLog, "4101a", "上传清单")
  19695. var dat map[string]interface{}
  19696. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19697. fmt.Println(dat)
  19698. } else {
  19699. fmt.Println(err)
  19700. }
  19701. userJSONBytes, _ := json.Marshal(dat)
  19702. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19703. utils.ErrorLog("解析失败:%v", err)
  19704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19705. return
  19706. }
  19707. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19708. var pp models.PublicParams
  19709. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19710. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19711. pp.FixmedinsName = miConfig.OrgName
  19712. pp.FixmedinsCode = miConfig.Code
  19713. pp.RequestUrl = miConfig.Url
  19714. pp.Cainfo = miConfig.Cainfo
  19715. pp.SecretKey = miConfig.SecretKey
  19716. pp.AccessKey = miConfig.AccessKey
  19717. pp.OpterName = curRoles.UserName
  19718. client := &http.Client{}
  19719. var req *http.Request
  19720. data := make(map[string]interface{})
  19721. data["struct4101"] = struct4101
  19722. data["pp"] = pp
  19723. bytesData, _ := json.Marshal(data)
  19724. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19725. resp, _ := client.Do(req)
  19726. defer resp.Body.Close()
  19727. body, ioErr := ioutil.ReadAll(resp.Body)
  19728. if ioErr != nil {
  19729. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19731. return
  19732. }
  19733. var respJSON map[string]interface{}
  19734. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19737. return
  19738. }
  19739. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19740. userJSONBytes, _ := json.Marshal(respJSON)
  19741. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19742. utils.ErrorLog("解析失败:%v", err)
  19743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19744. return
  19745. }
  19746. } else {
  19747. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19748. var dat map[string]interface{}
  19749. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19750. fmt.Println(dat)
  19751. } else {
  19752. fmt.Println(err)
  19753. }
  19754. userJSONBytes, _ := json.Marshal(dat)
  19755. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19756. utils.ErrorLog("解析失败:%v", err)
  19757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19758. return
  19759. }
  19760. }
  19761. if res.Infcode != 0 {
  19762. c.ServeSuccessJSON(map[string]interface{}{
  19763. "failed_code": -10,
  19764. "msg": res.ErrMsg,
  19765. })
  19766. return
  19767. } else {
  19768. //order.FaPiaoNumber = zero
  19769. //order.FaPiaoCode = last_order.FaPiaoCode
  19770. //service.UpdateOrder(order)
  19771. hisFundSettleListResult := &models.HisFundSettleListResult{
  19772. Number: res.Output.SetlListId,
  19773. Status: 1,
  19774. Ctime: time.Now().Unix(),
  19775. Mtime: time.Now().Unix(),
  19776. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19777. IsUpload: 1,
  19778. OrderId: order_id,
  19779. }
  19780. service.CreateUploadRecord(hisFundSettleListResult)
  19781. c.ServeSuccessJSON(map[string]interface{}{
  19782. "msg": "上传成功",
  19783. "result": hisFundSettleListResult,
  19784. })
  19785. return
  19786. }
  19787. }
  19788. func (c *HisApiController) GetSettleListHospital() {
  19789. order_id, _ := c.GetInt64("order_id")
  19790. admin_user_id, _ := c.GetInt64("admin_user_id")
  19791. order, _ := service.GetHisOrderByIDTwo(order_id)
  19792. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19793. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  19794. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19795. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19796. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19797. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19798. if order.ID == 0 {
  19799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19800. return
  19801. }
  19802. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19803. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19804. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19805. fmt.Println(count)
  19806. var zero string
  19807. number := count + 1
  19808. if number >= 1000 {
  19809. zero = "0000" + strconv.FormatInt(number, 10)
  19810. } else if number >= 10000 {
  19811. zero = "000" + strconv.FormatInt(number, 10)
  19812. } else if number >= 100000 {
  19813. zero = "00" + strconv.FormatInt(number, 10)
  19814. } else if number >= 1000000 {
  19815. zero = "0" + strconv.FormatInt(number, 10)
  19816. } else {
  19817. zero = strconv.FormatInt(number, 10)
  19818. }
  19819. fmt.Println(zero)
  19820. struct4101 := service.Struct4101{
  19821. PsnNo: order.PsnNo,
  19822. MdtrtId: order.MdtrtId,
  19823. SetlId: order.SetlId,
  19824. PsnName: order.PsnName,
  19825. Gend: order.Gend,
  19826. Brdy: his.Brdy,
  19827. Age: int64(order.Age),
  19828. Naty: order.Naty,
  19829. PatnCertType: "01",
  19830. Certno: order.Certno,
  19831. Prfs: "90",
  19832. ConerName: roles[0].UserName,
  19833. PatnRlts: "99",
  19834. ConerAddr: miConfig.OrgName,
  19835. ConerTel: admin.Mobile,
  19836. HiType: order.Insutype,
  19837. Insuplc: miConfig.InsuplcAdmdvs,
  19838. MaindiagFlag: "1",
  19839. BillCode: order.SetlId,
  19840. BillNo: order.SetlId,
  19841. BizSn: order.Number,
  19842. PsnSelfPay: order.PsnPartAmt,
  19843. PsnOwnPay: order.PsnPartAmt,
  19844. AcctPay: order.AcctPay,
  19845. PsnCashpay: order.PsnCashPay,
  19846. HiPaymtd: "1",
  19847. Hsorg: miConfig.InsuplcAdmdvs,
  19848. HsorgOpter: miConfig.InsuplcAdmdvs,
  19849. MedinsFillPsn: curRoles.UserName,
  19850. MedinsFillDept: depart.Name,
  19851. IptMedType: "2",
  19852. AdmTime: his.InHosptialTime,
  19853. AdmEndTime: his.OutHosptialTime,
  19854. }
  19855. struct4101.SetlBegnDate = order.SetlTime
  19856. struct4101.SetlEndDate = order.SetlTime
  19857. //var rf []CustomFundPay
  19858. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19859. //
  19860. //var tempFunPays []service.CustomStruct
  19861. //for _, item := range rf {
  19862. // var tempFunPay service.CustomStruct
  19863. // tempFunPay.FundPayamt = item.FundPayamt
  19864. // tempFunPay.FundPayType = item.FundPayType
  19865. // tempFunPays = append(tempFunPays, tempFunPay)
  19866. //}
  19867. //struct4101.CustomStruct = tempFunPays
  19868. var tempDiaginfos []service.DiaginfoStructTwo
  19869. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19870. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19871. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  19872. //for _, item := range infos {
  19873. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  19874. //}
  19875. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  19876. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  19877. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19878. fmt.Println(diagnosis_ids_arr)
  19879. if order.UserOrgId == 10210 {
  19880. var diagnosis_ids_arr_two []int64
  19881. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  19882. var config []*models.HisXtDiagnoseConfig
  19883. for _, id := range diagnosis_ids_arr_two {
  19884. //id, _ := strconv.ParseInt(item, 10, 64)
  19885. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19886. if diagnosisConfig.ID > 0 {
  19887. config = append(config, &diagnosisConfig)
  19888. }
  19889. }
  19890. for index, item := range config {
  19891. if item.ID > 0 {
  19892. if index == 0 {
  19893. var tempDiaginfo service.DiaginfoStructTwo
  19894. tempDiaginfo.DiagCode = item.CountryCode
  19895. tempDiaginfo.DiagName = item.CountryContentName
  19896. tempDiaginfo.DiagType = "1"
  19897. tempDiaginfo.MaindiagFlag = "1"
  19898. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19899. } else {
  19900. var tempDiaginfo service.DiaginfoStructTwo
  19901. tempDiaginfo.DiagCode = item.CountryCode
  19902. tempDiaginfo.DiagName = item.CountryContentName
  19903. tempDiaginfo.DiagType = "1"
  19904. tempDiaginfo.MaindiagFlag = "0"
  19905. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19906. }
  19907. }
  19908. }
  19909. struct4101.Diseinfo = tempDiaginfos
  19910. } else {
  19911. var config []*models.HisXtDiagnoseConfig
  19912. for _, item := range diagnosis_ids_arr {
  19913. id, _ := strconv.ParseInt(item, 10, 64)
  19914. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19915. if diagnosisConfig.ID > 0 {
  19916. config = append(config, &diagnosisConfig)
  19917. }
  19918. }
  19919. for index, item := range config {
  19920. if item.ID > 0 {
  19921. if index == 0 {
  19922. var tempDiaginfo service.DiaginfoStructTwo
  19923. tempDiaginfo.DiagCode = item.CountryCode
  19924. tempDiaginfo.DiagName = item.CountryContentName
  19925. tempDiaginfo.DiagType = "1"
  19926. tempDiaginfo.MaindiagFlag = "1"
  19927. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19928. } else {
  19929. var tempDiaginfo service.DiaginfoStructTwo
  19930. tempDiaginfo.DiagCode = item.CountryCode
  19931. tempDiaginfo.DiagName = item.CountryContentName
  19932. tempDiaginfo.DiagType = "1"
  19933. tempDiaginfo.MaindiagFlag = "0"
  19934. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19935. }
  19936. }
  19937. }
  19938. struct4101.Diseinfo = tempDiaginfos
  19939. }
  19940. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19941. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19942. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19943. tempOpspdiseinfo2.OprnOprtCode = ""
  19944. tempOpspdiseinfo2.OprnOprtName = ""
  19945. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19946. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19947. var iteminfo service.IteminfoStruct
  19948. var bedCostTotal float64 = 0 //床位总费
  19949. var bedCostSelfTotal float64 = 0 //床位自费
  19950. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19951. var operationCostTotal float64 = 0 //手术费
  19952. var operationCostSelfTotal float64 = 0 //手术费
  19953. var operationCostPartSelfTotal float64 = 0 //手术费
  19954. var otherCostTotal float64 = 0 //其他费用
  19955. var otherCostSelfTotal float64 = 0 //其他费用
  19956. var otherCostPartSelfTotal float64 = 0 //其他费用
  19957. var materialCostTotal float64 = 0 //材料费
  19958. var materialCostSelfTotal float64 = 0 //材料费
  19959. var materialCostPartSelfTotal float64 = 0 //材料费
  19960. var westernMedicineCostTotal float64 = 0 //西药费
  19961. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19962. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19963. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19964. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19965. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19966. var checkCostTotal float64 = 0 //检查费
  19967. var checkCostSelfTotal float64 = 0 //检查费
  19968. var checkCostPartSelfTotal float64 = 0 //检查费
  19969. var laboratoryCostTotal float64 = 0 //化验费
  19970. var laboratoryCostSelfTotal float64 = 0 //化验费
  19971. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19972. var treatCostTotal float64 = 0 //治疗费用
  19973. var treatCostSelfTotal float64 = 0 //治疗费用
  19974. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19975. decimal.DivisionPrecision = 2
  19976. var bed_fulamt_ownpay_amt float64 = 0
  19977. var operation_fulamt_ownpay_amt float64 = 0
  19978. var other_fulamt_ownpay_amt float64 = 0
  19979. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19980. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19981. var check_fulamt_ownpay_amt float64 = 0
  19982. var material_fulamt_ownpay_amt float64 = 0
  19983. var laboratory_fulamt_ownpay_amt float64 = 0
  19984. var treat_fulamt_ownpay_amt float64 = 0
  19985. var bed_claa_sunmfee float64 = 0
  19986. var bed_clab_amt float64 = 0
  19987. var bed_other_amt float64 = 0
  19988. var operation_claa_sunmfee float64 = 0
  19989. var operation_clab_amt float64 = 0
  19990. var operation_other_amt float64 = 0
  19991. var other_claa_sunmfee float64 = 0
  19992. var other_clab_amt float64 = 0
  19993. var other_other_amt float64 = 0
  19994. var westernMedicine_claa_sunmfee float64 = 0
  19995. var westernMedicine_clab_amt float64 = 0
  19996. var westernMedicine_other_amt float64 = 0
  19997. var chineseTraditional_claa_sunmfee float64 = 0
  19998. var chineseTraditional_clab_amt float64 = 0
  19999. var chineseTraditional_other_amt float64 = 0
  20000. var check_claa_sunmfee float64 = 0
  20001. var check_clab_amt float64 = 0
  20002. var check_other_amt float64 = 0
  20003. var material_claa_sunmfee float64 = 0
  20004. var material_clab_amt float64 = 0
  20005. var material_other_amt float64 = 0
  20006. var laboratory_claa_sunmfee float64 = 0
  20007. var laboratory_clab_amt float64 = 0
  20008. var laboratory_other_amt float64 = 0
  20009. var treat_claa_sunmfee float64 = 0
  20010. var treat_clab_amt float64 = 0
  20011. var treat_other_amt float64 = 0
  20012. for _, item := range order.HisOrderInfo {
  20013. if item.MedChrgitmType == "01" { //床位费
  20014. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20015. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20016. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20017. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20018. if item.ChrgitmLv == "1" {
  20019. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20020. }
  20021. if item.ChrgitmLv == "2" {
  20022. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20023. }
  20024. if item.ChrgitmLv == "3" {
  20025. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20026. }
  20027. }
  20028. if item.MedChrgitmType == "03" { //检查费
  20029. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20030. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20031. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20032. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20033. if item.ChrgitmLv == "1" {
  20034. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20035. }
  20036. if item.ChrgitmLv == "2" {
  20037. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20038. }
  20039. if item.ChrgitmLv == "3" {
  20040. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20041. }
  20042. }
  20043. if item.MedChrgitmType == "04" { //化验费
  20044. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20045. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20046. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20047. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20048. if item.ChrgitmLv == "1" {
  20049. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20050. }
  20051. if item.ChrgitmLv == "2" {
  20052. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20053. }
  20054. if item.ChrgitmLv == "3" {
  20055. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20056. }
  20057. }
  20058. if item.MedChrgitmType == "05" { //治疗费
  20059. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20060. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20061. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20062. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20063. if item.ChrgitmLv == "1" {
  20064. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20065. }
  20066. if item.ChrgitmLv == "2" {
  20067. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20068. }
  20069. if item.ChrgitmLv == "3" {
  20070. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20071. }
  20072. }
  20073. if item.MedChrgitmType == "06" { //手术费
  20074. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20075. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20076. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20077. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20078. if item.ChrgitmLv == "1" {
  20079. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20080. }
  20081. if item.ChrgitmLv == "2" {
  20082. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20083. }
  20084. if item.ChrgitmLv == "3" {
  20085. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20086. }
  20087. }
  20088. if item.MedChrgitmType == "08" { //材料费
  20089. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20090. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20091. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20092. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20093. if item.ChrgitmLv == "1" {
  20094. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20095. }
  20096. if item.ChrgitmLv == "2" {
  20097. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20098. }
  20099. if item.ChrgitmLv == "3" {
  20100. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20101. }
  20102. }
  20103. if item.MedChrgitmType == "09" { //西药费
  20104. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20105. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20106. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20107. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20108. if item.ChrgitmLv == "1" {
  20109. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20110. }
  20111. if item.ChrgitmLv == "2" {
  20112. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20113. }
  20114. if item.ChrgitmLv == "3" {
  20115. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20116. }
  20117. }
  20118. if item.MedChrgitmType == "11" { //中成费
  20119. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20120. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20121. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20122. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20123. if item.ChrgitmLv == "1" {
  20124. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20125. }
  20126. if item.ChrgitmLv == "2" {
  20127. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20128. }
  20129. if item.ChrgitmLv == "3" {
  20130. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20131. }
  20132. }
  20133. if item.MedChrgitmType == "14" { //其他费
  20134. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20135. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20136. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20137. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20138. if item.ChrgitmLv == "1" {
  20139. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20140. }
  20141. if item.ChrgitmLv == "2" {
  20142. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20143. }
  20144. if item.ChrgitmLv == "3" {
  20145. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20146. }
  20147. }
  20148. }
  20149. var iteminfoStructs []service.IteminfoStruct
  20150. if bedCostTotal != 0 {
  20151. iteminfo.MedChrgitm = "01"
  20152. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20153. iteminfo.Amt = bedCostTotal
  20154. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20155. iteminfo.ClabAmt = bed_clab_amt
  20156. iteminfo.OthAmt = bed_other_amt
  20157. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20158. }
  20159. if checkCostTotal != 0 {
  20160. iteminfo.MedChrgitm = "03"
  20161. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20162. iteminfo.Amt = checkCostTotal
  20163. iteminfo.ClaaSumfee = check_claa_sunmfee
  20164. iteminfo.ClabAmt = check_clab_amt
  20165. iteminfo.OthAmt = check_other_amt
  20166. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20167. }
  20168. if laboratoryCostTotal != 0 {
  20169. iteminfo.MedChrgitm = "04"
  20170. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20171. iteminfo.Amt = laboratoryCostTotal
  20172. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20173. iteminfo.ClabAmt = laboratory_clab_amt
  20174. iteminfo.OthAmt = laboratory_other_amt
  20175. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20176. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20177. }
  20178. if treatCostTotal != 0 {
  20179. iteminfo.MedChrgitm = "05"
  20180. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20181. iteminfo.Amt = treatCostTotal
  20182. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20183. iteminfo.ClabAmt = treat_clab_amt
  20184. iteminfo.OthAmt = treat_other_amt
  20185. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20186. //(struct4101.IteminfoStruct, iteminfo)
  20187. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20188. }
  20189. if operationCostTotal != 0 {
  20190. iteminfo.MedChrgitm = "06"
  20191. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20192. iteminfo.Amt = operationCostTotal
  20193. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20194. iteminfo.ClabAmt = operation_clab_amt
  20195. iteminfo.OthAmt = operation_other_amt
  20196. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20197. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20198. }
  20199. if materialCostTotal != 0 {
  20200. iteminfo.MedChrgitm = "08"
  20201. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20202. iteminfo.Amt = materialCostTotal
  20203. iteminfo.ClaaSumfee = material_claa_sunmfee
  20204. iteminfo.ClabAmt = material_clab_amt
  20205. iteminfo.OthAmt = material_other_amt
  20206. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20207. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20208. }
  20209. if westernMedicineCostTotal != 0 {
  20210. iteminfo.MedChrgitm = "09"
  20211. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20212. iteminfo.Amt = westernMedicineCostTotal
  20213. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20214. iteminfo.ClabAmt = westernMedicine_clab_amt
  20215. iteminfo.OthAmt = westernMedicine_other_amt
  20216. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20217. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20218. }
  20219. if chineseTraditionalMedicineCostTotal != 0 {
  20220. iteminfo.MedChrgitm = "11"
  20221. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20222. iteminfo.Amt = westernMedicineCostTotal
  20223. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20224. iteminfo.ClabAmt = westernMedicine_clab_amt
  20225. iteminfo.OthAmt = westernMedicine_other_amt
  20226. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20227. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20228. }
  20229. if otherCostTotal != 0 {
  20230. iteminfo.MedChrgitm = "14"
  20231. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20232. iteminfo.Amt = otherCostTotal
  20233. iteminfo.ClaaSumfee = other_claa_sunmfee
  20234. iteminfo.ClabAmt = other_clab_amt
  20235. iteminfo.OthAmt = other_other_amt
  20236. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20237. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20238. }
  20239. struct4101.IteminfoStruct = iteminfoStructs
  20240. struct4101.Ntly = "中国"
  20241. struct4101.AdmCaty = "A03.06"
  20242. var resOther ResultSeventeenOther
  20243. var res ResultSeventeen
  20244. if miConfig.MdtrtareaAdmvs == "150499" {
  20245. var pp models.PublicParams
  20246. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20247. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20248. pp.FixmedinsName = miConfig.OrgName
  20249. pp.FixmedinsCode = miConfig.Code
  20250. pp.RequestUrl = miConfig.Url
  20251. pp.Cainfo = miConfig.Cainfo
  20252. pp.SecretKey = miConfig.SecretKey
  20253. pp.AccessKey = miConfig.AccessKey
  20254. pp.OpterName = curRoles.UserName
  20255. client := &http.Client{}
  20256. var req *http.Request
  20257. data := make(map[string]interface{})
  20258. data["struct4101"] = struct4101
  20259. data["pp"] = pp
  20260. bytesData, _ := json.Marshal(data)
  20261. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20262. resp, _ := client.Do(req)
  20263. defer resp.Body.Close()
  20264. body, ioErr := ioutil.ReadAll(resp.Body)
  20265. if ioErr != nil {
  20266. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20268. return
  20269. }
  20270. var respJSON map[string]interface{}
  20271. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20274. return
  20275. }
  20276. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20277. userJSONBytes, _ := json.Marshal(respJSON)
  20278. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20279. utils.ErrorLog("解析失败:%v", err)
  20280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20281. return
  20282. }
  20283. res.InfRefmsgid = resOther.InfRefmsgid
  20284. res.Output = resOther.Output
  20285. res.ErrMsg = resOther.ErrMsg
  20286. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20287. res.Infcode = infocode
  20288. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20289. var pp models.PublicParams
  20290. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20291. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20292. pp.FixmedinsName = miConfig.OrgName
  20293. pp.FixmedinsCode = miConfig.Code
  20294. pp.RequestUrl = miConfig.Url
  20295. pp.Cainfo = miConfig.Cainfo
  20296. pp.SecretKey = miConfig.SecretKey
  20297. pp.AccessKey = miConfig.AccessKey
  20298. pp.OpterName = curRoles.UserName
  20299. result, _ := service.Jxyb4101(struct4101, pp)
  20300. var dat map[string]interface{}
  20301. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20302. fmt.Println(dat)
  20303. } else {
  20304. fmt.Println(err)
  20305. }
  20306. userJSONBytes, _ := json.Marshal(dat)
  20307. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20308. utils.ErrorLog("解析失败:%v", err)
  20309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20310. return
  20311. }
  20312. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20313. var pp models.PublicParams
  20314. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20315. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20316. pp.FixmedinsName = miConfig.OrgName
  20317. pp.FixmedinsCode = miConfig.Code
  20318. pp.RequestUrl = miConfig.Url
  20319. pp.Cainfo = miConfig.Cainfo
  20320. pp.SecretKey = miConfig.SecretKey
  20321. pp.AccessKey = miConfig.AccessKey
  20322. pp.OpterName = curRoles.UserName
  20323. result, _ := service.Jxyb4101(struct4101, pp)
  20324. var dat map[string]interface{}
  20325. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20326. fmt.Println(dat)
  20327. } else {
  20328. fmt.Println(err)
  20329. }
  20330. userJSONBytes, _ := json.Marshal(dat)
  20331. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20332. utils.ErrorLog("解析失败:%v", err)
  20333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20334. return
  20335. }
  20336. } else {
  20337. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20338. var dat map[string]interface{}
  20339. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20340. fmt.Println(dat)
  20341. } else {
  20342. fmt.Println(err)
  20343. }
  20344. userJSONBytes, _ := json.Marshal(dat)
  20345. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20346. utils.ErrorLog("解析失败:%v", err)
  20347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20348. return
  20349. }
  20350. }
  20351. if res.Infcode != 0 {
  20352. c.ServeSuccessJSON(map[string]interface{}{
  20353. "failed_code": -10,
  20354. "msg": res.ErrMsg,
  20355. })
  20356. return
  20357. } else {
  20358. if miConfig.MdtrtareaAdmvs != "150499" {
  20359. order.FaPiaoNumber = zero
  20360. order.FaPiaoCode = last_order.FaPiaoCode
  20361. service.UpdateOrder(order)
  20362. }
  20363. hisFundSettleListResult := &models.HisFundSettleListResult{
  20364. Number: res.Output.SetlListId,
  20365. Status: 1,
  20366. Ctime: time.Now().Unix(),
  20367. Mtime: time.Now().Unix(),
  20368. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20369. IsUpload: 1,
  20370. OrderId: order_id,
  20371. }
  20372. service.CreateUploadRecord(hisFundSettleListResult)
  20373. c.ServeSuccessJSON(map[string]interface{}{
  20374. "msg": "上传成功",
  20375. "result": hisFundSettleListResult,
  20376. })
  20377. return
  20378. }
  20379. }
  20380. //func (c *HisApiController) GetBatchSettleList() {
  20381. // orders, _ := service.GetAllHisOrder(10106)
  20382. // for _, item := range orders {
  20383. // order_id := item.ID
  20384. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20385. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20386. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20387. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20388. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20389. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20390. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20391. //
  20392. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20393. //
  20394. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20395. //
  20396. // if order.ID == 0 {
  20397. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20398. // return
  20399. // }
  20400. // if his.BalanceAccountsType == 2 {
  20401. // continue
  20402. // }
  20403. // struct4101 := service.Struct4101{
  20404. // PsnNo: order.PsnNo,
  20405. // MdtrtId: order.MdtrtId,
  20406. // SetlId: order.SetlId,
  20407. // PsnName: order.PsnName,
  20408. // Gend: order.Gend,
  20409. // Brdy: his.Brdy,
  20410. // Age: his.Age,
  20411. // Naty: order.Naty,
  20412. // PatnCertType: "01",
  20413. // Certno: order.Certno,
  20414. // Prfs: "90",
  20415. // ConerName: roles[0].UserName,
  20416. // PatnRlts: "99",
  20417. // ConerAddr: miConfig.OrgName,
  20418. // ConerTel: admin.Mobile,
  20419. // HiType: order.Insutype,
  20420. // Insuplc: his.InsuplcAdmdvs,
  20421. // MaindiagFlag: "1",
  20422. // BillCode: order.SetlId,
  20423. // BillNo: order.SetlId,
  20424. // BizSn: order.Number,
  20425. // PsnSelfPay: order.PsnPartAmt,
  20426. // PsnOwnPay: order.PsnPartAmt,
  20427. // AcctPay: order.AcctPay,
  20428. // PsnCashpay: order.PsnCashPay,
  20429. // HiPaymtd: "1",
  20430. // Hsorg: his.InsuplcAdmdvs,
  20431. // HsorgOpter: his.InsuplcAdmdvs,
  20432. // MedinsFillPsn: curRoles.UserName,
  20433. // MedinsFillDept: depart.Name,
  20434. // IptMedType: "2",
  20435. // }
  20436. // struct4101.SetlBegnDate = order.SetlTime
  20437. // struct4101.SetlEndDate = order.SetlTime
  20438. // //if order.SettleType == 1 {
  20439. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20440. // // dateStr := t.Format("2006-01-02")
  20441. // // struct4101.SetlBegnDate = dateStr
  20442. // // struct4101.SetlEndDate = dateStr
  20443. // //} else {
  20444. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20445. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20446. // // dateStartStr := t.Format("2006-01-02")
  20447. // // dateEndStr := t2.Format("2006-01-02")
  20448. // // struct4101.SetlBegnDate = dateStartStr
  20449. // // struct4101.SetlEndDate = dateEndStr
  20450. // //}
  20451. //
  20452. // var rf []CustomFundPay
  20453. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20454. //
  20455. // var tempFunPays []service.CustomStruct
  20456. // var tempFunPay610100 service.CustomStruct
  20457. //
  20458. // for _, item := range rf {
  20459. // if item.FundPayType == "610100" {
  20460. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20461. // tempFunPay610100.FundPayType = item.FundPayType
  20462. // } else {
  20463. // var tempFunPay service.CustomStruct
  20464. // tempFunPay.FundPayamt = item.FundPayamt
  20465. // tempFunPay.FundPayType = item.FundPayType
  20466. // tempFunPays = append(tempFunPays, tempFunPay)
  20467. // }
  20468. // }
  20469. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20470. // struct4101.CustomStruct = tempFunPays
  20471. //
  20472. // var tempDiaginfos []service.DiaginfoStructTwo
  20473. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20474. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20475. //
  20476. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20477. // var config []*models.HisXtDiagnoseConfig
  20478. // for _, item := range diagnosis_ids {
  20479. // id, _ := strconv.ParseInt(item, 10, 64)
  20480. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20481. // config = append(config, &diagnosisConfig)
  20482. // }
  20483. //
  20484. // for index, item := range config {
  20485. // if index == 0 {
  20486. // var tempDiaginfo service.DiaginfoStructTwo
  20487. // tempDiaginfo.DiagCode = item.CountryCode
  20488. // tempDiaginfo.DiagName = item.CountryContentName
  20489. // tempDiaginfo.DiagType = "1"
  20490. // tempDiaginfo.MaindiagFlag = "1"
  20491. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20492. // } else {
  20493. //
  20494. // var tempDiaginfo service.DiaginfoStructTwo
  20495. // tempDiaginfo.DiagCode = item.CountryCode
  20496. // tempDiaginfo.DiagName = item.CountryContentName
  20497. // tempDiaginfo.DiagType = "2"
  20498. // tempDiaginfo.MaindiagFlag = "0"
  20499. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20500. // }
  20501. // }
  20502. // struct4101.Diseinfo = tempDiaginfos
  20503. //
  20504. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20505. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20506. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20507. // tempOpspdiseinfo2.OprnOprtCode = ""
  20508. // tempOpspdiseinfo2.OprnOprtName = ""
  20509. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20510. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20511. //
  20512. // var iteminfo service.IteminfoStruct
  20513. //
  20514. // var bedCostTotal float64 = 0 //床位总费
  20515. // var bedCostSelfTotal float64 = 0 //床位自费
  20516. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20517. //
  20518. // var examineCostTotal float64 = 0 //诊查总费
  20519. // var examineCostSelfTotal float64 = 0 //诊查自费
  20520. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  20521. //
  20522. // var nursingCostTotal float64 = 0 //护理总费
  20523. // var nursingCostSelfTotal float64 = 0 //护理自费
  20524. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  20525. //
  20526. // var chineseMedicineCostTotal float64 = 0 //中成药
  20527. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  20528. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  20529. //
  20530. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  20531. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  20532. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  20533. //
  20534. // var registerCostTotal float64 = 0 //一般诊疗费
  20535. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  20536. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  20537. //
  20538. // var operationCostTotal float64 = 0 //手术费
  20539. // var operationCostSelfTotal float64 = 0 //手术费
  20540. // var operationCostPartSelfTotal float64 = 0 //手术费
  20541. //
  20542. // var otherCostTotal float64 = 0 //其他费用
  20543. // var otherCostSelfTotal float64 = 0 //其他费用
  20544. // var otherCostPartSelfTotal float64 = 0 //其他费用
  20545. //
  20546. // var materialCostTotal float64 = 0 //材料费
  20547. // var materialCostSelfTotal float64 = 0 //材料费
  20548. // var materialCostPartSelfTotal float64 = 0 //材料费
  20549. //
  20550. // var westernMedicineCostTotal float64 = 0 //西药费
  20551. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  20552. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20553. //
  20554. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20555. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20556. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20557. //
  20558. // var checkCostTotal float64 = 0 //检查费
  20559. // var checkCostSelfTotal float64 = 0 //检查费
  20560. // var checkCostPartSelfTotal float64 = 0 //检查费
  20561. //
  20562. // var laboratoryCostTotal float64 = 0 //化验费
  20563. // var laboratoryCostSelfTotal float64 = 0 //化验费
  20564. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20565. //
  20566. // var treatCostTotal float64 = 0 //治疗费用
  20567. // var treatCostSelfTotal float64 = 0 //治疗费用
  20568. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  20569. //
  20570. // decimal.DivisionPrecision = 2
  20571. //
  20572. // var bed_fulamt_ownpay_amt float64 = 0
  20573. //
  20574. // var examine_fulamt_ownpay_amt float64 = 0
  20575. //
  20576. // var nursing_fulamt_ownpay_amt float64 = 0
  20577. //
  20578. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  20579. //
  20580. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  20581. //
  20582. // var register_fulamt_ownpay_amt float64 = 0
  20583. //
  20584. // var operation_fulamt_ownpay_amt float64 = 0
  20585. // var other_fulamt_ownpay_amt float64 = 0
  20586. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  20587. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20588. // var check_fulamt_ownpay_amt float64 = 0
  20589. // var material_fulamt_ownpay_amt float64 = 0
  20590. // var laboratory_fulamt_ownpay_amt float64 = 0
  20591. // var treat_fulamt_ownpay_amt float64 = 0
  20592. //
  20593. // var bed_claa_sunmfee float64 = 0
  20594. // var bed_clab_amt float64 = 0
  20595. // var bed_other_amt float64 = 0
  20596. //
  20597. // var examine_claa_sunmfee float64 = 0
  20598. // var examine_clab_amt float64 = 0
  20599. // var examine_other_amt float64 = 0
  20600. //
  20601. // var nursing_claa_sunmfee float64 = 0
  20602. // var nursing_clab_amt float64 = 0
  20603. // var nursing_other_amt float64 = 0
  20604. //
  20605. // var chinese_medicine_claa_sunmfee float64 = 0
  20606. // var chinese_medicine_clab_amt float64 = 0
  20607. // var chinese_medicine_other_amt float64 = 0
  20608. //
  20609. // var commonly_treatment_claa_sunmfee float64 = 0
  20610. // var commonly_treatment_clab_amt float64 = 0
  20611. // var commonly_treatment_other_amt float64 = 0
  20612. //
  20613. // var operation_claa_sunmfee float64 = 0
  20614. // var operation_clab_amt float64 = 0
  20615. // var operation_other_amt float64 = 0
  20616. //
  20617. // var other_claa_sunmfee float64 = 0
  20618. // var other_clab_amt float64 = 0
  20619. // var other_other_amt float64 = 0
  20620. //
  20621. // var westernMedicine_claa_sunmfee float64 = 0
  20622. // var westernMedicine_clab_amt float64 = 0
  20623. // var westernMedicine_other_amt float64 = 0
  20624. //
  20625. // var chineseTraditional_claa_sunmfee float64 = 0
  20626. // var chineseTraditional_clab_amt float64 = 0
  20627. // var chineseTraditional_other_amt float64 = 0
  20628. //
  20629. // var check_claa_sunmfee float64 = 0
  20630. // var check_clab_amt float64 = 0
  20631. // var check_other_amt float64 = 0
  20632. //
  20633. // var material_claa_sunmfee float64 = 0
  20634. // var material_clab_amt float64 = 0
  20635. // var material_other_amt float64 = 0
  20636. //
  20637. // var laboratory_claa_sunmfee float64 = 0
  20638. // var laboratory_clab_amt float64 = 0
  20639. // var laboratory_other_amt float64 = 0
  20640. //
  20641. // var treat_claa_sunmfee float64 = 0
  20642. // var treat_clab_amt float64 = 0
  20643. // var treat_other_amt float64 = 0
  20644. //
  20645. // var register_claa_sunmfee float64 = 0
  20646. // var register_clab_amt float64 = 0
  20647. // var register_other_amt float64 = 0
  20648. //
  20649. // for _, item := range order.HisOrderInfo {
  20650. // if item.MedChrgitmType == "01" { //床位费
  20651. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20652. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20653. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20654. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20655. // if item.ChrgitmLv == "1" {
  20656. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20657. // }
  20658. // if item.ChrgitmLv == "2" {
  20659. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20660. //
  20661. // }
  20662. // if item.ChrgitmLv == "3" {
  20663. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20664. // }
  20665. //
  20666. // }
  20667. //
  20668. // if item.MedChrgitmType == "02" { //诊查
  20669. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20670. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20671. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20672. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20673. // if item.ChrgitmLv == "1" {
  20674. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20675. // }
  20676. // if item.ChrgitmLv == "2" {
  20677. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20678. //
  20679. // }
  20680. // if item.ChrgitmLv == "3" {
  20681. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20682. // }
  20683. //
  20684. // }
  20685. //
  20686. // if item.MedChrgitmType == "03" { //检查费
  20687. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20688. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20689. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20690. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20691. // if item.ChrgitmLv == "1" {
  20692. //
  20693. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20694. //
  20695. // }
  20696. // if item.ChrgitmLv == "2" {
  20697. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20698. //
  20699. // }
  20700. // if item.ChrgitmLv == "3" {
  20701. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20702. // }
  20703. // }
  20704. //
  20705. // if item.MedChrgitmType == "04" { //化验费
  20706. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20707. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20708. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20709. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20710. // if item.ChrgitmLv == "1" {
  20711. //
  20712. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20713. //
  20714. // }
  20715. // if item.ChrgitmLv == "2" {
  20716. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20717. //
  20718. // }
  20719. // if item.ChrgitmLv == "3" {
  20720. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20721. // }
  20722. // }
  20723. //
  20724. // if item.MedChrgitmType == "05" { //治疗费
  20725. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20726. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20727. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20728. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20729. // if item.ChrgitmLv == "1" {
  20730. //
  20731. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20732. //
  20733. // }
  20734. // if item.ChrgitmLv == "2" {
  20735. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20736. //
  20737. // }
  20738. // if item.ChrgitmLv == "3" {
  20739. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20740. // }
  20741. // }
  20742. //
  20743. // if item.MedChrgitmType == "06" { //手术费
  20744. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20745. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20746. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20747. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20748. //
  20749. // if item.ChrgitmLv == "1" {
  20750. //
  20751. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20752. //
  20753. // }
  20754. // if item.ChrgitmLv == "2" {
  20755. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20756. //
  20757. // }
  20758. // if item.ChrgitmLv == "3" {
  20759. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20760. // }
  20761. // }
  20762. //
  20763. // if item.MedChrgitmType == "07" { //手术费
  20764. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20765. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20766. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20767. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20768. //
  20769. // if item.ChrgitmLv == "1" {
  20770. //
  20771. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20772. //
  20773. // }
  20774. // if item.ChrgitmLv == "2" {
  20775. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20776. //
  20777. // }
  20778. // if item.ChrgitmLv == "3" {
  20779. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20780. // }
  20781. // }
  20782. //
  20783. // if item.MedChrgitmType == "08" { //材料费
  20784. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20785. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20786. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20787. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20788. // if item.ChrgitmLv == "1" {
  20789. //
  20790. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20791. //
  20792. // }
  20793. // if item.ChrgitmLv == "2" {
  20794. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20795. //
  20796. // }
  20797. // if item.ChrgitmLv == "3" {
  20798. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20799. // }
  20800. // }
  20801. // if item.MedChrgitmType == "09" { //西药费
  20802. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20803. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20804. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20805. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20806. // if item.ChrgitmLv == "1" {
  20807. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20808. // }
  20809. // if item.ChrgitmLv == "2" {
  20810. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20811. // }
  20812. // if item.ChrgitmLv == "3" {
  20813. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20814. // }
  20815. // }
  20816. // if item.MedChrgitmType == "10" { //中药饮片
  20817. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20818. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20819. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20820. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20821. // if item.ChrgitmLv == "1" {
  20822. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20823. // }
  20824. // if item.ChrgitmLv == "2" {
  20825. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20826. // }
  20827. // if item.ChrgitmLv == "3" {
  20828. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20829. // }
  20830. // }
  20831. //
  20832. // if item.MedChrgitmType == "11" { //中成费
  20833. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20834. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20835. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20836. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20837. // if item.ChrgitmLv == "1" {
  20838. //
  20839. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20840. //
  20841. // }
  20842. // if item.ChrgitmLv == "2" {
  20843. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20844. //
  20845. // }
  20846. // if item.ChrgitmLv == "3" {
  20847. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20848. // }
  20849. // }
  20850. //
  20851. // if item.MedChrgitmType == "12" { //中成费
  20852. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20853. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20854. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20855. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20856. // if item.ChrgitmLv == "1" {
  20857. //
  20858. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20859. //
  20860. // }
  20861. // if item.ChrgitmLv == "2" {
  20862. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20863. //
  20864. // }
  20865. // if item.ChrgitmLv == "3" {
  20866. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20867. // }
  20868. // }
  20869. //
  20870. // if item.MedChrgitmType == "13" { //中成费
  20871. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20872. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20873. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20874. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20875. // if item.ChrgitmLv == "1" {
  20876. //
  20877. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20878. //
  20879. // }
  20880. // if item.ChrgitmLv == "2" {
  20881. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20882. //
  20883. // }
  20884. // if item.ChrgitmLv == "3" {
  20885. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20886. // }
  20887. // }
  20888. //
  20889. // if item.MedChrgitmType == "14" { //其他费
  20890. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20891. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20892. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20893. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20894. // if item.ChrgitmLv == "1" {
  20895. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20896. //
  20897. // }
  20898. // if item.ChrgitmLv == "2" {
  20899. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20900. //
  20901. // }
  20902. // if item.ChrgitmLv == "3" {
  20903. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20904. // }
  20905. // }
  20906. //
  20907. // }
  20908. //
  20909. // var iteminfoStructs []service.IteminfoStruct
  20910. //
  20911. // if bedCostTotal != 0 {
  20912. // iteminfo.MedChrgitm = "01"
  20913. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20914. // iteminfo.Amt = bedCostTotal
  20915. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  20916. // iteminfo.ClabAmt = bed_clab_amt
  20917. // iteminfo.OthAmt = bed_other_amt
  20918. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20919. // }
  20920. //
  20921. // if examineCostTotal != 0 {
  20922. // iteminfo.MedChrgitm = "02"
  20923. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  20924. // iteminfo.Amt = examineCostTotal
  20925. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  20926. // iteminfo.ClabAmt = examine_clab_amt
  20927. // iteminfo.OthAmt = examine_other_amt
  20928. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20929. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20930. // }
  20931. //
  20932. // if checkCostTotal != 0 {
  20933. // iteminfo.MedChrgitm = "03"
  20934. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20935. // iteminfo.Amt = checkCostTotal
  20936. // iteminfo.ClaaSumfee = check_claa_sunmfee
  20937. // iteminfo.ClabAmt = check_clab_amt
  20938. // iteminfo.OthAmt = check_other_amt
  20939. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20940. //
  20941. // }
  20942. //
  20943. // if laboratoryCostTotal != 0 {
  20944. // iteminfo.MedChrgitm = "04"
  20945. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20946. // iteminfo.Amt = laboratoryCostTotal
  20947. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20948. // iteminfo.ClabAmt = laboratory_clab_amt
  20949. // iteminfo.OthAmt = laboratory_other_amt
  20950. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20951. //
  20952. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20953. //
  20954. // }
  20955. //
  20956. // if treatCostTotal != 0 {
  20957. // iteminfo.MedChrgitm = "05"
  20958. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20959. // iteminfo.Amt = treatCostTotal
  20960. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  20961. // iteminfo.ClabAmt = treat_clab_amt
  20962. // iteminfo.OthAmt = treat_other_amt
  20963. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20964. // //(struct4101.IteminfoStruct, iteminfo)
  20965. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20966. // }
  20967. //
  20968. // if operationCostTotal != 0 {
  20969. // iteminfo.MedChrgitm = "06"
  20970. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20971. // iteminfo.Amt = operationCostTotal
  20972. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  20973. // iteminfo.ClabAmt = operation_clab_amt
  20974. // iteminfo.OthAmt = operation_other_amt
  20975. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20976. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20977. // }
  20978. //
  20979. // if nursingCostTotal != 0 {
  20980. // iteminfo.MedChrgitm = "07"
  20981. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  20982. // iteminfo.Amt = nursingCostTotal
  20983. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  20984. // iteminfo.ClabAmt = nursing_clab_amt
  20985. // iteminfo.OthAmt = nursing_other_amt
  20986. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20987. // }
  20988. //
  20989. // if materialCostTotal != 0 {
  20990. // iteminfo.MedChrgitm = "08"
  20991. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20992. // iteminfo.Amt = materialCostTotal
  20993. // iteminfo.ClaaSumfee = material_claa_sunmfee
  20994. // iteminfo.ClabAmt = material_clab_amt
  20995. // iteminfo.OthAmt = material_other_amt
  20996. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20997. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20998. // }
  20999. //
  21000. // if westernMedicineCostTotal != 0 {
  21001. // iteminfo.MedChrgitm = "09"
  21002. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21003. // iteminfo.Amt = westernMedicineCostTotal
  21004. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21005. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21006. // iteminfo.OthAmt = westernMedicine_other_amt
  21007. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21008. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21009. //
  21010. // }
  21011. //
  21012. // if chineseMedicineCostTotal != 0 {
  21013. // iteminfo.MedChrgitm = "10"
  21014. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  21015. // iteminfo.Amt = chineseMedicineCostTotal
  21016. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  21017. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  21018. // iteminfo.OthAmt = chinese_medicine_other_amt
  21019. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21020. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21021. //
  21022. // }
  21023. //
  21024. // if chineseTraditionalMedicineCostTotal != 0 {
  21025. // iteminfo.MedChrgitm = "11"
  21026. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21027. // iteminfo.Amt = westernMedicineCostTotal
  21028. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21029. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21030. // iteminfo.OthAmt = westernMedicine_other_amt
  21031. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21032. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21033. //
  21034. // }
  21035. //
  21036. // if commonlyTreatmentCostTotal != 0 {
  21037. // iteminfo.MedChrgitm = "12"
  21038. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  21039. // iteminfo.Amt = commonlyTreatmentCostTotal
  21040. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  21041. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  21042. // iteminfo.OthAmt = commonly_treatment_other_amt
  21043. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21044. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21045. //
  21046. // }
  21047. //
  21048. // if registerCostTotal != 0 {
  21049. // iteminfo.MedChrgitm = "13"
  21050. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  21051. // iteminfo.Amt = registerCostTotal
  21052. // iteminfo.ClaaSumfee = register_claa_sunmfee
  21053. // iteminfo.ClabAmt = register_clab_amt
  21054. // iteminfo.OthAmt = register_other_amt
  21055. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21056. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21057. //
  21058. // }
  21059. //
  21060. // if otherCostTotal != 0 {
  21061. // iteminfo.MedChrgitm = "14"
  21062. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21063. // iteminfo.Amt = otherCostTotal
  21064. // iteminfo.ClaaSumfee = other_claa_sunmfee
  21065. // iteminfo.ClabAmt = other_clab_amt
  21066. // iteminfo.OthAmt = other_other_amt
  21067. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21068. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21069. //
  21070. // }
  21071. // struct4101.IteminfoStruct = iteminfoStructs
  21072. // time_arr := strings.Split(order.SetlTime, " ")
  21073. // struct4101.AdmTime = time_arr[0]
  21074. // struct4101.AdmEndTime = time_arr[0]
  21075. //
  21076. // struct4101.DoctorName = doctor.UserName
  21077. // struct4101.DoctorCode = doctor.DoctorNumber
  21078. //
  21079. // struct4101.Ntly = "中国"
  21080. // struct4101.AdmCaty = "A03.06"
  21081. // var res ResultSeventeen
  21082. // if miConfig.MdtrtareaAdmvs == "421300" {
  21083. // data := make(map[string]interface{})
  21084. // data["struct4101"] = struct4101
  21085. // data["secret_key"] = miConfig.SecretKey
  21086. // data["org_name"] = miConfig.OrgName
  21087. // data["opera"] = curRoles.UserName
  21088. // data["code"] = miConfig.Code
  21089. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21090. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21091. //
  21092. // client := &http.Client{}
  21093. // bytesData, _ := json.Marshal(data)
  21094. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21095. // resp, _ := client.Do(req)
  21096. // defer resp.Body.Close()
  21097. // body, ioErr := ioutil.ReadAll(resp.Body)
  21098. // if ioErr != nil {
  21099. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21101. // return
  21102. // }
  21103. // var respJSON map[string]interface{}
  21104. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21105. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21107. // return
  21108. // }
  21109. //
  21110. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21111. // userJSONBytes, _ := json.Marshal(respJSON)
  21112. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21113. // utils.ErrorLog("解析失败:%v", err)
  21114. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21115. // adminUser := c.GetAdminUserInfo()
  21116. // errlog := &models.HisOrderError{
  21117. // UserOrgId: adminUser.CurrentOrgId,
  21118. // Ctime: time.Now().Unix(),
  21119. // Mtime: time.Now().Unix(),
  21120. // ErrMsg: res.ErrMsg + "解析失败",
  21121. // Status: 1,
  21122. // PatientId: order_id,
  21123. // Stage: 10088,
  21124. // }
  21125. // service.CreateErrMsgLog(errlog)
  21126. // continue
  21127. // }
  21128. //
  21129. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  21130. // data := make(map[string]interface{})
  21131. // data["struct4101"] = struct4101
  21132. // data["secret_key"] = miConfig.SecretKey
  21133. // data["org_name"] = miConfig.OrgName
  21134. // data["opera"] = curRoles.UserName
  21135. // data["code"] = miConfig.Code
  21136. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21137. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21138. //
  21139. // client := &http.Client{}
  21140. // bytesData, _ := json.Marshal(data)
  21141. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21142. // resp, _ := client.Do(req)
  21143. // defer resp.Body.Close()
  21144. // body, ioErr := ioutil.ReadAll(resp.Body)
  21145. // if ioErr != nil {
  21146. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21147. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21148. // return
  21149. // }
  21150. // var respJSON map[string]interface{}
  21151. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21152. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21153. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21154. // return
  21155. // }
  21156. //
  21157. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21158. // userJSONBytes, _ := json.Marshal(respJSON)
  21159. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21160. // utils.ErrorLog("解析失败:%v", err)
  21161. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21162. // adminUser := c.GetAdminUserInfo()
  21163. // errlog := &models.HisOrderError{
  21164. // UserOrgId: adminUser.CurrentOrgId,
  21165. // Ctime: time.Now().Unix(),
  21166. // Mtime: time.Now().Unix(),
  21167. // ErrMsg: res.ErrMsg + "解析失败",
  21168. // Status: 1,
  21169. // PatientId: order_id,
  21170. // Stage: 10088,
  21171. // }
  21172. // service.CreateErrMsgLog(errlog)
  21173. // continue
  21174. // }
  21175. //
  21176. // } else {
  21177. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  21178. // fmt.Println(result)
  21179. //
  21180. // var dat map[string]interface{}
  21181. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21182. // fmt.Println(dat)
  21183. // } else {
  21184. // fmt.Println(err)
  21185. // }
  21186. // userJSONBytes, _ := json.Marshal(dat)
  21187. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21188. // utils.ErrorLog("解析失败:%v", err)
  21189. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21190. // adminUser := c.GetAdminUserInfo()
  21191. // errlog := &models.HisOrderError{
  21192. // UserOrgId: adminUser.CurrentOrgId,
  21193. // Ctime: time.Now().Unix(),
  21194. // Mtime: time.Now().Unix(),
  21195. // ErrMsg: res.ErrMsg + "解析失败",
  21196. // Status: 1,
  21197. // PatientId: order_id,
  21198. // Stage: 10106,
  21199. // }
  21200. // service.CreateErrMsgLog(errlog)
  21201. // continue
  21202. // }
  21203. // }
  21204. //
  21205. // if res.Infcode != 0 {
  21206. // adminUser := c.GetAdminUserInfo()
  21207. // errlog := &models.HisOrderError{
  21208. // UserOrgId: adminUser.CurrentOrgId,
  21209. // Ctime: time.Now().Unix(),
  21210. // Mtime: time.Now().Unix(),
  21211. // ErrMsg: res.ErrMsg,
  21212. // Status: 1,
  21213. // PatientId: order_id,
  21214. // Stage: 10106,
  21215. // }
  21216. // service.CreateErrMsgLog(errlog)
  21217. // continue
  21218. // } else {
  21219. // hisFundSettleListResult := &models.HisFundSettleListResult{
  21220. // Number: res.Output.SetlListId,
  21221. // Status: 1,
  21222. // Ctime: time.Now().Unix(),
  21223. // Mtime: time.Now().Unix(),
  21224. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21225. // IsUpload: 1,
  21226. // OrderId: order_id,
  21227. // }
  21228. // service.CreateUploadRecord(hisFundSettleListResult)
  21229. // continue
  21230. // }
  21231. // }
  21232. //}
  21233. func (c *HisApiController) GetOrgInfo() {
  21234. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  21235. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  21236. }
  21237. func (c *HisApiController) GetHisPatientInfo() {
  21238. medical_insurance_card := c.GetString("medical_insurance_card")
  21239. id_card_type, _ := c.GetInt64("id_card_type")
  21240. id_card := c.GetString("id_card")
  21241. adminInfo := c.GetAdminUserInfo()
  21242. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21243. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21244. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  21245. IdCardNo := ""
  21246. if id_card_type == 1 {
  21247. IdCardNo = medical_insurance_card
  21248. } else if id_card_type == 2 {
  21249. IdCardNo = id_card
  21250. }
  21251. if config.IsOpen == 1 {
  21252. 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
  21253. resp, requestErr := http.Get(api)
  21254. if requestErr != nil {
  21255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21256. return
  21257. }
  21258. defer resp.Body.Close()
  21259. body, ioErr := ioutil.ReadAll(resp.Body)
  21260. if ioErr != nil {
  21261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21263. return
  21264. }
  21265. var respJSON map[string]interface{}
  21266. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21269. return
  21270. }
  21271. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21272. userJSONBytes, _ := json.Marshal(userJSON)
  21273. var res ResultTwo
  21274. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21275. utils.ErrorLog("解析失败:%v", err)
  21276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21277. return
  21278. }
  21279. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21280. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21281. infoStr := string(Iinfos)
  21282. idetinfoStr := string(Idetinfos)
  21283. if res.Infcode == 0 {
  21284. his := models.VMHisPatient{
  21285. Status: 1,
  21286. Ctime: time.Now().Unix(),
  21287. Mtime: time.Now().Unix(),
  21288. PsnNo: res.Output.Baseinfo.PsnNo,
  21289. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21290. Certno: res.Output.Baseinfo.Certno,
  21291. PsnName: res.Output.Baseinfo.PsnName,
  21292. Gend: res.Output.Baseinfo.Gend,
  21293. Naty: res.Output.Baseinfo.Naty,
  21294. Iinfo: infoStr,
  21295. Idetinfo: idetinfoStr,
  21296. UserOrgId: adminInfo.CurrentOrgId,
  21297. IsReturn: 1,
  21298. IdCardType: id_card_type,
  21299. }
  21300. c.ServeSuccessJSON(map[string]interface{}{
  21301. "info": his,
  21302. })
  21303. } else {
  21304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21305. return
  21306. }
  21307. }
  21308. }
  21309. //func GetBasBaseInfo() (jsonStr string, err error) {
  21310. //
  21311. // handle := syscall.NewLazyDLL("SSCard.dll")
  21312. // add := handle.NewProc("ReadCardBas")
  21313. // str := make([]byte, 1024)
  21314. // str1 := make([]byte, 1024)
  21315. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21316. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  21317. //
  21318. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  21319. //
  21320. // fmt.Println("> Add(4,5)的结果为:", ret)
  21321. // handle.Release()
  21322. //
  21323. // return "", nil
  21324. //
  21325. //}
  21326. //func GetQRBaseInfo() (jsonStr string, err error) {
  21327. // handle := syscall.LoadDLL("SSCard.dll")
  21328. // ReadCardBas := handle.FindProc("GetQRBase")
  21329. //
  21330. // str := make([]byte, 256)
  21331. // str1 := make([]byte, 256)
  21332. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21333. //
  21334. // fmt.Println(string(str))
  21335. // fmt.Println(r)
  21336. // return string(str), nil
  21337. //}
  21338. //func CardInit() int {
  21339. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21340. // add := DllTestDef.MustFindProc("Init")
  21341. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21342. // if err != nil {
  21343. // fmt.Println("SSCard的运算结果为:", ret)
  21344. // }
  21345. // result := int(ret)
  21346. // return result
  21347. //}
  21348. //func CardInit() int {
  21349. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21350. // if err != nil {
  21351. // fmt.Println("SSCard的运算结果为:", ret)
  21352. // }
  21353. // fmt.Println(err)
  21354. // result := int(ret)
  21355. // return result
  21356. //}
  21357. func IntPtr(n int) uintptr {
  21358. return uintptr(n)
  21359. }
  21360. func StrPtr(s string) uintptr {
  21361. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21362. }
  21363. type Result2001 struct {
  21364. Cainfo interface{} `json:"cainfo"`
  21365. ErrMsg string `json:"err_msg"`
  21366. InfRefmsgid string `json:"inf_refmsgid"`
  21367. Infcode int64 `json:"infcode"`
  21368. Output struct {
  21369. Trtinfo struct {
  21370. PsnNo string `json:"psn_no"`
  21371. TrtChkType string `json:"trt_chk_type"`
  21372. FundPayType string `json:"fund_pay_type"`
  21373. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21374. Begndate string `json:"begndate"`
  21375. Enddate string `json:"enddate"`
  21376. TrtChkRslt string `json:"trt_chk_rslt"`
  21377. } `json:"trtinfo"`
  21378. } `json:"output"`
  21379. RefmsgTime string `json:"refmsg_time"`
  21380. RespondTime string `json:"respond_time"`
  21381. Signtype interface{} `json:"signtype"`
  21382. WarnMsg interface{} `json:"warn_msg"`
  21383. }
  21384. type Result2001Org10265 struct {
  21385. Cainfo interface{} `json:"cainfo"`
  21386. ErrMsg string `json:"err_msg"`
  21387. InfRefmsgid string `json:"inf_refmsgid"`
  21388. Infcode string `json:"infcode"`
  21389. Output struct {
  21390. Trtinfo struct {
  21391. PsnNo string `json:"psn_no"`
  21392. TrtChkType string `json:"trt_chk_type"`
  21393. FundPayType string `json:"fund_pay_type"`
  21394. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21395. Begndate string `json:"begndate"`
  21396. Enddate string `json:"enddate"`
  21397. TrtChkRslt string `json:"trt_chk_rslt"`
  21398. } `json:"trtinfo"`
  21399. } `json:"output"`
  21400. RefmsgTime string `json:"refmsg_time"`
  21401. RespondTime string `json:"respond_time"`
  21402. Signtype interface{} `json:"signtype"`
  21403. WarnMsg interface{} `json:"warn_msg"`
  21404. }
  21405. type ResultTwo struct {
  21406. ErrMsg string `json:"err_msg"`
  21407. InfRefmsgid string `json:"inf_refmsgid"`
  21408. Infcode int64 `json:"infcode"`
  21409. Output struct {
  21410. Baseinfo struct {
  21411. //Brdy string `json:"brdy"`
  21412. Certno string `json:"certno"`
  21413. Gend string `json:"gend"`
  21414. Naty string `json:"naty"`
  21415. PsnCertType string `json:"psn_cert_type"`
  21416. PsnName string `json:"psn_name"`
  21417. PsnNo string `json:"psn_no"`
  21418. } `json:"baseinfo"`
  21419. Idetinfo []interface{} `json:"idetinfo"`
  21420. Iinfo []struct {
  21421. Balc float64 `json:"balc"`
  21422. CvlservFlag string `json:"cvlserv_flag"`
  21423. EmpName string `json:"emp_name"`
  21424. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21425. Insutype string `json:"insutype"`
  21426. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21427. //PausInsuDate string `json:"paus_insu_date"`
  21428. //PsnInsuDate string `json:"psn_insu_date"`
  21429. PsnInsuStas string `json:"psn_insu_stas"`
  21430. PsnType string `json:"psn_type"`
  21431. } `json:"insuinfo"`
  21432. } `json:"output"`
  21433. RefmsgTime string `json:"refmsg_time"`
  21434. RespondTime string `json:"respond_time"`
  21435. Signtype interface{} `json:"signtype"`
  21436. WarnInfo interface{} `json:"warn_info"`
  21437. }
  21438. type ResultTwo10265 struct {
  21439. ErrMsg string `json:"err_msg"`
  21440. InfRefmsgid string `json:"inf_refmsgid"`
  21441. Infcode string `json:"infcode"`
  21442. Output struct {
  21443. Baseinfo struct {
  21444. //Brdy string `json:"brdy"`
  21445. Certno string `json:"certno"`
  21446. Gend string `json:"gend"`
  21447. Naty string `json:"naty"`
  21448. PsnCertType string `json:"psn_cert_type"`
  21449. PsnName string `json:"psn_name"`
  21450. PsnNo string `json:"psn_no"`
  21451. } `json:"baseinfo"`
  21452. Idetinfo []interface{} `json:"idetinfo"`
  21453. Iinfo []struct {
  21454. Balc float64 `json:"balc"`
  21455. CvlservFlag string `json:"cvlserv_flag"`
  21456. EmpName string `json:"emp_name"`
  21457. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21458. Insutype string `json:"insutype"`
  21459. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21460. PsnInsuStas string `json:"psn_insu_stas"`
  21461. PsnType string `json:"psn_type"`
  21462. } `json:"insuinfo"`
  21463. } `json:"output"`
  21464. RefmsgTime string `json:"refmsg_time"`
  21465. RespondTime string `json:"respond_time"`
  21466. Signtype interface{} `json:"signtype"`
  21467. WarnInfo interface{} `json:"warn_info"`
  21468. }
  21469. type ResultThree struct {
  21470. Cainfo interface{} `json:"cainfo"`
  21471. ErrMsg string `json:"err_msg"`
  21472. InfRefmsgid string `json:"inf_refmsgid"`
  21473. Infcode int64 `json:"infcode"`
  21474. Output struct {
  21475. Data struct {
  21476. IptOtpNo string `json:"ipt_otp_no"`
  21477. MdtrtID string `json:"mdtrt_id"`
  21478. PsnNo string `json:"psn_no"`
  21479. } `json:"data"`
  21480. } `json:"output"`
  21481. RefmsgTime string `json:"refmsg_time"`
  21482. RespondTime string `json:"respond_time"`
  21483. Signtype interface{} `json:"signtype"`
  21484. WarnMsg interface{} `json:"warn_msg"`
  21485. }
  21486. type ResultThree10265 struct {
  21487. Cainfo interface{} `json:"cainfo"`
  21488. ErrMsg string `json:"err_msg"`
  21489. InfRefmsgid string `json:"inf_refmsgid"`
  21490. Infcode string `json:"infcode"`
  21491. Output struct {
  21492. Data struct {
  21493. IptOtpNo string `json:"ipt_otp_no"`
  21494. MdtrtID string `json:"mdtrt_id"`
  21495. PsnNo string `json:"psn_no"`
  21496. } `json:"data"`
  21497. } `json:"output"`
  21498. RefmsgTime string `json:"refmsg_time"`
  21499. RespondTime string `json:"respond_time"`
  21500. Signtype interface{} `json:"signtype"`
  21501. WarnMsg interface{} `json:"warn_msg"`
  21502. }
  21503. type ResultFour struct {
  21504. Cainfo string `json:"cainfo"`
  21505. ErrMsg string `json:"err_msg"`
  21506. InfRefmsgid string `json:"inf_refmsgid"`
  21507. Infcode int64 `json:"infcode"`
  21508. Output struct {
  21509. Result []struct {
  21510. BasMednFlag string `json:"bas_medn_flag"`
  21511. ChldMedcFlag string `json:"chld_medc_flag"`
  21512. ChrgitmLv string `json:"chrgitm_lv"`
  21513. Cnt float64 `json:"cnt"`
  21514. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21515. DrtReimFlag string `json:"drt_reim_flag"`
  21516. FeedetlSn string `json:"feedetl_sn"`
  21517. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21518. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21519. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21520. ListSpItemFlag string `json:"list_sp_item_flag"`
  21521. LmtUsedFlag string `json:"lmt_used_flag"`
  21522. MedChrgitmType string `json:"med_chrgitm_type"`
  21523. Memo string `json:"memo"`
  21524. OverlmtAmt float64 `json:"overlmt_amt"`
  21525. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21526. Pric float64 `json:"pric"`
  21527. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21528. SelfpayProp float64 `json:"selfpay_prop"`
  21529. } `json:"result"`
  21530. } `json:"output"`
  21531. RefmsgTime string `json:"refmsg_time"`
  21532. RespondTime string `json:"respond_time"`
  21533. Signtype string `json:"signtype"`
  21534. WarnMsg string `json:"warn_msg"`
  21535. }
  21536. type ResultFour10265 struct {
  21537. Cainfo string `json:"cainfo"`
  21538. ErrMsg string `json:"err_msg"`
  21539. InfRefmsgid string `json:"inf_refmsgid"`
  21540. Infcode string `json:"infcode"`
  21541. Output struct {
  21542. Result []struct {
  21543. BasMednFlag string `json:"bas_medn_flag"`
  21544. ChldMedcFlag string `json:"chld_medc_flag"`
  21545. ChrgitmLv string `json:"chrgitm_lv"`
  21546. Cnt float64 `json:"cnt"`
  21547. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21548. DrtReimFlag string `json:"drt_reim_flag"`
  21549. FeedetlSn string `json:"feedetl_sn"`
  21550. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21551. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21552. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21553. ListSpItemFlag string `json:"list_sp_item_flag"`
  21554. LmtUsedFlag string `json:"lmt_used_flag"`
  21555. MedChrgitmType string `json:"med_chrgitm_type"`
  21556. Memo string `json:"memo"`
  21557. OverlmtAmt float64 `json:"overlmt_amt"`
  21558. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21559. Pric float64 `json:"pric"`
  21560. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21561. SelfpayProp float64 `json:"selfpay_prop"`
  21562. } `json:"result"`
  21563. } `json:"output"`
  21564. RefmsgTime string `json:"refmsg_time"`
  21565. RespondTime string `json:"respond_time"`
  21566. Signtype string `json:"signtype"`
  21567. WarnMsg string `json:"warn_msg"`
  21568. }
  21569. type ResultMemo struct {
  21570. InsuAdmdvs string `json:"insuAdmdvs"`
  21571. }
  21572. // [{"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}]
  21573. type ResultIDInfo struct {
  21574. Begntime string `json:"begntime"`
  21575. Endtime string `json:"endtime"`
  21576. Memo string `json:"memo"`
  21577. }
  21578. type ResultFive struct {
  21579. Balc float64 `json:"balc"`
  21580. CvlservFlag string `json:"cvlserv_flag"`
  21581. EmpName string `json:"emp_name"`
  21582. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21583. Insutype string `json:"insutype"`
  21584. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21585. PausInsuDate string `json:"paus_insu_date"`
  21586. PsnInsuDate string `json:"psn_insu_date"`
  21587. PsnInsuStas string `json:"psn_insu_stas"`
  21588. PsnType string `json:"psn_type"`
  21589. }
  21590. type ResultSix struct {
  21591. Cainfo interface{} `json:"cainfo"`
  21592. ErrMsg string `json:"err_msg"`
  21593. InfRefmsgid string `json:"inf_refmsgid"`
  21594. Infcode int64 `json:"infcode"`
  21595. Output struct {
  21596. } `json:"output"`
  21597. RefmsgTime string `json:"refmsg_time"`
  21598. RespondTime string `json:"respond_time"`
  21599. Signtype interface{} `json:"signtype"`
  21600. WarnMsg interface{} `json:"warn_msg"`
  21601. }
  21602. type FJ3507Result struct {
  21603. Cainfo interface{} `json:"cainfo"`
  21604. ErrMsg string `json:"err_msg"`
  21605. InfRefmsgid string `json:"inf_refmsgid"`
  21606. Infcode int64 `json:"infcode"`
  21607. Output struct {
  21608. retRslt string `json:"retRslt"`
  21609. msgRslt string `json:"msgRslt"`
  21610. } `json:"output"`
  21611. RefmsgTime string `json:"refmsg_time"`
  21612. RespondTime string `json:"respond_time"`
  21613. Signtype interface{} `json:"signtype"`
  21614. WarnMsg interface{} `json:"warn_msg"`
  21615. }
  21616. type FJ3507ResultFor10188 struct {
  21617. Cainfo interface{} `json:"cainfo"`
  21618. ErrMsg string `json:"err_msg"`
  21619. InfRefmsgid string `json:"inf_refmsgid"`
  21620. Infcode string `json:"infcode"`
  21621. RefmsgTime string `json:"refmsg_time"`
  21622. RespondTime string `json:"respond_time"`
  21623. Signtype interface{} `json:"signtype"`
  21624. WarnMsg interface{} `json:"warn_msg"`
  21625. }
  21626. type Result2406 struct {
  21627. Cainfo interface{} `json:"cainfo"`
  21628. ErrMsg string `json:"err_msg"`
  21629. InfRefmsgid string `json:"inf_refmsgid"`
  21630. Infcode int64 `json:"infcode"`
  21631. Output struct {
  21632. Result struct {
  21633. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  21634. } `json:"result"`
  21635. } `json:"output"`
  21636. RefmsgTime string `json:"refmsg_time"`
  21637. RespondTime string `json:"respond_time"`
  21638. Signtype interface{} `json:"signtype"`
  21639. WarnMsg interface{} `json:"warn_msg"`
  21640. }
  21641. type GZResultSix struct {
  21642. Cainfo interface{} `json:"cainfo"`
  21643. ErrMsg string `json:"err_msg"`
  21644. InfRefmsgid string `json:"inf_refmsgid"`
  21645. Infcode int64 `json:"infcode"`
  21646. Output string `json:"output"`
  21647. RefmsgTime string `json:"refmsg_time"`
  21648. RespondTime string `json:"respond_time"`
  21649. Signtype interface{} `json:"signtype"`
  21650. WarnMsg interface{} `json:"warn_msg"`
  21651. }
  21652. type ResultSix10265 struct {
  21653. Cainfo interface{} `json:"cainfo"`
  21654. ErrMsg string `json:"err_msg"`
  21655. InfRefmsgid string `json:"inf_refmsgid"`
  21656. Infcode string `json:"infcode"`
  21657. Output struct {
  21658. } `json:"output"`
  21659. RefmsgTime string `json:"refmsg_time"`
  21660. RespondTime string `json:"respond_time"`
  21661. Signtype interface{} `json:"signtype"`
  21662. WarnMsg interface{} `json:"warn_msg"`
  21663. }
  21664. type ResultSeven struct {
  21665. Cainfo string `json:"cainfo"`
  21666. ErrMsg string `json:"err_msg"`
  21667. InfRefmsgid string `json:"inf_refmsgid"`
  21668. Infcode int64 `json:"infcode"`
  21669. Output struct {
  21670. Setlinfo struct {
  21671. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21672. AcctPay float64 `json:"acct_pay"`
  21673. ActPayDedc float64 `json:"act_pay_dedc"`
  21674. Age float64 `json:"age"`
  21675. Balc float64 `json:"balc"`
  21676. Certno string `json:"certno"`
  21677. ClrOptins string `json:"clr_optins"`
  21678. ClrType string `json:"clr_type"`
  21679. ClrWay string `json:"clr_way"`
  21680. CvlservFlag string `json:"cvlserv_flag"`
  21681. CvlservPay float64 `json:"cvlserv_pay"`
  21682. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21683. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21684. Gend string `json:"gend"`
  21685. HifesPay float64 `json:"hifes_pay"`
  21686. HifmiPay float64 `json:"hifmi_pay"`
  21687. HifpPay float64 `json:"hifp_pay"`
  21688. HospPartAmt float64 `json:"hosp_part_amt"`
  21689. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21690. Insutype string `json:"insutype"`
  21691. MafPay float64 `json:"maf_pay"`
  21692. MdtrtCertType string `json:"mdtrt_cert_type"`
  21693. HifobPay float64 `json:"hifob_pay"`
  21694. MdtrtID string `json:"mdtrt_id"`
  21695. MedType string `json:"med_type"`
  21696. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21697. MedinsSetlID string `json:"medins_setl_id"`
  21698. Naty string `json:"naty"`
  21699. OthPay float64 `json:"oth_pay"`
  21700. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21701. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21702. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21703. PsnCashPay float64 `json:"psn_cash_pay"`
  21704. PsnCertType string `json:"psn_cert_type"`
  21705. PsnName string `json:"psn_name"`
  21706. PsnNo string `json:"psn_no"`
  21707. PsnPartAmt float64 `json:"psn_part_amt"`
  21708. PsnType string `json:"psn_type"`
  21709. SetlID string `json:"setl_id"`
  21710. SetlTime string `json:"setl_time"`
  21711. } `json:"setlinfo"`
  21712. Setldetail interface{} `json:"setldetail"`
  21713. } `json:"output"`
  21714. RefmsgTime string `json:"refmsg_time"`
  21715. RespondTime string `json:"respond_time"`
  21716. Signtype interface{} `json:"signtype"`
  21717. WarnMsg interface{} `json:"warn_msg"`
  21718. }
  21719. type ResultSevenAH struct {
  21720. Cainfo string `json:"cainfo"`
  21721. ErrMsg string `json:"err_msg"`
  21722. InfRefmsgid string `json:"inf_refmsgid"`
  21723. Infcode int64 `json:"infcode"`
  21724. Output struct {
  21725. Setlinfo struct {
  21726. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21727. AcctPay float64 `json:"acct_pay"`
  21728. ActPayDedc float64 `json:"act_pay_dedc"`
  21729. Age float64 `json:"age"`
  21730. Balc float64 `json:"balc"`
  21731. Certno string `json:"certno"`
  21732. ClrOptins string `json:"clr_optins"`
  21733. ClrType string `json:"clr_type"`
  21734. ClrWay string `json:"clr_way"`
  21735. CvlservFlag string `json:"cvlserv_flag"`
  21736. CvlservPay float64 `json:"cvlserv_pay"`
  21737. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21738. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21739. Gend string `json:"gend"`
  21740. HifesPay float64 `json:"hifes_pay"`
  21741. HifmiPay float64 `json:"hifmi_pay"`
  21742. HifpPay float64 `json:"hifp_pay"`
  21743. HospPartAmt float64 `json:"hosp_part_amt"`
  21744. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21745. Insutype string `json:"insutype"`
  21746. MafPay float64 `json:"maf_pay"`
  21747. MdtrtCertType string `json:"mdtrt_cert_type"`
  21748. HifobPay float64 `json:"hifob_pay"`
  21749. MdtrtID string `json:"mdtrt_id"`
  21750. MedType string `json:"med_type"`
  21751. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21752. MedinsSetlID string `json:"medins_setl_id"`
  21753. Naty string `json:"naty"`
  21754. OthPay float64 `json:"oth_pay"`
  21755. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21756. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21757. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21758. PsnCashPay float64 `json:"psn_cash_pay"`
  21759. PsnCertType string `json:"psn_cert_type"`
  21760. PsnName string `json:"psn_name"`
  21761. PsnNo string `json:"psn_no"`
  21762. PsnPartAmt float64 `json:"psn_part_amt"`
  21763. PsnType string `json:"psn_type"`
  21764. SetlID string `json:"setl_id"`
  21765. SetlTime int64 `json:"setl_time"`
  21766. } `json:"setlinfo"`
  21767. Setldetail interface{} `json:"setldetail"`
  21768. } `json:"output"`
  21769. RefmsgTime string `json:"refmsg_time"`
  21770. RespondTime string `json:"respond_time"`
  21771. Signtype interface{} `json:"signtype"`
  21772. WarnMsg interface{} `json:"warn_msg"`
  21773. }
  21774. type ResultSeven10265 struct {
  21775. Cainfo string `json:"cainfo"`
  21776. ErrMsg string `json:"err_msg"`
  21777. InfRefmsgid string `json:"inf_refmsgid"`
  21778. Infcode string `json:"infcode"`
  21779. Output struct {
  21780. Setlinfo struct {
  21781. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21782. AcctPay float64 `json:"acct_pay"`
  21783. ActPayDedc float64 `json:"act_pay_dedc"`
  21784. Age float64 `json:"age"`
  21785. Balc float64 `json:"balc"`
  21786. Certno string `json:"certno"`
  21787. ClrOptins string `json:"clr_optins"`
  21788. ClrType string `json:"clr_type"`
  21789. ClrWay string `json:"clr_way"`
  21790. CvlservFlag string `json:"cvlserv_flag"`
  21791. CvlservPay float64 `json:"cvlserv_pay"`
  21792. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21793. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21794. Gend string `json:"gend"`
  21795. HifesPay float64 `json:"hifes_pay"`
  21796. HifmiPay float64 `json:"hifmi_pay"`
  21797. HifpPay float64 `json:"hifp_pay"`
  21798. HospPartAmt float64 `json:"hosp_part_amt"`
  21799. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21800. Insutype string `json:"insutype"`
  21801. MafPay float64 `json:"maf_pay"`
  21802. MdtrtCertType string `json:"mdtrt_cert_type"`
  21803. HifobPay float64 `json:"hifob_pay"`
  21804. MdtrtID string `json:"mdtrt_id"`
  21805. MedType string `json:"med_type"`
  21806. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21807. MedinsSetlID string `json:"medins_setl_id"`
  21808. Naty string `json:"naty"`
  21809. OthPay float64 `json:"oth_pay"`
  21810. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21811. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21812. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21813. PsnCashPay float64 `json:"psn_cash_pay"`
  21814. PsnCertType string `json:"psn_cert_type"`
  21815. PsnName string `json:"psn_name"`
  21816. PsnNo string `json:"psn_no"`
  21817. PsnPartAmt float64 `json:"psn_part_amt"`
  21818. PsnType string `json:"psn_type"`
  21819. SetlID string `json:"setl_id"`
  21820. SetlTime string `json:"setl_time"`
  21821. } `json:"setlinfo"`
  21822. Setldetail interface{} `json:"setldetail"`
  21823. } `json:"output"`
  21824. RefmsgTime string `json:"refmsg_time"`
  21825. RespondTime string `json:"respond_time"`
  21826. Signtype interface{} `json:"signtype"`
  21827. WarnMsg interface{} `json:"warn_msg"`
  21828. }
  21829. type ResultSeven10265Two struct {
  21830. Cainfo string `json:"cainfo"`
  21831. ErrMsg string `json:"err_msg"`
  21832. InfRefmsgid string `json:"inf_refmsgid"`
  21833. Infcode string `json:"infcode"`
  21834. Output struct {
  21835. Setlinfo struct {
  21836. AcctMulaidPay string `json:"acct_mulaid_pay"`
  21837. AcctPay float64 `json:"acct_pay"`
  21838. ActPayDedc float64 `json:"act_pay_dedc"`
  21839. Age float64 `json:"age"`
  21840. Balc float64 `json:"balc"`
  21841. Certno string `json:"certno"`
  21842. ClrOptins string `json:"clr_optins"`
  21843. ClrType string `json:"clr_type"`
  21844. ClrWay string `json:"clr_way"`
  21845. CvlservFlag string `json:"cvlserv_flag"`
  21846. CvlservPay float64 `json:"cvlserv_pay"`
  21847. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21848. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21849. Gend string `json:"gend"`
  21850. HifesPay float64 `json:"hifes_pay"`
  21851. HifmiPay float64 `json:"hifmi_pay"`
  21852. HifpPay float64 `json:"hifp_pay"`
  21853. HospPartAmt string `json:"hosp_part_amt"`
  21854. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21855. Insutype string `json:"insutype"`
  21856. MafPay float64 `json:"maf_pay"`
  21857. MdtrtCertType string `json:"mdtrt_cert_type"`
  21858. HifobPay float64 `json:"hifob_pay"`
  21859. MdtrtID string `json:"mdtrt_id"`
  21860. MedType string `json:"med_type"`
  21861. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21862. MedinsSetlID string `json:"medins_setl_id"`
  21863. Naty string `json:"naty"`
  21864. OthPay float64 `json:"oth_pay"`
  21865. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21866. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21867. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21868. PsnCashPay float64 `json:"psn_cash_pay"`
  21869. PsnCertType string `json:"psn_cert_type"`
  21870. PsnName string `json:"psn_name"`
  21871. PsnNo string `json:"psn_no"`
  21872. PsnPartAmt float64 `json:"psn_part_amt"`
  21873. PsnType string `json:"psn_type"`
  21874. SetlID string `json:"setl_id"`
  21875. SetlTime string `json:"setl_time"`
  21876. } `json:"setlinfo"`
  21877. Setldetail interface{} `json:"setldetail"`
  21878. } `json:"output"`
  21879. RefmsgTime string `json:"refmsg_time"`
  21880. RespondTime string `json:"respond_time"`
  21881. Signtype interface{} `json:"signtype"`
  21882. WarnMsg interface{} `json:"warn_msg"`
  21883. }
  21884. type GZResultSeven10265Two struct {
  21885. Cainfo string `json:"cainfo"`
  21886. ErrMsg string `json:"err_msg"`
  21887. InfRefmsgid string `json:"inf_refmsgid"`
  21888. Infcode int64 `json:"infcode"`
  21889. Output struct {
  21890. Setlinfo struct {
  21891. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21892. AcctPay float64 `json:"acct_pay"`
  21893. ActPayDedc float64 `json:"act_pay_dedc"`
  21894. Age float64 `json:"age"`
  21895. Balc float64 `json:"balc"`
  21896. Certno string `json:"certno"`
  21897. ClrOptins string `json:"clr_optins"`
  21898. ClrType string `json:"clr_type"`
  21899. ClrWay string `json:"clr_way"`
  21900. CvlservFlag string `json:"cvlserv_flag"`
  21901. CvlservPay float64 `json:"cvlserv_pay"`
  21902. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21903. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21904. Gend string `json:"gend"`
  21905. HifesPay float64 `json:"hifes_pay"`
  21906. HifmiPay float64 `json:"hifmi_pay"`
  21907. HifpPay float64 `json:"hifp_pay"`
  21908. HospPartAmt float64 `json:"hosp_part_amt"`
  21909. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21910. Insutype string `json:"insutype"`
  21911. MafPay float64 `json:"maf_pay"`
  21912. MdtrtCertType string `json:"mdtrt_cert_type"`
  21913. HifobPay float64 `json:"hifob_pay"`
  21914. MdtrtID string `json:"mdtrt_id"`
  21915. MedType string `json:"med_type"`
  21916. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21917. MedinsSetlID string `json:"medins_setl_id"`
  21918. Naty string `json:"naty"`
  21919. OthPay float64 `json:"oth_pay"`
  21920. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21921. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21922. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21923. PsnCashPay float64 `json:"psn_cash_pay"`
  21924. PsnCertType string `json:"psn_cert_type"`
  21925. PsnName string `json:"psn_name"`
  21926. PsnNo string `json:"psn_no"`
  21927. PsnPartAmt float64 `json:"psn_part_amt"`
  21928. PsnType string `json:"psn_type"`
  21929. SetlID string `json:"setl_id"`
  21930. SetlTime string `json:"setl_time"`
  21931. } `json:"setlinfo"`
  21932. Setldetail interface{} `json:"setldetail"`
  21933. } `json:"output"`
  21934. RefmsgTime string `json:"refmsg_time"`
  21935. RespondTime string `json:"respond_time"`
  21936. Signtype interface{} `json:"signtype"`
  21937. WarnMsg interface{} `json:"warn_msg"`
  21938. }
  21939. type ResultEight struct {
  21940. Cainfo string `json:"cainfo"`
  21941. ErrMsg string `json:"err_msg"`
  21942. InfRefmsgid string `json:"inf_refmsgid"`
  21943. Infcode int64 `json:"infcode"`
  21944. Output struct {
  21945. Stmtinfo struct {
  21946. SetlOptins string `json:"setl_optins"`
  21947. StmtRslt string `json:"stmt_rslt"`
  21948. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21949. } `json:"stmtinfo"`
  21950. } `json:"output"`
  21951. RefmsgTime string `json:"refmsg_time"`
  21952. RespondTime string `json:"respond_time"`
  21953. Signtype interface{} `json:"signtype"`
  21954. WarnMsg interface{} `json:"warn_msg"`
  21955. }
  21956. type ResultEightFor10188 struct {
  21957. Cainfo string `json:"cainfo"`
  21958. ErrMsg string `json:"err_msg"`
  21959. InfRefmsgid string `json:"inf_refmsgid"`
  21960. Infcode string `json:"infcode"`
  21961. Output struct {
  21962. Stmtinfo struct {
  21963. SetlOptins string `json:"setl_optins"`
  21964. StmtRslt string `json:"stmt_rslt"`
  21965. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21966. } `json:"stmtinfo"`
  21967. } `json:"output"`
  21968. RefmsgTime string `json:"refmsg_time"`
  21969. RespondTime string `json:"respond_time"`
  21970. Signtype interface{} `json:"signtype"`
  21971. WarnMsg interface{} `json:"warn_msg"`
  21972. }
  21973. type ResultNine struct {
  21974. Cainfo string `json:"cainfo"`
  21975. ErrMsg string `json:"err_msg"`
  21976. InfRefmsgid string `json:"inf_refmsgid"`
  21977. Infcode int64 `json:"infcode"`
  21978. Output struct {
  21979. FileQuryNo string `json:"file_qury_no"`
  21980. } `json:"output"`
  21981. RefmsgTime string `json:"refmsg_time"`
  21982. RespondTime string `json:"respond_time"`
  21983. Signtype interface{} `json:"signtype"`
  21984. WarnMsg interface{} `json:"warn_msg"`
  21985. }
  21986. type ResultTen struct {
  21987. Cainfo string `json:"cainfo"`
  21988. ErrMsg string `json:"err_msg"`
  21989. InfRefmsgid string `json:"inf_refmsgid"`
  21990. Infcode int64 `json:"infcode"`
  21991. Output struct {
  21992. Fileinfo struct {
  21993. DldEndtime string `json:"dld_endtime"`
  21994. FileQuryNo string `json:"file_qury_no"`
  21995. Filename string `json:"filename"`
  21996. } `json:"fileinfo"`
  21997. } `json:"output"`
  21998. RefmsgTime string `json:"refmsg_time"`
  21999. RespondTime string `json:"respond_time"`
  22000. Signtype interface{} `json:"signtype"`
  22001. WarnMsg interface{} `json:"warn_msg"`
  22002. }
  22003. type Result5262 struct {
  22004. ErrMsg string `json:"err_msg"`
  22005. InfRefmsgid string `json:"inf_refmsgid"`
  22006. Infcode int64 `json:"infcode"`
  22007. Output struct {
  22008. PageInfo struct {
  22009. Size int `json:"size"`
  22010. RecordCounts int `json:"record_counts"`
  22011. } `json:"page_info"`
  22012. Idetinfo []interface{} `json:"idetinfo"`
  22013. Result []struct {
  22014. SetlID string `json:"setl_id"`
  22015. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22016. MdtrtID string `json:"mdtrt_id"`
  22017. InitSetlID string `json:"init_setl_id,omitempty"`
  22018. PsnNo string `json:"psn_no"`
  22019. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22020. PsnName string `json:"psn_name"`
  22021. PsnCertType string `json:"psn_cert_type"`
  22022. Certno string `json:"certno"`
  22023. Gend string `json:"gend,omitempty"`
  22024. Naty string `json:"naty,omitempty"`
  22025. Brdy string `json:"brdy,omitempty"`
  22026. Age float64 `json:"age,omitempty"`
  22027. Insutype string `json:"insutype,omitempty"`
  22028. PsnType string `json:"psn_type"`
  22029. CvlservFlag string `json:"cvlserv_flag"`
  22030. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22031. SpPsnType string `json:"sp_psn_type,omitempty"`
  22032. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22033. ClctGrde string `json:"clct_grde,omitempty"`
  22034. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22035. NwbFlag string `json:"nwb_flag,omitempty"`
  22036. InsuAdmdvs string `json:"insu_admdvs"`
  22037. EmpNo string `json:"emp_no,omitempty"`
  22038. EmpName string `json:"emp_name,omitempty"`
  22039. EmpType string `json:"emp_type,omitempty"`
  22040. EconType string `json:"econ_type,omitempty"`
  22041. AfilIndu string `json:"afil_indu,omitempty"`
  22042. AfilRlts string `json:"afil_rlts,omitempty"`
  22043. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22044. PayLoc string `json:"pay_loc,omitempty"`
  22045. FixmedinsCode string `json:"fixmedins_code"`
  22046. FixmedinsName string `json:"fixmedins_name"`
  22047. HospLv string `json:"hosp_lv,omitempty"`
  22048. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22049. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22050. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22051. Begndate string `json:"begndate"`
  22052. Enddate string `json:"enddate"`
  22053. SetlTime string `json:"setl_time"`
  22054. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22055. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22056. MedType string `json:"med_type"`
  22057. SetlType string `json:"setl_type,omitempty"`
  22058. ClrType string `json:"clr_type,omitempty"`
  22059. ClrWay string `json:"clr_way,omitempty"`
  22060. PsnSetlway string `json:"psn_setlway,omitempty"`
  22061. ClrOptins string `json:"clr_optins,omitempty"`
  22062. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22063. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22064. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22065. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22066. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22067. DedcStd float64 `json:"dedc_std,omitempty"`
  22068. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22069. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22070. HifpPay float64 `json:"hifp_pay,omitempty"`
  22071. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22072. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22073. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22074. HifesPay float64 `json:"hifes_pay,omitempty"`
  22075. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22076. HifobPay float64 `json:"hifob_pay,omitempty"`
  22077. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22078. MafPay float64 `json:"maf_pay,omitempty"`
  22079. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22080. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22081. PsnPay float64 `json:"psn_pay,omitempty"`
  22082. AcctPay float64 `json:"acct_pay,omitempty"`
  22083. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22084. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22085. Balc float64 `json:"balc,omitempty"`
  22086. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22087. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22088. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22089. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22090. Year string `json:"year,omitempty"`
  22091. DiseNo string `json:"dise_no,omitempty"`
  22092. DiseName string `json:"dise_name,omitempty"`
  22093. Invono string `json:"invono,omitempty"`
  22094. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22095. ValiFlag string `json:"vali_flag,omitempty"`
  22096. Memo string `json:"memo,omitempty"`
  22097. Rid string `json:"rid"`
  22098. UpdtTime string `json:"updt_time,omitempty"`
  22099. CrterID string `json:"crter_id,omitempty"`
  22100. CrterName string `json:"crter_name,omitempty"`
  22101. CrteTime string `json:"crte_time,omitempty"`
  22102. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  22103. OpterID string `json:"opter_id,omitempty"`
  22104. OpterName string `json:"opter_name,omitempty"`
  22105. OptTime string `json:"opt_time,omitempty"`
  22106. OptinsNo string `json:"optins_no,omitempty"`
  22107. PoolareaNo string `json:"poolarea_no,omitempty"`
  22108. } `json:"result"`
  22109. } `json:"output"`
  22110. RefmsgTime string `json:"refmsg_time"`
  22111. RespondTime string `json:"respond_time"`
  22112. Signtype interface{} `json:"signtype"`
  22113. WarnInfo interface{} `json:"warn_info"`
  22114. }
  22115. type Result5267 struct {
  22116. ErrMsg string `json:"err_msg"`
  22117. InfRefmsgid string `json:"inf_refmsgid"`
  22118. Infcode int64 `json:"infcode"`
  22119. Output struct {
  22120. PageInfo struct {
  22121. Size int `json:"size"`
  22122. RecordCounts int `json:"record_counts"`
  22123. } `json:"pageinfo"`
  22124. Result []struct {
  22125. SetlID string `json:"setl_id"`
  22126. ClrOptins string `json:"clr_optins"`
  22127. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22128. MdtrtID string `json:"mdtrt_id"`
  22129. InitSetlID string `json:"init_setl_id,omitempty"`
  22130. PsnNo string `json:"psn_no"`
  22131. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22132. PsnName string `json:"psn_name"`
  22133. PsnCertType string `json:"psn_cert_type"`
  22134. Certno string `json:"certno"`
  22135. Gend string `json:"gend,omitempty"`
  22136. Naty string `json:"naty,omitempty"`
  22137. Brdy string `json:"brdy,omitempty"`
  22138. Age float64 `json:"age,omitempty"`
  22139. Insutype string `json:"insutype,omitempty"`
  22140. PsnType string `json:"psn_type"`
  22141. CvlservFlag string `json:"cvlserv_flag"`
  22142. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22143. SpPsnType string `json:"sp_psn_type,omitempty"`
  22144. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22145. ClctGrde string `json:"clct_grde,omitempty"`
  22146. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22147. NwbFlag string `json:"nwb_flag,omitempty"`
  22148. InsuAdmdvs string `json:"insu_admdvs"`
  22149. EmpNo string `json:"emp_no,omitempty"`
  22150. EmpName string `json:"emp_name,omitempty"`
  22151. EmpType string `json:"emp_type,omitempty"`
  22152. EconType string `json:"econ_type,omitempty"`
  22153. AfilIndu string `json:"afil_indu,omitempty"`
  22154. AfilRlts string `json:"afil_rlts,omitempty"`
  22155. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22156. PayLoc string `json:"pay_loc,omitempty"`
  22157. FixmedinsCode string `json:"fixmedins_code"`
  22158. FixmedinsName string `json:"fixmedins_name"`
  22159. HospLv string `json:"hosp_lv,omitempty"`
  22160. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22161. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22162. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22163. Begndate string `json:"begndate,omitempty"`
  22164. Enddate string `json:"enddate,omitempty"`
  22165. SetlTime string `json:"setl_time,omitempty"`
  22166. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22167. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22168. MedType string `json:"med_type"`
  22169. SetlType string `json:"setl_type,omitempty"`
  22170. ClrType string `json:"clr_type,omitempty"`
  22171. ClrWay string `json:"clr_way,omitempty"`
  22172. PsnSetlway string `json:"psn_setlway,omitempty"`
  22173. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22174. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22175. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22176. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22177. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22178. DedcStd float64 `json:"dedc_std,omitempty"`
  22179. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22180. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22181. HifpPay float64 `json:"hifp_pay,omitempty"`
  22182. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22183. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22184. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22185. HifesPay float64 `json:"hifes_pay,omitempty"`
  22186. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22187. HifobPay float64 `json:"hifob_pay,omitempty"`
  22188. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22189. MafPay float64 `json:"maf_pay,omitempty"`
  22190. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22191. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22192. PsnPay float64 `json:"psn_pay,omitempty"`
  22193. AcctPay float64 `json:"acct_pay,omitempty"`
  22194. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22195. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22196. Balc float64 `json:"balc,omitempty"`
  22197. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22198. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22199. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22200. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22201. Year string `json:"year,omitempty"`
  22202. DiseNo string `json:"dise_no,omitempty"`
  22203. DiseName string `json:"dise_name,omitempty"`
  22204. Invono string `json:"invono,omitempty"`
  22205. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22206. Memo string `json:"memo,omitempty"`
  22207. UpdtTime string `json:"updt_time,omitempty"`
  22208. OpterID string `json:"opter_id,omitempty"`
  22209. OpterName string `json:"opter_name,omitempty"`
  22210. OptTime string `json:"opt_time,omitempty"`
  22211. OptinsNo string `json:"optins_no,omitempty"`
  22212. PoolareaNo string `json:"poolarea_no,omitempty"`
  22213. } `json:"result"`
  22214. } `json:"output"`
  22215. RefmsgTime string `json:"refmsg_time"`
  22216. RespondTime string `json:"respond_time"`
  22217. Signtype interface{} `json:"signtype"`
  22218. WarnInfo interface{} `json:"warn_info"`
  22219. }
  22220. // type Autogenerated struct {
  22221. // Output struct {
  22222. // Setlinfo struct {
  22223. // SetlTime string `json:"setl_time"`
  22224. // CvlservPay float64 `json:"cvlserv_pay"`
  22225. // Year string `json:"year"`
  22226. // MedType string `json:"med_type"`
  22227. // PsnPay float64 `json:"psn_pay"`
  22228. // OpterID string `json:"opter_id"`
  22229. // Begndate string `json:"begndate"`
  22230. // FlxempeFlag string `json:"flxempe_flag"`
  22231. // HifmiPay float64 `json:"hifmi_pay"`
  22232. // PsnNo string `json:"psn_no"`
  22233. // ActPayDedc float64 `json:"act_pay_dedc"`
  22234. // MedinsSetlID interface{} `json:"medins_setl_id"`
  22235. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22236. // ClrWay string `json:"clr_way"`
  22237. // OthPay float64 `json:"oth_pay"`
  22238. // Gend string `json:"gend"`
  22239. // MdtrtID string `json:"mdtrt_id"`
  22240. // AcctPay float64 `json:"acct_pay"`
  22241. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  22242. // Insutype string `json:"insutype"`
  22243. // Invono interface{} `json:"invono"`
  22244. // Enddate string `json:"enddate"`
  22245. // CashPayamt float64 `json:"cash_payamt"`
  22246. // PsnType string `json:"psn_type"`
  22247. // FixmedinsName string `json:"fixmedins_name"`
  22248. // HifpPay float64 `json:"hifp_pay"`
  22249. // NewFlag interface{} `json:"new_flag"`
  22250. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22251. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  22252. // PayLoc string `json:"pay_loc"`
  22253. // ClrType string `json:"clr_type"`
  22254. // RefdSetlFlag string `json:"refd_setl_flag"`
  22255. // CvlservFlag string `json:"cvlserv_flag"`
  22256. // EmpName string `json:"emp_name"`
  22257. // Brdy string `json:"brdy"`
  22258. // Naty string `json:"naty"`
  22259. // Certno string `json:"certno"`
  22260. // DiseCode string `json:"dise_code"`
  22261. // FixmedinsCode string `json:"fixmedins_code"`
  22262. // DedcHospLv string `json:"dedc_hosp_lv"`
  22263. // OpterName string `json:"opter_name"`
  22264. // Balc float64 `json:"balc"`
  22265. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22266. // PsnCertType string `json:"psn_cert_type"`
  22267. // HifobPay float64 `json:"hifob_pay"`
  22268. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  22269. // HifesPay float64 `json:"hifes_pay"`
  22270. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22271. // OptTime string `json:"opt_time"`
  22272. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22273. // SetlID string `json:"setl_id"`
  22274. // MafPay float64 `json:"maf_pay"`
  22275. // PsnName string `json:"psn_name"`
  22276. // InsuOptins interface{} `json:"insu_optins"`
  22277. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22278. // ClrOptins string `json:"clr_optins"`
  22279. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22280. // DiseName string `json:"dise_name"`
  22281. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22282. // Age float64 `json:"age"`
  22283. // DtrtCertType string `json:"dtrt_cert_type"`
  22284. // HospLv string `json:"hosp_lv"`
  22285. // } `json:"setlinfo"`
  22286. // Setldetail []struct {
  22287. // FundPayType string `json:"fund_pay_type"`
  22288. // FundPayamt float64 `json:"fund_payamt"`
  22289. // SetlProcInfo interface{} `json:"setl_proc_info"`
  22290. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  22291. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  22292. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  22293. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22294. // } `json:"setldetail"`
  22295. // } `json:"output"`
  22296. // Infcode int `json:"infcode"`
  22297. // WarnMsg interface{} `json:"warn_msg"`
  22298. // Cainfo interface{} `json:"cainfo"`
  22299. // ErrMsg interface{} `json:"err_msg"`
  22300. // RefmsgTime string `json:"refmsg_time"`
  22301. // Signtype interface{} `json:"signtype"`
  22302. // RespondTime string `json:"respond_time"`
  22303. // InfRefmsgid string `json:"inf_refmsgid"`
  22304. // }
  22305. type Result002 struct {
  22306. Cainfo interface{} `json:"cainfo"`
  22307. ErrMsg string `json:"err_msg"`
  22308. InfRefmsgid string `json:"inf_refmsgid"`
  22309. Infcode int64 `json:"infcode"`
  22310. Output struct {
  22311. RxFile string `json:"rx_file"`
  22312. SignDigest string `json:"sign_digest"`
  22313. SignCertSn string `json:"sign_cert_sn"`
  22314. SignCertDn string `json:"sign_cert_dn"`
  22315. } `json:"output"`
  22316. RefmsgTime string `json:"refmsg_time"`
  22317. RespondTime string `json:"respond_time"`
  22318. Signtype interface{} `json:"signtype"`
  22319. WarnMsg interface{} `json:"warn_msg"`
  22320. }
  22321. type Result003 struct {
  22322. Cainfo interface{} `json:"cainfo"`
  22323. ErrMsg string `json:"err_msg"`
  22324. InfRefmsgid string `json:"inf_refmsgid"`
  22325. Infcode int64 `json:"infcode"`
  22326. Output struct {
  22327. HiRxno string `json:"hi_rxno"`
  22328. RxStasCodg string `json:"rx_stas_codg"`
  22329. RxStasName string `json:"rx_stas_name"`
  22330. } `json:"output"`
  22331. RefmsgTime string `json:"refmsg_time"`
  22332. RespondTime string `json:"respond_time"`
  22333. Signtype interface{} `json:"signtype"`
  22334. WarnMsg interface{} `json:"warn_msg"`
  22335. }
  22336. type ResultEleven struct {
  22337. Cainfo string `json:"cainfo"`
  22338. ErrMsg string `json:"err_msg"`
  22339. InfRefmsgid string `json:"inf_refmsgid"`
  22340. Infcode int64 `json:"infcode"`
  22341. Output struct {
  22342. Setlinfo struct {
  22343. SetlTime string `json:"setl_time"`
  22344. CvlservPay float64 `json:"cvlserv_pay"`
  22345. Year string `json:"year"`
  22346. MedType string `json:"med_type"`
  22347. PsnPay float64 `json:"psn_pay"`
  22348. OpterID string `json:"opter_id"`
  22349. Begndate string `json:"begndate"`
  22350. FlxempeFlag string `json:"flxempe_flag"`
  22351. HifmiPay float64 `json:"hifmi_pay"`
  22352. PsnNo string `json:"psn_no"`
  22353. ActPayDedc float64 `json:"act_pay_dedc"`
  22354. MedinsSetlID interface{} `json:"medins_setl_id"`
  22355. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22356. ClrWay string `json:"clr_way"`
  22357. OthPay float64 `json:"oth_pay"`
  22358. Gend string `json:"gend"`
  22359. MdtrtID string `json:"mdtrt_id"`
  22360. AcctPay float64 `json:"acct_pay"`
  22361. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22362. Insutype string `json:"insutype"`
  22363. Invono interface{} `json:"invono"`
  22364. Enddate string `json:"enddate"`
  22365. CashPayamt float64 `json:"cash_payamt"`
  22366. PsnType string `json:"psn_type"`
  22367. FixmedinsName string `json:"fixmedins_name"`
  22368. HifpPay float64 `json:"hifp_pay"`
  22369. NewFlag interface{} `json:"new_flag"`
  22370. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22371. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22372. PayLoc string `json:"pay_loc"`
  22373. ClrType string `json:"clr_type"`
  22374. RefdSetlFlag string `json:"refd_setl_flag"`
  22375. CvlservFlag string `json:"cvlserv_flag"`
  22376. EmpName string `json:"emp_name"`
  22377. Brdy string `json:"brdy"`
  22378. Naty string `json:"naty"`
  22379. Certno string `json:"certno"`
  22380. DiseCode string `json:"dise_code"`
  22381. FixmedinsCode string `json:"fixmedins_code"`
  22382. DedcHospLv string `json:"dedc_hosp_lv"`
  22383. OpterName string `json:"opter_name"`
  22384. Balc float64 `json:"balc"`
  22385. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22386. PsnCertType string `json:"psn_cert_type"`
  22387. HifobPay float64 `json:"hifob_pay"`
  22388. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22389. HifesPay float64 `json:"hifes_pay"`
  22390. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22391. OptTime string `json:"opt_time"`
  22392. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22393. SetlID string `json:"setl_id"`
  22394. MafPay float64 `json:"maf_pay"`
  22395. PsnName string `json:"psn_name"`
  22396. InsuOptins interface{} `json:"insu_optins"`
  22397. PrefFundPay interface{} `json:"pref_fund_pay"`
  22398. ClrOptins string `json:"clr_optins"`
  22399. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22400. DiseName string `json:"dise_name"`
  22401. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22402. Age float64 `json:"age"`
  22403. DtrtCertType string `json:"dtrt_cert_type"`
  22404. HospLv string `json:"hosp_lv"`
  22405. PsnCashPay float64 `json:"psn_cash_pay"`
  22406. } `json:"setlinfo"`
  22407. } `json:"output"`
  22408. RefmsgTime string `json:"refmsg_time"`
  22409. RespondTime string `json:"respond_time"`
  22410. Signtype interface{} `json:"signtype"`
  22411. WarnMsg interface{} `json:"warn_msg"`
  22412. }
  22413. type ResultElevenah struct {
  22414. Cainfo string `json:"cainfo"`
  22415. ErrMsg string `json:"err_msg"`
  22416. InfRefmsgid string `json:"inf_refmsgid"`
  22417. Infcode int64 `json:"infcode"`
  22418. Output struct {
  22419. Setlinfo struct {
  22420. SetlTime int64 `json:"setl_time"`
  22421. CvlservPay float64 `json:"cvlserv_pay"`
  22422. Year string `json:"year"`
  22423. MedType string `json:"med_type"`
  22424. PsnPay float64 `json:"psn_pay"`
  22425. OpterID string `json:"opter_id"`
  22426. Begndate int64 `json:"begndate"`
  22427. FlxempeFlag string `json:"flxempe_flag"`
  22428. HifmiPay float64 `json:"hifmi_pay"`
  22429. PsnNo string `json:"psn_no"`
  22430. ActPayDedc float64 `json:"act_pay_dedc"`
  22431. MedinsSetlID interface{} `json:"medins_setl_id"`
  22432. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22433. ClrWay string `json:"clr_way"`
  22434. OthPay float64 `json:"oth_pay"`
  22435. Gend string `json:"gend"`
  22436. MdtrtID string `json:"mdtrt_id"`
  22437. AcctPay float64 `json:"acct_pay"`
  22438. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22439. Insutype string `json:"insutype"`
  22440. Invono interface{} `json:"invono"`
  22441. Enddate int64 `json:"enddate"`
  22442. CashPayamt float64 `json:"cash_payamt"`
  22443. PsnType string `json:"psn_type"`
  22444. FixmedinsName string `json:"fixmedins_name"`
  22445. HifpPay float64 `json:"hifp_pay"`
  22446. NewFlag interface{} `json:"new_flag"`
  22447. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22448. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22449. PayLoc string `json:"pay_loc"`
  22450. ClrType string `json:"clr_type"`
  22451. RefdSetlFlag string `json:"refd_setl_flag"`
  22452. CvlservFlag string `json:"cvlserv_flag"`
  22453. EmpName string `json:"emp_name"`
  22454. Brdy int64 `json:"brdy"`
  22455. Naty string `json:"naty"`
  22456. Certno string `json:"certno"`
  22457. DiseCode string `json:"dise_code"`
  22458. FixmedinsCode string `json:"fixmedins_code"`
  22459. DedcHospLv string `json:"dedc_hosp_lv"`
  22460. OpterName string `json:"opter_name"`
  22461. Balc float64 `json:"balc"`
  22462. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22463. PsnCertType string `json:"psn_cert_type"`
  22464. HifobPay float64 `json:"hifob_pay"`
  22465. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22466. HifesPay float64 `json:"hifes_pay"`
  22467. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22468. OptTime int64 `json:"opt_time"`
  22469. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22470. SetlID string `json:"setl_id"`
  22471. MafPay float64 `json:"maf_pay"`
  22472. PsnName string `json:"psn_name"`
  22473. InsuOptins interface{} `json:"insu_optins"`
  22474. PrefFundPay interface{} `json:"pref_fund_pay"`
  22475. ClrOptins string `json:"clr_optins"`
  22476. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22477. DiseName string `json:"dise_name"`
  22478. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22479. Age float64 `json:"age"`
  22480. DtrtCertType string `json:"dtrt_cert_type"`
  22481. HospLv string `json:"hosp_lv"`
  22482. PsnCashPay float64 `json:"psn_cash_pay"`
  22483. } `json:"setlinfo"`
  22484. } `json:"output"`
  22485. RefmsgTime string `json:"refmsg_time"`
  22486. RespondTime string `json:"respond_time"`
  22487. Signtype interface{} `json:"signtype"`
  22488. WarnMsg interface{} `json:"warn_msg"`
  22489. }
  22490. type ResultEleven10265 struct {
  22491. Cainfo string `json:"cainfo"`
  22492. ErrMsg string `json:"err_msg"`
  22493. InfRefmsgid string `json:"inf_refmsgid"`
  22494. Infcode string `json:"infcode"`
  22495. Output struct {
  22496. Setlinfo struct {
  22497. SetlTime string `json:"setl_time"`
  22498. CvlservPay float64 `json:"cvlserv_pay"`
  22499. Year string `json:"year"`
  22500. MedType string `json:"med_type"`
  22501. PsnPay float64 `json:"psn_pay"`
  22502. OpterID string `json:"opter_id"`
  22503. Begndate string `json:"begndate"`
  22504. FlxempeFlag string `json:"flxempe_flag"`
  22505. HifmiPay float64 `json:"hifmi_pay"`
  22506. PsnNo string `json:"psn_no"`
  22507. ActPayDedc float64 `json:"act_pay_dedc"`
  22508. MedinsSetlID interface{} `json:"medins_setl_id"`
  22509. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22510. ClrWay string `json:"clr_way"`
  22511. OthPay float64 `json:"oth_pay"`
  22512. Gend string `json:"gend"`
  22513. MdtrtID string `json:"mdtrt_id"`
  22514. AcctPay float64 `json:"acct_pay"`
  22515. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22516. Insutype string `json:"insutype"`
  22517. Invono interface{} `json:"invono"`
  22518. Enddate string `json:"enddate"`
  22519. CashPayamt float64 `json:"cash_payamt"`
  22520. PsnType string `json:"psn_type"`
  22521. FixmedinsName string `json:"fixmedins_name"`
  22522. HifpPay float64 `json:"hifp_pay"`
  22523. NewFlag interface{} `json:"new_flag"`
  22524. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22525. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22526. PayLoc string `json:"pay_loc"`
  22527. ClrType string `json:"clr_type"`
  22528. RefdSetlFlag string `json:"refd_setl_flag"`
  22529. CvlservFlag string `json:"cvlserv_flag"`
  22530. EmpName string `json:"emp_name"`
  22531. Brdy string `json:"brdy"`
  22532. Naty string `json:"naty"`
  22533. Certno string `json:"certno"`
  22534. DiseCode string `json:"dise_code"`
  22535. FixmedinsCode string `json:"fixmedins_code"`
  22536. DedcHospLv string `json:"dedc_hosp_lv"`
  22537. OpterName string `json:"opter_name"`
  22538. Balc float64 `json:"balc"`
  22539. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22540. PsnCertType string `json:"psn_cert_type"`
  22541. HifobPay float64 `json:"hifob_pay"`
  22542. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22543. HifesPay float64 `json:"hifes_pay"`
  22544. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22545. OptTime string `json:"opt_time"`
  22546. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22547. SetlID string `json:"setl_id"`
  22548. MafPay float64 `json:"maf_pay"`
  22549. PsnName string `json:"psn_name"`
  22550. InsuOptins interface{} `json:"insu_optins"`
  22551. PrefFundPay interface{} `json:"pref_fund_pay"`
  22552. ClrOptins string `json:"clr_optins"`
  22553. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22554. DiseName string `json:"dise_name"`
  22555. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22556. Age float64 `json:"age"`
  22557. DtrtCertType string `json:"dtrt_cert_type"`
  22558. HospLv string `json:"hosp_lv"`
  22559. PsnCashPay float64 `json:"psn_cash_pay"`
  22560. } `json:"setlinfo"`
  22561. } `json:"output"`
  22562. RefmsgTime string `json:"refmsg_time"`
  22563. RespondTime string `json:"respond_time"`
  22564. Signtype interface{} `json:"signtype"`
  22565. WarnMsg interface{} `json:"warn_msg"`
  22566. }
  22567. type ResultTwelve struct {
  22568. Cainfo string `json:"cainfo"`
  22569. ErrMsg string `json:"err_msg"`
  22570. InfRefmsgid string `json:"inf_refmsgid"`
  22571. Infcode int64 `json:"infcode"`
  22572. Output struct {
  22573. MdtrtId string `json:"mdtrt_id"`
  22574. ChrgBchno string `json:"chrg_bchno"`
  22575. PsnNo string `json:"psn_no"`
  22576. } `json:"output"`
  22577. RefmsgTime string `json:"refmsg_time"`
  22578. RespondTime string `json:"respond_time"`
  22579. Signtype interface{} `json:"signtype"`
  22580. WarnMsg interface{} `json:"warn_msg"`
  22581. }
  22582. type ResultThirteen struct {
  22583. ErrMsg string `json:"err_msg"`
  22584. InfRefmsgid string `json:"inf_refmsgid"`
  22585. Infcode int64 `json:"infcode"`
  22586. Output struct {
  22587. Result struct {
  22588. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22589. } `json:"result"`
  22590. } `json:"output"`
  22591. RefmsgTime string `json:"refmsg_time"`
  22592. RespondTime string `json:"respond_time"`
  22593. Signtype interface{} `json:"signtype"`
  22594. WarnInfo interface{} `json:"warn_info"`
  22595. }
  22596. type ResultThirteen10265 struct {
  22597. ErrMsg string `json:"err_msg"`
  22598. InfRefmsgid string `json:"inf_refmsgid"`
  22599. Infcode string `json:"infcode"`
  22600. Output struct {
  22601. Result struct {
  22602. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22603. } `json:"result"`
  22604. } `json:"output"`
  22605. RefmsgTime string `json:"refmsg_time"`
  22606. RespondTime string `json:"respond_time"`
  22607. Signtype interface{} `json:"signtype"`
  22608. WarnInfo interface{} `json:"warn_info"`
  22609. }
  22610. type ResultFourteen struct {
  22611. ErrMsg string `json:"err_msg"`
  22612. InfRefmsgid string `json:"inf_refmsgid"`
  22613. Infcode int64 `json:"infcode"`
  22614. Output struct {
  22615. } `json:"output"`
  22616. RefmsgTime string `json:"refmsg_time"`
  22617. RespondTime string `json:"respond_time"`
  22618. Signtype interface{} `json:"signtype"`
  22619. WarnInfo interface{} `json:"warn_info"`
  22620. }
  22621. type ResultCFYLJG001 struct {
  22622. ErrMsg string `json:"err_msg"`
  22623. InfRefmsgid string `json:"inf_refmsgid"`
  22624. Infcode int64 `json:"infcode"`
  22625. Output struct {
  22626. RxTraceCode string `json:"rx_trace_code"`
  22627. HiRxno string `json:"hi_rxno"`
  22628. } `json:"output"`
  22629. RefmsgTime string `json:"refmsg_time"`
  22630. RespondTime string `json:"respond_time"`
  22631. Signtype interface{} `json:"signtype"`
  22632. WarnInfo interface{} `json:"warn_info"`
  22633. }
  22634. type ResultCFYLJG007 struct {
  22635. ErrMsg string `json:"err_msg"`
  22636. InfRefmsgid string `json:"inf_refmsgid"`
  22637. Infcode int64 `json:"infcode"`
  22638. Output struct {
  22639. HiRxno string `json:"hi_rxno"`
  22640. RxStasName string `json:"rx_stas_name"`
  22641. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  22642. Seltdelts []interface{} `json:"seltdelts"`
  22643. RxUsedStasName string `json:"rx_used_stas_name"`
  22644. RxStasCodg string `json:"rx_stas_codg"`
  22645. } `json:"output"`
  22646. RefmsgTime string `json:"refmsg_time"`
  22647. RespondTime string `json:"respond_time"`
  22648. Signtype interface{} `json:"signtype"`
  22649. WarnInfo interface{} `json:"warn_info"`
  22650. }
  22651. type ResultCFYLJG002 struct {
  22652. ErrMsg string `json:"err_msg"`
  22653. InfRefmsgid string `json:"inf_refmsgid"`
  22654. Infcode int64 `json:"infcode"`
  22655. Output struct {
  22656. RxFile string `json:"rx_file"`
  22657. SignDigest string `json:"sign_digest"`
  22658. SignCertSn string `json:"sign_cert_sn"`
  22659. SignCertDn string `json:"sign_cert_dn"`
  22660. } `json:"output"`
  22661. RefmsgTime string `json:"refmsg_time"`
  22662. RespondTime string `json:"respond_time"`
  22663. Signtype interface{} `json:"signtype"`
  22664. WarnInfo interface{} `json:"warn_info"`
  22665. }
  22666. type ResultCFYLJG003 struct {
  22667. ErrMsg string `json:"err_msg"`
  22668. InfRefmsgid string `json:"inf_refmsgid"`
  22669. Infcode int64 `json:"infcode"`
  22670. Output struct {
  22671. HiRxno string `json:"hi_rxno"`
  22672. RxStasCodg string `json:"rx_stas_codg"`
  22673. RxStasName string `json:"rx_stas_name"`
  22674. } `json:"output"`
  22675. RefmsgTime string `json:"refmsg_time"`
  22676. RespondTime string `json:"respond_time"`
  22677. Signtype interface{} `json:"signtype"`
  22678. WarnInfo interface{} `json:"warn_info"`
  22679. }
  22680. type ResultCFYLJG004 struct {
  22681. ErrMsg string `json:"err_msg"`
  22682. InfRefmsgid string `json:"inf_refmsgid"`
  22683. Infcode int64 `json:"infcode"`
  22684. Output struct {
  22685. HiRxno string `json:"hi_rxno"`
  22686. RxStasCodg string `json:"rx_stas_codg"`
  22687. RxStasName string `json:"rx_stas_name"`
  22688. } `json:"output"`
  22689. RefmsgTime string `json:"refmsg_time"`
  22690. RespondTime string `json:"respond_time"`
  22691. Signtype interface{} `json:"signtype"`
  22692. WarnInfo interface{} `json:"warn_info"`
  22693. }
  22694. type ResultCFYLJG008 struct {
  22695. ErrMsg string `json:"err_msg"`
  22696. InfRefmsgid string `json:"inf_refmsgid"`
  22697. Infcode int64 `json:"infcode"`
  22698. Output struct {
  22699. PoolareaNo string `json:"poolareaNo"`
  22700. AdmdvsName string `json:"admdvsName"`
  22701. Count string `json:"count"`
  22702. } `json:"output"`
  22703. RefmsgTime string `json:"refmsg_time"`
  22704. RespondTime string `json:"respond_time"`
  22705. Signtype interface{} `json:"signtype"`
  22706. WarnInfo interface{} `json:"warn_info"`
  22707. }
  22708. type ResultCFYLJG005 struct {
  22709. ErrMsg string `json:"err_msg"`
  22710. InfRefmsgid string `json:"inf_refmsgid"`
  22711. Infcode int64 `json:"infcode"`
  22712. Output struct {
  22713. HiRxNo string `json:"hi_rxno"`
  22714. FixMedinsCode string `json:"fixmedins_code"`
  22715. FixMedinsName string `json:"fixmedins_name"`
  22716. RxStasCodg string `json:"rx_stas_codg"`
  22717. RxStasName string `json:"rx_stas_name"`
  22718. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  22719. RxUserdStasName string `json:"rx_userd_stas_name"`
  22720. PrscTime string `json:"prsc_time"`
  22721. RxDrugCnt float64 `json:"rx_drug_cnt"`
  22722. RxUsedWayCodg string `json:"rx_used_way_codg"`
  22723. RxUsedWayName string `json:"rx_used_way_name"`
  22724. RxFrquCodg string `json:"rx_frqu_codg"`
  22725. RxFrquName string `json:"rx_frqu_name"`
  22726. RxDosunt string `json:"rx_dosunt"`
  22727. RxDoscnt float64 `json:"rx_doscnt"`
  22728. RxDrordDscr string `json:"rx_drord_dscr"`
  22729. ValiDays int64 `json:"vali_days"`
  22730. ValiEndTime string `json:"vali_end_time"`
  22731. ReptFlag string `json:"rept_flag"`
  22732. MaxReptCnt int64 `json:"max_rept_cnt"`
  22733. ReptdCnt int64 `json:"reptd_cnt"`
  22734. MinInrvDays int64 `json:"min_inrv_days"`
  22735. RxTypeCode string `json:"rx_type_code"`
  22736. RxTypeName string `json:"rx_type_name"`
  22737. LongRxFlag string `json:"long_rx_flag"`
  22738. RxDetlList []struct {
  22739. MedListCodg string `json:"med_list_codg"`
  22740. MedinsListCodg string `json:"medins_list_codg"`
  22741. HospPrepFlag string `json:"hosp_prep_flag"`
  22742. RxItemTypeCode string `json:"rx_item_type_code"`
  22743. RxItemTypeName string `json:"rx_item_type_name"`
  22744. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  22745. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  22746. TcmHerbFoote string `json:"tcmherb_foote"`
  22747. MednTypeCode string `json:"medn_type_code"`
  22748. MednTypeName string `json:"medn_type_name"`
  22749. MainMedcFlag string `json:"main_medc_flag"`
  22750. UrgtFlag string `json:"urgt_flag"`
  22751. BasMednFlag string `json:"bas_medn_flag"`
  22752. ImpDrugFlag string `json:"imp_drug_flag"`
  22753. ProdBarc string `json:"prod_barc"`
  22754. DrugProdname string `json:"drug_prodname"`
  22755. GennameCodg string `json:"genname_codg"`
  22756. DrugGenname string `json:"drug_genname"`
  22757. DrugDosform string `json:"drug_dosform"`
  22758. DrugSpec string `json:"drug_spec"`
  22759. PrdrName string `json:"prdr_name"`
  22760. MedcWayCodg string `json:"medc_way_codg"`
  22761. MedcWayDscr string `json:"medc_way_dscr"`
  22762. MedcBegntime string `json:"medc_begntime"`
  22763. MedcEndtime string `json:"medc_endtime"`
  22764. MedcDays float64 `json:"medc_days"`
  22765. DrugPric float64 `json:"drug_pric"`
  22766. DrugSumamt float64 `json:"drug_sumamt"`
  22767. DrugCnt float64 `json:"drug_cnt"`
  22768. DrugDosunt string `json:"drug_dosunt"`
  22769. SinDoscnt float64 `json:"sin_doscnt"`
  22770. SinDosunt string `json:"sin_dosunt"`
  22771. UsedFrquCodg string `json:"used_frqu_codg"`
  22772. UsedFrquName string `json:"used_frqu_name"`
  22773. DrugTotlcnt string `json:"drug_totlcnt"`
  22774. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  22775. DiseCodg string `json:"dise_codg"`
  22776. HospApprFlag string `json:"hosp_appr_flag"`
  22777. } `json:"rx_detl_list"`
  22778. RxOtpinfo struct {
  22779. MedType string `json:"med_type"`
  22780. IptOtpNo string `json:"ipt_otp_no"`
  22781. OtpIptFlag string `json:"otp_ipt_flag"`
  22782. PatnName string `json:"patn_name"`
  22783. PatnAge float64 `json:"patn_age"`
  22784. PatnHgt float64 `json:"patn_hgt"`
  22785. PatnWt float64 `json:"patn_wt"`
  22786. Gend string `json:"gend"`
  22787. GesoVal float64 `json:"geso_val"`
  22788. NwbFlag string `json:"nwb_flag"`
  22789. NwbAge string `json:"nwb_age"`
  22790. SuckPrdFlag string `json:"suck_prd_flag"`
  22791. AlgsHis string `json:"algs_his"`
  22792. Insutype string `json:"insutype"`
  22793. PrscDeptName string `json:"prsc_dept_name"`
  22794. PrscDrName string `json:"prsc_dr_name"`
  22795. PharName string `json:"phar_name"`
  22796. PharChkTime string `json:"phar_chk_time"`
  22797. MdtrtTime string `json:"mdtrt_time"`
  22798. DiseCodg string `json:"dise_codg"`
  22799. DiseName string `json:"dise_name"`
  22800. SpDiseFlag string `json:"sp_dise_flag"`
  22801. MaindiagCode string `json:"maindiag_code"`
  22802. MaindiagName string `json:"maindiag_name"`
  22803. DiseCondDscr string `json:"dise_cond_dscr"`
  22804. FstdiagFlag string `json:"fstdiag_flag"`
  22805. } `json:"rx_otpinfo"`
  22806. RxDiseList []struct {
  22807. DiagType string `json:"diag_type"`
  22808. MaindiagFlag string `json:"maindiag_flag"`
  22809. DiagSrtNo string `json:"diag_srt_no"`
  22810. DiagCode string `json:"diag_code"`
  22811. DiagName string `json:"diag_name"`
  22812. DiagDept string `json:"diag_dept"`
  22813. DiagDrNo string `json:"diag_dr_no"`
  22814. DiagDrName string `json:"diag_dr_name"`
  22815. DiagTime string `json:"diag_time"`
  22816. TcmDiseCode string `json:"tcm_dise_code"`
  22817. TcmDiseName string `json:"tcm_dise_name"`
  22818. TcmSympCode string `json:"tcmsymp_code"`
  22819. TcmSymp string `json:"tcmsymp"`
  22820. } `json:"rx_dise_list"`
  22821. } `json:"output"`
  22822. RefmsgTime string `json:"refmsg_time"`
  22823. RespondTime string `json:"respond_time"`
  22824. Signtype interface{} `json:"signtype"`
  22825. WarnInfo interface{} `json:"warn_info"`
  22826. }
  22827. type ResultCFYLJG006 struct {
  22828. ErrMsg string `json:"err_msg"`
  22829. InfRefmsgid string `json:"inf_refmsgid"`
  22830. Infcode int64 `json:"infcode"`
  22831. Output struct {
  22832. HiRxNo string `json:"hi_rxno"`
  22833. PharCode string `json:"phar_code"`
  22834. PharName string `json:"phar_name"`
  22835. RxChkOpnn string `json:"rx_chk_opnn"`
  22836. RxChkTime string `json:"rx_chk_time"`
  22837. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  22838. RxChkStasName string `json:"rx_chk_stas_name"`
  22839. RxStasCodg string `json:"rx_stas_codg"`
  22840. RxStasName string `json:"rx_stas_name"`
  22841. } `json:"output"`
  22842. RefmsgTime string `json:"refmsg_time"`
  22843. RespondTime string `json:"respond_time"`
  22844. Signtype interface{} `json:"signtype"`
  22845. WarnInfo interface{} `json:"warn_info"`
  22846. }
  22847. type ResultFourteen10265 struct {
  22848. ErrMsg string `json:"err_msg"`
  22849. InfRefmsgid string `json:"inf_refmsgid"`
  22850. Infcode string `json:"infcode"`
  22851. Output struct {
  22852. } `json:"output"`
  22853. RefmsgTime string `json:"refmsg_time"`
  22854. RespondTime string `json:"respond_time"`
  22855. Signtype interface{} `json:"signtype"`
  22856. WarnInfo interface{} `json:"warn_info"`
  22857. }
  22858. type ResultSixteen struct {
  22859. Cainfo string `json:"cainfo"`
  22860. ErrMsg string `json:"err_msg"`
  22861. InfRefmsgid string `json:"inf_refmsgid"`
  22862. Infcode int64 `json:"infcode"`
  22863. Output struct {
  22864. Setlinfo struct {
  22865. MdtrtID string `json:"mdtrt_id"`
  22866. SetlID string `json:"setl_id"`
  22867. ClrOptins string `json:"clr_optins"`
  22868. SetlTime string `json:"setl_time"`
  22869. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22870. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22871. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22872. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22873. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22874. ActPayDedc float64 `json:"act_pay_dedc"`
  22875. HifpPay float64 `json:"hifp_pay"`
  22876. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22877. Lfpay float64 `json:"selfpay"`
  22878. CvlservPay float64 `json:"cvlserv_pay"`
  22879. HifesPay float64 `json:"hifes_pay"`
  22880. HifmiPay float64 `json:"hifmi_pay"`
  22881. HifobPay float64 `json:"hifob_pay"`
  22882. MafPay float64 `json:"maf_pay"`
  22883. OthPay float64 `json:"oth_pay"`
  22884. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22885. PsnPartAmt float64 `json:"psn_part_amt"`
  22886. AcctPay float64 `json:"acct_pay"`
  22887. Balc float64 `json:"balc"`
  22888. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22889. HospPartAmt float64 `json:"hosp_part_amt"`
  22890. MedinsSetlID string `json:"medins_setl_id"`
  22891. PdnCashPay string `json:"pdn_cash_pay"`
  22892. } `json:"setlinfo"`
  22893. } `json:"output"`
  22894. RefmsgTime string `json:"refmsg_time"`
  22895. RespondTime string `json:"respond_time"`
  22896. Signtype interface{} `json:"signtype"`
  22897. WarnMsg interface{} `json:"warn_msg"`
  22898. }
  22899. type ResultSixteen10265 struct {
  22900. Cainfo string `json:"cainfo"`
  22901. ErrMsg string `json:"err_msg"`
  22902. InfRefmsgid string `json:"inf_refmsgid"`
  22903. Infcode string `json:"infcode"`
  22904. Output struct {
  22905. Setlinfo struct {
  22906. MdtrtID string `json:"mdtrt_id"`
  22907. SetlID string `json:"setl_id"`
  22908. ClrOptins string `json:"clr_optins"`
  22909. SetlTime string `json:"setl_time"`
  22910. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22911. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22912. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22913. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22914. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22915. ActPayDedc float64 `json:"act_pay_dedc"`
  22916. HifpPay float64 `json:"hifp_pay"`
  22917. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22918. Lfpay float64 `json:"selfpay"`
  22919. CvlservPay float64 `json:"cvlserv_pay"`
  22920. HifesPay float64 `json:"hifes_pay"`
  22921. HifmiPay float64 `json:"hifmi_pay"`
  22922. HifobPay float64 `json:"hifob_pay"`
  22923. MafPay float64 `json:"maf_pay"`
  22924. OthPay float64 `json:"oth_pay"`
  22925. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22926. PsnPartAmt float64 `json:"psn_part_amt"`
  22927. AcctPay float64 `json:"acct_pay"`
  22928. Balc float64 `json:"balc"`
  22929. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22930. HospPartAmt float64 `json:"hosp_part_amt"`
  22931. MedinsSetlID string `json:"medins_setl_id"`
  22932. PdnCashPay string `json:"pdn_cash_pay"`
  22933. } `json:"setlinfo"`
  22934. } `json:"output"`
  22935. RefmsgTime string `json:"refmsg_time"`
  22936. RespondTime string `json:"respond_time"`
  22937. Signtype interface{} `json:"signtype"`
  22938. WarnMsg interface{} `json:"warn_msg"`
  22939. }
  22940. type ResultSixteen10265Two struct {
  22941. Cainfo string `json:"cainfo"`
  22942. ErrMsg string `json:"err_msg"`
  22943. InfRefmsgid string `json:"inf_refmsgid"`
  22944. Infcode string `json:"infcode"`
  22945. Output struct {
  22946. Setlinfo interface{} `json:"setlinfo"`
  22947. } `json:"output"`
  22948. RefmsgTime string `json:"refmsg_time"`
  22949. RespondTime string `json:"respond_time"`
  22950. Signtype interface{} `json:"signtype"`
  22951. WarnMsg interface{} `json:"warn_msg"`
  22952. }
  22953. type ResultgzSixteen10265Two struct {
  22954. Cainfo string `json:"cainfo"`
  22955. ErrMsg string `json:"err_msg"`
  22956. InfRefmsgid string `json:"inf_refmsgid"`
  22957. Infcode int64 `json:"infcode"`
  22958. Output struct {
  22959. Setlinfo interface{} `json:"setlinfo"`
  22960. } `json:"output"`
  22961. RefmsgTime string `json:"refmsg_time"`
  22962. RespondTime string `json:"respond_time"`
  22963. Signtype interface{} `json:"signtype"`
  22964. WarnMsg interface{} `json:"warn_msg"`
  22965. }
  22966. type ResultSeventeen struct {
  22967. ErrMsg string `json:"err_msg"`
  22968. InfRefmsgid string `json:"inf_refmsgid"`
  22969. Infcode int64 `json:"infcode"`
  22970. Output struct {
  22971. SetlListId string `json:"setl_list_id"`
  22972. } `json:"output"`
  22973. RefmsgTime string `json:"refmsg_time"`
  22974. RespondTime string `json:"respond_time"`
  22975. Signtype string `json:"signtype"`
  22976. WarnInfo string `json:"warn_info"`
  22977. }
  22978. type ResultSeventeenOther struct {
  22979. ErrMsg string `json:"err_msg"`
  22980. InfRefmsgid string `json:"inf_refmsgid"`
  22981. Infcode string `json:"infcode"`
  22982. Output struct {
  22983. SetlListId string `json:"setl_list_id"`
  22984. } `json:"output"`
  22985. RefmsgTime string `json:"refmsg_time"`
  22986. RespondTime string `json:"respond_time"`
  22987. Signtype string `json:"signtype"`
  22988. WarnInfo string `json:"warn_info"`
  22989. }
  22990. type Result90991 struct {
  22991. ErrMsg string `json:"err_msg"`
  22992. InfRefmsgid string `json:"inf_refmsgid"`
  22993. Infcode int64 `json:"infcode"`
  22994. Output struct {
  22995. Result struct {
  22996. PsnNo string `json:"psn_no"`
  22997. CardStat string `json:"card_stat"`
  22998. Certno string `json:"certno"`
  22999. PsnName string `json:"psn_name"`
  23000. CheckStat string `json:"check_stat"`
  23001. SscnoCheckStat string `json:"sscno_check_stat"`
  23002. } `json:"result"`
  23003. } `json:"output"`
  23004. RefmsgTime string `json:"refmsg_time"`
  23005. RespondTime string `json:"respond_time"`
  23006. Signtype interface{} `json:"signtype"`
  23007. WarnInfo interface{} `json:"warn_info"`
  23008. }
  23009. type Result90100 struct {
  23010. ErrMsg string `json:"err_msg"`
  23011. InfRefmsgid string `json:"inf_refmsgid"`
  23012. Infcode int64 `json:"infcode"`
  23013. Output struct {
  23014. PoolareaNo string `json:"poolarea_no"`
  23015. PoolareaNoName string `json:"poolarea_no_name"`
  23016. Insutype string `json:"insutype"`
  23017. InsutypeName string `json:"insutype_name"`
  23018. ClctType string `json:"clct_type"`
  23019. ClctTypeName string `json:"clct_type_name"`
  23020. ClctFlag string `json:"clct_flag"`
  23021. ClctFlagName string `json:"clct_flag_name"`
  23022. AccrymBegn string `json:"accrym_begn"`
  23023. AccrymEnd string `json:"accrym_end"`
  23024. ClctTime string `json:"clct_time"`
  23025. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  23026. } `json:"output"`
  23027. RefmsgTime string `json:"refmsg_time"`
  23028. RespondTime string `json:"respond_time"`
  23029. Signtype interface{} `json:"signtype"`
  23030. WarnInfo interface{} `json:"warn_info"`
  23031. }
  23032. type Custom struct {
  23033. DetItemFeeSumamt string
  23034. Cut string
  23035. FeedetlSn string
  23036. Price string
  23037. MedListCodg string
  23038. Type int64
  23039. AdviceId int64
  23040. ProjectId int64
  23041. ItemId int64
  23042. }
  23043. type Result5301 struct {
  23044. ErrMsg string `json:"err_msg"`
  23045. InfRefmsgid string `json:"inf_refmsgid"`
  23046. Infcode int64 `json:"infcode"`
  23047. Output struct {
  23048. Result []struct {
  23049. OpspDiseCode string `json:"opsp_dise_code"`
  23050. OpspDiseName string `json:"opsp_dise_name"`
  23051. Begndate string `json:"begndate"`
  23052. Enddate string `json:"enddate"`
  23053. } `json:"feedetail"`
  23054. } `json:"output"`
  23055. RefmsgTime string `json:"refmsg_time"`
  23056. RespondTime string `json:"respond_time"`
  23057. Signtype interface{} `json:"signtype"`
  23058. WarnInfo interface{} `json:"warn_info"`
  23059. }
  23060. type Result5301For10265 struct {
  23061. ErrMsg string `json:"err_msg"`
  23062. InfRefmsgid string `json:"inf_refmsgid"`
  23063. Infcode string `json:"infcode"`
  23064. Output struct {
  23065. Result []struct {
  23066. OpspDiseCode string `json:"opsp_dise_code"`
  23067. OpspDiseName string `json:"opsp_dise_name"`
  23068. Begndate string `json:"begndate"`
  23069. Enddate string `json:"enddate"`
  23070. } `json:"feedetail"`
  23071. } `json:"output"`
  23072. RefmsgTime string `json:"refmsg_time"`
  23073. RespondTime string `json:"respond_time"`
  23074. Signtype interface{} `json:"signtype"`
  23075. WarnInfo interface{} `json:"warn_info"`
  23076. }
  23077. //获取个人信息----挂号-----上传就诊信息
  23078. func (c *HisApiController) GetRegisterInfo() {
  23079. id, _ := c.GetInt64("id")
  23080. record_time := c.GetString("record_time")
  23081. settlementValue, _ := c.GetInt64("settlement_value")
  23082. medical_insurance_card := c.GetString("medical_insurance_card")
  23083. name := c.GetString("name")
  23084. id_card_type, _ := c.GetInt64("id_card_type")
  23085. certificates, _ := c.GetInt64("certificates")
  23086. medical_care, _ := c.GetInt64("medical_care")
  23087. birthday := c.GetString("birthday")
  23088. id_card := c.GetString("id_card")
  23089. register_type, _ := c.GetInt64("register")
  23090. doctor, _ := c.GetInt64("doctor")
  23091. department, _ := c.GetInt64("department")
  23092. gender, _ := c.GetInt64("sex")
  23093. registration_fee, _ := c.GetFloat("registration_fee")
  23094. medical_expenses, _ := c.GetFloat("medical_expenses")
  23095. social_type, _ := c.GetInt64("social_type")
  23096. admin_user_id, _ := c.GetInt64("admin_user_id")
  23097. insuplc_admdvs := c.GetString("insuplc_admdvs")
  23098. mdtrt_type := c.GetString("mdtrt_type")
  23099. if id_card_type == 5 {
  23100. id_card_type = 4
  23101. }
  23102. timeLayout := "2006-01-02"
  23103. loc, _ := time.LoadLocation("Local")
  23104. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  23105. birthUnix := birthdays.Unix()
  23106. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23107. if err != nil {
  23108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23109. return
  23110. }
  23111. recordDateTime := theTime.Unix()
  23112. adminInfo := c.GetAdminUserInfo()
  23113. var patient service.Patients
  23114. if id == 0 {
  23115. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  23116. } else {
  23117. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  23118. }
  23119. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23120. if patientPrescription.ID == 0 {
  23121. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23122. }
  23123. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  23124. if patient.ID == 0 {
  23125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  23126. return
  23127. }
  23128. if len(patient.IdCardNo) == 0 {
  23129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  23130. return
  23131. }
  23132. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  23133. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  23134. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  23135. //就诊结算未完成,不能进行二次挂号
  23136. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  23137. if len(his) >= 1 {
  23138. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  23139. if len(his) >= 1 && order.ID == 0 {
  23140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  23141. return
  23142. }
  23143. }
  23144. //var register_log string
  23145. if config.IsOpen == 1 {
  23146. var res ResultTwo
  23147. var res10265 ResultTwo10265
  23148. var PsnNo string
  23149. var PsnCertType string
  23150. var Certno string
  23151. var PsnName string
  23152. var Gend string
  23153. var Naty string
  23154. var Brdy string
  23155. var Age float64
  23156. var infoStr string
  23157. var idetinfoStr string
  23158. var infocode int64
  23159. var verify_number string
  23160. fmt.Println(verify_number)
  23161. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  23162. psn_info, _ := service.GetPsnByPatientId(id)
  23163. PsnNo = psn_info.PsnNo
  23164. PsnCertType = psn_info.PsnCertType
  23165. Certno = psn_info.Certno
  23166. PsnName = psn_info.PsnName
  23167. Gend = psn_info.Gend
  23168. Naty = psn_info.Naty
  23169. Brdy = psn_info.Brdy
  23170. Age = psn_info.Age
  23171. infoStr = psn_info.Insuinfo
  23172. idetinfoStr = psn_info.Idetinfo
  23173. infocode = 0
  23174. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23175. psn_info, _ := service.GetPsnByPatientId(id)
  23176. PsnNo = psn_info.PsnNo
  23177. PsnCertType = psn_info.PsnCertType
  23178. Certno = psn_info.Certno
  23179. PsnName = psn_info.PsnName
  23180. Gend = psn_info.Gend
  23181. Naty = psn_info.Naty
  23182. Brdy = psn_info.Brdy
  23183. Age = psn_info.Age
  23184. infoStr = psn_info.Insuinfo
  23185. idetinfoStr = psn_info.Idetinfo
  23186. infocode = 0
  23187. verify_number = psn_info.VerifyNumber
  23188. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23189. if id_card_type == 2 {
  23190. //请求内网数据
  23191. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  23192. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23193. "&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
  23194. resp, requestErr := http.Get(api)
  23195. if requestErr != nil {
  23196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23197. return
  23198. }
  23199. body, ioErr := ioutil.ReadAll(resp.Body)
  23200. if ioErr != nil {
  23201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23203. return
  23204. }
  23205. var respJSON map[string]interface{}
  23206. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23209. return
  23210. }
  23211. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23212. result_byte, _ := json.Marshal(respJSON)
  23213. result := string(result_byte)
  23214. var dat map[string]interface{}
  23215. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23216. fmt.Println(dat)
  23217. } else {
  23218. fmt.Println(err)
  23219. }
  23220. userJSONBytes, _ := json.Marshal(dat)
  23221. var res ResultTwo
  23222. var resTwo10265 ResultTwo10265
  23223. if miConfig.Code == "H15049901371" {
  23224. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  23225. utils.ErrorLog("解析失败:%v", err)
  23226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23227. return
  23228. }
  23229. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  23230. res.Infcode = Infcode
  23231. res.ErrMsg = resTwo10265.ErrMsg
  23232. res.Output = resTwo10265.Output
  23233. res.InfRefmsgid = resTwo10265.InfRefmsgid
  23234. res.RespondTime = resTwo10265.RespondTime
  23235. res.WarnInfo = resTwo10265.WarnInfo
  23236. } else {
  23237. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23238. utils.ErrorLog("解析失败:%v", err)
  23239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23240. return
  23241. }
  23242. }
  23243. //var insutypes []string
  23244. //var insutype string
  23245. //var is390 int = 0
  23246. //var is310 int = 0
  23247. //for _, item := range res.Output.Iinfo {
  23248. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23249. // insutypes = append(insutypes, item.Insutype)
  23250. // }
  23251. //}
  23252. //if len(insutypes) == 1 {
  23253. // insutype = insutypes[0]
  23254. //} else {
  23255. // for _, i := range insutypes {
  23256. // if i == "390" {
  23257. // is390 = 1
  23258. // }
  23259. //
  23260. // if i == "310" {
  23261. // is310 = 1
  23262. // }
  23263. // }
  23264. //}
  23265. //if is390 == 1 {
  23266. // insutype = "390"
  23267. //}
  23268. //if is310 == 1 {
  23269. // insutype = "310"
  23270. //}
  23271. //if len(insutypes) == 0 {
  23272. // insutype = "310"
  23273. //}
  23274. PsnNo = res.Output.Baseinfo.PsnNo
  23275. PsnCertType = res.Output.Baseinfo.PsnCertType
  23276. Certno = res.Output.Baseinfo.Certno
  23277. PsnName = res.Output.Baseinfo.PsnName
  23278. Gend = res.Output.Baseinfo.Gend
  23279. Naty = res.Output.Baseinfo.Naty
  23280. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23281. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23282. infoStr = string(Iinfos)
  23283. idetinfoStr = string(Idetinfos)
  23284. infocode = res.Infcode
  23285. //infocode = 0
  23286. //verify_number = psn_info.VerifyNumber
  23287. } else {
  23288. psn_info, _ := service.GetPsnByPatientId(id)
  23289. PsnNo = psn_info.PsnNo
  23290. PsnCertType = psn_info.PsnCertType
  23291. Certno = psn_info.Certno
  23292. PsnName = psn_info.PsnName
  23293. Gend = psn_info.Gend
  23294. Naty = psn_info.Naty
  23295. Brdy = psn_info.Brdy
  23296. Age = psn_info.Age
  23297. infoStr = psn_info.Insuinfo
  23298. idetinfoStr = psn_info.Idetinfo
  23299. infocode = 0
  23300. verify_number = psn_info.VerifyNumber
  23301. }
  23302. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23303. if id_card_type == 1 {
  23304. psn_info, _ := service.GetPsnByPatientId(id)
  23305. PsnNo = psn_info.PsnNo
  23306. PsnCertType = psn_info.PsnCertType
  23307. Certno = psn_info.Certno
  23308. PsnName = psn_info.PsnName
  23309. Gend = psn_info.Gend
  23310. Naty = psn_info.Naty
  23311. Brdy = psn_info.Brdy
  23312. Age = psn_info.Age
  23313. infoStr = psn_info.Insuinfo
  23314. idetinfoStr = psn_info.Idetinfo
  23315. infocode = 0
  23316. verify_number = psn_info.VerifyNumber
  23317. } else if id_card_type == 2 {
  23318. 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)
  23319. fmt.Println(errMsgLog)
  23320. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23321. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23322. utils.ErrorLog("解析失败:%v", err)
  23323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23324. return
  23325. }
  23326. PsnNo = res.Output.Baseinfo.PsnNo
  23327. PsnCertType = res.Output.Baseinfo.PsnCertType
  23328. Certno = res.Output.Baseinfo.Certno
  23329. PsnName = res.Output.Baseinfo.PsnName
  23330. Gend = res.Output.Baseinfo.Gend
  23331. Naty = res.Output.Baseinfo.Naty
  23332. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23333. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23334. infoStr = string(Iinfos)
  23335. idetinfoStr = string(Idetinfos)
  23336. infocode = res.Infcode
  23337. }
  23338. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23339. if id_card_type == 1 {
  23340. psn_info, _ := service.GetPsnByPatientId(id)
  23341. PsnNo = psn_info.PsnNo
  23342. PsnCertType = psn_info.PsnCertType
  23343. Certno = psn_info.Certno
  23344. PsnName = psn_info.PsnName
  23345. Gend = psn_info.Gend
  23346. Naty = psn_info.Naty
  23347. Brdy = psn_info.Brdy
  23348. Age = psn_info.Age
  23349. infoStr = psn_info.Insuinfo
  23350. idetinfoStr = psn_info.Idetinfo
  23351. infocode = 0
  23352. verify_number = psn_info.VerifyNumber
  23353. } else if id_card_type == 2 {
  23354. 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, "")
  23355. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23356. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23357. utils.ErrorLog("解析失败:%v", err)
  23358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23359. return
  23360. }
  23361. PsnNo = res.Output.Baseinfo.PsnNo
  23362. PsnCertType = res.Output.Baseinfo.PsnCertType
  23363. Certno = res.Output.Baseinfo.Certno
  23364. PsnName = res.Output.Baseinfo.PsnName
  23365. Gend = res.Output.Baseinfo.Gend
  23366. Naty = res.Output.Baseinfo.Naty
  23367. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23368. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23369. infoStr = string(Iinfos)
  23370. idetinfoStr = string(Idetinfos)
  23371. infocode = res.Infcode
  23372. } else {
  23373. psn_info, _ := service.GetPsnByPatientId(id)
  23374. PsnNo = psn_info.PsnNo
  23375. PsnCertType = psn_info.PsnCertType
  23376. Certno = psn_info.Certno
  23377. PsnName = psn_info.PsnName
  23378. Gend = psn_info.Gend
  23379. Naty = psn_info.Naty
  23380. Brdy = psn_info.Brdy
  23381. Age = psn_info.Age
  23382. infoStr = psn_info.Insuinfo
  23383. idetinfoStr = psn_info.Idetinfo
  23384. infocode = 0
  23385. verify_number = psn_info.VerifyNumber
  23386. }
  23387. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23388. if id_card_type == 1 {
  23389. psn_info, _ := service.GetPsnByPatientId(id)
  23390. PsnNo = psn_info.PsnNo
  23391. PsnCertType = psn_info.PsnCertType
  23392. Certno = psn_info.Certno
  23393. PsnName = psn_info.PsnName
  23394. Gend = psn_info.Gend
  23395. Naty = psn_info.Naty
  23396. Brdy = psn_info.Brdy
  23397. Age = psn_info.Age
  23398. infoStr = psn_info.Insuinfo
  23399. idetinfoStr = psn_info.Idetinfo
  23400. infocode = 0
  23401. verify_number = psn_info.VerifyNumber
  23402. } else if id_card_type == 2 {
  23403. psn_info, _ := service.GetPsnByPatientId(id)
  23404. PsnNo = psn_info.PsnNo
  23405. PsnCertType = psn_info.PsnCertType
  23406. Certno = psn_info.Certno
  23407. PsnName = psn_info.PsnName
  23408. Gend = psn_info.Gend
  23409. Naty = psn_info.Naty
  23410. Brdy = psn_info.Brdy
  23411. Age = psn_info.Age
  23412. infoStr = psn_info.Insuinfo
  23413. idetinfoStr = psn_info.Idetinfo
  23414. infocode = 0
  23415. verify_number = psn_info.VerifyNumber
  23416. } else {
  23417. psn_info, _ := service.GetPsnByPatientId(id)
  23418. PsnNo = psn_info.PsnNo
  23419. PsnCertType = psn_info.PsnCertType
  23420. Certno = psn_info.Certno
  23421. PsnName = psn_info.PsnName
  23422. Gend = psn_info.Gend
  23423. Naty = psn_info.Naty
  23424. Brdy = psn_info.Brdy
  23425. Age = psn_info.Age
  23426. infoStr = psn_info.Insuinfo
  23427. idetinfoStr = psn_info.Idetinfo
  23428. infocode = 0
  23429. verify_number = psn_info.VerifyNumber
  23430. }
  23431. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23432. psn_info, _ := service.GetPsnByPatientId(id)
  23433. PsnNo = psn_info.PsnNo
  23434. PsnCertType = psn_info.PsnCertType
  23435. Certno = psn_info.Certno
  23436. PsnName = psn_info.PsnName
  23437. Gend = psn_info.Gend
  23438. Naty = psn_info.Naty
  23439. Brdy = psn_info.Brdy
  23440. Age = psn_info.Age
  23441. infoStr = psn_info.Insuinfo
  23442. idetinfoStr = psn_info.Idetinfo
  23443. infocode = 0
  23444. verify_number = psn_info.VerifyNumber
  23445. idetinfoStr = psn_info.Idetinfo
  23446. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23447. if id_card_type == 1 {
  23448. psn_info, _ := service.GetPsnByPatientId(id)
  23449. PsnNo = psn_info.PsnNo
  23450. PsnCertType = psn_info.PsnCertType
  23451. Certno = psn_info.Certno
  23452. PsnName = psn_info.PsnName
  23453. Gend = psn_info.Gend
  23454. Naty = psn_info.Naty
  23455. Brdy = psn_info.Brdy
  23456. Age = psn_info.Age
  23457. infoStr = psn_info.Insuinfo
  23458. idetinfoStr = psn_info.Idetinfo
  23459. infocode = 0
  23460. verify_number = psn_info.VerifyNumber
  23461. } else if id_card_type == 2 {
  23462. 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)
  23463. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23464. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23465. utils.ErrorLog("解析失败:%v", err)
  23466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23467. return
  23468. }
  23469. PsnNo = res.Output.Baseinfo.PsnNo
  23470. PsnCertType = res.Output.Baseinfo.PsnCertType
  23471. Certno = res.Output.Baseinfo.Certno
  23472. PsnName = res.Output.Baseinfo.PsnName
  23473. Gend = res.Output.Baseinfo.Gend
  23474. Naty = res.Output.Baseinfo.Naty
  23475. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23476. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23477. infoStr = string(Iinfos)
  23478. idetinfoStr = string(Idetinfos)
  23479. infocode = res.Infcode
  23480. } else if id_card_type == 4 {
  23481. psn_info, _ := service.GetPsnByPatientId(id)
  23482. PsnNo = psn_info.PsnNo
  23483. PsnCertType = psn_info.PsnCertType
  23484. Certno = psn_info.Certno
  23485. PsnName = psn_info.PsnName
  23486. Gend = psn_info.Gend
  23487. Naty = psn_info.Naty
  23488. Brdy = psn_info.Brdy
  23489. Age = psn_info.Age
  23490. infoStr = psn_info.Insuinfo
  23491. idetinfoStr = psn_info.Idetinfo
  23492. infocode = 0
  23493. verify_number = psn_info.VerifyNumber
  23494. }
  23495. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23496. var result string
  23497. var requestLog string
  23498. 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), "")
  23499. if id_card_type == 4 {
  23500. psn_info, _ := service.GetPsnByPatientId(id)
  23501. PsnNo = psn_info.PsnNo
  23502. PsnCertType = psn_info.PsnCertType
  23503. Certno = psn_info.Certno
  23504. PsnName = psn_info.PsnName
  23505. Gend = psn_info.Gend
  23506. Naty = psn_info.Naty
  23507. Brdy = psn_info.Brdy
  23508. Age = psn_info.Age
  23509. infoStr = psn_info.Insuinfo
  23510. idetinfoStr = psn_info.Idetinfo
  23511. infocode = 0
  23512. verify_number = psn_info.VerifyNumber
  23513. } else {
  23514. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23515. if miConfig.Code == "H15049901371" {
  23516. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23517. utils.ErrorLog("解析失败:%v", err)
  23518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23519. return
  23520. }
  23521. res.ErrMsg = res10265.ErrMsg
  23522. res.Output = res10265.Output
  23523. res.InfRefmsgid = res10265.InfRefmsgid
  23524. } else {
  23525. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23526. utils.ErrorLog("解析失败:%v", err)
  23527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23528. return
  23529. }
  23530. }
  23531. PsnNo = res.Output.Baseinfo.PsnNo
  23532. PsnCertType = res.Output.Baseinfo.PsnCertType
  23533. Certno = res.Output.Baseinfo.Certno
  23534. PsnName = res.Output.Baseinfo.PsnName
  23535. Gend = res.Output.Baseinfo.Gend
  23536. Naty = res.Output.Baseinfo.Naty
  23537. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23538. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23539. infoStr = string(Iinfos)
  23540. idetinfoStr = string(Idetinfos)
  23541. if miConfig.Code == "H15049901371" {
  23542. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23543. } else {
  23544. infocode = res.Infcode
  23545. }
  23546. }
  23547. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23548. psn_info, _ := service.GetPsnByPatientId(id)
  23549. PsnNo = psn_info.PsnNo
  23550. PsnCertType = psn_info.PsnCertType
  23551. Certno = psn_info.Certno
  23552. PsnName = psn_info.PsnName
  23553. Gend = psn_info.Gend
  23554. Naty = psn_info.Naty
  23555. Brdy = psn_info.Brdy
  23556. Age = psn_info.Age
  23557. infoStr = psn_info.Insuinfo
  23558. idetinfoStr = psn_info.Idetinfo
  23559. infocode = 0
  23560. verify_number = psn_info.VerifyNumber
  23561. } else if miConfig.MdtrtareaAdmvs == "450721" {
  23562. psn_info, _ := service.GetPsnByPatientId(id)
  23563. PsnNo = psn_info.PsnNo
  23564. PsnCertType = psn_info.PsnCertType
  23565. Certno = psn_info.Certno
  23566. PsnName = psn_info.PsnName
  23567. Gend = psn_info.Gend
  23568. Naty = psn_info.Naty
  23569. Brdy = psn_info.Brdy
  23570. Age = psn_info.Age
  23571. infoStr = psn_info.Insuinfo
  23572. idetinfoStr = psn_info.Idetinfo
  23573. infocode = 0
  23574. verify_number = psn_info.VerifyNumber
  23575. } else {
  23576. var result string
  23577. var requestLog string
  23578. //if miConfig.UserOrgId == 10138 {
  23579. if id_card_type != 4 || id_card_type != 1 {
  23580. var insa string
  23581. if len(patient.InsuplcAdmdvs) > 0 {
  23582. insa = patient.InsuplcAdmdvs
  23583. } else {
  23584. insa = miConfig.InsuplcAdmdvs
  23585. }
  23586. //psn_info, _ := service.GetPsnByPatientId(id)
  23587. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  23588. 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)
  23589. }
  23590. //}
  23591. //else {
  23592. // var insa string
  23593. // if len(patient.InsuplcAdmdvs) > 0 {
  23594. // insa = patient.InsuplcAdmdvs
  23595. // } else {
  23596. // insa = miConfig.InsuplcAdmdvs
  23597. // }
  23598. // 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)
  23599. //}
  23600. if id_card_type == 4 || id_card_type == 1 {
  23601. psn_info, _ := service.GetPsnByPatientId(id)
  23602. PsnNo = psn_info.PsnNo
  23603. PsnCertType = psn_info.PsnCertType
  23604. Certno = psn_info.Certno
  23605. PsnName = psn_info.PsnName
  23606. Gend = psn_info.Gend
  23607. Naty = psn_info.Naty
  23608. Brdy = psn_info.Brdy
  23609. Age = psn_info.Age
  23610. infoStr = psn_info.Insuinfo
  23611. idetinfoStr = psn_info.Idetinfo
  23612. infocode = 0
  23613. verify_number = psn_info.VerifyNumber
  23614. } else {
  23615. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23616. if miConfig.Code == "H15049901371" {
  23617. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23618. utils.ErrorLog("解析失败:%v", err)
  23619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23620. return
  23621. }
  23622. res.ErrMsg = res10265.ErrMsg
  23623. res.Output = res10265.Output
  23624. res.InfRefmsgid = res10265.InfRefmsgid
  23625. } else {
  23626. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23627. utils.ErrorLog("解析失败:%v", err)
  23628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23629. return
  23630. }
  23631. }
  23632. PsnNo = res.Output.Baseinfo.PsnNo
  23633. PsnCertType = res.Output.Baseinfo.PsnCertType
  23634. Certno = res.Output.Baseinfo.Certno
  23635. PsnName = res.Output.Baseinfo.PsnName
  23636. Gend = res.Output.Baseinfo.Gend
  23637. Naty = res.Output.Baseinfo.Naty
  23638. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23639. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23640. infoStr = string(Iinfos)
  23641. idetinfoStr = string(Idetinfos)
  23642. if miConfig.Code == "H15049901371" {
  23643. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23644. } else {
  23645. infocode = res.Infcode
  23646. }
  23647. }
  23648. }
  23649. if infocode == 0 {
  23650. his := models.VMHisPatient{
  23651. Name: name,
  23652. Gender: gender,
  23653. Birthday: birthUnix,
  23654. MedicalTreatmentType: medical_care,
  23655. IdType: certificates,
  23656. IdCardNo: id_card,
  23657. BalanceAccountsType: settlementValue,
  23658. SocialType: social_type,
  23659. MedicalInsuranceNumber: medical_insurance_card,
  23660. RegisterType: register_type,
  23661. RegisterCost: registration_fee,
  23662. TreatmentCost: medical_expenses,
  23663. Status: 1,
  23664. Ctime: time.Now().Unix(),
  23665. Mtime: time.Now().Unix(),
  23666. PsnNo: PsnNo,
  23667. PsnCertType: PsnCertType,
  23668. Certno: Certno,
  23669. PsnName: PsnName,
  23670. Gend: Gend,
  23671. Naty: Naty,
  23672. Brdy: Brdy,
  23673. Age: Age,
  23674. Iinfo: infoStr,
  23675. Idetinfo: idetinfoStr,
  23676. PatientId: patient.ID,
  23677. RecordDate: theTime.Unix(),
  23678. UserOrgId: adminInfo.CurrentOrgId,
  23679. AdminUserId: admin_user_id,
  23680. IsReturn: 1,
  23681. IdCardType: id_card_type,
  23682. Doctor: doctor,
  23683. Departments: department,
  23684. MdtrtGrpType: mdtrt_type,
  23685. }
  23686. timestamp := time.Now().Unix()
  23687. tempTime := time.Unix(timestamp, 0)
  23688. timeFormat := tempTime.Format("20060102150405")
  23689. chrgBchno := rand.Intn(100000) + 10000
  23690. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23691. his.Number = ipt_otp_no
  23692. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  23693. department, _ := service.GetDepartMentDetail(department)
  23694. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  23695. IdCardNo := ""
  23696. if id_card_type == 1 {
  23697. // IdCardNo = medical_insurance_card
  23698. IdCardNo = patient.IdCardNo
  23699. } else {
  23700. IdCardNo = patient.IdCardNo
  23701. }
  23702. var rf []*ResultFive
  23703. json.Unmarshal([]byte(his.Iinfo), &rf)
  23704. var insutypes []*ResultFive
  23705. var insutype string
  23706. var insuplc_admdvs_temp string
  23707. var is390 int = 0
  23708. var is310 int = 0
  23709. for _, item := range rf {
  23710. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23711. insutypes = append(insutypes, item)
  23712. }
  23713. }
  23714. if len(insutypes) == 1 {
  23715. insutype = insutypes[0].Insutype
  23716. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23717. if insutype == "390" {
  23718. is390 = 1
  23719. }
  23720. if insutype == "310" {
  23721. is310 = 1
  23722. }
  23723. } else {
  23724. for _, i := range insutypes {
  23725. if i.Insutype == "390" {
  23726. is390 = 1
  23727. }
  23728. if i.Insutype == "310" {
  23729. is310 = 1
  23730. }
  23731. }
  23732. }
  23733. if is390 == 1 {
  23734. insutype = "390"
  23735. }
  23736. if is310 == 1 {
  23737. insutype = "310"
  23738. }
  23739. fmt.Println(social_type)
  23740. if social_type > 0 {
  23741. insutype = strconv.FormatInt(social_type, 10)
  23742. }
  23743. var infocode int64
  23744. var resThree ResultThree
  23745. var resThree10265 ResultThree10265
  23746. if len(insuplc_admdvs) == 0 {
  23747. psn_info, _ := service.GetPsnByPatientId(id)
  23748. //if len(psn_info.InsuplcAdmdvs) > 0 {
  23749. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23750. //}
  23751. } else {
  23752. insuplc_admdvs_temp = insuplc_admdvs
  23753. }
  23754. if miConfig.MdtrtareaAdmvs == "421300" {
  23755. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23756. psn_info, _ := service.GetPsnByPatientId(id)
  23757. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23758. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23759. "&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
  23760. resp, requestErr := http.Get(api)
  23761. if requestErr != nil {
  23762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23763. return
  23764. }
  23765. body, ioErr := ioutil.ReadAll(resp.Body)
  23766. if ioErr != nil {
  23767. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23769. return
  23770. }
  23771. var respJSON map[string]interface{}
  23772. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23775. return
  23776. }
  23777. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23778. result, _ := json.Marshal(respJSON)
  23779. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23780. utils.ErrorLog("解析失败:%v", err)
  23781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23782. return
  23783. }
  23784. infocode = resThree.Infcode
  23785. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23786. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23787. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23788. // insuplc_admdvs_temp =
  23789. //}
  23790. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23791. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23792. //}
  23793. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23794. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23795. "&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
  23796. resp, requestErr := http.Get(api)
  23797. if requestErr != nil {
  23798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23799. return
  23800. }
  23801. body, ioErr := ioutil.ReadAll(resp.Body)
  23802. if ioErr != nil {
  23803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23805. return
  23806. }
  23807. var respJSON map[string]interface{}
  23808. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23811. return
  23812. }
  23813. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23814. result, _ := json.Marshal(respJSON)
  23815. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23816. utils.ErrorLog("解析失败:%v", err)
  23817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23818. return
  23819. }
  23820. infocode = resThree.Infcode
  23821. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23822. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23823. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23824. // insuplc_admdvs_temp =
  23825. //}
  23826. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23827. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23828. //}
  23829. utils.ErrorLog("解析失败:%v", insutype)
  23830. utils.ErrorLog("解析失败:%v", PsnNo)
  23831. utils.ErrorLog("解析失败:%v", Certno)
  23832. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  23833. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  23834. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  23835. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  23836. utils.ErrorLog("解析失败:%v", PsnNo)
  23837. utils.ErrorLog("解析失败:%v", department.Number)
  23838. utils.ErrorLog("解析失败:%v", department.Name)
  23839. utils.ErrorLog("解析失败:%v", roles.UserName)
  23840. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23841. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23842. "&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
  23843. resp, requestErr := http.Get(api)
  23844. if requestErr != nil {
  23845. utils.ErrorLog("解析失败:%v", requestErr)
  23846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23847. return
  23848. }
  23849. body, ioErr := ioutil.ReadAll(resp.Body)
  23850. if ioErr != nil {
  23851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23853. return
  23854. }
  23855. var respJSON map[string]interface{}
  23856. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23859. return
  23860. }
  23861. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23862. result, _ := json.Marshal(respJSON)
  23863. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23864. utils.ErrorLog("解析失败:%v", err)
  23865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23866. return
  23867. }
  23868. infocode = resThree.Infcode
  23869. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23870. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23871. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23872. // insuplc_admdvs_temp =
  23873. //}
  23874. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23875. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23876. //}
  23877. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23878. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23879. "&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
  23880. resp, requestErr := http.Get(api)
  23881. if requestErr != nil {
  23882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23883. return
  23884. }
  23885. body, ioErr := ioutil.ReadAll(resp.Body)
  23886. if ioErr != nil {
  23887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23889. return
  23890. }
  23891. var respJSON map[string]interface{}
  23892. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23895. return
  23896. }
  23897. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23898. result, _ := json.Marshal(respJSON)
  23899. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23900. utils.ErrorLog("解析失败:%v", err)
  23901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23902. return
  23903. }
  23904. infocode = resThree.Infcode
  23905. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23906. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23907. psn_info, _ := service.GetPsnByPatientId(id)
  23908. var verify_number string
  23909. if id_card_type == 4 {
  23910. verify_number = psn_info.VerifyNumber
  23911. } else if id_card_type == 1 {
  23912. bas := strings.Split(psn_info.CardInfo, "|")
  23913. cardNumber := bas[2]
  23914. verify_number = cardNumber
  23915. }
  23916. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23917. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23918. "&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
  23919. resp, requestErr := http.Get(api)
  23920. if requestErr != nil {
  23921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23922. return
  23923. }
  23924. body, ioErr := ioutil.ReadAll(resp.Body)
  23925. if ioErr != nil {
  23926. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23928. return
  23929. }
  23930. var respJSON map[string]interface{}
  23931. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23934. return
  23935. }
  23936. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23937. result, _ := json.Marshal(respJSON)
  23938. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23939. // utils.ErrorLog("解析失败:%v", err)
  23940. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23941. // return
  23942. //}
  23943. //infocode = resThree.Infcode
  23944. //result, _ := json.Marshal(respJSON)
  23945. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23946. utils.ErrorLog("解析失败:%v", err)
  23947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23948. return
  23949. }
  23950. resThree.ErrMsg = resThree10265.ErrMsg
  23951. resThree.Output = resThree10265.Output
  23952. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23953. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23954. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23955. psn_info, _ := service.GetPsnByPatientId(id)
  23956. his.PsnNo = psn_info.PsnNo
  23957. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23958. var cert_no string
  23959. if id_card_type == 3 {
  23960. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  23961. cert_no = IdCardNo
  23962. } else if id_card_type == 4 {
  23963. cert_no = IdCardNo
  23964. psn_info.VerifyNumber = psn_info.VerifyNumber
  23965. } else {
  23966. bas := strings.Split(psn_info.CardInfo, "|")
  23967. cert_no = bas[2]
  23968. }
  23969. var hisPrescription []*models.HisPrescription
  23970. for _, item := range rf {
  23971. if item.Insutype == insutype {
  23972. //insuplc_admdvs = item.InsuplcAdmdvs
  23973. his.InsuplcAdmdvs = insuplc_admdvs
  23974. }
  23975. }
  23976. his.Insutype = insutype
  23977. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  23978. fmt.Println(res3101)
  23979. fmt.Println(res3101.Infcode)
  23980. if res3101.Infcode == "0" {
  23981. fmt.Println("33333333")
  23982. if len(res3101.Output.Result) > 0 {
  23983. fmt.Println("222222")
  23984. for _, item := range res3101.Output.Result {
  23985. if len(res3101.ErrMsg) == 0 {
  23986. res3101.ErrMsg = item.VolaCont
  23987. } else {
  23988. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  23989. }
  23990. }
  23991. c.ServeSuccessJSON(map[string]interface{}{
  23992. "failed_code": -10,
  23993. "msg": res3101.ErrMsg,
  23994. })
  23995. return
  23996. } else {
  23997. fmt.Println("11111")
  23998. var api string
  23999. if miConfig.MdtrtareaAdmvs == "320921" {
  24000. ipt_otp_no = timeFormat
  24001. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24002. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24003. "&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
  24004. } else {
  24005. ipt_otp_no = timeFormat
  24006. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24007. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24008. "&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
  24009. }
  24010. resp, requestErr := http.Get(api)
  24011. if requestErr != nil {
  24012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24013. return
  24014. }
  24015. body, ioErr := ioutil.ReadAll(resp.Body)
  24016. if ioErr != nil {
  24017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24019. return
  24020. }
  24021. var respJSON map[string]interface{}
  24022. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24025. return
  24026. }
  24027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24028. result, _ := json.Marshal(respJSON)
  24029. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24030. utils.ErrorLog("解析失败:%v", err)
  24031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24032. return
  24033. }
  24034. resThree.ErrMsg = resThree10265.ErrMsg
  24035. resThree.Output = resThree10265.Output
  24036. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24037. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24038. }
  24039. } else if res3101.Infcode != "0" {
  24040. c.ServeSuccessJSON(map[string]interface{}{
  24041. "failed_code": -10,
  24042. "msg": res3101.ErrMsg,
  24043. })
  24044. return
  24045. }
  24046. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24047. psn_info, _ := service.GetPsnByPatientId(id)
  24048. var cert_no string
  24049. if id_card_type == 1 {
  24050. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24051. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24052. } else if id_card_type == 4 {
  24053. cert_no = psn_info.VerifyNumber
  24054. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24055. } else {
  24056. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24057. cert_no = psn_info.VerifyNumber
  24058. }
  24059. 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)
  24060. saveLog(result, requestLog, "2201", "挂号")
  24061. if miConfig.Code == "H15049901371" {
  24062. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24063. utils.ErrorLog("解析失败:%v", err)
  24064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24065. return
  24066. }
  24067. resThree.ErrMsg = resThree10265.ErrMsg
  24068. resThree.Output = resThree10265.Output
  24069. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24070. } else {
  24071. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24072. utils.ErrorLog("解析失败:%v", err)
  24073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24074. return
  24075. }
  24076. }
  24077. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24078. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  24079. psn_info, _ := service.GetPsnByPatientId(id)
  24080. var result string
  24081. var requestLog string
  24082. if id_card_type == 1 {
  24083. bas := strings.Split(psn_info.CardInfo, "|")
  24084. basNumber := bas[2]
  24085. card_sn := bas[3]
  24086. 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)
  24087. saveLog(result, requestLog, "2201A", "挂号")
  24088. } else if id_card_type == 2 {
  24089. 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, "", "", "", "", "", "")
  24090. saveLog(result, requestLog, "2201A", "挂号")
  24091. } else {
  24092. 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)
  24093. saveLog(result, requestLog, "2201A", "挂号")
  24094. }
  24095. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24096. utils.ErrorLog("解析失败:%v", err)
  24097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24098. return
  24099. }
  24100. infocode = resThree.Infcode
  24101. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  24102. psn_info, _ := service.GetPsnByPatientId(id)
  24103. var result string
  24104. var requestLog string
  24105. if id_card_type == 1 {
  24106. bas := strings.Split(psn_info.CardInfo, "|")
  24107. basNumber := bas[2]
  24108. card_sn := ""
  24109. 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)
  24110. saveLog(result, requestLog, "2201A", "挂号")
  24111. } else if id_card_type == 2 {
  24112. 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, "", "", "", "", "", "")
  24113. saveLog(result, requestLog, "2201A", "挂号")
  24114. } else {
  24115. 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)
  24116. saveLog(result, requestLog, "2201A", "挂号")
  24117. }
  24118. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24119. utils.ErrorLog("解析失败:%v", err)
  24120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24121. return
  24122. }
  24123. infocode = resThree.Infcode
  24124. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24125. psn_info, _ := service.GetPsnByPatientId(id)
  24126. his.PsnNo = psn_info.PsnNo
  24127. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24128. var cert_no string
  24129. if id_card_type == 1 {
  24130. bas := strings.Split(psn_info.CardInfo, "|")
  24131. cert_no = bas[2]
  24132. } else if id_card_type == 4 {
  24133. cert_no = psn_info.VerifyNumber
  24134. psn_info.VerifyNumber = psn_info.VerifyNumber
  24135. IdCardNo = psn_info.VerifyNumber
  24136. } else {
  24137. cert_no = IdCardNo
  24138. psn_info.VerifyNumber = cert_no
  24139. }
  24140. for _, item := range rf {
  24141. if item.Insutype == insutype {
  24142. his.InsuplcAdmdvs = insuplc_admdvs
  24143. }
  24144. }
  24145. his.Insutype = insutype
  24146. var api string
  24147. ipt_otp_no = timeFormat
  24148. api = miConfig.SecretKey + "ahyb/2201?verify_number=" + cert_no + "&cert_no=" + IdCardNo + "&psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24149. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24150. "&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
  24151. resp, requestErr := http.Get(api)
  24152. if requestErr != nil {
  24153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24154. return
  24155. }
  24156. body, ioErr := ioutil.ReadAll(resp.Body)
  24157. if ioErr != nil {
  24158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24160. return
  24161. }
  24162. var respJSON map[string]interface{}
  24163. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24166. return
  24167. }
  24168. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24169. if status == "0" {
  24170. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24171. c.ServeSuccessJSON(map[string]interface{}{
  24172. "failed_code": -10,
  24173. "msg": err_msg,
  24174. })
  24175. return
  24176. }
  24177. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24178. result, _ := json.Marshal(respJSON)
  24179. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24180. utils.ErrorLog("解析失败:%v", err)
  24181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24182. return
  24183. }
  24184. infocode = resThree.Infcode
  24185. } else if miConfig.MdtrtareaAdmvs == "340699" {
  24186. psn_info, _ := service.GetPsnByPatientId(id)
  24187. his.PsnNo = psn_info.PsnNo
  24188. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24189. var cert_no string
  24190. if id_card_type == 1 {
  24191. bas := strings.Split(psn_info.CardInfo, "|")
  24192. cert_no = bas[2]
  24193. } else if id_card_type == 4 {
  24194. cert_no = psn_info.VerifyNumber
  24195. psn_info.VerifyNumber = psn_info.VerifyNumber
  24196. IdCardNo = psn_info.VerifyNumber
  24197. } else {
  24198. cert_no = IdCardNo
  24199. psn_info.VerifyNumber = cert_no
  24200. }
  24201. for _, item := range rf {
  24202. if item.Insutype == insutype {
  24203. his.InsuplcAdmdvs = insuplc_admdvs
  24204. patient.InsuplcAdmdvs = insuplc_admdvs
  24205. }
  24206. }
  24207. his.Insutype = insutype
  24208. var api string
  24209. ipt_otp_no = timeFormat
  24210. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&verify_number=" + cert_no + "&cert_no=" + IdCardNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24211. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24212. "&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
  24213. resp, requestErr := http.Get(api)
  24214. if requestErr != nil {
  24215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24216. return
  24217. }
  24218. body, ioErr := ioutil.ReadAll(resp.Body)
  24219. if ioErr != nil {
  24220. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24222. return
  24223. }
  24224. var respJSON map[string]interface{}
  24225. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24228. return
  24229. }
  24230. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24231. if status == "0" {
  24232. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24233. c.ServeSuccessJSON(map[string]interface{}{
  24234. "failed_code": -10,
  24235. "msg": err_msg,
  24236. })
  24237. return
  24238. }
  24239. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24240. result, _ := json.Marshal(respJSON)
  24241. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24242. utils.ErrorLog("解析失败:%v", err)
  24243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24244. return
  24245. }
  24246. infocode = resThree.Infcode
  24247. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24248. psn_info, _ := service.GetPsnByPatientId(id)
  24249. var result string
  24250. var requestLog string
  24251. if id_card_type == 1 {
  24252. bas := strings.Split(psn_info.CardInfo, "|")
  24253. basNumber := bas[2]
  24254. card_sn := bas[3]
  24255. 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)
  24256. saveLog(result, requestLog, "2201A", "挂号")
  24257. } else if id_card_type == 2 {
  24258. 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, "", "")
  24259. saveLog(result, requestLog, "2201A", "挂号")
  24260. } else {
  24261. 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, "", "")
  24262. saveLog(result, requestLog, "2201A", "挂号")
  24263. }
  24264. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24265. utils.ErrorLog("解析失败:%v", err)
  24266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24267. return
  24268. }
  24269. infocode = resThree.Infcode
  24270. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24271. psn_info, _ := service.GetPsnByPatientId(id)
  24272. 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)
  24273. saveLog(result, requestLog, "2201A", "挂号")
  24274. if miConfig.Code == "H15049901371" {
  24275. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24276. utils.ErrorLog("解析失败:%v", err)
  24277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24278. return
  24279. }
  24280. resThree.ErrMsg = resThree10265.ErrMsg
  24281. resThree.Output = resThree10265.Output
  24282. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24283. } else {
  24284. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24285. utils.ErrorLog("解析失败:%v", err)
  24286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24287. return
  24288. }
  24289. }
  24290. if miConfig.Code == "H15049901371" {
  24291. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24292. } else {
  24293. infocode = resThree.Infcode
  24294. }
  24295. } else {
  24296. psn_info, _ := service.GetPsnByPatientId(id)
  24297. if id_card_type == 4 || id_card_type == 1 {
  24298. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24299. }
  24300. var rf []*ResultFive
  24301. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24302. var insutypes []*ResultFive
  24303. var insutype string
  24304. var is390 int = 0
  24305. var is310 int = 0
  24306. for _, item := range rf {
  24307. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24308. insutypes = append(insutypes, item)
  24309. }
  24310. }
  24311. if len(insutypes) == 1 {
  24312. insutype = insutypes[0].Insutype
  24313. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24314. } else {
  24315. for _, i := range insutypes {
  24316. if i.Insutype == "390" {
  24317. is390 = 1
  24318. }
  24319. if i.Insutype == "310" {
  24320. is310 = 1
  24321. }
  24322. }
  24323. }
  24324. if is390 == 1 {
  24325. insutype = "390"
  24326. }
  24327. if is310 == 1 {
  24328. insutype = "310"
  24329. }
  24330. fmt.Println(len(insutypes))
  24331. if len(insutypes) == 0 {
  24332. for index, item := range rf {
  24333. if index == 0 {
  24334. insutype = item.Insutype
  24335. insuplc_admdvs = item.InsuplcAdmdvs
  24336. }
  24337. }
  24338. fmt.Println(insutype)
  24339. fmt.Println(insuplc_admdvs)
  24340. }
  24341. if social_type > 0 {
  24342. insutype = strconv.FormatInt(social_type, 10)
  24343. }
  24344. fmt.Println("--------")
  24345. fmt.Println(psn_info)
  24346. fmt.Println(psn_info.PsnNo)
  24347. if miConfig.MdtrtareaAdmvs == "441202" {
  24348. var hisPrescription []*models.HisPrescription
  24349. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24350. if res3101.Infcode == 0 {
  24351. fmt.Println("33333333")
  24352. if len(res3101.Output.Result) > 0 {
  24353. fmt.Println("222222")
  24354. for _, item := range res3101.Output.Result {
  24355. if len(res3101.ErrMsg) == 0 {
  24356. res3101.ErrMsg = item.VolaCont
  24357. } else {
  24358. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24359. }
  24360. }
  24361. c.ServeSuccessJSON(map[string]interface{}{
  24362. "failed_code": -10,
  24363. "msg": res3101.ErrMsg,
  24364. })
  24365. return
  24366. } else {
  24367. hour := time.Now().Format("15")
  24368. min := time.Now().Format("04")
  24369. sec := time.Now().Format("05")
  24370. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24371. fmt.Println(record_time_two)
  24372. 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)
  24373. saveLog(result, requestLog, "2201A", "挂号")
  24374. if miConfig.Code == "H15049901371" {
  24375. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24376. utils.ErrorLog("解析失败:%v", err)
  24377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24378. return
  24379. }
  24380. resThree.ErrMsg = resThree10265.ErrMsg
  24381. resThree.Output = resThree10265.Output
  24382. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24383. } else {
  24384. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24385. utils.ErrorLog("解析失败:%v", err)
  24386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24387. return
  24388. }
  24389. }
  24390. if miConfig.Code == "H15049901371" {
  24391. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24392. } else {
  24393. infocode = resThree.Infcode
  24394. }
  24395. }
  24396. } else if res3101.Infcode != 0 {
  24397. c.ServeSuccessJSON(map[string]interface{}{
  24398. "failed_code": -10,
  24399. "msg": res3101.ErrMsg,
  24400. })
  24401. return
  24402. }
  24403. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24404. var hisPrescription []*models.HisPrescription
  24405. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24406. if res3101.Infcode == 0 {
  24407. fmt.Println("33333333")
  24408. if len(res3101.Output.Result) > 0 {
  24409. fmt.Println("222222")
  24410. for _, item := range res3101.Output.Result {
  24411. if len(res3101.ErrMsg) == 0 {
  24412. res3101.ErrMsg = item.VolaCont
  24413. } else {
  24414. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24415. }
  24416. }
  24417. c.ServeSuccessJSON(map[string]interface{}{
  24418. "failed_code": -10,
  24419. "msg": res3101.ErrMsg,
  24420. })
  24421. return
  24422. } else {
  24423. hour := time.Now().Format("15")
  24424. min := time.Now().Format("04")
  24425. sec := time.Now().Format("05")
  24426. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24427. fmt.Println(record_time_two)
  24428. 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)
  24429. saveLog(result, requestLog, "2201A", "挂号")
  24430. if miConfig.Code == "H15049901371" {
  24431. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24432. utils.ErrorLog("解析失败:%v", err)
  24433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24434. return
  24435. }
  24436. resThree.ErrMsg = resThree10265.ErrMsg
  24437. resThree.Output = resThree10265.Output
  24438. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24439. } else {
  24440. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24441. utils.ErrorLog("解析失败:%v", err)
  24442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24443. return
  24444. }
  24445. }
  24446. if miConfig.Code == "H15049901371" {
  24447. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24448. } else {
  24449. infocode = resThree.Infcode
  24450. }
  24451. }
  24452. } else if res3101.Infcode != 0 {
  24453. c.ServeSuccessJSON(map[string]interface{}{
  24454. "failed_code": -10,
  24455. "msg": res3101.ErrMsg,
  24456. })
  24457. return
  24458. }
  24459. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24460. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24461. psn_info, _ := service.GetPsnByPatientId(id)
  24462. var verify_number string
  24463. if id_card_type == 4 {
  24464. verify_number = psn_info.VerifyNumber
  24465. } else if id_card_type == 1 {
  24466. bas := strings.Split(psn_info.CardInfo, "|")
  24467. cardNumber := bas[2]
  24468. verify_number = cardNumber
  24469. } else {
  24470. verify_number = psn_info.Certno
  24471. }
  24472. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24473. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24474. "&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
  24475. resp, requestErr := http.Get(api)
  24476. if requestErr != nil {
  24477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24478. return
  24479. }
  24480. body, ioErr := ioutil.ReadAll(resp.Body)
  24481. if ioErr != nil {
  24482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24484. return
  24485. }
  24486. var respJSON map[string]interface{}
  24487. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24490. return
  24491. }
  24492. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24493. result, _ := json.Marshal(respJSON)
  24494. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24495. utils.ErrorLog("解析失败:%v", err)
  24496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24497. return
  24498. }
  24499. infocode = resThree.Infcode
  24500. } else {
  24501. hour := time.Now().Format("15")
  24502. min := time.Now().Format("04")
  24503. sec := time.Now().Format("05")
  24504. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24505. if id_card_type == 1 {
  24506. for _, item := range rf {
  24507. if item.Insutype == strconv.FormatInt(social_type, 10) {
  24508. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  24509. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24510. } else if strconv.FormatInt(social_type, 10) == "390" {
  24511. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24512. } else {
  24513. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24514. }
  24515. }
  24516. }
  24517. }
  24518. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  24519. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24520. }
  24521. if id_card_type == 1 {
  24522. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  24523. bas := strings.Split(psn_info.CardInfo, "|")
  24524. basNumber := bas[1]
  24525. IdCardNo = basNumber
  24526. }
  24527. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  24528. IdCardNo = psn_info.VerifyNumber
  24529. }
  24530. if len(insuplc_admdvs_temp) == 0 {
  24531. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24532. }
  24533. var result string
  24534. var requestLog string
  24535. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  24536. var hisPrescription []*models.HisPrescription
  24537. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24538. if res3101.Infcode == 0 {
  24539. if len(res3101.Output.Result) > 0 {
  24540. for _, item := range res3101.Output.Result {
  24541. if len(res3101.ErrMsg) == 0 {
  24542. res3101.ErrMsg = item.VolaCont
  24543. } else {
  24544. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24545. }
  24546. }
  24547. c.ServeSuccessJSON(map[string]interface{}{
  24548. "failed_code": -10,
  24549. "msg": res3101.ErrMsg,
  24550. })
  24551. return
  24552. } else {
  24553. hour := time.Now().Format("15")
  24554. min := time.Now().Format("04")
  24555. sec := time.Now().Format("05")
  24556. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24557. fmt.Println(record_time_two)
  24558. if his.IdCardType == 2 {
  24559. IdCardNo = psn_info.Certno
  24560. psn_info.VerifyNumber = psn_info.Certno
  24561. } else if his.IdCardType == 4 {
  24562. IdCardNo = psn_info.Certno
  24563. } else {
  24564. bas := strings.Split(psn_info.CardInfo, "|")
  24565. IdCardNo = bas[2]
  24566. }
  24567. 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)
  24568. saveLog(result, requestLog, "2201A", "挂号")
  24569. if miConfig.Code == "H15049901371" {
  24570. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24571. utils.ErrorLog("解析失败:%v", err)
  24572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24573. return
  24574. }
  24575. resThree.ErrMsg = resThree10265.ErrMsg
  24576. resThree.Output = resThree10265.Output
  24577. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24578. } else {
  24579. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24580. utils.ErrorLog("解析失败:%v", err)
  24581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24582. return
  24583. }
  24584. }
  24585. if miConfig.Code == "H15049901371" {
  24586. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24587. } else {
  24588. infocode = resThree.Infcode
  24589. }
  24590. }
  24591. } else if res3101.Infcode != 0 {
  24592. c.ServeSuccessJSON(map[string]interface{}{
  24593. "failed_code": -10,
  24594. "msg": res3101.ErrMsg,
  24595. })
  24596. return
  24597. }
  24598. } else {
  24599. psn_info, _ := service.GetPsnByPatientId(id)
  24600. var rf []*ResultFive
  24601. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24602. //var insutypes []*ResultFive
  24603. var insutype string
  24604. var insutypes []*ResultFive
  24605. var is390 int = 0
  24606. var is310 int = 0
  24607. for _, item := range rf {
  24608. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24609. insutypes = append(insutypes, item)
  24610. }
  24611. }
  24612. if len(insutypes) == 1 {
  24613. insutype = insutypes[0].Insutype
  24614. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24615. } else {
  24616. for _, i := range insutypes {
  24617. if i.Insutype == "390" {
  24618. is390 = 1
  24619. }
  24620. if i.Insutype == "310" {
  24621. is310 = 1
  24622. }
  24623. }
  24624. }
  24625. if is390 == 1 {
  24626. insutype = "390"
  24627. }
  24628. if is310 == 1 {
  24629. insutype = "310"
  24630. }
  24631. if len(insutypes) == 0 {
  24632. insutype = "310"
  24633. }
  24634. if social_type > 0 {
  24635. insutype = strconv.FormatInt(social_type, 10)
  24636. }
  24637. for _, item := range rf {
  24638. if item.Insutype == insutype {
  24639. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24640. }
  24641. }
  24642. 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)
  24643. saveLog(result, requestLog, "2201A", "挂号")
  24644. }
  24645. if miConfig.Code == "H15049901371" {
  24646. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24647. utils.ErrorLog("解析失败:%v", err)
  24648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24649. return
  24650. }
  24651. resThree.ErrMsg = resThree10265.ErrMsg
  24652. resThree.Output = resThree10265.Output
  24653. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24654. } else {
  24655. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24656. utils.ErrorLog("解析失败:%v", err)
  24657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24658. return
  24659. }
  24660. }
  24661. if miConfig.Code == "H15049901371" {
  24662. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24663. } else {
  24664. infocode = resThree.Infcode
  24665. }
  24666. }
  24667. }
  24668. if infocode == -1 {
  24669. adminUser := c.GetAdminUserInfo()
  24670. errlog := &models.HisOrderError{
  24671. UserOrgId: adminUser.CurrentOrgId,
  24672. Ctime: time.Now().Unix(),
  24673. Mtime: time.Now().Unix(),
  24674. ErrMsg: resThree.ErrMsg,
  24675. Status: 1,
  24676. PatientId: id,
  24677. RecordTime: recordDateTime,
  24678. Stage: 2,
  24679. }
  24680. service.CreateErrMsgLog(errlog)
  24681. c.ServeSuccessJSON(map[string]interface{}{
  24682. "failed_code": -10,
  24683. "msg": resThree.ErrMsg,
  24684. })
  24685. return
  24686. }
  24687. his.Number = resThree.Output.Data.MdtrtID
  24688. his.PsnNo = resThree.Output.Data.PsnNo
  24689. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  24690. his.IdCardNo = patient.IdCardNo
  24691. his.PhoneNumber = patient.Phone
  24692. his.UserOrgId = adminInfo.CurrentOrgId
  24693. his.Insutype = insutype
  24694. his.Ctime = time.Now().Unix()
  24695. his.Mtime = time.Now().Unix()
  24696. his.InsuplcAdmdvs = insuplc_admdvs_temp
  24697. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  24698. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24699. }
  24700. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  24701. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24702. }
  24703. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  24704. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24705. }
  24706. his.Status = 1
  24707. his.MdtrtGrpType = mdtrt_type
  24708. service.UpdateHisPatientStatus(&his)
  24709. service.UpdateHisPatient123(&patient)
  24710. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  24711. c.ServeSuccessJSON(map[string]interface{}{
  24712. "his_info": his,
  24713. })
  24714. } else {
  24715. adminUser := c.GetAdminUserInfo()
  24716. errlog := &models.HisOrderError{
  24717. UserOrgId: adminUser.CurrentOrgId,
  24718. Ctime: time.Now().Unix(),
  24719. Mtime: time.Now().Unix(),
  24720. ErrMsg: res.ErrMsg,
  24721. Status: 1,
  24722. PatientId: id,
  24723. RecordTime: recordDateTime,
  24724. Stage: 1,
  24725. }
  24726. service.CreateErrMsgLog(errlog)
  24727. c.ServeSuccessJSON(map[string]interface{}{
  24728. "failed_code": -10,
  24729. "msg": res.ErrMsg,
  24730. })
  24731. return
  24732. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  24733. }
  24734. }
  24735. }
  24736. func (c *HisApiController) GetUploadInfo() {
  24737. id, _ := c.GetInt64("id")
  24738. record_time := c.GetString("record_time")
  24739. his_patient_id, _ := c.GetInt64("his_patient_id")
  24740. order_id, _ := c.GetInt64("order_id")
  24741. pay_way, _ := c.GetInt64("pay_way")
  24742. pay_ways := c.GetString("pay_ways")
  24743. oth_desc := c.GetString("oth_desc")
  24744. pay_price, _ := c.GetFloat("pay_price")
  24745. pay_card_no := c.GetString("pay_card_no")
  24746. discount_price, _ := c.GetFloat("discount_price")
  24747. preferential_price, _ := c.GetFloat("preferential_price")
  24748. reality_price, _ := c.GetFloat("reality_price")
  24749. found_price, _ := c.GetFloat("found_price")
  24750. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  24751. private_price, _ := c.GetFloat("private_price")
  24752. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  24753. admin_user_id, _ := c.GetInt64("admin_user_id")
  24754. fapiao_code := c.GetString("fapiao_code")
  24755. fapiao_number := c.GetString("fapiao_number")
  24756. diagnosis_id := c.GetString("diagnosis")
  24757. sick_type, _ := c.GetInt64("sick_type")
  24758. reg_type, _ := c.GetInt64("p_type")
  24759. begin_time := c.GetString("begin_time")
  24760. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  24761. cash_pay := c.GetString("cash_pay")
  24762. band_card_pay := c.GetString("band_card_pay")
  24763. wechat_pay := c.GetString("wechat_pay")
  24764. ali_pay := c.GetString("ali_pay")
  24765. jifen_pay := c.GetString("jifen_pay")
  24766. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  24767. fmt.Println(acct_used_flag)
  24768. id_str := c.GetString("ids")
  24769. ids_arr := strings.Split(id_str, ",")
  24770. timeLayout := "2006-01-02"
  24771. loc, _ := time.LoadLocation("Local")
  24772. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24773. if err != nil {
  24774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24775. return
  24776. }
  24777. recordDateTime := theTime.Unix()
  24778. adminUser := c.GetAdminUserInfo()
  24779. var tempOrder models.HisOrder
  24780. tempOrder, _ = service.GetHisOrderByID(order_id)
  24781. var prescriptions []*models.HisPrescription
  24782. var start_time int64
  24783. var end_time int64
  24784. //押金模块
  24785. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  24786. tmp_decimal := c.GetString("tmp_decimal")
  24787. var decimal float64 //本次使用的押金
  24788. var errmsg error
  24789. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  24790. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  24791. return
  24792. }
  24793. if len(tmp_decimal) > 0 {
  24794. if tmp_decimal[0] == 45 {
  24795. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  24796. return
  24797. }
  24798. }
  24799. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  24800. fmt.Println(errs)
  24801. decimal = tt
  24802. //if adminUser.CurrentOrgId == 10106{
  24803. // if len(fapiao_code) == 0{
  24804. // fapiao_code = "144072080589"
  24805. // }
  24806. // if len(fapiao_number) == 0{
  24807. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  24808. // if order.ID == 0{
  24809. // fapiao_number = "00001520"
  24810. // }else{
  24811. // //fapiao_code = "00001520"
  24812. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  24813. // var zero string
  24814. // if fpNumber >= 1000{
  24815. // zero = "0000" + strconv.Itoa(fpNumber)
  24816. // }else if fpNumber >= 10000{
  24817. // zero = "000" + strconv.Itoa(fpNumber)
  24818. // } else if fpNumber >= 100000{
  24819. // zero = "00" + strconv.Itoa(fpNumber)
  24820. // } else if fpNumber >= 1000000{
  24821. // zero = "0" + strconv.Itoa(fpNumber)
  24822. // }else {
  24823. // zero = strconv.Itoa(fpNumber)
  24824. // }
  24825. // fapiao_number = zero
  24826. // }
  24827. // }
  24828. //}
  24829. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24830. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24831. var patientPrescription models.HisPrescriptionInfo
  24832. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24833. if patientPrescription.ID == 0 {
  24834. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  24835. }
  24836. //if patientPrescription.Do
  24837. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24838. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  24839. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  24840. diagnosis_ids := strings.Split(diagnosis_id, ",")
  24841. var config []*models.HisXtDiagnoseConfig
  24842. for _, item := range diagnosis_ids {
  24843. id, _ := strconv.ParseInt(item, 10, 64)
  24844. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24845. config = append(config, &diagnosisConfig)
  24846. }
  24847. sickConfig, _ := service.FindSickById(sick_type)
  24848. //if tempOrder.ID == 0 {
  24849. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  24850. //}
  24851. if tempOrder.ID == 0 {
  24852. var result string
  24853. var requestLog string
  24854. var res2 ResultSix
  24855. var res3 GZResultSix
  24856. var ressix10265 ResultSix10265
  24857. if miConfig.MdtrtareaAdmvs == "421300" {
  24858. data := make(map[string]interface{})
  24859. client := &http.Client{}
  24860. data["psn_no"] = his.PsnNo
  24861. data["mdtrt_id"] = his.Number
  24862. data["opter"] = roles.UserName
  24863. data["org_name"] = miConfig.OrgName
  24864. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24865. data["doctor_id"] = doctor_info.DoctorNumber
  24866. data["doctor_name"] = doctor_info.UserName
  24867. data["department"] = department.Name
  24868. data["fixmedins_code"] = miConfig.Code
  24869. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24870. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24871. data["secret_key"] = miConfig.SecretKey
  24872. data["sick_code"] = sickConfig.CountryCode
  24873. data["sick_name"] = sickConfig.ClassName
  24874. data["dept"] = strconv.FormatInt(department.ID, 10)
  24875. data["config"] = config
  24876. data["begin_time"] = begin_time
  24877. bytesData, _ := json.Marshal(data)
  24878. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24879. resp, _ := client.Do(req)
  24880. defer resp.Body.Close()
  24881. body, ioErr := ioutil.ReadAll(resp.Body)
  24882. if ioErr != nil {
  24883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24885. return
  24886. }
  24887. var respJSON map[string]interface{}
  24888. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24891. return
  24892. }
  24893. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24894. userJSONBytes, _ := json.Marshal(respJSON)
  24895. fmt.Println("log")
  24896. fmt.Println(string(userJSONBytes))
  24897. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24898. utils.ErrorLog("解析失败:%v", err)
  24899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24900. return
  24901. }
  24902. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24903. data := make(map[string]interface{})
  24904. client := &http.Client{}
  24905. data["psn_no"] = his.PsnNo
  24906. data["mdtrt_id"] = his.Number
  24907. data["opter"] = roles.UserName
  24908. data["org_name"] = miConfig.OrgName
  24909. if reg_type == 11 && his.Insutype == "390" {
  24910. data["med_type"] = "110104"
  24911. } else {
  24912. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24913. }
  24914. data["doctor_id"] = doctor_info.DoctorNumber
  24915. data["doctor_name"] = doctor_info.UserName
  24916. data["department"] = department.Name
  24917. data["fixmedins_code"] = miConfig.Code
  24918. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24919. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24920. data["secret_key"] = miConfig.SecretKey
  24921. data["sick_code"] = sickConfig.CountryCode
  24922. data["sick_name"] = sickConfig.ClassName
  24923. data["dept"] = strconv.FormatInt(department.ID, 10)
  24924. data["config"] = config
  24925. data["begin_time"] = begin_time
  24926. bytesData, _ := json.Marshal(data)
  24927. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24928. resp, _ := client.Do(req)
  24929. defer resp.Body.Close()
  24930. body, ioErr := ioutil.ReadAll(resp.Body)
  24931. if ioErr != nil {
  24932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24934. return
  24935. }
  24936. var respJSON map[string]interface{}
  24937. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24940. return
  24941. }
  24942. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24943. userJSONBytes, _ := json.Marshal(respJSON)
  24944. fmt.Println("log")
  24945. fmt.Println(string(userJSONBytes))
  24946. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24947. utils.ErrorLog("解析失败:%v", err)
  24948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24949. return
  24950. }
  24951. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24952. data := make(map[string]interface{})
  24953. client := &http.Client{}
  24954. data["psn_no"] = his.PsnNo
  24955. data["mdtrt_id"] = his.Number
  24956. data["opter"] = roles.UserName
  24957. data["org_name"] = miConfig.OrgName
  24958. if reg_type == 11 && his.Insutype == "390" {
  24959. data["med_type"] = "110104"
  24960. } else {
  24961. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24962. }
  24963. data["doctor_id"] = doctor_info.DoctorNumber
  24964. data["doctor_name"] = doctor_info.UserName
  24965. data["department"] = department.Name
  24966. data["fixmedins_code"] = miConfig.Code
  24967. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24968. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24969. data["secret_key"] = miConfig.SecretKey
  24970. data["sick_code"] = sickConfig.CountryCode
  24971. data["sick_name"] = sickConfig.ClassName
  24972. data["dept"] = strconv.FormatInt(department.ID, 10)
  24973. data["config"] = config
  24974. data["begin_time"] = begin_time
  24975. bytesData, _ := json.Marshal(data)
  24976. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24977. resp, _ := client.Do(req)
  24978. defer resp.Body.Close()
  24979. body, ioErr := ioutil.ReadAll(resp.Body)
  24980. if ioErr != nil {
  24981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24983. return
  24984. }
  24985. var respJSON map[string]interface{}
  24986. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24989. return
  24990. }
  24991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24992. userJSONBytes, _ := json.Marshal(respJSON)
  24993. fmt.Println("log")
  24994. fmt.Println(string(userJSONBytes))
  24995. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24996. utils.ErrorLog("解析失败:%v", err)
  24997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24998. return
  24999. }
  25000. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25001. data := make(map[string]interface{})
  25002. client := &http.Client{}
  25003. data["psn_no"] = his.PsnNo
  25004. data["mdtrt_id"] = his.Number
  25005. data["opter"] = roles.UserName
  25006. data["org_name"] = miConfig.OrgName
  25007. if reg_type == 11 && his.Insutype == "390" {
  25008. data["med_type"] = "110104"
  25009. } else {
  25010. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25011. }
  25012. data["doctor_id"] = doctor_info.DoctorNumber
  25013. data["doctor_name"] = doctor_info.UserName
  25014. data["department"] = department.Name
  25015. data["fixmedins_code"] = miConfig.Code
  25016. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25017. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25018. data["secret_key"] = miConfig.SecretKey
  25019. data["sick_code"] = sickConfig.CountryCode
  25020. data["sick_name"] = sickConfig.ClassName
  25021. data["dept"] = strconv.FormatInt(department.ID, 10)
  25022. data["config"] = config
  25023. data["begin_time"] = begin_time
  25024. bytesData, _ := json.Marshal(data)
  25025. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25026. resp, _ := client.Do(req)
  25027. defer resp.Body.Close()
  25028. body, ioErr := ioutil.ReadAll(resp.Body)
  25029. if ioErr != nil {
  25030. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25032. return
  25033. }
  25034. var respJSON map[string]interface{}
  25035. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25038. return
  25039. }
  25040. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25041. userJSONBytes, _ := json.Marshal(respJSON)
  25042. fmt.Println("log")
  25043. fmt.Println(string(userJSONBytes))
  25044. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25045. utils.ErrorLog("解析失败:%v", err)
  25046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25047. return
  25048. }
  25049. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25050. data := make(map[string]interface{})
  25051. client := &http.Client{}
  25052. data["psn_no"] = his.PsnNo
  25053. data["mdtrt_id"] = his.Number
  25054. data["doctor"] = roles.UserName
  25055. data["department"] = department.Name
  25056. data["org_name"] = miConfig.OrgName
  25057. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25058. data["doctor_id"] = doctor_info.DoctorNumber
  25059. data["new_doctor_name"] = doctor_info.UserName
  25060. data["fixmedins_code"] = miConfig.Code
  25061. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25062. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25063. data["secret_key"] = miConfig.SecretKey
  25064. data["sick_code"] = sickConfig.CountryCode
  25065. data["sick_name"] = sickConfig.ClassName
  25066. data["url"] = miConfig.Url
  25067. data["ak"] = miConfig.AccessKey
  25068. data["begin_time"] = begin_time
  25069. data["cainfo"] = miConfig.Cainfo
  25070. data["dept"] = strconv.FormatInt(department.ID, 10)
  25071. data["config"] = config
  25072. bytesData, _ := json.Marshal(data)
  25073. var req *http.Request
  25074. if miConfig.MdtrtareaAdmvs == "320921" {
  25075. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25076. //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 +
  25077. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  25078. } else {
  25079. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25080. }
  25081. resp, _ := client.Do(req)
  25082. defer resp.Body.Close()
  25083. body, ioErr := ioutil.ReadAll(resp.Body)
  25084. if ioErr != nil {
  25085. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25087. return
  25088. }
  25089. var respJSON map[string]interface{}
  25090. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25093. return
  25094. }
  25095. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25096. userJSONBytes, _ := json.Marshal(respJSON)
  25097. fmt.Println("log")
  25098. fmt.Println(string(userJSONBytes))
  25099. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25100. utils.ErrorLog("解析失败:%v", err)
  25101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25102. return
  25103. }
  25104. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25105. res2.Output = ressix10265.Output
  25106. res2.ErrMsg = ressix10265.ErrMsg
  25107. res2.Cainfo = ressix10265.Cainfo
  25108. res2.WarnMsg = ressix10265.WarnMsg
  25109. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25110. res2.Infcode = infocode
  25111. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25112. data := make(map[string]interface{})
  25113. client := &http.Client{}
  25114. data["psn_no"] = his.PsnNo
  25115. data["mdtrt_id"] = his.Number
  25116. data["doctor"] = roles.UserName
  25117. data["department"] = department.Name
  25118. data["org_name"] = miConfig.OrgName
  25119. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25120. data["doctor_id"] = doctor_info.DoctorNumber
  25121. data["new_doctor_name"] = doctor_info.UserName
  25122. data["fixmedins_code"] = miConfig.Code
  25123. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25124. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25125. data["secret_key"] = miConfig.SecretKey
  25126. data["sick_code"] = sickConfig.CountryCode
  25127. data["sick_name"] = sickConfig.ClassName
  25128. data["url"] = miConfig.Url
  25129. data["ak"] = miConfig.AccessKey
  25130. data["begin_time"] = begin_time
  25131. data["cainfo"] = miConfig.Cainfo
  25132. data["dept"] = strconv.FormatInt(department.ID, 10)
  25133. data["config"] = config
  25134. bytesData, _ := json.Marshal(data)
  25135. var req *http.Request
  25136. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25137. resp, _ := client.Do(req)
  25138. defer resp.Body.Close()
  25139. body, ioErr := ioutil.ReadAll(resp.Body)
  25140. if ioErr != nil {
  25141. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25143. return
  25144. }
  25145. var respJSON map[string]interface{}
  25146. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25149. return
  25150. }
  25151. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25152. userJSONBytes, _ := json.Marshal(respJSON)
  25153. fmt.Println("log")
  25154. fmt.Println(string(userJSONBytes))
  25155. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25156. utils.ErrorLog("解析失败:%v", err)
  25157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25158. return
  25159. }
  25160. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25161. res2.Output = ressix10265.Output
  25162. res2.ErrMsg = ressix10265.ErrMsg
  25163. res2.Cainfo = ressix10265.Cainfo
  25164. res2.WarnMsg = ressix10265.WarnMsg
  25165. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25166. res2.Infcode = infocode
  25167. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25168. 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)
  25169. saveLog(result, requestLog, "2203", "上传就诊信息")
  25170. var respJSON2 map[string]interface{}
  25171. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25172. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25174. return
  25175. }
  25176. userJSONBytes2, _ := json.Marshal(respJSON2)
  25177. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25178. utils.ErrorLog("解析失败:%v", err)
  25179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25180. return
  25181. }
  25182. 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)
  25183. fmt.Println(result2)
  25184. fmt.Println(src_request)
  25185. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25186. data := make(map[string]interface{})
  25187. client := &http.Client{}
  25188. data["psn_no"] = his.PsnNo
  25189. data["mdtrt_id"] = his.Number
  25190. data["doctor"] = roles.UserName
  25191. data["department"] = department.Name
  25192. data["org_name"] = miConfig.OrgName
  25193. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25194. data["doctor_id"] = doctor_info.DoctorNumber
  25195. data["new_doctor_name"] = doctor_info.UserName
  25196. data["fixmedins_code"] = miConfig.Code
  25197. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25198. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25199. data["secret_key"] = miConfig.SecretKey
  25200. data["sick_code"] = sickConfig.CountryCode
  25201. data["sick_name"] = sickConfig.ClassName
  25202. data["url"] = miConfig.Url
  25203. data["ak"] = miConfig.AccessKey
  25204. data["begin_time"] = begin_time
  25205. data["cainfo"] = miConfig.Cainfo
  25206. data["dept"] = strconv.FormatInt(department.ID, 10)
  25207. data["config"] = config
  25208. bytesData, _ := json.Marshal(data)
  25209. var req *http.Request
  25210. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  25211. resp, _ := client.Do(req)
  25212. defer resp.Body.Close()
  25213. body, ioErr := ioutil.ReadAll(resp.Body)
  25214. if ioErr != nil {
  25215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25217. return
  25218. }
  25219. var respJSON map[string]interface{}
  25220. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25223. return
  25224. }
  25225. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25226. userJSONBytes, _ := json.Marshal(respJSON)
  25227. fmt.Println("log")
  25228. fmt.Println(string(userJSONBytes))
  25229. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25230. utils.ErrorLog("解析失败:%v", err)
  25231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25232. return
  25233. }
  25234. } else {
  25235. if miConfig.MdtrtareaAdmvs == "440781" { //
  25236. 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)
  25237. } else {
  25238. if miConfig.Code == "H15049901371" {
  25239. //赤峰地区国家医保医疗类别
  25240. //职工透析:医疗类别选特殊情况门诊990502
  25241. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25242. var med_type string
  25243. if his.Insutype == "390" {
  25244. if reg_type == 14 {
  25245. med_type = "9933"
  25246. } else if reg_type == 11 {
  25247. med_type = "11"
  25248. }
  25249. } else if his.Insutype == "310" {
  25250. if reg_type == 14 {
  25251. med_type = "990502"
  25252. } else if reg_type == 11 {
  25253. med_type = "11"
  25254. }
  25255. }
  25256. 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)
  25257. } else {
  25258. 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)
  25259. }
  25260. }
  25261. saveLog(result, requestLog, "2203", "上传就诊信息")
  25262. var respJSON2 map[string]interface{}
  25263. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25266. return
  25267. }
  25268. userJSONBytes2, _ := json.Marshal(respJSON2)
  25269. if miConfig.Code == "H15049901371" {
  25270. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  25271. utils.ErrorLog("解析失败:%v", err)
  25272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25273. return
  25274. }
  25275. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25276. res2.Output = ressix10265.Output
  25277. res2.ErrMsg = ressix10265.ErrMsg
  25278. res2.Cainfo = ressix10265.Cainfo
  25279. res2.WarnMsg = ressix10265.WarnMsg
  25280. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25281. res2.Infcode = infocode
  25282. } else {
  25283. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25284. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  25285. utils.ErrorLog("解析失败:%v", err)
  25286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25287. return
  25288. }
  25289. res2.Infcode = res3.Infcode
  25290. } else {
  25291. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25292. utils.ErrorLog("解析失败:%v", err)
  25293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25294. return
  25295. }
  25296. }
  25297. }
  25298. }
  25299. if res2.Infcode == -1 {
  25300. adminUser := c.GetAdminUserInfo()
  25301. errlog := &models.HisOrderError{
  25302. UserOrgId: adminUser.CurrentOrgId,
  25303. Ctime: time.Now().Unix(),
  25304. Mtime: time.Now().Unix(),
  25305. ErrMsg: res2.ErrMsg,
  25306. Status: 1,
  25307. PatientId: id,
  25308. RecordTime: recordDateTime,
  25309. Stage: 3,
  25310. }
  25311. service.CreateErrMsgLog(errlog)
  25312. c.ServeSuccessJSON(map[string]interface{}{
  25313. "failed_code": -10,
  25314. "msg": res2.ErrMsg,
  25315. })
  25316. return
  25317. } else {
  25318. his.Diagnosis = diagnosis_id
  25319. his.SickType = sickConfig.ID
  25320. //var p_type int64
  25321. //if reg_type == 1111 || reg_type == 1112 {
  25322. // p_type = 11
  25323. //
  25324. //}
  25325. his.PType = fmt.Sprintf("%d", reg_type)
  25326. service.UpdateHisPatientThree(&his)
  25327. data := make(map[string]interface{})
  25328. if settle_accounts_type == 1 { //日结
  25329. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25330. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25331. } else {
  25332. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25333. }
  25334. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  25335. data["pre"] = prescriptions
  25336. } else { //月结
  25337. start_time_str := c.GetString("start_time")
  25338. end_time_str := c.GetString("end_time")
  25339. timeLayout := "2006-01-02"
  25340. loc, _ := time.LoadLocation("Local")
  25341. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25342. if err != nil {
  25343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25344. return
  25345. }
  25346. recordStartTime := theStartTime.Unix()
  25347. start_time = recordStartTime
  25348. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25349. if err != nil {
  25350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25351. return
  25352. }
  25353. recordEndTime := theEndTime.Unix()
  25354. end_time = recordEndTime
  25355. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25356. data["pre"] = prescriptions
  25357. }
  25358. timestamp := time.Now().Unix()
  25359. tempTime := time.Unix(timestamp, 0)
  25360. timeFormat := tempTime.Format("20060102150405")
  25361. chrgBchno := rand.Intn(100000) + 10000
  25362. new_chrg_bchno := ""
  25363. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25364. new_chrg_bchno = chrg_bchno
  25365. strconv.FormatInt(his.PatientId, 10)
  25366. client := &http.Client{}
  25367. if adminUser.CurrentOrgId == 10265 {
  25368. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25369. new_chrg_bchno = "0000"
  25370. }
  25371. }
  25372. data["psn_no"] = his.PsnNo
  25373. data["mdtrt_id"] = his.Number
  25374. data["chrg_bchno"] = new_chrg_bchno
  25375. data["org_name"] = miConfig.OrgName
  25376. data["doctor"] = doctor_info.UserName
  25377. data["doctor_id"] = doctor_info.DoctorNumber
  25378. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25379. data["fixmedins_code"] = miConfig.Code
  25380. data["dept_code"] = department.Number
  25381. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25382. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25383. data["secret_key"] = miConfig.SecretKey
  25384. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25385. data["url"] = miConfig.Url
  25386. data["ak"] = miConfig.AccessKey
  25387. data["new_doctor_name"] = patientPrescription.Doctor
  25388. data["diag_code"] = sickConfig.CountryCode
  25389. data["cainfo"] = miConfig.Cainfo
  25390. data["opter"] = roles.UserName
  25391. var ids []int64
  25392. for _, item := range prescriptions {
  25393. ids = append(ids, item.ID)
  25394. }
  25395. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25396. if config.IsOpen == 1 { //对接了医保,走医保流程
  25397. var res ResultFour
  25398. var resFour10265 ResultFour10265
  25399. if miConfig.MdtrtareaAdmvs == "421300" {
  25400. bytesData, _ := json.Marshal(data)
  25401. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25402. resp, _ := client.Do(req)
  25403. defer resp.Body.Close()
  25404. body, ioErr := ioutil.ReadAll(resp.Body)
  25405. if ioErr != nil {
  25406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25408. return
  25409. }
  25410. var respJSON map[string]interface{}
  25411. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25414. return
  25415. }
  25416. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25417. userJSONBytes, _ := json.Marshal(respJSON)
  25418. fmt.Println("log")
  25419. fmt.Println(string(userJSONBytes))
  25420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25421. utils.ErrorLog("解析失败:%v", err)
  25422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25423. return
  25424. }
  25425. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25426. bytesData, _ := json.Marshal(data)
  25427. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25428. resp, _ := client.Do(req)
  25429. defer resp.Body.Close()
  25430. body, ioErr := ioutil.ReadAll(resp.Body)
  25431. if ioErr != nil {
  25432. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25434. return
  25435. }
  25436. var respJSON map[string]interface{}
  25437. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25438. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25440. return
  25441. }
  25442. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25443. userJSONBytes, _ := json.Marshal(respJSON)
  25444. fmt.Println("log")
  25445. fmt.Println(string(userJSONBytes))
  25446. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25447. utils.ErrorLog("解析失败:%v", err)
  25448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25449. return
  25450. }
  25451. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25452. bytesData, _ := json.Marshal(data)
  25453. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25454. resp, _ := client.Do(req)
  25455. defer resp.Body.Close()
  25456. body, ioErr := ioutil.ReadAll(resp.Body)
  25457. if ioErr != nil {
  25458. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25460. return
  25461. }
  25462. var respJSON map[string]interface{}
  25463. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25466. return
  25467. }
  25468. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25469. userJSONBytes, _ := json.Marshal(respJSON)
  25470. fmt.Println("log")
  25471. fmt.Println(string(userJSONBytes))
  25472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25473. utils.ErrorLog("解析失败:%v", err)
  25474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25475. return
  25476. }
  25477. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25478. bytesData, _ := json.Marshal(data)
  25479. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25480. resp, _ := client.Do(req)
  25481. defer resp.Body.Close()
  25482. body, ioErr := ioutil.ReadAll(resp.Body)
  25483. if ioErr != nil {
  25484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25486. return
  25487. }
  25488. var respJSON map[string]interface{}
  25489. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25492. return
  25493. }
  25494. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25495. userJSONBytes, _ := json.Marshal(respJSON)
  25496. fmt.Println("log")
  25497. fmt.Println(string(userJSONBytes))
  25498. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25499. utils.ErrorLog("解析失败:%v", err)
  25500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25501. return
  25502. }
  25503. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25504. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25505. if result3101.Infcode == "0" {
  25506. if len(result3101.Output.Result) > 0 {
  25507. var errMsgs []string
  25508. for _, item := range result3101.Output.Result {
  25509. errMsgs = append(errMsgs, item.VolaCont)
  25510. }
  25511. c.ServeSuccessJSON(map[string]interface{}{
  25512. "failed_code": -10,
  25513. "msg": errMsgs,
  25514. })
  25515. return
  25516. }
  25517. }
  25518. bytesData, _ := json.Marshal(data)
  25519. var req *http.Request
  25520. if miConfig.MdtrtareaAdmvs == "320921" {
  25521. data["diag_code"] = sickConfig.CountryCode
  25522. fmt.Println(data)
  25523. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25524. } else {
  25525. data["diag_code"] = sickConfig.CountryCode
  25526. fmt.Println(data)
  25527. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25528. }
  25529. resp, _ := client.Do(req)
  25530. defer resp.Body.Close()
  25531. body, ioErr := ioutil.ReadAll(resp.Body)
  25532. if ioErr != nil {
  25533. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25535. return
  25536. }
  25537. var respJSON map[string]interface{}
  25538. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25541. return
  25542. }
  25543. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25544. userJSONBytes, _ := json.Marshal(respJSON)
  25545. fmt.Println("log")
  25546. fmt.Println(string(userJSONBytes))
  25547. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25548. utils.ErrorLog("解析失败:%v", err)
  25549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25550. return
  25551. }
  25552. res.InfRefmsgid = resFour10265.InfRefmsgid
  25553. res.Output = resFour10265.Output
  25554. res.ErrMsg = resFour10265.ErrMsg
  25555. res.Cainfo = resFour10265.Cainfo
  25556. res.WarnMsg = resFour10265.WarnMsg
  25557. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25558. res.Infcode = infocode
  25559. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25560. var pagesize int = 2
  25561. var start int = 1
  25562. var stop int
  25563. var pagecount int
  25564. var curpage int
  25565. var isSuccess bool = true
  25566. data["doctor_id"] = doctor_info.DoctorNumber
  25567. //总页数,向上取整,注意除之前要先转换类型为float64
  25568. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  25569. for curpage = 1; curpage <= pagecount; curpage++ {
  25570. if curpage == 1 {
  25571. start = 1
  25572. } else {
  25573. start = (curpage-1)*pagesize + 1
  25574. }
  25575. stop = curpage * pagesize
  25576. if stop > len(prescriptions) {
  25577. stop = len(prescriptions)
  25578. }
  25579. //var requestLog string
  25580. data["pre"] = prescriptions[start-1 : stop]
  25581. fmt.Println(data["pre"])
  25582. bytesData, _ := json.Marshal(data)
  25583. var req *http.Request
  25584. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  25585. resp, _ := client.Do(req)
  25586. defer resp.Body.Close()
  25587. body, ioErr := ioutil.ReadAll(resp.Body)
  25588. if ioErr != nil {
  25589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25591. return
  25592. }
  25593. var respJSON map[string]interface{}
  25594. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25595. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25597. return
  25598. }
  25599. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25600. userJSONBytes, _ := json.Marshal(respJSON)
  25601. fmt.Println("log")
  25602. fmt.Println(string(userJSONBytes))
  25603. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25604. utils.ErrorLog("解析失败:%v", err)
  25605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25606. return
  25607. }
  25608. res.InfRefmsgid = resFour10265.InfRefmsgid
  25609. res.Output = resFour10265.Output
  25610. res.ErrMsg = resFour10265.ErrMsg
  25611. res.Cainfo = resFour10265.Cainfo
  25612. res.WarnMsg = resFour10265.WarnMsg
  25613. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25614. res.Infcode = infocode
  25615. if infocode == 0 {
  25616. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  25617. } else {
  25618. isSuccess = false
  25619. errlog := &models.HisOrderError{
  25620. UserOrgId: adminUser.CurrentOrgId,
  25621. Ctime: time.Now().Unix(),
  25622. Mtime: time.Now().Unix(),
  25623. Number: chrg_bchno,
  25624. ErrMsg: "",
  25625. Status: 1,
  25626. PatientId: id,
  25627. RecordTime: recordDateTime,
  25628. Stage: 4,
  25629. }
  25630. service.CreateErrMsgLog(errlog)
  25631. c.ServeSuccessJSON(map[string]interface{}{
  25632. "failed_code": -10,
  25633. "msg": res.ErrMsg,
  25634. })
  25635. return
  25636. }
  25637. }
  25638. if isSuccess {
  25639. res.Infcode = 0
  25640. }
  25641. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25642. 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)
  25643. var dat map[string]interface{}
  25644. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25645. fmt.Println(dat)
  25646. } else {
  25647. fmt.Println(err)
  25648. }
  25649. saveLog(result, request_log, "2204", "上传费用明细")
  25650. userJSONBytes, _ := json.Marshal(dat)
  25651. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25652. utils.ErrorLog("解析失败:%v", err)
  25653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25654. return
  25655. }
  25656. res.InfRefmsgid = resFour10265.InfRefmsgid
  25657. res.Output = resFour10265.Output
  25658. res.ErrMsg = resFour10265.ErrMsg
  25659. res.Cainfo = resFour10265.Cainfo
  25660. res.WarnMsg = resFour10265.WarnMsg
  25661. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25662. res.Infcode = infocode
  25663. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25664. bytesData, _ := json.Marshal(data)
  25665. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  25666. resp, _ := client.Do(req)
  25667. defer resp.Body.Close()
  25668. body, ioErr := ioutil.ReadAll(resp.Body)
  25669. if ioErr != nil {
  25670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25672. return
  25673. }
  25674. var respJSON map[string]interface{}
  25675. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25678. return
  25679. }
  25680. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25681. userJSONBytes, _ := json.Marshal(respJSON)
  25682. fmt.Println("log")
  25683. fmt.Println(string(userJSONBytes))
  25684. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25685. utils.ErrorLog("解析失败:%v", err)
  25686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25687. return
  25688. }
  25689. } else {
  25690. if miConfig.Code == "H15049901371" {
  25691. 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)
  25692. var dat map[string]interface{}
  25693. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25694. fmt.Println(dat)
  25695. } else {
  25696. fmt.Println(err)
  25697. }
  25698. saveLog(result, request_log, "2204", "上传费用明细")
  25699. userJSONBytes, _ := json.Marshal(dat)
  25700. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25701. utils.ErrorLog("解析失败:%v", err)
  25702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25703. return
  25704. }
  25705. res.InfRefmsgid = resFour10265.InfRefmsgid
  25706. res.Output = resFour10265.Output
  25707. res.ErrMsg = resFour10265.ErrMsg
  25708. res.Cainfo = resFour10265.Cainfo
  25709. res.WarnMsg = resFour10265.WarnMsg
  25710. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25711. res.Infcode = infocode
  25712. } else {
  25713. 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)
  25714. var dat map[string]interface{}
  25715. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25716. fmt.Println(dat)
  25717. } else {
  25718. fmt.Println(err)
  25719. }
  25720. saveLog(result, request_log, "2204", "上传费用明细")
  25721. userJSONBytes, _ := json.Marshal(dat)
  25722. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25723. utils.ErrorLog("解析失败:%v", err)
  25724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25725. return
  25726. }
  25727. }
  25728. }
  25729. if res.Infcode == 0 {
  25730. order := &models.HisOrder{
  25731. UserOrgId: adminUser.CurrentOrgId,
  25732. HisPatientId: his.ID,
  25733. PatientId: his.PatientId,
  25734. SettleAccountsDate: recordDateTime,
  25735. MdtrtId: his.Number,
  25736. PsnNo: his.PsnNo,
  25737. MedType: strconv.FormatInt(reg_type, 10),
  25738. Ctime: time.Now().Unix(),
  25739. Mtime: time.Now().Unix(),
  25740. Status: 1,
  25741. Number: chrg_bchno,
  25742. Infcode: res.Infcode,
  25743. WarnMsg: res.WarnMsg,
  25744. Cainfo: res.Cainfo,
  25745. ErrMsg: res.ErrMsg,
  25746. RespondTime: res.RefmsgTime,
  25747. InfRefmsgid: res.InfRefmsgid,
  25748. OrderStatus: 1,
  25749. PayWay: pay_way,
  25750. PayWays: pay_ways,
  25751. OthDesc: oth_desc,
  25752. PayPrice: pay_price,
  25753. PayCardNo: pay_card_no,
  25754. DiscountPrice: discount_price,
  25755. PreferentialPrice: preferential_price,
  25756. RealityPrice: reality_price,
  25757. FoundPrice: found_price,
  25758. MedicalInsurancePrice: medical_insurance_price,
  25759. PrivatePrice: private_price,
  25760. IsMedicineInsurance: 1,
  25761. SettleType: settle_accounts_type,
  25762. SettleStartTime: start_time,
  25763. SettleEndTime: end_time,
  25764. Creator: roles.AdminUserId,
  25765. Modify: roles.AdminUserId,
  25766. FaPiaoNumber: fapiao_number,
  25767. FaPiaoCode: fapiao_code,
  25768. PType: 2,
  25769. Diagnosis: diagnosis_id,
  25770. CashPay: cash_pay,
  25771. WechatPay: wechat_pay,
  25772. AliPay: ali_pay,
  25773. JifenPay: jifen_pay,
  25774. BandCardPay: band_card_pay,
  25775. }
  25776. err = service.CreateOrder(order)
  25777. if err != nil {
  25778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25779. return
  25780. }
  25781. for _, item := range res.Output.Result {
  25782. temp := strings.Split(item.FeedetlSn, "-")
  25783. var advice_id int64 = 0
  25784. var project_id int64 = 0
  25785. var types int64 = 0
  25786. id, _ := strconv.ParseInt(temp[2], 10, 64)
  25787. types, _ = strconv.ParseInt(temp[1], 10, 64)
  25788. if temp[1] == "1" {
  25789. advice_id = id
  25790. project_id = 0
  25791. } else if temp[1] == "2" {
  25792. advice_id = 0
  25793. project_id = id
  25794. }
  25795. if item.MedChrgitmType == "9" {
  25796. item.MedChrgitmType = "09"
  25797. }
  25798. info := &models.HisOrderInfo{
  25799. OrderNumber: order.Number,
  25800. FeedetlSn: item.FeedetlSn,
  25801. UploadDate: time.Now().Unix(),
  25802. AdviceId: advice_id,
  25803. DetItemFeeSumamt: item.DetItemFeeSumamt,
  25804. Cnt: item.Cnt,
  25805. Pric: float64(item.Pric),
  25806. PatientId: his.PatientId,
  25807. PricUplmtAmt: item.PricUplmtAmt,
  25808. SelfpayProp: item.SelfpayProp,
  25809. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  25810. OverlmtAmt: item.OverlmtAmt,
  25811. PreselfpayAmt: item.PreselfpayAmt,
  25812. BasMednFlag: item.BasMednFlag,
  25813. MedChrgitmType: item.MedChrgitmType,
  25814. HiNegoDrugFlag: item.HiNegoDrugFlag,
  25815. Status: 1,
  25816. Memo: item.Memo,
  25817. Mtime: time.Now().Unix(),
  25818. InscpScpAmt: item.InscpScpAmt,
  25819. DrtReimFlag: item.DrtReimFlag,
  25820. Ctime: time.Now().Unix(),
  25821. ListSpItemFlag: item.ListSpItemFlag,
  25822. ChldMedcFlag: item.ChldMedcFlag,
  25823. LmtUsedFlag: item.LmtUsedFlag,
  25824. ChrgitmLv: item.ChrgitmLv,
  25825. UserOrgId: adminUser.CurrentOrgId,
  25826. HisPatientId: his.ID,
  25827. OrderId: order.ID,
  25828. ProjectId: project_id,
  25829. Type: types,
  25830. }
  25831. service.CreateOrderInfo(info)
  25832. }
  25833. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  25834. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  25835. var total float64
  25836. for _, item := range prescriptions {
  25837. if item.Type == 1 { //药品
  25838. for _, subItem := range item.HisDoctorAdviceInfo {
  25839. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25840. total_one := price * subItem.PrescribingNumber
  25841. total = total + total_one
  25842. }
  25843. }
  25844. if item.Type == 2 { //项目
  25845. for _, subItem := range item.HisPrescriptionProject {
  25846. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  25847. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25848. total_one := price * cnt
  25849. total = total + total_one
  25850. }
  25851. }
  25852. }
  25853. allTotal := fmt.Sprintf("%.2f", total)
  25854. //if adminUser.CurrentOrgId == 9919 {
  25855. //
  25856. // allTotal = fmt.Sprintf("%.2f", total)
  25857. //
  25858. //} else {
  25859. //
  25860. // allTotal = fmt.Sprintf("%.2f", total)
  25861. //
  25862. //}
  25863. if res.Infcode == 0 {
  25864. var rf []*ResultFive
  25865. json.Unmarshal([]byte(his.Iinfo), &rf)
  25866. chrg_bchno := chrg_bchno
  25867. cert_no := his.Certno
  25868. var insutypes []string
  25869. var insutype string
  25870. var is390 int = 0
  25871. var is310 int = 0
  25872. for _, item := range rf {
  25873. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25874. insutypes = append(insutypes, item.Insutype)
  25875. }
  25876. }
  25877. if len(insutypes) == 1 {
  25878. insutype = insutypes[0]
  25879. } else {
  25880. for _, i := range insutypes {
  25881. if i == "390" {
  25882. is390 = 1
  25883. }
  25884. if i == "310" {
  25885. is310 = 1
  25886. }
  25887. }
  25888. }
  25889. if is390 == 1 {
  25890. insutype = "390"
  25891. }
  25892. if is310 == 1 {
  25893. insutype = "310"
  25894. }
  25895. if len(insutypes) == 0 {
  25896. insutype = "310"
  25897. }
  25898. if len(insutypes) == 2 {
  25899. insutype = strconv.FormatInt(his.SocialType, 10)
  25900. }
  25901. insutype = strconv.FormatInt(his.SocialType, 10)
  25902. //insutype = "390"
  25903. if his.IdCardType == 1 {
  25904. // cert_no = his.MedicalInsuranceNumber
  25905. cert_no = his.Certno
  25906. } else {
  25907. cert_no = his.Certno
  25908. }
  25909. var res ResultSeven
  25910. var resSeven10265 ResultSeven10265
  25911. var gzresSeven10265Two GZResultSeven10265Two
  25912. var src_resquest string
  25913. var result2 string
  25914. if miConfig.MdtrtareaAdmvs == "421300" {
  25915. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25916. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25917. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25918. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25919. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25920. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25921. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25922. resp, requestErr := http.Get(api)
  25923. if requestErr != nil {
  25924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25925. return
  25926. }
  25927. body, ioErr := ioutil.ReadAll(resp.Body)
  25928. if ioErr != nil {
  25929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25931. return
  25932. }
  25933. var respJSON map[string]interface{}
  25934. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25937. return
  25938. }
  25939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25940. result, _ := json.Marshal(respJSON)
  25941. if miConfig.Code == "H15049901371" {
  25942. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25943. utils.ErrorLog("解析失败:%v", err)
  25944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25945. return
  25946. }
  25947. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25948. res.Output = resSeven10265.Output
  25949. res.ErrMsg = resSeven10265.ErrMsg
  25950. res.Cainfo = resSeven10265.Cainfo
  25951. res.WarnMsg = resSeven10265.WarnMsg
  25952. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25953. res.Infcode = infocode
  25954. } else {
  25955. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25956. utils.ErrorLog("解析失败:%v", err)
  25957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25958. return
  25959. }
  25960. }
  25961. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25962. if reg_type == 11 && his.Insutype == "390" {
  25963. reg_type = 110104
  25964. }
  25965. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25966. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25967. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25968. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25969. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25970. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25971. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25972. resp, requestErr := http.Get(api)
  25973. if requestErr != nil {
  25974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25975. return
  25976. }
  25977. body, ioErr := ioutil.ReadAll(resp.Body)
  25978. if ioErr != nil {
  25979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25981. return
  25982. }
  25983. var respJSON map[string]interface{}
  25984. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25987. return
  25988. }
  25989. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25990. result, _ := json.Marshal(respJSON)
  25991. if miConfig.Code == "H15049901371" {
  25992. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25993. utils.ErrorLog("解析失败:%v", err)
  25994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25995. return
  25996. }
  25997. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25998. res.Output = resSeven10265.Output
  25999. res.ErrMsg = resSeven10265.ErrMsg
  26000. res.Cainfo = resSeven10265.Cainfo
  26001. res.WarnMsg = resSeven10265.WarnMsg
  26002. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26003. res.Infcode = infocode
  26004. } else {
  26005. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26006. utils.ErrorLog("解析失败:%v", err)
  26007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26008. return
  26009. }
  26010. }
  26011. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26012. if reg_type == 11 && his.Insutype == "390" {
  26013. reg_type = 110104
  26014. }
  26015. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26016. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26017. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26018. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26019. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26020. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26021. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26022. resp, requestErr := http.Get(api)
  26023. if requestErr != nil {
  26024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26025. return
  26026. }
  26027. body, ioErr := ioutil.ReadAll(resp.Body)
  26028. if ioErr != nil {
  26029. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26031. return
  26032. }
  26033. var respJSON map[string]interface{}
  26034. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26037. return
  26038. }
  26039. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26040. result, _ := json.Marshal(respJSON)
  26041. if miConfig.Code == "H15049901371" {
  26042. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26043. utils.ErrorLog("解析失败:%v", err)
  26044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26045. return
  26046. }
  26047. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26048. res.Output = resSeven10265.Output
  26049. res.ErrMsg = resSeven10265.ErrMsg
  26050. res.Cainfo = resSeven10265.Cainfo
  26051. res.WarnMsg = resSeven10265.WarnMsg
  26052. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26053. res.Infcode = infocode
  26054. } else {
  26055. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26056. utils.ErrorLog("解析失败:%v", err)
  26057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26058. return
  26059. }
  26060. }
  26061. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26062. if reg_type == 11 && his.Insutype == "390" {
  26063. reg_type = 110104
  26064. }
  26065. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26066. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26067. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26068. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26069. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26070. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26071. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26072. resp, requestErr := http.Get(api)
  26073. if requestErr != nil {
  26074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26075. return
  26076. }
  26077. body, ioErr := ioutil.ReadAll(resp.Body)
  26078. if ioErr != nil {
  26079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26081. return
  26082. }
  26083. var respJSON map[string]interface{}
  26084. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26087. return
  26088. }
  26089. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26090. result, _ := json.Marshal(respJSON)
  26091. if miConfig.Code == "H15049901371" {
  26092. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26093. utils.ErrorLog("解析失败:%v", err)
  26094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26095. return
  26096. }
  26097. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26098. res.Output = resSeven10265.Output
  26099. res.ErrMsg = resSeven10265.ErrMsg
  26100. res.Cainfo = resSeven10265.Cainfo
  26101. res.WarnMsg = resSeven10265.WarnMsg
  26102. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26103. res.Infcode = infocode
  26104. } else {
  26105. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26106. utils.ErrorLog("解析失败:%v", err)
  26107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26108. return
  26109. }
  26110. }
  26111. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26112. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  26113. if result3101.Infcode == "0" {
  26114. if len(result3101.Output.Result) > 0 {
  26115. var errMsgs []string
  26116. for _, item := range result3101.Output.Result {
  26117. errMsgs = append(errMsgs, item.VolaCont)
  26118. }
  26119. c.ServeSuccessJSON(map[string]interface{}{
  26120. "failed_code": -10,
  26121. "msg": errMsgs,
  26122. })
  26123. return
  26124. } else {
  26125. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26126. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26127. bas := strings.Split(psn_info.CardInfo, "|")
  26128. if his.IdCardType == 1 {
  26129. cert_no = bas[2]
  26130. } else if his.IdCardType == 3 {
  26131. cert_no = his.Certno
  26132. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26133. } else if his.IdCardType == 4 {
  26134. cert_no = his.Certno
  26135. psn_info.VerifyNumber = psn_info.VerifyNumber
  26136. }
  26137. var api string
  26138. if miConfig.MdtrtareaAdmvs == "320921" {
  26139. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26140. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26141. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26142. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26143. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26144. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26145. "&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
  26146. } else {
  26147. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26148. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26149. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26150. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26151. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26152. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26153. "&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
  26154. }
  26155. resp, requestErr := http.Get(api)
  26156. if requestErr != nil {
  26157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26158. return
  26159. }
  26160. body, ioErr := ioutil.ReadAll(resp.Body)
  26161. if ioErr != nil {
  26162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26164. return
  26165. }
  26166. var respJSON map[string]interface{}
  26167. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26170. return
  26171. }
  26172. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26173. result, _ := json.Marshal(respJSON)
  26174. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26175. utils.ErrorLog("解析失败:%v", err)
  26176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26177. return
  26178. }
  26179. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26180. res.Output = resSeven10265.Output
  26181. res.ErrMsg = resSeven10265.ErrMsg
  26182. res.Cainfo = resSeven10265.Cainfo
  26183. res.WarnMsg = resSeven10265.WarnMsg
  26184. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26185. res.Infcode = infocode
  26186. }
  26187. }
  26188. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26189. psn_info, _ := service.GetPsnByPatientId(id)
  26190. var verify_number string
  26191. if psn_info.IdCardType == 4 {
  26192. verify_number = psn_info.VerifyNumber
  26193. } else if psn_info.IdCardType == 1 {
  26194. bas := strings.Split(psn_info.CardInfo, "|")
  26195. cardNumber := bas[2]
  26196. verify_number = cardNumber
  26197. } else {
  26198. psn_info.IdCardType = 2
  26199. verify_number = psn_info.Certno
  26200. }
  26201. var api string
  26202. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26203. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26204. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26205. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26206. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26207. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26208. "&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
  26209. resp, requestErr := http.Get(api)
  26210. if requestErr != nil {
  26211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26212. return
  26213. }
  26214. body, ioErr := ioutil.ReadAll(resp.Body)
  26215. if ioErr != nil {
  26216. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26218. return
  26219. }
  26220. var respJSON map[string]interface{}
  26221. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26222. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26224. return
  26225. }
  26226. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26227. result, _ := json.Marshal(respJSON)
  26228. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26229. utils.ErrorLog("解析失败:%v", err)
  26230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26231. return
  26232. }
  26233. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26234. res.Output = resSeven10265.Output
  26235. res.ErrMsg = resSeven10265.ErrMsg
  26236. res.Cainfo = resSeven10265.Cainfo
  26237. res.WarnMsg = resSeven10265.WarnMsg
  26238. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26239. res.Infcode = infocode
  26240. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26241. var cert_no string
  26242. if his.IdCardType == 4 {
  26243. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26244. cert_no = psn_info.VerifyNumber
  26245. 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)
  26246. } else if his.IdCardType == 1 {
  26247. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26248. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26249. 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)
  26250. }
  26251. //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)
  26252. var dat map[string]interface{}
  26253. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26254. fmt.Println(dat)
  26255. } else {
  26256. fmt.Println(err)
  26257. }
  26258. saveLog(result2, src_resquest, "2207", "结算")
  26259. userJSONBytes, _ := json.Marshal(dat)
  26260. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26261. utils.ErrorLog("解析失败:%v", err)
  26262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26263. return
  26264. }
  26265. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26266. res.Output = resSeven10265.Output
  26267. res.ErrMsg = resSeven10265.ErrMsg
  26268. res.Cainfo = resSeven10265.Cainfo
  26269. res.WarnMsg = resSeven10265.WarnMsg
  26270. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26271. res.Infcode = infocode
  26272. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26273. res2 := c.GetoleInfo()
  26274. if res2.Infcode == 0 {
  26275. var result string
  26276. var request_log string
  26277. var result_log string
  26278. if res2.Output.MdtrtCertType == "02" {
  26279. 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)
  26280. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26281. } else if res2.Output.MdtrtCertType == "01" {
  26282. 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)
  26283. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26284. } else {
  26285. 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)
  26286. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26287. }
  26288. var dat map[string]interface{}
  26289. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26290. fmt.Println(dat)
  26291. } else {
  26292. fmt.Println(err)
  26293. }
  26294. userJSONBytes, _ := json.Marshal(dat)
  26295. var res5 ResultTwo
  26296. //var resTwo10265 ResultTwo10265
  26297. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26298. utils.ErrorLog("解析失败:%v", err)
  26299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26300. return
  26301. }
  26302. if res5.Infcode == -1 {
  26303. c.ServeSuccessJSON(map[string]interface{}{
  26304. "failed_code": -10,
  26305. "msg": res5.ErrMsg,
  26306. })
  26307. return
  26308. }
  26309. var insutypes []string
  26310. var insutype string
  26311. var is390 int = 0
  26312. var is310 int = 0
  26313. for _, item := range res5.Output.Iinfo {
  26314. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26315. insutypes = append(insutypes, item.Insutype)
  26316. }
  26317. }
  26318. if len(insutypes) == 1 {
  26319. insutype = insutypes[0]
  26320. } else {
  26321. for _, i := range insutypes {
  26322. if i == "390" {
  26323. is390 = 1
  26324. }
  26325. if i == "310" {
  26326. is310 = 1
  26327. }
  26328. }
  26329. }
  26330. if is390 == 1 {
  26331. insutype = "390"
  26332. }
  26333. if is310 == 1 {
  26334. insutype = "310"
  26335. }
  26336. if len(insutypes) == 0 {
  26337. insutype = "310"
  26338. }
  26339. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26340. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26341. infoStr := string(Iinfos)
  26342. idetinfoStr := string(Idetinfos)
  26343. psn := &models.HisPsn{
  26344. PsnNo: res5.Output.Baseinfo.PsnNo,
  26345. PatientId: id,
  26346. Certno: res5.Output.Baseinfo.Certno,
  26347. Gend: res5.Output.Baseinfo.Gend,
  26348. Naty: res5.Output.Baseinfo.Naty,
  26349. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26350. PsnName: res5.Output.Baseinfo.PsnName,
  26351. Idetinfo: idetinfoStr,
  26352. Insuinfo: infoStr,
  26353. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26354. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26355. VerifyNumber: res2.Output.EcToken,
  26356. }
  26357. if res2.Output.MdtrtCertType == "01" {
  26358. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26359. psn.VerifyNumber = res2.Output.EcToken
  26360. } else if res2.Output.MdtrtCertType == "02" {
  26361. psn.VerifyNumber = res2.Output.CardNo
  26362. } else {
  26363. psn.VerifyNumber = res2.Output.MdtrtCertNo
  26364. }
  26365. service.CreateHisPsn(psn)
  26366. if res2.Output.MdtrtCertType == "01" {
  26367. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26368. token := res2.Output.EcToken
  26369. 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)
  26370. } else if res2.Output.MdtrtCertType == "02" {
  26371. 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)
  26372. } else {
  26373. 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)
  26374. }
  26375. var dat2 map[string]interface{}
  26376. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26377. fmt.Println(dat2)
  26378. } else {
  26379. fmt.Println(err)
  26380. }
  26381. userJSONBytes3, _ := json.Marshal(dat2)
  26382. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26383. utils.ErrorLog("解析失败:%v", err)
  26384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26385. return
  26386. }
  26387. saveLog(result2, src_resquest, "2207", "结算")
  26388. } else {
  26389. c.ServeSuccessJSON(map[string]interface{}{
  26390. "failed_code": -10,
  26391. "msg": res2.ErrMsg,
  26392. })
  26393. return
  26394. }
  26395. } else {
  26396. if miConfig.Code == "H15049901371" {
  26397. //赤峰地区国家医保医疗类别
  26398. //职工透析:医疗类别选特殊情况门诊990502
  26399. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26400. var med_type string
  26401. if his.Insutype == "390" {
  26402. if reg_type == 14 {
  26403. med_type = "9933"
  26404. } else if reg_type == 11 {
  26405. med_type = "11"
  26406. }
  26407. } else if his.Insutype == "310" {
  26408. if reg_type == 14 {
  26409. med_type = "990502"
  26410. } else if reg_type == 11 {
  26411. med_type = "11"
  26412. }
  26413. }
  26414. 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)
  26415. } else {
  26416. if his.IdCardType == 4 {
  26417. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26418. var token string
  26419. token = psn_info.VerifyNumber
  26420. 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)
  26421. } else {
  26422. if his.IdCardType == 1 {
  26423. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26424. bas := strings.Split(psn_info.CardInfo, "|")
  26425. basNumber := bas[2]
  26426. cert_no = basNumber
  26427. }
  26428. 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)
  26429. }
  26430. }
  26431. //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)
  26432. var dat map[string]interface{}
  26433. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26434. fmt.Println(dat)
  26435. } else {
  26436. fmt.Println(err)
  26437. }
  26438. saveLog(result2, src_resquest, "2207", "结算")
  26439. userJSONBytes, _ := json.Marshal(dat)
  26440. if miConfig.Code == "H15049901371" {
  26441. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26442. utils.ErrorLog("解析失败:%v", err)
  26443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26444. return
  26445. }
  26446. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26447. res.Output = resSeven10265.Output
  26448. res.ErrMsg = resSeven10265.ErrMsg
  26449. res.Cainfo = resSeven10265.Cainfo
  26450. res.WarnMsg = resSeven10265.WarnMsg
  26451. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26452. res.Infcode = infocode
  26453. } else {
  26454. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26455. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26456. utils.ErrorLog("解析失败:%v", err)
  26457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26458. return
  26459. }
  26460. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26461. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26462. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26463. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26464. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26465. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26466. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26467. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26468. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26469. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26470. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26471. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26472. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26473. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26474. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26475. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26476. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26477. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26478. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26479. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26480. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26481. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26482. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26483. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26484. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26485. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26486. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26487. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26488. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26489. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26490. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26491. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26492. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26493. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26494. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26495. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26496. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26497. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26498. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26499. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26500. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26501. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26502. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26503. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26504. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26505. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26506. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26507. res.Cainfo = gzresSeven10265Two.Cainfo
  26508. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26509. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26510. //res.Infcode = infocode
  26511. } else {
  26512. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26513. utils.ErrorLog("解析失败:%v", err)
  26514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26515. return
  26516. }
  26517. }
  26518. }
  26519. }
  26520. if res.Infcode == -1 {
  26521. errlog := &models.HisOrderError{
  26522. UserOrgId: adminUser.CurrentOrgId,
  26523. Ctime: time.Now().Unix(),
  26524. Mtime: time.Now().Unix(),
  26525. Number: chrg_bchno,
  26526. ErrMsg: res.ErrMsg,
  26527. Status: 1,
  26528. PatientId: id,
  26529. RecordTime: recordDateTime,
  26530. Stage: 6,
  26531. }
  26532. service.CreateErrMsgLog(errlog)
  26533. c.ServeSuccessJSON(map[string]interface{}{
  26534. "failed_code": -10,
  26535. "msg": res.ErrMsg,
  26536. })
  26537. return
  26538. } else {
  26539. sickConfig, _ := service.FindSickById(his.SickType)
  26540. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  26541. order.OrderStatus = 2
  26542. order.Status = 1
  26543. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  26544. order.SetlId = res.Output.Setlinfo.SetlID
  26545. order.PsnNo = res.Output.Setlinfo.PsnNo
  26546. order.PsnName = res.Output.Setlinfo.PsnName
  26547. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26548. order.Certno = res.Output.Setlinfo.Certno
  26549. order.Gend = res.Output.Setlinfo.Gend
  26550. order.Naty = res.Output.Setlinfo.Naty
  26551. order.Age = res.Output.Setlinfo.Age
  26552. order.Insutype = res.Output.Setlinfo.Insutype
  26553. order.PsnType = res.Output.Setlinfo.PsnType
  26554. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26555. order.SetlTime = res.Output.Setlinfo.SetlTime
  26556. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26557. if res.Output.Setlinfo.MedType == "140101" {
  26558. order.MedType = "14"
  26559. } else {
  26560. if res.Output.Setlinfo.MedType == "110104" {
  26561. order.MedType = "11"
  26562. } else {
  26563. order.MedType = res.Output.Setlinfo.MedType
  26564. }
  26565. }
  26566. if reg_type == 1112 {
  26567. order.MedType = "1112"
  26568. }
  26569. if reg_type == 1111 {
  26570. order.MedType = "1111"
  26571. }
  26572. order.ClrType = res.Output.Setlinfo.ClrType
  26573. if adminUser.CurrentOrgId == 10480 {
  26574. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26575. order.ClrType = "11"
  26576. } else {
  26577. order.ClrType = "9903"
  26578. }
  26579. }
  26580. if adminUser.CurrentOrgId == 10721 {
  26581. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  26582. order.ClrType = "11"
  26583. } else {
  26584. order.ClrType = "9903"
  26585. }
  26586. }
  26587. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26588. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26589. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26590. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26591. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26592. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26593. order.HifpPay = res.Output.Setlinfo.HifpPay
  26594. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26595. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26596. order.HifesPay = res.Output.Setlinfo.HifesPay
  26597. order.HifobPay = res.Output.Setlinfo.HifobPay
  26598. order.MafPay = res.Output.Setlinfo.MafPay
  26599. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26600. order.OthPay = res.Output.Setlinfo.OthPay
  26601. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26602. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26603. order.AcctPay = res.Output.Setlinfo.AcctPay
  26604. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26605. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26606. order.Balc = res.Output.Setlinfo.Balc
  26607. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26608. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26609. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26610. //order.ClrType = res.Output.Setlinfo.ClrType
  26611. order.ClrWay = res.Output.Setlinfo.ClrWay
  26612. order.Creator = order.Creator
  26613. order.Modify = roles.AdminUserId
  26614. order.RequestLog = src_resquest
  26615. order.FaPiaoNumber = fapiao_number
  26616. order.FaPiaoCode = fapiao_code
  26617. order.SickName = sickConfig.ClassName
  26618. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26619. //detailStr := string(setlDetail)
  26620. //order.SetlDetail = detailStr
  26621. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26622. err = service.UpDateOrder(order)
  26623. if err == nil {
  26624. //判断是否使用了押金
  26625. if dec_way == "true" {
  26626. tmpstring := strconv.FormatInt(order.ID, 10)
  26627. order.Decimal = decimal
  26628. service.UpDateOrder(order)
  26629. //扣押金
  26630. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  26631. if errmsg != nil {
  26632. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  26633. return
  26634. }
  26635. }
  26636. c.ServeSuccessJSON(map[string]interface{}{
  26637. "msg": "结算成功",
  26638. })
  26639. } else {
  26640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26641. return
  26642. }
  26643. }
  26644. } else {
  26645. adminUser := c.GetAdminUserInfo()
  26646. errlog := &models.HisOrderError{
  26647. UserOrgId: adminUser.CurrentOrgId,
  26648. Ctime: time.Now().Unix(),
  26649. Mtime: time.Now().Unix(),
  26650. ErrMsg: res.ErrMsg,
  26651. Status: 1,
  26652. PatientId: id,
  26653. RecordTime: recordDateTime,
  26654. Stage: 4,
  26655. }
  26656. service.CreateErrMsgLog(errlog)
  26657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  26658. return
  26659. }
  26660. } else {
  26661. adminUser := c.GetAdminUserInfo()
  26662. errlog := &models.HisOrderError{
  26663. UserOrgId: adminUser.CurrentOrgId,
  26664. Ctime: time.Now().Unix(),
  26665. Mtime: time.Now().Unix(),
  26666. ErrMsg: res.ErrMsg,
  26667. Status: 1,
  26668. PatientId: id,
  26669. RecordTime: recordDateTime,
  26670. Stage: 4,
  26671. }
  26672. service.CreateErrMsgLog(errlog)
  26673. c.ServeSuccessJSON(map[string]interface{}{
  26674. "failed_code": -10,
  26675. "msg": res.ErrMsg,
  26676. })
  26677. return
  26678. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  26679. //return
  26680. }
  26681. }
  26682. }
  26683. } else if tempOrder.ID > 0 {
  26684. if tempOrder.IsPre == 1 {
  26685. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  26686. var rf []*ResultFive
  26687. json.Unmarshal([]byte(his.Iinfo), &rf)
  26688. chrg_bchno := tempOrder.Number
  26689. cert_no := his.Certno
  26690. var insutypes []string
  26691. var insutype string
  26692. var is390 int = 0
  26693. var is310 int = 0
  26694. for _, item := range rf {
  26695. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26696. insutypes = append(insutypes, item.Insutype)
  26697. }
  26698. }
  26699. if len(insutypes) == 1 {
  26700. insutype = insutypes[0]
  26701. } else {
  26702. for _, i := range insutypes {
  26703. if i == "390" {
  26704. is390 = 1
  26705. }
  26706. if i == "310" {
  26707. is310 = 1
  26708. }
  26709. }
  26710. }
  26711. if is390 == 1 {
  26712. insutype = "390"
  26713. }
  26714. if is310 == 1 {
  26715. insutype = "310"
  26716. }
  26717. if len(insutypes) == 0 {
  26718. insutype = "310"
  26719. }
  26720. if len(insutypes) == 2 {
  26721. insutype = strconv.FormatInt(his.SocialType, 10)
  26722. }
  26723. //insutype = "390"
  26724. if his.IdCardType == 1 {
  26725. // cert_no = his.MedicalInsuranceNumber
  26726. cert_no = his.Certno
  26727. } else {
  26728. cert_no = his.Certno
  26729. }
  26730. var res ResultSeven
  26731. var ahres ResultSevenAH
  26732. var resSeven10265 ResultSeven10265
  26733. var gzresSeven10265Two GZResultSeven10265Two
  26734. var src_resquest string
  26735. var result2 string
  26736. if miConfig.MdtrtareaAdmvs == "450721" {
  26737. res2 := c.GetoleInfo()
  26738. if res2.Infcode == 0 {
  26739. var result string
  26740. var request_log string
  26741. var result_log string
  26742. if res2.Output.MdtrtCertType == "02" {
  26743. 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)
  26744. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26745. } else if res2.Output.MdtrtCertType == "01" {
  26746. 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)
  26747. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26748. } else {
  26749. 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)
  26750. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26751. }
  26752. var dat map[string]interface{}
  26753. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26754. fmt.Println(dat)
  26755. } else {
  26756. fmt.Println(err)
  26757. }
  26758. userJSONBytes, _ := json.Marshal(dat)
  26759. var res5 ResultTwo
  26760. //var resTwo10265 ResultTwo10265
  26761. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26762. utils.ErrorLog("解析失败:%v", err)
  26763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26764. return
  26765. }
  26766. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  26767. if res5.Infcode == -1 {
  26768. c.ServeSuccessJSON(map[string]interface{}{
  26769. "failed_code": -10,
  26770. "msg": res5.ErrMsg,
  26771. })
  26772. return
  26773. }
  26774. var insutypes []string
  26775. var insutype string
  26776. var is390 int = 0
  26777. var is310 int = 0
  26778. for _, item := range res5.Output.Iinfo {
  26779. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26780. insutypes = append(insutypes, item.Insutype)
  26781. }
  26782. }
  26783. if len(insutypes) == 1 {
  26784. insutype = insutypes[0]
  26785. } else {
  26786. for _, i := range insutypes {
  26787. if i == "390" {
  26788. is390 = 1
  26789. }
  26790. if i == "310" {
  26791. is310 = 1
  26792. }
  26793. }
  26794. }
  26795. if is390 == 1 {
  26796. insutype = "390"
  26797. }
  26798. if is310 == 1 {
  26799. insutype = "310"
  26800. }
  26801. if len(insutypes) == 0 {
  26802. insutype = "310"
  26803. }
  26804. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26805. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26806. infoStr := string(Iinfos)
  26807. idetinfoStr := string(Idetinfos)
  26808. psn := &models.HisPsn{
  26809. PsnNo: res5.Output.Baseinfo.PsnNo,
  26810. PatientId: id,
  26811. Certno: res5.Output.Baseinfo.Certno,
  26812. Gend: res5.Output.Baseinfo.Gend,
  26813. Naty: res5.Output.Baseinfo.Naty,
  26814. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26815. PsnName: res5.Output.Baseinfo.PsnName,
  26816. Idetinfo: idetinfoStr,
  26817. Insuinfo: infoStr,
  26818. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26819. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26820. VerifyNumber: res2.Output.EcToken,
  26821. }
  26822. service.CreateHisPsn(psn)
  26823. if res2.Output.MdtrtCertType == "01" {
  26824. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26825. token := res2.Output.EcToken
  26826. 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)
  26827. } else if res2.Output.MdtrtCertType == "02" {
  26828. 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)
  26829. } else {
  26830. 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)
  26831. }
  26832. var dat2 map[string]interface{}
  26833. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26834. fmt.Println(dat2)
  26835. } else {
  26836. fmt.Println(err)
  26837. }
  26838. userJSONBytes3, _ := json.Marshal(dat2)
  26839. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26840. utils.ErrorLog("解析失败:%v", err)
  26841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26842. return
  26843. }
  26844. saveLog(result2, src_resquest, "2207", "结算")
  26845. } else {
  26846. c.ServeSuccessJSON(map[string]interface{}{
  26847. "failed_code": -10,
  26848. "msg": res2.ErrMsg,
  26849. })
  26850. return
  26851. }
  26852. } else if miConfig.MdtrtareaAdmvs == "421300" {
  26853. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26854. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26855. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26856. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26857. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26858. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26859. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26860. resp, requestErr := http.Get(api)
  26861. if requestErr != nil {
  26862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26863. return
  26864. }
  26865. body, ioErr := ioutil.ReadAll(resp.Body)
  26866. if ioErr != nil {
  26867. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26869. return
  26870. }
  26871. var respJSON map[string]interface{}
  26872. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26875. return
  26876. }
  26877. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26878. result, _ := json.Marshal(respJSON)
  26879. fmt.Println("log")
  26880. fmt.Println(string(result))
  26881. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26882. utils.ErrorLog("解析失败:%v", err)
  26883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26884. return
  26885. }
  26886. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26887. if reg_type == 11 && his.Insutype == "390" {
  26888. reg_type = 110104
  26889. }
  26890. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26891. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26892. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26893. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26894. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26895. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26896. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26897. resp, requestErr := http.Get(api)
  26898. if requestErr != nil {
  26899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26900. return
  26901. }
  26902. body, ioErr := ioutil.ReadAll(resp.Body)
  26903. if ioErr != nil {
  26904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26906. return
  26907. }
  26908. var respJSON map[string]interface{}
  26909. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26912. return
  26913. }
  26914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26915. result, _ := json.Marshal(respJSON)
  26916. fmt.Println("log")
  26917. fmt.Println(string(result))
  26918. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26919. utils.ErrorLog("解析失败:%v", err)
  26920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26921. return
  26922. }
  26923. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26924. if reg_type == 11 && his.Insutype == "390" {
  26925. reg_type = 110104
  26926. }
  26927. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26928. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26929. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26930. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26931. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26932. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26933. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26934. resp, requestErr := http.Get(api)
  26935. if requestErr != nil {
  26936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26937. return
  26938. }
  26939. body, ioErr := ioutil.ReadAll(resp.Body)
  26940. if ioErr != nil {
  26941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26943. return
  26944. }
  26945. var respJSON map[string]interface{}
  26946. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26949. return
  26950. }
  26951. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26952. result, _ := json.Marshal(respJSON)
  26953. fmt.Println("log")
  26954. fmt.Println(string(result))
  26955. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26956. utils.ErrorLog("解析失败:%v", err)
  26957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26958. return
  26959. }
  26960. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26961. if reg_type == 11 && his.Insutype == "390" {
  26962. reg_type = 110104
  26963. }
  26964. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26965. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26966. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26967. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26968. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26969. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26970. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26971. resp, requestErr := http.Get(api)
  26972. if requestErr != nil {
  26973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26974. return
  26975. }
  26976. body, ioErr := ioutil.ReadAll(resp.Body)
  26977. if ioErr != nil {
  26978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26980. return
  26981. }
  26982. var respJSON map[string]interface{}
  26983. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26986. return
  26987. }
  26988. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26989. result, _ := json.Marshal(respJSON)
  26990. fmt.Println("log")
  26991. fmt.Println(string(result))
  26992. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26993. utils.ErrorLog("解析失败:%v", err)
  26994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26995. return
  26996. }
  26997. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26998. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  26999. if result3101.Infcode == "0" {
  27000. if len(result3101.Output.Result) > 0 {
  27001. var errMsgs []string
  27002. for _, item := range result3101.Output.Result {
  27003. errMsgs = append(errMsgs, item.VolaCont)
  27004. }
  27005. c.ServeSuccessJSON(map[string]interface{}{
  27006. "failed_code": -10,
  27007. "msg": errMsgs,
  27008. })
  27009. return
  27010. } else {
  27011. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27012. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27013. bas := strings.Split(psn_info.CardInfo, "|")
  27014. if his.IdCardType == 1 {
  27015. cert_no = bas[2]
  27016. } else if his.IdCardType == 3 {
  27017. cert_no = his.Certno
  27018. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27019. } else if his.IdCardType == 4 {
  27020. cert_no = his.Certno
  27021. psn_info.VerifyNumber = psn_info.VerifyNumber
  27022. }
  27023. //江苏地区国家医保医疗类别
  27024. //职工透析:医疗类别选特殊情况门诊9933
  27025. //居民血透门慢: 医疗类别选门诊慢病1402
  27026. //var med_type string
  27027. //if his.Insutype == "310" {
  27028. // if reg_type == 14 {
  27029. // med_type = "9933"
  27030. // } else if reg_type == 11 {
  27031. // med_type = "11"
  27032. //
  27033. // }
  27034. //} else if his.Insutype == "390" {
  27035. // if reg_type == 14 {
  27036. // med_type = "1402"
  27037. // } else if reg_type == 11 {
  27038. // med_type = "11"
  27039. // }
  27040. //}
  27041. var api string
  27042. if miConfig.MdtrtareaAdmvs == "320921" {
  27043. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27044. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27045. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27046. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27047. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27048. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27049. "&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
  27050. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27051. } else {
  27052. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27053. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27054. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27055. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27056. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27057. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27058. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27059. "&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
  27060. }
  27061. resp, requestErr := http.Get(api)
  27062. if requestErr != nil {
  27063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27064. return
  27065. }
  27066. body, ioErr := ioutil.ReadAll(resp.Body)
  27067. if ioErr != nil {
  27068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27070. return
  27071. }
  27072. var respJSON map[string]interface{}
  27073. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27076. return
  27077. }
  27078. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27079. result, _ := json.Marshal(respJSON)
  27080. fmt.Println("log")
  27081. fmt.Println(string(result))
  27082. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27083. utils.ErrorLog("解析失败:%v", err)
  27084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27085. return
  27086. }
  27087. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27088. res.Output = resSeven10265.Output
  27089. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27090. res.ErrMsg = resSeven10265.ErrMsg
  27091. res.Cainfo = resSeven10265.Cainfo
  27092. res.WarnMsg = resSeven10265.WarnMsg
  27093. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27094. res.Infcode = infocode
  27095. }
  27096. }
  27097. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27098. psn_info, _ := service.GetPsnByPatientId(id)
  27099. var verify_number string
  27100. if psn_info.IdCardType == 4 {
  27101. verify_number = psn_info.VerifyNumber
  27102. } else if psn_info.IdCardType == 1 {
  27103. bas := strings.Split(psn_info.CardInfo, "|")
  27104. cardNumber := bas[2]
  27105. verify_number = cardNumber
  27106. } else {
  27107. verify_number = psn_info.Certno
  27108. psn_info.IdCardType = 2
  27109. }
  27110. var api string
  27111. new_chrg_bchno := chrg_bchno
  27112. if adminUser.CurrentOrgId == 10265 {
  27113. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27114. new_chrg_bchno = "0000"
  27115. }
  27116. }
  27117. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27118. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27119. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27120. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27121. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27122. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27123. "&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
  27124. resp, requestErr := http.Get(api)
  27125. if requestErr != nil {
  27126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27127. return
  27128. }
  27129. body, ioErr := ioutil.ReadAll(resp.Body)
  27130. if ioErr != nil {
  27131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27133. return
  27134. }
  27135. var respJSON map[string]interface{}
  27136. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27139. return
  27140. }
  27141. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27142. result, _ := json.Marshal(respJSON)
  27143. fmt.Println("log")
  27144. fmt.Println(string(result))
  27145. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27146. utils.ErrorLog("解析失败:%v", err)
  27147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27148. return
  27149. }
  27150. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27151. res.Output = resSeven10265.Output
  27152. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27153. res.ErrMsg = resSeven10265.ErrMsg
  27154. res.Cainfo = resSeven10265.Cainfo
  27155. res.WarnMsg = resSeven10265.WarnMsg
  27156. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27157. res.Infcode = infocode
  27158. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27159. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27160. var cert_no string
  27161. if his.IdCardType == 1 {
  27162. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27163. } else {
  27164. cert_no = psn_info.VerifyNumber
  27165. }
  27166. 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)
  27167. var dat map[string]interface{}
  27168. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27169. fmt.Println(dat)
  27170. } else {
  27171. fmt.Println(err)
  27172. }
  27173. saveLog(result2, src_resquest, "2207", "结算")
  27174. userJSONBytes, _ := json.Marshal(dat)
  27175. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27176. utils.ErrorLog("解析失败:%v", err)
  27177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27178. return
  27179. }
  27180. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27181. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27182. var cert_no string
  27183. var card_sn string
  27184. if his.IdCardType == 1 {
  27185. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27186. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27187. bas := strings.Split(psn_info.CardInfo, "|")
  27188. card_sn = bas[3]
  27189. } else if his.IdCardType == 2 {
  27190. cert_no = his.IdCardNo
  27191. } else {
  27192. cert_no = psn_info.VerifyNumber
  27193. }
  27194. var rf []*ResultFive
  27195. json.Unmarshal([]byte(his.Iinfo), &rf)
  27196. var psn_type string
  27197. for _, item := range rf {
  27198. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27199. psn_type = item.PsnType
  27200. }
  27201. }
  27202. 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)
  27203. var dat map[string]interface{}
  27204. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27205. fmt.Println(dat)
  27206. } else {
  27207. fmt.Println(err)
  27208. }
  27209. saveLog(result2, src_resquest, "2207", "结算")
  27210. userJSONBytes, _ := json.Marshal(dat)
  27211. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27212. utils.ErrorLog("解析失败:%v", err)
  27213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27214. return
  27215. }
  27216. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27217. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27218. var cert_no string
  27219. var card_sn string
  27220. if his.IdCardType == 1 {
  27221. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27222. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27223. //bas := strings.Split(psn_info.CardInfo, "|")
  27224. card_sn = ""
  27225. } else if his.IdCardType == 2 {
  27226. cert_no = his.IdCardNo
  27227. } else {
  27228. cert_no = psn_info.VerifyNumber
  27229. }
  27230. var rf []*ResultFive
  27231. json.Unmarshal([]byte(his.Iinfo), &rf)
  27232. var psn_type string
  27233. for _, item := range rf {
  27234. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27235. psn_type = item.PsnType
  27236. }
  27237. }
  27238. 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)
  27239. var dat map[string]interface{}
  27240. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27241. fmt.Println(dat)
  27242. } else {
  27243. fmt.Println(err)
  27244. }
  27245. saveLog(result2, src_resquest, "2207", "结算")
  27246. userJSONBytes, _ := json.Marshal(dat)
  27247. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27248. utils.ErrorLog("解析失败:%v", err)
  27249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27250. return
  27251. }
  27252. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27253. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27254. if his.IdCardType == 1 {
  27255. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27256. bas := strings.Split(psn_info.CardInfo, "|")
  27257. cert_no = bas[2]
  27258. } else if his.IdCardType == 3 {
  27259. cert_no = his.Certno
  27260. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27261. } else if his.IdCardType == 4 {
  27262. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27263. cert_no = psn_info.VerifyNumber
  27264. psn_info.VerifyNumber = psn_info.VerifyNumber
  27265. } else {
  27266. cert_no = his.Certno
  27267. psn_info.VerifyNumber = his.Certno
  27268. }
  27269. var api string
  27270. var med_type string
  27271. if his.Insutype == "390" {
  27272. if reg_type == 992102 {
  27273. med_type = "992102"
  27274. }
  27275. if reg_type == 140104 {
  27276. med_type = "140104"
  27277. }
  27278. if reg_type == 140201 {
  27279. med_type = "140201"
  27280. }
  27281. if reg_type == 14 {
  27282. med_type = "14"
  27283. }
  27284. } else if his.Insutype == "310" {
  27285. if reg_type == 992102 {
  27286. med_type = "992102"
  27287. }
  27288. if reg_type == 140104 {
  27289. med_type = "140104"
  27290. }
  27291. if reg_type == 140201 {
  27292. med_type = "140201"
  27293. }
  27294. if reg_type == 14 {
  27295. med_type = "14"
  27296. }
  27297. }
  27298. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27299. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27300. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27301. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27302. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27303. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27304. "&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
  27305. resp, requestErr := http.Get(api)
  27306. if requestErr != nil {
  27307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27308. return
  27309. }
  27310. body, ioErr := ioutil.ReadAll(resp.Body)
  27311. if ioErr != nil {
  27312. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27314. return
  27315. }
  27316. var respJSON map[string]interface{}
  27317. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27320. return
  27321. }
  27322. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27323. if status == "0" {
  27324. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27325. c.ServeSuccessJSON(map[string]interface{}{
  27326. "failed_code": -10,
  27327. "msg": err_msg,
  27328. })
  27329. return
  27330. }
  27331. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27332. result, _ := json.Marshal(respJSON)
  27333. fmt.Println("log")
  27334. fmt.Println(string(result))
  27335. if err := json.Unmarshal(result, &ahres); err != nil {
  27336. utils.ErrorLog("解析失败:%v", err)
  27337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27338. return
  27339. }
  27340. res.InfRefmsgid = ahres.InfRefmsgid
  27341. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27342. // 创建对应的Time类型
  27343. t := time.UnixMilli(timestamp)
  27344. // 格式化成指定的日期字符串
  27345. str := t.Format("2006-01-02 15:04:05")
  27346. res.Output.Setlinfo.SetlTime = str
  27347. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27348. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27349. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27350. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27351. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27352. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27353. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27354. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27355. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27356. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27357. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27358. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27359. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27360. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27361. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27362. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27363. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27364. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27365. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27366. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27367. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27368. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27369. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27370. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27371. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27372. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27373. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27374. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27375. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27376. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27377. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27378. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27379. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27380. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27381. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27382. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27383. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27384. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27385. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27386. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27387. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27388. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27389. res.Output.Setldetail = ahres.Output.Setldetail
  27390. res.ErrMsg = ahres.ErrMsg
  27391. res.Cainfo = ahres.Cainfo
  27392. res.WarnMsg = ahres.WarnMsg
  27393. res.Infcode = ahres.Infcode
  27394. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27395. res.Output.Setlinfo.ClrType = "11"
  27396. } else {
  27397. res.Output.Setlinfo.ClrType = "9903"
  27398. }
  27399. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27400. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27401. if his.IdCardType == 1 {
  27402. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27403. bas := strings.Split(psn_info.CardInfo, "|")
  27404. cert_no = bas[2]
  27405. } else if his.IdCardType == 3 {
  27406. cert_no = his.Certno
  27407. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27408. } else if his.IdCardType == 4 {
  27409. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27410. cert_no = his.Certno
  27411. psn_info.VerifyNumber = psn_info.VerifyNumber
  27412. } else {
  27413. cert_no = his.Certno
  27414. psn_info.VerifyNumber = his.Certno
  27415. }
  27416. var api string
  27417. var med_type string
  27418. if his.Insutype == "390" {
  27419. if reg_type == 992102 {
  27420. med_type = "992102"
  27421. }
  27422. if reg_type == 140104 {
  27423. med_type = "140104"
  27424. }
  27425. if reg_type == 14 {
  27426. med_type = "14"
  27427. }
  27428. if reg_type == 140201 {
  27429. med_type = "140201"
  27430. }
  27431. } else if his.Insutype == "310" {
  27432. if reg_type == 992102 {
  27433. med_type = "992102"
  27434. }
  27435. if reg_type == 14 {
  27436. med_type = "14"
  27437. }
  27438. if reg_type == 140104 {
  27439. med_type = "140104"
  27440. }
  27441. if reg_type == 140201 {
  27442. med_type = "140201"
  27443. }
  27444. }
  27445. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27446. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27447. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27448. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27449. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27450. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27451. "&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
  27452. resp, requestErr := http.Get(api)
  27453. if requestErr != nil {
  27454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27455. return
  27456. }
  27457. body, ioErr := ioutil.ReadAll(resp.Body)
  27458. if ioErr != nil {
  27459. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27461. return
  27462. }
  27463. var respJSON map[string]interface{}
  27464. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27465. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27467. return
  27468. }
  27469. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27470. if status == "0" {
  27471. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27472. c.ServeSuccessJSON(map[string]interface{}{
  27473. "failed_code": -10,
  27474. "msg": err_msg,
  27475. })
  27476. return
  27477. }
  27478. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27479. result, _ := json.Marshal(respJSON)
  27480. fmt.Println("log")
  27481. fmt.Println(string(result))
  27482. if err := json.Unmarshal(result, &ahres); err != nil {
  27483. utils.ErrorLog("解析失败:%v", err)
  27484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27485. return
  27486. }
  27487. res.InfRefmsgid = ahres.InfRefmsgid
  27488. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27489. // 创建对应的Time类型
  27490. t := time.UnixMilli(timestamp)
  27491. // 格式化成指定的日期字符串
  27492. str := t.Format("2006-01-02 15:04:05")
  27493. res.Output.Setlinfo.SetlTime = str
  27494. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27495. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27496. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27497. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27498. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27499. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27500. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27501. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27502. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27503. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27504. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27505. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27506. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27507. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27508. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27509. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27510. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27511. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27512. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27513. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27514. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27515. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27516. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27517. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27518. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27519. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27520. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27521. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27522. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27523. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27524. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27525. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27526. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27527. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27528. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27529. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27530. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27531. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27532. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27533. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27534. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27535. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27536. res.Output.Setldetail = ahres.Output.Setldetail
  27537. res.ErrMsg = ahres.ErrMsg
  27538. res.Cainfo = ahres.Cainfo
  27539. res.WarnMsg = ahres.WarnMsg
  27540. res.Infcode = ahres.Infcode
  27541. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27542. res.Output.Setlinfo.ClrType = "11"
  27543. } else {
  27544. res.Output.Setlinfo.ClrType = "9903"
  27545. }
  27546. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27547. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27548. var cert_no string
  27549. if his.IdCardType == 1 {
  27550. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27551. } else if his.IdCardType == 2 {
  27552. cert_no = his.IdCardNo
  27553. } else {
  27554. cert_no = psn_info.VerifyNumber
  27555. }
  27556. 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, "")
  27557. var dat map[string]interface{}
  27558. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27559. fmt.Println(dat)
  27560. } else {
  27561. fmt.Println(err)
  27562. }
  27563. saveLog(result2, src_resquest, "2207", "结算")
  27564. userJSONBytes, _ := json.Marshal(dat)
  27565. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27566. utils.ErrorLog("解析失败:%v", err)
  27567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27568. return
  27569. }
  27570. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27571. psn_info, _ := service.GetPsnByPatientId(id)
  27572. var verify_number string
  27573. if psn_info.IdCardType == 4 {
  27574. verify_number = psn_info.VerifyNumber
  27575. } else if psn_info.IdCardType == 1 {
  27576. bas := strings.Split(psn_info.CardInfo, "|")
  27577. cardNumber := bas[2]
  27578. verify_number = cardNumber
  27579. } else {
  27580. verify_number = psn_info.Certno
  27581. psn_info.IdCardType = 2
  27582. }
  27583. var api string
  27584. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27585. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27586. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27587. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27588. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27589. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27590. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  27591. resp, requestErr := http.Get(api)
  27592. if requestErr != nil {
  27593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27594. return
  27595. }
  27596. body, ioErr := ioutil.ReadAll(resp.Body)
  27597. if ioErr != nil {
  27598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27600. return
  27601. }
  27602. var respJSON map[string]interface{}
  27603. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27606. return
  27607. }
  27608. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27609. result, _ := json.Marshal(respJSON)
  27610. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27611. utils.ErrorLog("解析失败:%v", err)
  27612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27613. return
  27614. }
  27615. } else {
  27616. var src_resquest string
  27617. if miConfig.Code == "H15049901371" {
  27618. //赤峰地区国家医保医疗类别
  27619. //职工透析:医疗类别选特殊情况门诊990502
  27620. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27621. var med_type string
  27622. if his.Insutype == "390" {
  27623. if reg_type == 14 {
  27624. med_type = "9933"
  27625. } else if reg_type == 11 {
  27626. med_type = "11"
  27627. }
  27628. } else if his.Insutype == "310" {
  27629. if reg_type == 14 {
  27630. med_type = "990502"
  27631. } else if reg_type == 11 {
  27632. med_type = "11"
  27633. }
  27634. }
  27635. 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)
  27636. } else {
  27637. if his.IdCardType == 4 {
  27638. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27639. token := psn_info.VerifyNumber
  27640. 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)
  27641. } else {
  27642. 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)
  27643. }
  27644. }
  27645. var dat map[string]interface{}
  27646. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27647. fmt.Println(dat)
  27648. } else {
  27649. fmt.Println(err)
  27650. }
  27651. saveLog(result2, src_resquest, "2207", "结算")
  27652. userJSONBytes, _ := json.Marshal(dat)
  27653. if miConfig.Code == "H15049901371" {
  27654. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27655. utils.ErrorLog("解析失败:%v", err)
  27656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27657. return
  27658. }
  27659. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27660. res.Output = resSeven10265.Output
  27661. res.ErrMsg = resSeven10265.ErrMsg
  27662. res.Cainfo = resSeven10265.Cainfo
  27663. res.WarnMsg = resSeven10265.WarnMsg
  27664. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27665. res.Infcode = infocode
  27666. } else {
  27667. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27668. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27669. utils.ErrorLog("解析失败:%v", err)
  27670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27671. return
  27672. }
  27673. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27674. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27675. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27676. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27677. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27678. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27679. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27680. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27681. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27682. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27683. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27684. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27685. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27686. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27687. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27688. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27689. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27690. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27691. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27692. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27693. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27694. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27695. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27696. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27697. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27698. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27699. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27700. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27701. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27702. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27703. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27704. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27705. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27706. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27707. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27708. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27709. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27710. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27711. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27712. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27713. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27714. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27715. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27716. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27717. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27718. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27719. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27720. res.Cainfo = gzresSeven10265Two.Cainfo
  27721. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27722. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27723. //res.Infcode = infocode
  27724. } else {
  27725. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27726. utils.ErrorLog("解析失败:%v", err)
  27727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27728. return
  27729. }
  27730. }
  27731. }
  27732. }
  27733. if res.Infcode == -1 {
  27734. errlog := &models.HisOrderError{
  27735. UserOrgId: adminUser.CurrentOrgId,
  27736. Ctime: time.Now().Unix(),
  27737. Mtime: time.Now().Unix(),
  27738. Number: chrg_bchno,
  27739. ErrMsg: res.ErrMsg,
  27740. Status: 1,
  27741. PatientId: id,
  27742. RecordTime: recordDateTime,
  27743. Stage: 6,
  27744. }
  27745. service.CreateErrMsgLog(errlog)
  27746. c.ServeSuccessJSON(map[string]interface{}{
  27747. "failed_code": -10,
  27748. "msg": res.ErrMsg,
  27749. })
  27750. return
  27751. } else {
  27752. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27753. order.OrderStatus = 2
  27754. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27755. order.SetlId = res.Output.Setlinfo.SetlID
  27756. order.PsnNo = res.Output.Setlinfo.PsnNo
  27757. order.PsnName = res.Output.Setlinfo.PsnName
  27758. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27759. order.Certno = res.Output.Setlinfo.Certno
  27760. order.Gend = res.Output.Setlinfo.Gend
  27761. order.Naty = res.Output.Setlinfo.Naty
  27762. order.Age = res.Output.Setlinfo.Age
  27763. order.Insutype = res.Output.Setlinfo.Insutype
  27764. order.PsnType = res.Output.Setlinfo.PsnType
  27765. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27766. order.SetlTime = res.Output.Setlinfo.SetlTime
  27767. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27768. order.PayWays = pay_ways
  27769. order.AcctUsedFlag = acct_used_flag
  27770. order.WechatPay = wechat_pay
  27771. order.AliPay = ali_pay
  27772. order.JifenPay = jifen_pay
  27773. order.BandCardPay = band_card_pay
  27774. order.CashPay = cash_pay
  27775. order.OthDesc = oth_desc
  27776. //order.MedType = res.Output.Setlinfo.MedType
  27777. if reg_type == 1112 {
  27778. order.MedType = "1112"
  27779. }
  27780. if reg_type == 1111 {
  27781. order.MedType = "1111"
  27782. }
  27783. order.ClrType = res.Output.Setlinfo.ClrType
  27784. if adminUser.CurrentOrgId == 10480 {
  27785. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27786. order.ClrType = "11"
  27787. } else {
  27788. order.ClrType = "9903"
  27789. }
  27790. }
  27791. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27792. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27793. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27794. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27795. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27796. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27797. order.HifpPay = res.Output.Setlinfo.HifpPay
  27798. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27799. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27800. order.HifesPay = res.Output.Setlinfo.HifesPay
  27801. order.HifobPay = res.Output.Setlinfo.HifobPay
  27802. order.MafPay = res.Output.Setlinfo.MafPay
  27803. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27804. order.OthPay = res.Output.Setlinfo.OthPay
  27805. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27806. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27807. order.AcctPay = res.Output.Setlinfo.AcctPay
  27808. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27809. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27810. order.Balc = res.Output.Setlinfo.Balc
  27811. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27812. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27813. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27814. order.ClrWay = res.Output.Setlinfo.ClrWay
  27815. order.Creator = order.Creator
  27816. order.Modify = roles.AdminUserId
  27817. order.RequestLog = src_resquest
  27818. order.Diagnosis = diagnosis_id
  27819. order.FaPiaoNumber = fapiao_number
  27820. order.FaPiaoCode = fapiao_code
  27821. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27822. detailStr := string(setlDetail)
  27823. order.SetlDetail = detailStr
  27824. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27825. err = service.UpDateOrder(order)
  27826. if err == nil {
  27827. //判断是否使用了押金
  27828. if dec_way == "true" {
  27829. tmpstring := strconv.FormatInt(order.ID, 10)
  27830. //扣押金
  27831. order.Decimal = decimal
  27832. service.UpDateOrder(order)
  27833. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27834. if errmsg != nil {
  27835. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27836. return
  27837. }
  27838. }
  27839. c.ServeSuccessJSON(map[string]interface{}{
  27840. "msg": "结算成功",
  27841. })
  27842. } else {
  27843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27844. return
  27845. }
  27846. }
  27847. }
  27848. }
  27849. }
  27850. // 上传明细-预结算-
  27851. func (c *HisApiController) GetPreUploadInfo() {
  27852. id, _ := c.GetInt64("id")
  27853. record_time := c.GetString("record_time")
  27854. his_patient_id, _ := c.GetInt64("his_patient_id")
  27855. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  27856. admin_user_id, _ := c.GetInt64("admin_user_id")
  27857. diagnosis_id := c.GetString("diagnosis")
  27858. sick_type, _ := c.GetInt64("sick_type")
  27859. reg_type, _ := c.GetInt64("p_type")
  27860. begin_time := c.GetString("begin_time")
  27861. acct_used_flag := c.GetString("acct_used_flag")
  27862. id_str := c.GetString("ids")
  27863. ids_arr := strings.Split(id_str, ",")
  27864. timeLayout := "2006-01-02"
  27865. loc, _ := time.LoadLocation("Local")
  27866. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27867. if err != nil {
  27868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27869. return
  27870. }
  27871. recordDateTime := theTime.Unix()
  27872. adminUser := c.GetAdminUserInfo()
  27873. diagnosis_ids := strings.Split(diagnosis_id, ",")
  27874. var config []*models.HisXtDiagnoseConfig
  27875. for _, item := range diagnosis_ids {
  27876. id, _ := strconv.ParseInt(item, 10, 64)
  27877. if id > 0 {
  27878. diagnosisConfig, _ := service.FindDiagnoseById(id)
  27879. config = append(config, &diagnosisConfig)
  27880. }
  27881. }
  27882. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27883. sickConfig, _ := service.FindSickById(sick_type)
  27884. var prescriptions []*models.HisPrescription
  27885. var start_time int64
  27886. var end_time int64
  27887. var isSuccess bool = true
  27888. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27889. fmt.Println(his_patient_id)
  27890. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27891. timestamp := time.Now().Unix()
  27892. tempTime := time.Unix(timestamp, 0)
  27893. timeFormat := tempTime.Format("20060102150405")
  27894. chrgBchno := rand.Intn(100000) + 10000
  27895. new_chrg_bchno := ""
  27896. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  27897. new_chrg_bchno = chrg_bchno
  27898. if adminUser.CurrentOrgId == 10265 {
  27899. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27900. new_chrg_bchno = "0000"
  27901. }
  27902. }
  27903. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27904. var patientPrescription models.HisPrescriptionInfo
  27905. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27906. if patientPrescription.ID == 0 {
  27907. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  27908. }
  27909. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27910. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27911. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27912. strconv.FormatInt(his.PatientId, 10)
  27913. var res2406 Result2406
  27914. //安徽单病种处理
  27915. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  27916. data := make(map[string]interface{})
  27917. client := &http.Client{}
  27918. data["psn_no"] = his.PsnNo
  27919. data["mdtrt_id"] = his.Number
  27920. data["operator"] = roles.UserName
  27921. data["cert_no"] = his.IdCardNo
  27922. data["org_name"] = miConfig.OrgName
  27923. data["psn_name"] = his.Name
  27924. data["ipt_otp_no"] = his.IptOtpNo
  27925. data["ipt_psn_sp_flag_type"] = "0901"
  27926. data["ipt_psn_sp_flag"] = "1"
  27927. data["fixmedins_code"] = miConfig.Code
  27928. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27929. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27930. data["url"] = miConfig.Url
  27931. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27932. bytesData, _ := json.Marshal(data)
  27933. var req *http.Request
  27934. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27935. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27936. resp, _ := client.Do(req)
  27937. defer resp.Body.Close()
  27938. body, ioErr := ioutil.ReadAll(resp.Body)
  27939. if ioErr != nil {
  27940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27942. return
  27943. }
  27944. var respJSON map[string]interface{}
  27945. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27948. return
  27949. }
  27950. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27951. if status == "0" {
  27952. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27953. c.ServeSuccessJSON(map[string]interface{}{
  27954. "failed_code": -10,
  27955. "msg": err_msg,
  27956. })
  27957. return
  27958. }
  27959. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27960. userJSONBytes, _ := json.Marshal(respJSON)
  27961. fmt.Println("log")
  27962. fmt.Println(string(userJSONBytes))
  27963. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  27964. utils.ErrorLog("解析失败:%v", err)
  27965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27966. return
  27967. }
  27968. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  27969. data := make(map[string]interface{})
  27970. client := &http.Client{}
  27971. data["psn_no"] = his.PsnNo
  27972. data["mdtrt_id"] = his.Number
  27973. data["operator"] = roles.UserName
  27974. data["cert_no"] = his.IdCardNo
  27975. data["org_name"] = miConfig.OrgName
  27976. data["psn_name"] = his.Name
  27977. data["ipt_otp_no"] = his.IptOtpNo
  27978. data["ipt_psn_sp_flag_type"] = "0901"
  27979. data["ipt_psn_sp_flag"] = "1"
  27980. data["fixmedins_code"] = miConfig.Code
  27981. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27982. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27983. data["url"] = miConfig.Url
  27984. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27985. bytesData, _ := json.Marshal(data)
  27986. var req *http.Request
  27987. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27988. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27989. resp, _ := client.Do(req)
  27990. defer resp.Body.Close()
  27991. body, ioErr := ioutil.ReadAll(resp.Body)
  27992. if ioErr != nil {
  27993. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27995. return
  27996. }
  27997. var respJSON map[string]interface{}
  27998. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27999. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28001. return
  28002. }
  28003. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28004. if status == "0" {
  28005. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28006. c.ServeSuccessJSON(map[string]interface{}{
  28007. "failed_code": -10,
  28008. "msg": err_msg,
  28009. })
  28010. return
  28011. }
  28012. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28013. userJSONBytes, _ := json.Marshal(respJSON)
  28014. fmt.Println("log")
  28015. fmt.Println(string(userJSONBytes))
  28016. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28017. utils.ErrorLog("解析失败:%v", err)
  28018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28019. return
  28020. }
  28021. }
  28022. if res2406.Infcode != 0 {
  28023. adminUser := c.GetAdminUserInfo()
  28024. errlog := &models.HisOrderError{
  28025. UserOrgId: adminUser.CurrentOrgId,
  28026. Ctime: time.Now().Unix(),
  28027. Mtime: time.Now().Unix(),
  28028. ErrMsg: res2406.ErrMsg,
  28029. Status: 1,
  28030. PatientId: id,
  28031. RecordTime: recordDateTime,
  28032. Stage: 3,
  28033. }
  28034. service.CreateErrMsgLog(errlog)
  28035. c.ServeSuccessJSON(map[string]interface{}{
  28036. "failed_code": -10,
  28037. "msg": res2406.ErrMsg,
  28038. })
  28039. return
  28040. }
  28041. var res2 ResultSix
  28042. var res3 GZResultSix
  28043. var resSix10265 ResultSix10265
  28044. //var time_stamp string
  28045. if miConfig.MdtrtareaAdmvs == "421300" {
  28046. data := make(map[string]interface{})
  28047. client := &http.Client{}
  28048. data["psn_no"] = his.PsnNo
  28049. data["mdtrt_id"] = his.Number
  28050. data["department"] = department.Name
  28051. data["org_name"] = miConfig.OrgName
  28052. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28053. data["doctor_id"] = doctor_info.DoctorNumber
  28054. data["doctor_name"] = roles.UserName
  28055. data["fixmedins_code"] = miConfig.Code
  28056. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28057. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28058. data["secret_key"] = miConfig.SecretKey
  28059. data["sick_code"] = sickConfig.CountryCode
  28060. data["sick_name"] = sickConfig.ClassName
  28061. data["begin_time"] = begin_time
  28062. data["dept"] = strconv.FormatInt(department.ID, 10)
  28063. data["config"] = config
  28064. data["opter"] = roles.UserName
  28065. fmt.Println(data)
  28066. bytesData, _ := json.Marshal(data)
  28067. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28068. resp, _ := client.Do(req)
  28069. defer resp.Body.Close()
  28070. body, ioErr := ioutil.ReadAll(resp.Body)
  28071. if ioErr != nil {
  28072. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28074. return
  28075. }
  28076. var respJSON map[string]interface{}
  28077. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28078. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28080. return
  28081. }
  28082. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28083. userJSONBytes, _ := json.Marshal(respJSON)
  28084. fmt.Println("log")
  28085. fmt.Println(string(userJSONBytes))
  28086. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28087. utils.ErrorLog("解析失败:%v", err)
  28088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28089. return
  28090. }
  28091. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28092. data := make(map[string]interface{})
  28093. client := &http.Client{}
  28094. data["psn_no"] = his.PsnNo
  28095. data["mdtrt_id"] = his.Number
  28096. data["department"] = department.Name
  28097. data["org_name"] = miConfig.OrgName
  28098. if reg_type == 11 && his.Insutype == "390" {
  28099. data["med_type"] = "110104"
  28100. } else {
  28101. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28102. }
  28103. data["doctor_id"] = doctor_info.DoctorNumber
  28104. data["doctor_name"] = roles.UserName
  28105. data["fixmedins_code"] = miConfig.Code
  28106. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28107. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28108. data["secret_key"] = miConfig.SecretKey
  28109. data["sick_code"] = sickConfig.CountryCode
  28110. data["sick_name"] = sickConfig.ClassName
  28111. data["begin_time"] = begin_time
  28112. data["dept"] = strconv.FormatInt(department.ID, 10)
  28113. data["config"] = config
  28114. data["opter"] = roles.UserName
  28115. fmt.Println(data)
  28116. bytesData, _ := json.Marshal(data)
  28117. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28118. resp, _ := client.Do(req)
  28119. defer resp.Body.Close()
  28120. body, ioErr := ioutil.ReadAll(resp.Body)
  28121. if ioErr != nil {
  28122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28124. return
  28125. }
  28126. var respJSON map[string]interface{}
  28127. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28130. return
  28131. }
  28132. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28133. userJSONBytes, _ := json.Marshal(respJSON)
  28134. fmt.Println("log")
  28135. fmt.Println(string(userJSONBytes))
  28136. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28137. utils.ErrorLog("解析失败:%v", err)
  28138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28139. return
  28140. }
  28141. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28142. data := make(map[string]interface{})
  28143. client := &http.Client{}
  28144. data["psn_no"] = his.PsnNo
  28145. data["mdtrt_id"] = his.Number
  28146. data["department"] = department.Name
  28147. data["org_name"] = miConfig.OrgName
  28148. if reg_type == 11 && his.Insutype == "390" {
  28149. data["med_type"] = "110104"
  28150. } else {
  28151. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28152. }
  28153. data["doctor_id"] = doctor_info.DoctorNumber
  28154. data["doctor_name"] = roles.UserName
  28155. data["fixmedins_code"] = miConfig.Code
  28156. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28157. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28158. data["secret_key"] = miConfig.SecretKey
  28159. data["sick_code"] = sickConfig.CountryCode
  28160. data["sick_name"] = sickConfig.ClassName
  28161. data["begin_time"] = begin_time
  28162. data["dept"] = strconv.FormatInt(department.ID, 10)
  28163. data["config"] = config
  28164. data["opter"] = roles.UserName
  28165. fmt.Println(data)
  28166. bytesData, _ := json.Marshal(data)
  28167. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28168. resp, _ := client.Do(req)
  28169. defer resp.Body.Close()
  28170. body, ioErr := ioutil.ReadAll(resp.Body)
  28171. if ioErr != nil {
  28172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28174. return
  28175. }
  28176. var respJSON map[string]interface{}
  28177. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28180. return
  28181. }
  28182. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28183. userJSONBytes, _ := json.Marshal(respJSON)
  28184. fmt.Println("log")
  28185. fmt.Println(string(userJSONBytes))
  28186. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28187. utils.ErrorLog("解析失败:%v", err)
  28188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28189. return
  28190. }
  28191. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28192. data := make(map[string]interface{})
  28193. client := &http.Client{}
  28194. data["psn_no"] = his.PsnNo
  28195. data["mdtrt_id"] = his.Number
  28196. data["department"] = department.Name
  28197. data["org_name"] = miConfig.OrgName
  28198. if reg_type == 11 && his.Insutype == "390" {
  28199. data["med_type"] = "110104"
  28200. } else {
  28201. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28202. }
  28203. data["doctor_id"] = doctor_info.DoctorNumber
  28204. data["doctor_name"] = roles.UserName
  28205. data["fixmedins_code"] = miConfig.Code
  28206. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28207. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28208. data["secret_key"] = miConfig.SecretKey
  28209. data["sick_code"] = sickConfig.CountryCode
  28210. data["sick_name"] = sickConfig.ClassName
  28211. data["begin_time"] = begin_time
  28212. data["dept"] = strconv.FormatInt(department.ID, 10)
  28213. data["config"] = config
  28214. data["opter"] = roles.UserName
  28215. fmt.Println(data)
  28216. bytesData, _ := json.Marshal(data)
  28217. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28218. resp, _ := client.Do(req)
  28219. defer resp.Body.Close()
  28220. body, ioErr := ioutil.ReadAll(resp.Body)
  28221. if ioErr != nil {
  28222. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28224. return
  28225. }
  28226. var respJSON map[string]interface{}
  28227. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28228. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28230. return
  28231. }
  28232. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28233. userJSONBytes, _ := json.Marshal(respJSON)
  28234. fmt.Println("log")
  28235. fmt.Println(string(userJSONBytes))
  28236. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28237. utils.ErrorLog("解析失败:%v", err)
  28238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28239. return
  28240. }
  28241. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28242. data := make(map[string]interface{})
  28243. client := &http.Client{}
  28244. data["psn_no"] = his.PsnNo
  28245. data["mdtrt_id"] = his.Number
  28246. data["doctor"] = roles.UserName
  28247. data["department"] = department.Name
  28248. data["org_name"] = miConfig.OrgName
  28249. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28250. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28251. data["fixmedins_code"] = miConfig.Code
  28252. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28253. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28254. data["secret_key"] = miConfig.SecretKey
  28255. data["sick_code"] = sickConfig.CountryCode
  28256. data["sick_name"] = sickConfig.ClassName
  28257. data["begin_time"] = begin_time
  28258. data["dept"] = strconv.FormatInt(department.ID, 10)
  28259. data["config"] = config
  28260. data["url"] = miConfig.Url
  28261. data["ak"] = miConfig.AccessKey
  28262. data["cainfo"] = miConfig.Cainfo
  28263. bytesData, _ := json.Marshal(data)
  28264. var req *http.Request
  28265. if miConfig.MdtrtareaAdmvs == "320921" {
  28266. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28267. } else {
  28268. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28269. }
  28270. resp, _ := client.Do(req)
  28271. defer resp.Body.Close()
  28272. body, ioErr := ioutil.ReadAll(resp.Body)
  28273. if ioErr != nil {
  28274. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28276. return
  28277. }
  28278. var respJSON map[string]interface{}
  28279. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28280. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28282. return
  28283. }
  28284. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28285. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28286. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28287. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28288. userJSONBytes, _ := json.Marshal(respJSON)
  28289. fmt.Println("log")
  28290. fmt.Println(string(userJSONBytes))
  28291. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28292. utils.ErrorLog("解析失败:%v", err)
  28293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28294. return
  28295. }
  28296. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28297. res2.Output = resSix10265.Output
  28298. res2.ErrMsg = resSix10265.ErrMsg
  28299. res2.Cainfo = resSix10265.Cainfo
  28300. res2.WarnMsg = resSix10265.WarnMsg
  28301. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28302. res2.Infcode = infocode
  28303. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28304. data := make(map[string]interface{})
  28305. client := &http.Client{}
  28306. data["psn_no"] = his.PsnNo
  28307. data["mdtrt_id"] = his.Number
  28308. data["doctor"] = roles.UserName
  28309. data["department"] = department.Name
  28310. data["org_name"] = miConfig.OrgName
  28311. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28312. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28313. data["fixmedins_code"] = miConfig.Code
  28314. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28315. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28316. data["secret_key"] = miConfig.SecretKey
  28317. data["sick_code"] = sickConfig.CountryCode
  28318. data["sick_name"] = sickConfig.ClassName
  28319. data["begin_time"] = begin_time
  28320. data["dept"] = strconv.FormatInt(department.ID, 10)
  28321. data["config"] = config
  28322. //data["url"] = miConfig.Url
  28323. //data["ak"] = miConfig.AccessKey
  28324. data["cainfo"] = miConfig.Cainfo
  28325. fmt.Println(data)
  28326. bytesData, _ := json.Marshal(data)
  28327. var req *http.Request
  28328. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  28329. resp, _ := client.Do(req)
  28330. defer resp.Body.Close()
  28331. body, ioErr := ioutil.ReadAll(resp.Body)
  28332. if ioErr != nil {
  28333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28335. return
  28336. }
  28337. var respJSON map[string]interface{}
  28338. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28341. return
  28342. }
  28343. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28344. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28345. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28346. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28347. userJSONBytes, _ := json.Marshal(respJSON)
  28348. fmt.Println("log")
  28349. fmt.Println(string(userJSONBytes))
  28350. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28351. utils.ErrorLog("解析失败:%v", err)
  28352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28353. return
  28354. }
  28355. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28356. res2.Output = resSix10265.Output
  28357. res2.ErrMsg = resSix10265.ErrMsg
  28358. res2.Cainfo = resSix10265.Cainfo
  28359. res2.WarnMsg = resSix10265.WarnMsg
  28360. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28361. res2.Infcode = infocode
  28362. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28363. 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)
  28364. saveLog(result, requestLog, "2203", "上传就诊信息")
  28365. var respJSON2 map[string]interface{}
  28366. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28369. return
  28370. }
  28371. userJSONBytes2, _ := json.Marshal(respJSON2)
  28372. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28373. utils.ErrorLog("解析失败:%v", err)
  28374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28375. return
  28376. }
  28377. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28378. var result string
  28379. var requestLog string
  28380. 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, "")
  28381. saveLog(result, requestLog, "2203", "上传就诊信息")
  28382. var respJSON2 map[string]interface{}
  28383. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28386. return
  28387. }
  28388. userJSONBytes2, _ := json.Marshal(respJSON2)
  28389. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28390. utils.ErrorLog("解析失败:%v", err)
  28391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28392. return
  28393. }
  28394. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28395. var result string
  28396. var requestLog string
  28397. 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, "")
  28398. saveLog(result, requestLog, "2203", "上传就诊信息")
  28399. var respJSON2 map[string]interface{}
  28400. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28403. return
  28404. }
  28405. userJSONBytes2, _ := json.Marshal(respJSON2)
  28406. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28407. utils.ErrorLog("解析失败:%v", err)
  28408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28409. return
  28410. }
  28411. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28412. data := make(map[string]interface{})
  28413. client := &http.Client{}
  28414. data["psn_no"] = his.PsnNo
  28415. data["mdtrt_id"] = his.Number
  28416. data["operator"] = roles.UserName
  28417. data["department"] = department.Name
  28418. data["org_name"] = miConfig.OrgName
  28419. var med_type string
  28420. if his.Insutype == "390" {
  28421. if reg_type == 992102 {
  28422. med_type = "992102"
  28423. data["sick_code"] = "ZDZ940"
  28424. data["sick_name"] = "慢性肾衰竭"
  28425. }
  28426. if reg_type == 140104 {
  28427. med_type = "140104"
  28428. data["sick_code"] = sickConfig.CountryCode
  28429. data["sick_name"] = sickConfig.ClassName
  28430. }
  28431. if reg_type == 14 {
  28432. med_type = "140104"
  28433. data["sick_code"] = sickConfig.CountryCode
  28434. data["sick_name"] = sickConfig.ClassName
  28435. }
  28436. } else if his.Insutype == "310" {
  28437. if reg_type == 992102 {
  28438. med_type = "992102"
  28439. data["sick_code"] = "ZDZ940"
  28440. data["sick_name"] = "慢性肾衰竭"
  28441. }
  28442. if reg_type == 140104 {
  28443. med_type = "140104"
  28444. data["sick_code"] = sickConfig.CountryCode
  28445. data["sick_name"] = sickConfig.ClassName
  28446. }
  28447. if reg_type == 14 {
  28448. med_type = "14"
  28449. data["sick_code"] = sickConfig.CountryCode
  28450. data["sick_name"] = sickConfig.ClassName
  28451. }
  28452. }
  28453. data["med_type"] = med_type
  28454. data["doctor_number"] = doctor_info.DoctorNumber
  28455. data["doctor_name"] = doctor_info.UserName
  28456. data["fixmedins_code"] = miConfig.Code
  28457. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28458. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28459. data["secret_key"] = miConfig.SecretKey
  28460. data["begin_time"] = begin_time
  28461. data["dept"] = strconv.FormatInt(department.ID, 10)
  28462. data["config"] = config
  28463. data["url"] = miConfig.Url
  28464. data["ak"] = miConfig.AccessKey
  28465. data["cainfo"] = miConfig.Cainfo
  28466. bytesData, _ := json.Marshal(data)
  28467. var req *http.Request
  28468. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28469. resp, _ := client.Do(req)
  28470. defer resp.Body.Close()
  28471. body, ioErr := ioutil.ReadAll(resp.Body)
  28472. if ioErr != nil {
  28473. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28475. return
  28476. }
  28477. var respJSON map[string]interface{}
  28478. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28479. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28481. return
  28482. }
  28483. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28484. if status == "0" {
  28485. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28486. c.ServeSuccessJSON(map[string]interface{}{
  28487. "failed_code": -10,
  28488. "msg": err_msg,
  28489. })
  28490. return
  28491. }
  28492. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28493. userJSONBytes, _ := json.Marshal(respJSON)
  28494. fmt.Println("log")
  28495. fmt.Println(string(userJSONBytes))
  28496. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28497. utils.ErrorLog("解析失败:%v", err)
  28498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28499. return
  28500. }
  28501. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28502. data := make(map[string]interface{})
  28503. client := &http.Client{}
  28504. data["psn_no"] = his.PsnNo
  28505. data["mdtrt_id"] = his.Number
  28506. data["operator"] = roles.UserName
  28507. data["department"] = department.Name
  28508. data["org_name"] = miConfig.OrgName
  28509. var med_type string
  28510. if his.Insutype == "390" {
  28511. if reg_type == 992102 {
  28512. med_type = "992102"
  28513. data["sick_code"] = sickConfig.CountryCode
  28514. data["sick_name"] = sickConfig.ClassName
  28515. }
  28516. if reg_type == 140104 {
  28517. med_type = "140104"
  28518. data["sick_code"] = sickConfig.CountryCode
  28519. data["sick_name"] = sickConfig.ClassName
  28520. }
  28521. if reg_type == 140201 {
  28522. med_type = "140201"
  28523. data["sick_code"] = sickConfig.CountryCode
  28524. data["sick_name"] = sickConfig.ClassName
  28525. }
  28526. if reg_type == 14 {
  28527. med_type = "14"
  28528. data["sick_code"] = sickConfig.CountryCode
  28529. data["sick_name"] = sickConfig.ClassName
  28530. }
  28531. } else if his.Insutype == "310" {
  28532. if reg_type == 992102 {
  28533. med_type = "992102"
  28534. data["sick_code"] = sickConfig.CountryCode
  28535. data["sick_name"] = sickConfig.ClassName
  28536. }
  28537. if reg_type == 140104 {
  28538. med_type = "140104"
  28539. data["sick_code"] = sickConfig.CountryCode
  28540. data["sick_name"] = sickConfig.ClassName
  28541. }
  28542. if reg_type == 140201 {
  28543. med_type = "140201"
  28544. data["sick_code"] = sickConfig.CountryCode
  28545. data["sick_name"] = sickConfig.ClassName
  28546. }
  28547. if reg_type == 14 {
  28548. med_type = "14"
  28549. data["sick_code"] = sickConfig.CountryCode
  28550. data["sick_name"] = sickConfig.ClassName
  28551. }
  28552. }
  28553. data["med_type"] = med_type
  28554. data["doctor_number"] = doctor_info.DoctorNumber
  28555. data["doctor_name"] = doctor_info.UserName
  28556. data["fixmedins_code"] = miConfig.Code
  28557. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28558. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28559. data["secret_key"] = miConfig.SecretKey
  28560. data["begin_time"] = begin_time
  28561. data["dept"] = strconv.FormatInt(department.ID, 10)
  28562. data["config"] = config
  28563. data["url"] = miConfig.Url
  28564. data["ak"] = miConfig.AccessKey
  28565. data["cainfo"] = miConfig.Cainfo
  28566. bytesData, _ := json.Marshal(data)
  28567. var req *http.Request
  28568. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28569. resp, _ := client.Do(req)
  28570. defer resp.Body.Close()
  28571. body, ioErr := ioutil.ReadAll(resp.Body)
  28572. if ioErr != nil {
  28573. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28575. return
  28576. }
  28577. var respJSON map[string]interface{}
  28578. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28581. return
  28582. }
  28583. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28584. if status == "0" {
  28585. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28586. c.ServeSuccessJSON(map[string]interface{}{
  28587. "failed_code": -10,
  28588. "msg": err_msg,
  28589. })
  28590. return
  28591. }
  28592. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28593. userJSONBytes, _ := json.Marshal(respJSON)
  28594. fmt.Println("log")
  28595. fmt.Println(string(userJSONBytes))
  28596. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28597. utils.ErrorLog("解析失败:%v", err)
  28598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28599. return
  28600. }
  28601. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28602. var result string
  28603. var requestLog string
  28604. 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, "")
  28605. saveLog(result, requestLog, "2203", "上传就诊信息")
  28606. var respJSON2 map[string]interface{}
  28607. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28610. return
  28611. }
  28612. userJSONBytes2, _ := json.Marshal(respJSON2)
  28613. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28614. utils.ErrorLog("解析失败:%v", err)
  28615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28616. return
  28617. }
  28618. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28619. data := make(map[string]interface{})
  28620. client := &http.Client{}
  28621. data["psn_no"] = his.PsnNo
  28622. data["mdtrt_id"] = his.Number
  28623. data["doctor"] = roles.UserName
  28624. data["department"] = department.Name
  28625. data["org_name"] = miConfig.OrgName
  28626. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28627. data["doctor_id"] = doctor_info.DoctorNumber
  28628. data["fixmedins_code"] = miConfig.Code
  28629. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28630. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28631. data["secret_key"] = miConfig.SecretKey
  28632. data["sick_code"] = sickConfig.CountryCode
  28633. data["sick_name"] = sickConfig.ClassName
  28634. data["begin_time"] = begin_time
  28635. data["new_doctor_name"] = doctor_info.UserName
  28636. data["dept"] = strconv.FormatInt(department.ID, 10)
  28637. data["config"] = config
  28638. bytesData, _ := json.Marshal(data)
  28639. var req *http.Request
  28640. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  28641. resp, _ := client.Do(req)
  28642. defer resp.Body.Close()
  28643. body, ioErr := ioutil.ReadAll(resp.Body)
  28644. if ioErr != nil {
  28645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28647. return
  28648. }
  28649. var respJSON map[string]interface{}
  28650. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28653. return
  28654. }
  28655. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28656. userJSONBytes, _ := json.Marshal(respJSON)
  28657. fmt.Println("log")
  28658. fmt.Println(string(userJSONBytes))
  28659. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28660. utils.ErrorLog("解析失败:%v", err)
  28661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28662. return
  28663. }
  28664. } else {
  28665. var result string
  28666. var requestLog string
  28667. if miConfig.MdtrtareaAdmvs == "440781" { //
  28668. 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)
  28669. } else {
  28670. if miConfig.Code == "H15049901371" {
  28671. //赤峰地区国家医保医疗类别
  28672. //职工透析:医疗类别选特殊情况门诊990502
  28673. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28674. var med_type string
  28675. if his.Insutype == "390" {
  28676. if reg_type == 14 {
  28677. med_type = "9933"
  28678. } else if reg_type == 11 {
  28679. med_type = "11"
  28680. }
  28681. } else if his.Insutype == "310" {
  28682. if reg_type == 14 {
  28683. med_type = "990502"
  28684. } else if reg_type == 11 {
  28685. med_type = "11"
  28686. }
  28687. }
  28688. 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)
  28689. } else {
  28690. 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)
  28691. }
  28692. saveLog(result, requestLog, "2203", "上传就诊信息")
  28693. var respJSON2 map[string]interface{}
  28694. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28697. return
  28698. }
  28699. userJSONBytes2, _ := json.Marshal(respJSON2)
  28700. if miConfig.Code == "H15049901371" {
  28701. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  28702. utils.ErrorLog("解析失败:%v", err)
  28703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28704. return
  28705. }
  28706. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28707. res2.Output = resSix10265.Output
  28708. res2.ErrMsg = resSix10265.ErrMsg
  28709. res2.Cainfo = resSix10265.Cainfo
  28710. res2.WarnMsg = resSix10265.WarnMsg
  28711. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28712. res2.Infcode = infocode
  28713. } else {
  28714. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28715. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  28716. utils.ErrorLog("解析失败:%v", err)
  28717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28718. return
  28719. }
  28720. res2.Infcode = res3.Infcode
  28721. } else {
  28722. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28723. utils.ErrorLog("解析失败:%v", err)
  28724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28725. return
  28726. }
  28727. }
  28728. }
  28729. }
  28730. }
  28731. if res2.Infcode == -1 {
  28732. adminUser := c.GetAdminUserInfo()
  28733. errlog := &models.HisOrderError{
  28734. UserOrgId: adminUser.CurrentOrgId,
  28735. Ctime: time.Now().Unix(),
  28736. Mtime: time.Now().Unix(),
  28737. ErrMsg: res2.ErrMsg,
  28738. Status: 1,
  28739. PatientId: id,
  28740. RecordTime: recordDateTime,
  28741. Stage: 3,
  28742. }
  28743. service.CreateErrMsgLog(errlog)
  28744. c.ServeSuccessJSON(map[string]interface{}{
  28745. "failed_code": -10,
  28746. "msg": res2.ErrMsg,
  28747. })
  28748. return
  28749. }
  28750. if res2.Infcode != 0 {
  28751. adminUser := c.GetAdminUserInfo()
  28752. errlog := &models.HisOrderError{
  28753. UserOrgId: adminUser.CurrentOrgId,
  28754. Ctime: time.Now().Unix(),
  28755. Mtime: time.Now().Unix(),
  28756. ErrMsg: res2.ErrMsg,
  28757. Status: 1,
  28758. PatientId: id,
  28759. RecordTime: recordDateTime,
  28760. Stage: 3,
  28761. }
  28762. service.CreateErrMsgLog(errlog)
  28763. c.ServeSuccessJSON(map[string]interface{}{
  28764. "failed_code": -10,
  28765. "msg": res2.ErrMsg,
  28766. })
  28767. return
  28768. } else {
  28769. his.Diagnosis = diagnosis_id
  28770. his.SickType = sickConfig.ID
  28771. his.PType = fmt.Sprintf("%d", reg_type)
  28772. service.UpdateHisPatientThree(&his)
  28773. data := make(map[string]interface{})
  28774. if settle_accounts_type == 1 { //日结
  28775. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  28776. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  28777. } else {
  28778. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  28779. }
  28780. data["pre"] = prescriptions
  28781. } else { //月结
  28782. start_time_str := c.GetString("start_time")
  28783. end_time_str := c.GetString("end_time")
  28784. timeLayout := "2006-01-02"
  28785. loc, _ := time.LoadLocation("Local")
  28786. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  28787. if err != nil {
  28788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28789. return
  28790. }
  28791. recordStartTime := theStartTime.Unix()
  28792. start_time = recordStartTime
  28793. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  28794. if err != nil {
  28795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28796. return
  28797. }
  28798. recordEndTime := theEndTime.Unix()
  28799. end_time = recordEndTime
  28800. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  28801. data["pre"] = prescriptions
  28802. }
  28803. client := &http.Client{}
  28804. data["psn_no"] = his.PsnNo
  28805. data["mdtrt_id"] = his.Number
  28806. data["chrg_bchno"] = new_chrg_bchno
  28807. data["org_name"] = miConfig.OrgName
  28808. data["doctor"] = doctor_info.UserName
  28809. data["doctor_id"] = doctor_info.DoctorNumber
  28810. data["dept"] = department.Name
  28811. data["fixmedins_code"] = miConfig.Code
  28812. data["opter"] = roles.UserName
  28813. data["dept_code"] = department.Number
  28814. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28815. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28816. data["secret_key"] = miConfig.SecretKey
  28817. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  28818. data["url"] = miConfig.Url
  28819. data["ak"] = miConfig.AccessKey
  28820. data["new_doctor_name"] = patientPrescription.Doctor
  28821. if his.Insutype == "390" {
  28822. if reg_type == 992102 {
  28823. data["diag_code"] = "ZDZ940"
  28824. }
  28825. if reg_type == 140104 {
  28826. data["diag_code"] = sickConfig.CountryCode
  28827. }
  28828. if reg_type == 140201 {
  28829. data["diag_code"] = sickConfig.CountryCode
  28830. }
  28831. if reg_type == 14 {
  28832. data["diag_code"] = sickConfig.CountryCode
  28833. }
  28834. } else if his.Insutype == "310" {
  28835. if miConfig.MdtrtareaAdmvs == "341203" {
  28836. if reg_type == 992102 {
  28837. data["diag_code"] = "ZDZ940"
  28838. }
  28839. if reg_type != 992102 {
  28840. data["diag_code"] = sickConfig.CountryCode
  28841. }
  28842. } else {
  28843. data["diag_code"] = sickConfig.CountryCode
  28844. }
  28845. }
  28846. data["cainfo"] = miConfig.Cainfo
  28847. data["opter"] = roles.UserName
  28848. var ids []int64
  28849. for _, item := range prescriptions {
  28850. ids = append(ids, item.ID)
  28851. }
  28852. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28853. if config.IsOpen == 1 { //对接了医保,走医保流程
  28854. var res ResultFour
  28855. var resFour10265 ResultFour10265
  28856. if miConfig.MdtrtareaAdmvs == "421300" {
  28857. bytesData, _ := json.Marshal(data)
  28858. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28859. resp, _ := client.Do(req)
  28860. defer resp.Body.Close()
  28861. body, ioErr := ioutil.ReadAll(resp.Body)
  28862. if ioErr != nil {
  28863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28865. return
  28866. }
  28867. var respJSON map[string]interface{}
  28868. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28871. return
  28872. }
  28873. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28874. userJSONBytes, _ := json.Marshal(respJSON)
  28875. fmt.Println("log")
  28876. fmt.Println(string(userJSONBytes))
  28877. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28878. utils.ErrorLog("解析失败:%v", err)
  28879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28880. return
  28881. }
  28882. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28883. bytesData, _ := json.Marshal(data)
  28884. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28885. resp, _ := client.Do(req)
  28886. defer resp.Body.Close()
  28887. body, ioErr := ioutil.ReadAll(resp.Body)
  28888. if ioErr != nil {
  28889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28891. return
  28892. }
  28893. var respJSON map[string]interface{}
  28894. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28897. return
  28898. }
  28899. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28900. userJSONBytes, _ := json.Marshal(respJSON)
  28901. fmt.Println("log")
  28902. fmt.Println(string(userJSONBytes))
  28903. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28904. utils.ErrorLog("解析失败:%v", err)
  28905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28906. return
  28907. }
  28908. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28909. bytesData, _ := json.Marshal(data)
  28910. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28911. resp, _ := client.Do(req)
  28912. defer resp.Body.Close()
  28913. body, ioErr := ioutil.ReadAll(resp.Body)
  28914. if ioErr != nil {
  28915. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28917. return
  28918. }
  28919. var respJSON map[string]interface{}
  28920. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28923. return
  28924. }
  28925. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28926. userJSONBytes, _ := json.Marshal(respJSON)
  28927. fmt.Println("log")
  28928. fmt.Println(string(userJSONBytes))
  28929. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28930. utils.ErrorLog("解析失败:%v", err)
  28931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28932. return
  28933. }
  28934. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28935. bytesData, _ := json.Marshal(data)
  28936. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28937. resp, _ := client.Do(req)
  28938. defer resp.Body.Close()
  28939. body, ioErr := ioutil.ReadAll(resp.Body)
  28940. if ioErr != nil {
  28941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28943. return
  28944. }
  28945. var respJSON map[string]interface{}
  28946. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28949. return
  28950. }
  28951. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28952. userJSONBytes, _ := json.Marshal(respJSON)
  28953. fmt.Println("log")
  28954. fmt.Println(string(userJSONBytes))
  28955. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28956. utils.ErrorLog("解析失败:%v", err)
  28957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28958. return
  28959. }
  28960. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28961. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  28962. if result3101.Infcode == "0" {
  28963. if len(result3101.Output.Result) > 0 {
  28964. var errMsgs []string
  28965. for _, item := range result3101.Output.Result {
  28966. errMsgs = append(errMsgs, item.VolaCont)
  28967. }
  28968. c.ServeSuccessJSON(map[string]interface{}{
  28969. "failed_code": -10,
  28970. "msg": errMsgs,
  28971. })
  28972. return
  28973. } else {
  28974. if miConfig.MdtrtareaAdmvs == "320921" {
  28975. data["doctor_id"] = "D320923012139"
  28976. } else {
  28977. data["doctor_id"] = "D371621008686"
  28978. }
  28979. bytesData, _ := json.Marshal(data)
  28980. var req *http.Request
  28981. if miConfig.MdtrtareaAdmvs == "320921" {
  28982. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28983. } else {
  28984. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28985. }
  28986. resp, _ := client.Do(req)
  28987. defer resp.Body.Close()
  28988. body, ioErr := ioutil.ReadAll(resp.Body)
  28989. if ioErr != nil {
  28990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28992. return
  28993. }
  28994. var respJSON map[string]interface{}
  28995. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28998. return
  28999. }
  29000. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29001. userJSONBytes, _ := json.Marshal(respJSON)
  29002. fmt.Println("log")
  29003. fmt.Println(string(userJSONBytes))
  29004. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29005. utils.ErrorLog("解析失败:%v", err)
  29006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29007. return
  29008. }
  29009. res.InfRefmsgid = resFour10265.InfRefmsgid
  29010. res.Output = resFour10265.Output
  29011. res.ErrMsg = resFour10265.ErrMsg
  29012. res.Cainfo = resFour10265.Cainfo
  29013. res.WarnMsg = resFour10265.WarnMsg
  29014. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29015. res.Infcode = infocode
  29016. }
  29017. }
  29018. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29019. var pagesize int = 5
  29020. var start int = 1
  29021. var stop int
  29022. var pagecount int
  29023. var curpage int
  29024. data["doctor_id"] = doctor_info.DoctorNumber
  29025. var res2 ResultFour
  29026. //var result res.
  29027. //总页数,向上取整,注意除之前要先转换类型为float64
  29028. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  29029. for curpage = 1; curpage <= pagecount; curpage++ {
  29030. if curpage == 1 {
  29031. start = 1
  29032. } else {
  29033. start = (curpage-1)*pagesize + 1
  29034. }
  29035. stop = curpage * pagesize
  29036. if stop > len(prescriptions) {
  29037. stop = len(prescriptions)
  29038. }
  29039. //var requestLog string
  29040. data["pre"] = prescriptions[start-1 : stop]
  29041. fmt.Println(data["pre"])
  29042. bytesData, _ := json.Marshal(data)
  29043. var req *http.Request
  29044. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  29045. resp, _ := client.Do(req)
  29046. defer resp.Body.Close()
  29047. body, ioErr := ioutil.ReadAll(resp.Body)
  29048. if ioErr != nil {
  29049. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29051. return
  29052. }
  29053. var respJSON map[string]interface{}
  29054. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29055. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29057. return
  29058. }
  29059. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29060. userJSONBytes, _ := json.Marshal(respJSON)
  29061. fmt.Println("log")
  29062. fmt.Println(string(userJSONBytes))
  29063. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29064. utils.ErrorLog("解析失败:%v", err)
  29065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29066. return
  29067. }
  29068. res.InfRefmsgid = resFour10265.InfRefmsgid
  29069. res.Output = resFour10265.Output
  29070. res.ErrMsg = resFour10265.ErrMsg
  29071. res.Cainfo = resFour10265.Cainfo
  29072. res.WarnMsg = resFour10265.WarnMsg
  29073. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29074. res.Infcode = infocode
  29075. if infocode == 0 {
  29076. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  29077. } else {
  29078. isSuccess = false
  29079. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  29080. res.Infcode = -1
  29081. res.ErrMsg = resFour10265.ErrMsg
  29082. errlog := &models.HisOrderError{
  29083. UserOrgId: adminUser.CurrentOrgId,
  29084. Ctime: time.Now().Unix(),
  29085. Mtime: time.Now().Unix(),
  29086. Number: chrg_bchno,
  29087. ErrMsg: "",
  29088. Status: 1,
  29089. PatientId: id,
  29090. RecordTime: recordDateTime,
  29091. Stage: 4,
  29092. }
  29093. service.CreateErrMsgLog(errlog)
  29094. }
  29095. }
  29096. if isSuccess {
  29097. res.Infcode = 0
  29098. res.Output.Result = res2.Output.Result
  29099. } else {
  29100. order := &models.HisOrder{
  29101. UserOrgId: adminUser.CurrentOrgId,
  29102. HisPatientId: his.ID,
  29103. PatientId: his.PatientId,
  29104. SettleAccountsDate: recordDateTime,
  29105. Ctime: time.Now().Unix(),
  29106. Mtime: time.Now().Unix(),
  29107. MdtrtId: his.Number,
  29108. PsnNo: his.PsnNo,
  29109. MedType: strconv.FormatInt(reg_type, 10),
  29110. Status: 1,
  29111. Number: chrg_bchno,
  29112. Infcode: res.Infcode,
  29113. WarnMsg: res.WarnMsg,
  29114. Cainfo: res.Cainfo,
  29115. ErrMsg: res.ErrMsg,
  29116. RespondTime: res.RefmsgTime,
  29117. InfRefmsgid: res.InfRefmsgid,
  29118. OrderStatus: 1,
  29119. IsMedicineInsurance: 1,
  29120. SettleType: settle_accounts_type,
  29121. SettleStartTime: start_time,
  29122. SettleEndTime: end_time,
  29123. Creator: roles.AdminUserId,
  29124. Modify: roles.AdminUserId,
  29125. PType: 2,
  29126. Diagnosis: diagnosis_id,
  29127. }
  29128. err = service.CreateOrder(order)
  29129. if err != nil {
  29130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29131. return
  29132. }
  29133. c.ServeSuccessJSON(map[string]interface{}{
  29134. "failed_code": -10,
  29135. "msg": res2.ErrMsg,
  29136. })
  29137. return
  29138. }
  29139. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29140. 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)
  29141. var dat map[string]interface{}
  29142. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29143. fmt.Println(dat)
  29144. } else {
  29145. fmt.Println(err)
  29146. }
  29147. saveLog(result, request_log, "2204", "上传费用明细")
  29148. userJSONBytes, _ := json.Marshal(dat)
  29149. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29150. utils.ErrorLog("解析失败:%v", err)
  29151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29152. return
  29153. }
  29154. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29155. 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, "", "")
  29156. var dat map[string]interface{}
  29157. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29158. fmt.Println(dat)
  29159. } else {
  29160. fmt.Println(err)
  29161. }
  29162. saveLog(result, request_log, "2204", "上传费用明细")
  29163. userJSONBytes, _ := json.Marshal(dat)
  29164. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29165. utils.ErrorLog("解析失败:%v", err)
  29166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29167. return
  29168. }
  29169. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29170. 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, "", "")
  29171. var dat map[string]interface{}
  29172. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29173. fmt.Println(dat)
  29174. } else {
  29175. fmt.Println(err)
  29176. }
  29177. saveLog(result, request_log, "2204", "上传费用明细")
  29178. userJSONBytes, _ := json.Marshal(dat)
  29179. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29180. utils.ErrorLog("解析失败:%v", err)
  29181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29182. return
  29183. }
  29184. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29185. bytesData, _ := json.Marshal(data)
  29186. var req *http.Request
  29187. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29188. resp, _ := client.Do(req)
  29189. defer resp.Body.Close()
  29190. body, ioErr := ioutil.ReadAll(resp.Body)
  29191. if ioErr != nil {
  29192. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29194. return
  29195. }
  29196. var respJSON map[string]interface{}
  29197. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29200. return
  29201. }
  29202. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29203. if status == "0" {
  29204. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29205. c.ServeSuccessJSON(map[string]interface{}{
  29206. "failed_code": -10,
  29207. "msg": err_msg,
  29208. })
  29209. return
  29210. }
  29211. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29212. userJSONBytes, _ := json.Marshal(respJSON)
  29213. fmt.Println("log")
  29214. fmt.Println(string(userJSONBytes))
  29215. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29216. utils.ErrorLog("解析失败:%v", err)
  29217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29218. return
  29219. }
  29220. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29221. bytesData, _ := json.Marshal(data)
  29222. var req *http.Request
  29223. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29224. resp, _ := client.Do(req)
  29225. defer resp.Body.Close()
  29226. body, ioErr := ioutil.ReadAll(resp.Body)
  29227. if ioErr != nil {
  29228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29230. return
  29231. }
  29232. var respJSON map[string]interface{}
  29233. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29236. return
  29237. }
  29238. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29239. if status == "0" {
  29240. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29241. c.ServeSuccessJSON(map[string]interface{}{
  29242. "failed_code": -10,
  29243. "msg": err_msg,
  29244. })
  29245. return
  29246. }
  29247. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29248. userJSONBytes, _ := json.Marshal(respJSON)
  29249. fmt.Println("log")
  29250. fmt.Println(string(userJSONBytes))
  29251. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29252. utils.ErrorLog("解析失败:%v", err)
  29253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29254. return
  29255. }
  29256. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29257. 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, "", "")
  29258. var dat map[string]interface{}
  29259. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29260. fmt.Println(dat)
  29261. } else {
  29262. fmt.Println(err)
  29263. }
  29264. saveLog(result, request_log, "2204", "上传费用明细")
  29265. userJSONBytes, _ := json.Marshal(dat)
  29266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29267. utils.ErrorLog("解析失败:%v", err)
  29268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29269. return
  29270. }
  29271. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29272. bytesData, _ := json.Marshal(data)
  29273. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  29274. resp, _ := client.Do(req)
  29275. defer resp.Body.Close()
  29276. body, ioErr := ioutil.ReadAll(resp.Body)
  29277. if ioErr != nil {
  29278. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29280. return
  29281. }
  29282. var respJSON map[string]interface{}
  29283. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29286. return
  29287. }
  29288. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29289. userJSONBytes, _ := json.Marshal(respJSON)
  29290. fmt.Println("log")
  29291. fmt.Println(string(userJSONBytes))
  29292. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29293. utils.ErrorLog("解析失败:%v", err)
  29294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29295. return
  29296. }
  29297. } else {
  29298. if miConfig.MdtrtareaAdmvs == "441202" {
  29299. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29300. if result3101.Infcode == 0 {
  29301. if len(result3101.Output.Result) > 0 {
  29302. var errMsgs []string
  29303. for _, item := range result3101.Output.Result {
  29304. errMsgs = append(errMsgs, item.VolaCont)
  29305. }
  29306. c.ServeSuccessJSON(map[string]interface{}{
  29307. "failed_code": -10,
  29308. "msg": errMsgs,
  29309. })
  29310. return
  29311. } else {
  29312. 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)
  29313. var dat map[string]interface{}
  29314. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29315. fmt.Println(dat)
  29316. } else {
  29317. fmt.Println(err)
  29318. }
  29319. saveLog(result, request_log, "2204", "上传费用明细")
  29320. userJSONBytes, _ := json.Marshal(dat)
  29321. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29322. utils.ErrorLog("解析失败:%v", err)
  29323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29324. return
  29325. }
  29326. }
  29327. } else {
  29328. c.ServeSuccessJSON(map[string]interface{}{
  29329. "failed_code": -10,
  29330. "msg": result3101.ErrMsg,
  29331. })
  29332. return
  29333. }
  29334. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29335. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29336. if result3101.Infcode == 0 {
  29337. if len(result3101.Output.Result) > 0 {
  29338. var errMsgs []string
  29339. for _, item := range result3101.Output.Result {
  29340. errMsgs = append(errMsgs, item.VolaCont)
  29341. }
  29342. c.ServeSuccessJSON(map[string]interface{}{
  29343. "failed_code": -10,
  29344. "msg": errMsgs,
  29345. })
  29346. return
  29347. } else {
  29348. 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)
  29349. var dat map[string]interface{}
  29350. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29351. fmt.Println(dat)
  29352. } else {
  29353. fmt.Println(err)
  29354. }
  29355. saveLog(result, request_log, "2204", "上传费用明细")
  29356. userJSONBytes, _ := json.Marshal(dat)
  29357. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29358. utils.ErrorLog("解析失败:%v", err)
  29359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29360. return
  29361. }
  29362. }
  29363. } else {
  29364. c.ServeSuccessJSON(map[string]interface{}{
  29365. "failed_code": -10,
  29366. "msg": result3101.ErrMsg,
  29367. })
  29368. return
  29369. }
  29370. } else {
  29371. if miConfig.Code == "H15049901371" {
  29372. 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)
  29373. var dat map[string]interface{}
  29374. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29375. fmt.Println(dat)
  29376. } else {
  29377. fmt.Println(err)
  29378. }
  29379. saveLog(result, request_log, "2204", "上传费用明细")
  29380. userJSONBytes, _ := json.Marshal(dat)
  29381. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29382. utils.ErrorLog("解析失败:%v", err)
  29383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29384. return
  29385. }
  29386. res.InfRefmsgid = resFour10265.InfRefmsgid
  29387. res.Output = resFour10265.Output
  29388. res.ErrMsg = resFour10265.ErrMsg
  29389. res.Cainfo = resFour10265.Cainfo
  29390. res.WarnMsg = resFour10265.WarnMsg
  29391. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29392. res.Infcode = infocode
  29393. } else {
  29394. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" {
  29395. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29396. if result3101.Infcode == 0 {
  29397. if len(result3101.Output.Result) > 0 {
  29398. var errMsgs []string
  29399. for _, item := range result3101.Output.Result {
  29400. errMsgs = append(errMsgs, item.VolaCont)
  29401. }
  29402. c.ServeSuccessJSON(map[string]interface{}{
  29403. "failed_code": -10,
  29404. "msg": errMsgs,
  29405. })
  29406. return
  29407. } else {
  29408. 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)
  29409. var dat map[string]interface{}
  29410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29411. fmt.Println(dat)
  29412. } else {
  29413. fmt.Println(err)
  29414. }
  29415. saveLog(result, request_log, "2204", "上传费用明细")
  29416. userJSONBytes, _ := json.Marshal(dat)
  29417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29418. utils.ErrorLog("解析失败:%v", err)
  29419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29420. return
  29421. }
  29422. }
  29423. } else {
  29424. c.ServeSuccessJSON(map[string]interface{}{
  29425. "failed_code": -10,
  29426. "msg": result3101.ErrMsg,
  29427. })
  29428. return
  29429. }
  29430. } else {
  29431. 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)
  29432. var dat map[string]interface{}
  29433. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29434. fmt.Println(dat)
  29435. } else {
  29436. fmt.Println(err)
  29437. }
  29438. saveLog(result, request_log, "2204", "上传费用明细")
  29439. userJSONBytes, _ := json.Marshal(dat)
  29440. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29441. utils.ErrorLog("解析失败:%v", err)
  29442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29443. return
  29444. }
  29445. }
  29446. }
  29447. }
  29448. }
  29449. var total_two float64
  29450. if res.Infcode == -1 {
  29451. errlog := &models.HisOrderError{
  29452. UserOrgId: adminUser.CurrentOrgId,
  29453. Ctime: time.Now().Unix(),
  29454. Mtime: time.Now().Unix(),
  29455. Number: chrg_bchno,
  29456. ErrMsg: res.ErrMsg,
  29457. Status: 1,
  29458. PatientId: id,
  29459. RecordTime: recordDateTime,
  29460. Stage: 4,
  29461. }
  29462. service.CreateErrMsgLog(errlog)
  29463. c.ServeSuccessJSON(map[string]interface{}{
  29464. "failed_code": -10,
  29465. "msg": res.ErrMsg,
  29466. })
  29467. return
  29468. }
  29469. if res.Infcode == 0 {
  29470. order := &models.HisOrder{
  29471. UserOrgId: adminUser.CurrentOrgId,
  29472. HisPatientId: his.ID,
  29473. PatientId: his.PatientId,
  29474. SettleAccountsDate: recordDateTime,
  29475. Ctime: time.Now().Unix(),
  29476. Mtime: time.Now().Unix(),
  29477. MdtrtId: his.Number,
  29478. PsnNo: his.PsnNo,
  29479. MedType: strconv.FormatInt(reg_type, 10),
  29480. Status: 1,
  29481. Number: chrg_bchno,
  29482. Infcode: res.Infcode,
  29483. WarnMsg: res.WarnMsg,
  29484. Cainfo: res.Cainfo,
  29485. ErrMsg: res.ErrMsg,
  29486. RespondTime: res.RefmsgTime,
  29487. InfRefmsgid: res.InfRefmsgid,
  29488. OrderStatus: 1,
  29489. IsMedicineInsurance: 1,
  29490. SettleType: settle_accounts_type,
  29491. SettleStartTime: start_time,
  29492. SettleEndTime: end_time,
  29493. Creator: roles.AdminUserId,
  29494. Modify: roles.AdminUserId,
  29495. PType: 2,
  29496. Diagnosis: diagnosis_id,
  29497. }
  29498. err = service.CreateOrder(order)
  29499. if err != nil {
  29500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29501. return
  29502. }
  29503. for _, item := range res.Output.Result {
  29504. temp := strings.Split(item.FeedetlSn, "-")
  29505. var advice_id int64 = 0
  29506. var project_id int64 = 0
  29507. var types int64 = 0
  29508. id, _ := strconv.ParseInt(temp[2], 10, 64)
  29509. types, _ = strconv.ParseInt(temp[1], 10, 64)
  29510. if temp[1] == "1" {
  29511. advice_id = id
  29512. project_id = 0
  29513. } else if temp[1] == "2" {
  29514. advice_id = 0
  29515. project_id = id
  29516. }
  29517. total_two = total_two + item.DetItemFeeSumamt
  29518. info := &models.HisOrderInfo{
  29519. OrderNumber: order.Number,
  29520. FeedetlSn: item.FeedetlSn,
  29521. UploadDate: time.Now().Unix(),
  29522. AdviceId: advice_id,
  29523. DetItemFeeSumamt: item.DetItemFeeSumamt,
  29524. Cnt: item.Cnt,
  29525. Pric: float64(item.Pric),
  29526. PatientId: his.PatientId,
  29527. PricUplmtAmt: item.PricUplmtAmt,
  29528. SelfpayProp: item.SelfpayProp,
  29529. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  29530. OverlmtAmt: item.OverlmtAmt,
  29531. PreselfpayAmt: item.PreselfpayAmt,
  29532. BasMednFlag: item.BasMednFlag,
  29533. MedChrgitmType: item.MedChrgitmType,
  29534. HiNegoDrugFlag: item.HiNegoDrugFlag,
  29535. Status: 1,
  29536. Memo: item.Memo,
  29537. Mtime: time.Now().Unix(),
  29538. InscpScpAmt: item.InscpScpAmt,
  29539. DrtReimFlag: item.DrtReimFlag,
  29540. Ctime: time.Now().Unix(),
  29541. ListSpItemFlag: item.ListSpItemFlag,
  29542. ChldMedcFlag: item.ChldMedcFlag,
  29543. LmtUsedFlag: item.LmtUsedFlag,
  29544. ChrgitmLv: item.ChrgitmLv,
  29545. UserOrgId: adminUser.CurrentOrgId,
  29546. HisPatientId: his.ID,
  29547. OrderId: order.ID,
  29548. ProjectId: project_id,
  29549. Type: types,
  29550. }
  29551. service.CreateOrderInfo(info)
  29552. }
  29553. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  29554. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  29555. var total float64
  29556. for _, item := range prescriptions {
  29557. if item.Type == 1 { //药品
  29558. for _, subItem := range item.HisDoctorAdviceInfo {
  29559. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29560. total_one := price * subItem.PrescribingNumber
  29561. fmt.Println("subItem")
  29562. fmt.Println(subItem.Price)
  29563. fmt.Println("price")
  29564. fmt.Println(price)
  29565. fmt.Println("total_one")
  29566. fmt.Println(total_one)
  29567. total = total + total_one
  29568. fmt.Println(total)
  29569. }
  29570. }
  29571. if item.Type == 2 { //项目
  29572. for _, subItem := range item.HisPrescriptionProject {
  29573. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  29574. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29575. total_one := price * cnt
  29576. total = total + total_one
  29577. }
  29578. }
  29579. }
  29580. allTotal := fmt.Sprintf("%.2f", total)
  29581. if res.Infcode == 0 {
  29582. var rf []*ResultFive
  29583. json.Unmarshal([]byte(his.Iinfo), &rf)
  29584. chrg_bchno := chrg_bchno
  29585. cert_no := his.Certno
  29586. var insutypes []string
  29587. var insutype string
  29588. var is390 int = 0
  29589. var is310 int = 0
  29590. for _, item := range rf {
  29591. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29592. insutypes = append(insutypes, item.Insutype)
  29593. }
  29594. }
  29595. if len(insutypes) == 1 {
  29596. insutype = insutypes[0]
  29597. } else {
  29598. for _, i := range insutypes {
  29599. if i == "390" {
  29600. is390 = 1
  29601. }
  29602. if i == "310" {
  29603. is310 = 1
  29604. }
  29605. }
  29606. }
  29607. if is390 == 1 {
  29608. insutype = "390"
  29609. }
  29610. if is310 == 1 {
  29611. insutype = "310"
  29612. }
  29613. if len(insutypes) == 0 {
  29614. insutype = "390"
  29615. }
  29616. if len(insutypes) == 2 {
  29617. insutype = strconv.FormatInt(his.SocialType, 10)
  29618. }
  29619. //insutype = "390"
  29620. if his.IdCardType == 1 {
  29621. cert_no = his.MedicalInsuranceNumber
  29622. } else {
  29623. cert_no = his.Certno
  29624. }
  29625. var res ResultSeven
  29626. var ahres ResultSevenAH
  29627. var resSeven10265 ResultSeven10265
  29628. var resSeven10265Two ResultSeven10265Two
  29629. var gzresSeven10265Two GZResultSeven10265Two
  29630. if miConfig.MdtrtareaAdmvs == "421300" {
  29631. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  29632. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29633. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29634. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29635. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29636. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29637. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29638. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29639. resp, requestErr := http.Get(api)
  29640. if requestErr != nil {
  29641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29642. return
  29643. }
  29644. body, ioErr := ioutil.ReadAll(resp.Body)
  29645. if ioErr != nil {
  29646. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29648. return
  29649. }
  29650. var respJSON map[string]interface{}
  29651. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29652. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29654. return
  29655. }
  29656. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29657. result, _ := json.Marshal(respJSON)
  29658. fmt.Println("log")
  29659. fmt.Println(string(result))
  29660. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29661. utils.ErrorLog("解析失败:%v", err)
  29662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29663. return
  29664. }
  29665. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29666. if reg_type == 11 && his.Insutype == "390" {
  29667. reg_type = 110104
  29668. }
  29669. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29670. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29671. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29672. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29673. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29674. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29675. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29676. resp, requestErr := http.Get(api)
  29677. if requestErr != nil {
  29678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29679. return
  29680. }
  29681. body, ioErr := ioutil.ReadAll(resp.Body)
  29682. if ioErr != nil {
  29683. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29685. return
  29686. }
  29687. var respJSON map[string]interface{}
  29688. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29691. return
  29692. }
  29693. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29694. result, _ := json.Marshal(respJSON)
  29695. fmt.Println("log")
  29696. fmt.Println(string(result))
  29697. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29698. utils.ErrorLog("解析失败:%v", err)
  29699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29700. return
  29701. }
  29702. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29703. if reg_type == 11 && his.Insutype == "390" {
  29704. reg_type = 110104
  29705. }
  29706. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29707. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29708. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29709. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29710. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29711. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29712. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29713. resp, requestErr := http.Get(api)
  29714. if requestErr != nil {
  29715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29716. return
  29717. }
  29718. body, ioErr := ioutil.ReadAll(resp.Body)
  29719. if ioErr != nil {
  29720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29722. return
  29723. }
  29724. var respJSON map[string]interface{}
  29725. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29728. return
  29729. }
  29730. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29731. result, _ := json.Marshal(respJSON)
  29732. fmt.Println("log")
  29733. fmt.Println(string(result))
  29734. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29735. utils.ErrorLog("解析失败:%v", err)
  29736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29737. return
  29738. }
  29739. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29740. if reg_type == 11 && his.Insutype == "390" {
  29741. reg_type = 110104
  29742. }
  29743. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29744. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29745. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29746. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29747. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29748. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29749. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29750. resp, requestErr := http.Get(api)
  29751. if requestErr != nil {
  29752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29753. return
  29754. }
  29755. body, ioErr := ioutil.ReadAll(resp.Body)
  29756. if ioErr != nil {
  29757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29759. return
  29760. }
  29761. var respJSON map[string]interface{}
  29762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29765. return
  29766. }
  29767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29768. result, _ := json.Marshal(respJSON)
  29769. fmt.Println("log")
  29770. fmt.Println(string(result))
  29771. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29772. utils.ErrorLog("解析失败:%v", err)
  29773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29774. return
  29775. }
  29776. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29777. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29778. if result3101.Infcode == "0" {
  29779. if len(result3101.Output.Result) > 0 {
  29780. var errMsgs []string
  29781. for _, item := range result3101.Output.Result {
  29782. errMsgs = append(errMsgs, item.VolaCont)
  29783. }
  29784. c.ServeSuccessJSON(map[string]interface{}{
  29785. "failed_code": -10,
  29786. "msg": errMsgs,
  29787. })
  29788. return
  29789. } else {
  29790. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29791. if his.IdCardType != 4 {
  29792. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29793. bas := strings.Split(psn_info.CardInfo, "|")
  29794. if his.IdCardType == 1 {
  29795. cert_no = bas[2]
  29796. } else {
  29797. cert_no = bas[1]
  29798. }
  29799. } else {
  29800. cert_no = his.Certno
  29801. }
  29802. //江苏地区国家医保医疗类别
  29803. //职工透析:医疗类别选特殊情况门诊9933
  29804. //居民血透门慢: 医疗类别选门诊慢病1402
  29805. //var med_type string
  29806. //if his.Insutype == "310" {
  29807. // if reg_type == 14 {
  29808. // med_type = "9933"
  29809. // } else if reg_type == 11 {
  29810. // med_type = "11"
  29811. //
  29812. // }
  29813. //} else if his.Insutype == "390" {
  29814. // if reg_type == 14 {
  29815. // med_type = "1402"
  29816. // } else if reg_type == 11 {
  29817. // med_type = "11"
  29818. // }
  29819. //}
  29820. var api string
  29821. if miConfig.MdtrtareaAdmvs == "320921" {
  29822. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29823. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29824. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29825. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29826. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29827. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29828. "&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
  29829. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29830. } else {
  29831. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29832. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29833. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29834. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29835. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29836. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29837. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29838. "&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
  29839. }
  29840. resp, requestErr := http.Get(api)
  29841. if requestErr != nil {
  29842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29843. return
  29844. }
  29845. body, ioErr := ioutil.ReadAll(resp.Body)
  29846. if ioErr != nil {
  29847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29849. return
  29850. }
  29851. var respJSON map[string]interface{}
  29852. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29855. return
  29856. }
  29857. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29858. result, _ := json.Marshal(respJSON)
  29859. fmt.Println("log")
  29860. fmt.Println(string(result))
  29861. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  29862. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29863. utils.ErrorLog("解析失败:%v", err)
  29864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29865. return
  29866. }
  29867. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29868. res.Output = resSeven10265.Output
  29869. res.ErrMsg = resSeven10265.ErrMsg
  29870. res.Cainfo = resSeven10265.Cainfo
  29871. res.WarnMsg = resSeven10265.WarnMsg
  29872. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29873. res.Infcode = infocode
  29874. } else {
  29875. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  29876. utils.ErrorLog("解析失败:%v", err)
  29877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29878. return
  29879. }
  29880. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  29881. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  29882. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  29883. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  29884. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29885. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  29886. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  29887. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  29888. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  29889. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  29890. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  29891. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29892. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  29893. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  29894. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29895. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29896. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  29897. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  29898. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  29899. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  29900. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  29901. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29902. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  29903. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  29904. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  29905. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  29906. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  29907. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  29908. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  29909. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  29910. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29911. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  29912. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  29913. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  29914. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29915. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29916. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29917. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29918. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  29919. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29920. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  29921. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  29922. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  29923. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  29924. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  29925. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  29926. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  29927. res.ErrMsg = resSeven10265Two.ErrMsg
  29928. res.Cainfo = resSeven10265Two.Cainfo
  29929. res.WarnMsg = resSeven10265Two.WarnMsg
  29930. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29931. res.Infcode = infocode
  29932. }
  29933. }
  29934. }
  29935. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29936. psn_info, _ := service.GetPsnByPatientId(id)
  29937. var verify_number string
  29938. if psn_info.IdCardType == 4 {
  29939. verify_number = psn_info.VerifyNumber
  29940. } else if psn_info.IdCardType == 1 {
  29941. bas := strings.Split(psn_info.CardInfo, "|")
  29942. cardNumber := bas[2]
  29943. verify_number = cardNumber
  29944. } else {
  29945. psn_info.IdCardType = 2
  29946. verify_number = psn_info.Certno
  29947. }
  29948. var api string
  29949. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29950. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  29951. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29952. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29953. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29954. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29955. "&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
  29956. resp, requestErr := http.Get(api)
  29957. if requestErr != nil {
  29958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29959. return
  29960. }
  29961. body, ioErr := ioutil.ReadAll(resp.Body)
  29962. if ioErr != nil {
  29963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29965. return
  29966. }
  29967. var respJSON map[string]interface{}
  29968. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29971. return
  29972. }
  29973. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29974. result, _ := json.Marshal(respJSON)
  29975. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29976. utils.ErrorLog("解析失败:%v", err)
  29977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29978. return
  29979. }
  29980. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29981. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  29982. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  29983. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29984. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  29985. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  29986. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  29987. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  29988. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  29989. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  29990. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  29991. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  29992. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  29993. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29994. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  29995. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  29996. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  29997. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  29998. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  29999. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  30000. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30001. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  30002. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  30003. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  30004. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  30005. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  30006. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  30007. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  30008. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  30009. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  30010. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  30011. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  30012. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  30013. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  30014. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30015. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  30016. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  30017. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  30018. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  30019. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  30020. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  30021. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  30022. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  30023. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  30024. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  30025. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  30026. res.ErrMsg = resSeven10265.ErrMsg
  30027. res.Cainfo = resSeven10265.Cainfo
  30028. res.WarnMsg = resSeven10265.WarnMsg
  30029. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30030. res.Infcode = infocode
  30031. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30032. acct_used_flag := "1"
  30033. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  30034. var result string
  30035. var request_log string
  30036. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  30037. 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)
  30038. } else {
  30039. 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)
  30040. }
  30041. var dat map[string]interface{}
  30042. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30043. fmt.Println(dat)
  30044. } else {
  30045. fmt.Println(err)
  30046. }
  30047. saveLog(result, request_log, "2206", "预结算")
  30048. userJSONBytes, _ := json.Marshal(dat)
  30049. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30050. utils.ErrorLog("解析失败:%v", err)
  30051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30052. return
  30053. }
  30054. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30055. var result string
  30056. var request_log string
  30057. if his.IdCardType == 2 {
  30058. insutype = strconv.FormatInt(his.SocialType, 10)
  30059. 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, "")
  30060. } else if his.IdCardType == 1 {
  30061. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30062. bas := strings.Split(psn_info.CardInfo, "|")
  30063. basNumber := bas[2]
  30064. card_sn := bas[3]
  30065. var rf []*ResultFive
  30066. json.Unmarshal([]byte(his.Iinfo), &rf)
  30067. var psn_type string
  30068. for _, item := range rf {
  30069. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30070. psn_type = item.PsnType
  30071. }
  30072. }
  30073. insutype = strconv.FormatInt(his.SocialType, 10)
  30074. 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)
  30075. } else {
  30076. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30077. //bas := strings.Split(psn_info.CardInfo, "|")
  30078. //basNumber := bas[2]
  30079. //card_sn := bas[3]
  30080. var rf []*ResultFive
  30081. json.Unmarshal([]byte(his.Iinfo), &rf)
  30082. var psn_type string
  30083. for _, item := range rf {
  30084. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30085. psn_type = item.PsnType
  30086. }
  30087. }
  30088. insutype = strconv.FormatInt(his.SocialType, 10)
  30089. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30090. 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)
  30091. }
  30092. var dat map[string]interface{}
  30093. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30094. fmt.Println(dat)
  30095. } else {
  30096. fmt.Println(err)
  30097. }
  30098. saveLog(result, request_log, "2206", "预结算")
  30099. userJSONBytes, _ := json.Marshal(dat)
  30100. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30101. utils.ErrorLog("解析失败:%v", err)
  30102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30103. return
  30104. }
  30105. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30106. var result string
  30107. var request_log string
  30108. if his.IdCardType == 2 {
  30109. insutype = strconv.FormatInt(his.SocialType, 10)
  30110. 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, "")
  30111. } else if his.IdCardType == 1 {
  30112. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30113. bas := strings.Split(psn_info.CardInfo, "|")
  30114. basNumber := bas[0]
  30115. card_sn := ""
  30116. var rf []*ResultFive
  30117. json.Unmarshal([]byte(his.Iinfo), &rf)
  30118. var psn_type string
  30119. for _, item := range rf {
  30120. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30121. psn_type = item.PsnType
  30122. }
  30123. }
  30124. insutype = strconv.FormatInt(his.SocialType, 10)
  30125. 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)
  30126. } else {
  30127. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30128. //bas := strings.Split(psn_info.CardInfo, "|")
  30129. //basNumber := bas[2]
  30130. //card_sn := bas[3]
  30131. var rf []*ResultFive
  30132. json.Unmarshal([]byte(his.Iinfo), &rf)
  30133. var psn_type string
  30134. for _, item := range rf {
  30135. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30136. psn_type = item.PsnType
  30137. }
  30138. }
  30139. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30140. 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)
  30141. }
  30142. var dat map[string]interface{}
  30143. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30144. fmt.Println(dat)
  30145. } else {
  30146. fmt.Println(err)
  30147. }
  30148. saveLog(result, request_log, "2206", "预结算")
  30149. userJSONBytes, _ := json.Marshal(dat)
  30150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30151. utils.ErrorLog("解析失败:%v", err)
  30152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30153. return
  30154. }
  30155. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30156. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30157. if his.IdCardType == 4 {
  30158. psn_info.VerifyNumber = psn_info.VerifyNumber
  30159. cert_no = psn_info.VerifyNumber
  30160. } else if his.IdCardType == 2 {
  30161. cert_no = psn_info.Certno
  30162. psn_info.VerifyNumber = psn_info.Certno
  30163. } else {
  30164. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30165. bas := strings.Split(psn_info.CardInfo, "|")
  30166. if his.IdCardType == 1 {
  30167. cert_no = bas[2]
  30168. } else {
  30169. cert_no = bas[1]
  30170. }
  30171. }
  30172. var api string
  30173. var med_type string
  30174. if his.Insutype == "390" {
  30175. if reg_type == 992102 {
  30176. med_type = "992102"
  30177. }
  30178. if reg_type == 140104 {
  30179. med_type = "140104"
  30180. }
  30181. if reg_type == 140201 {
  30182. med_type = "140201"
  30183. }
  30184. if reg_type == 14 {
  30185. med_type = "140104"
  30186. }
  30187. } else if his.Insutype == "310" {
  30188. if reg_type == 992102 {
  30189. med_type = "992102"
  30190. }
  30191. if reg_type == 140104 {
  30192. med_type = "140104"
  30193. }
  30194. if reg_type == 140201 {
  30195. med_type = "140201"
  30196. }
  30197. if reg_type == 14 {
  30198. med_type = "140104"
  30199. }
  30200. }
  30201. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30202. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30203. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30204. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30205. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30206. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30207. "&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
  30208. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30209. resp, requestErr := http.Get(api)
  30210. if requestErr != nil {
  30211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30212. return
  30213. }
  30214. body, ioErr := ioutil.ReadAll(resp.Body)
  30215. if ioErr != nil {
  30216. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30218. return
  30219. }
  30220. var respJSON map[string]interface{}
  30221. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30222. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30224. return
  30225. }
  30226. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30227. if status == "0" {
  30228. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30229. c.ServeSuccessJSON(map[string]interface{}{
  30230. "failed_code": -10,
  30231. "msg": err_msg,
  30232. })
  30233. return
  30234. }
  30235. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30236. result, _ := json.Marshal(respJSON)
  30237. fmt.Println("log")
  30238. fmt.Println(string(result))
  30239. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30240. utils.ErrorLog("解析失败:%v", err)
  30241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30242. return
  30243. }
  30244. res.InfRefmsgid = ahres.InfRefmsgid
  30245. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30246. // 创建对应的Time类型
  30247. t := time.UnixMilli(timestamp)
  30248. // 格式化成指定的日期字符串
  30249. str := t.Format("2006-01-02 15:04:05")
  30250. res.Output.Setlinfo.SetlTime = str
  30251. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30252. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30253. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30254. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30255. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30256. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30257. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30258. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30259. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30260. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30261. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30262. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30263. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30264. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30265. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30266. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30267. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30268. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30269. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30270. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30271. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30272. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30273. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30274. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30275. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30276. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30277. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30278. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30279. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30280. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30281. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30282. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30283. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30284. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30285. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30286. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30287. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30288. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30289. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30290. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30291. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30292. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30293. //res.Output.Setldetail = ahres.Output.Setldetail
  30294. res.ErrMsg = ahres.ErrMsg
  30295. res.Cainfo = ahres.Cainfo
  30296. res.WarnMsg = ahres.WarnMsg
  30297. res.Infcode = ahres.Infcode
  30298. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30299. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30300. if his.IdCardType == 4 {
  30301. psn_info.VerifyNumber = psn_info.VerifyNumber
  30302. cert_no = psn_info.Certno
  30303. } else if his.IdCardType == 2 {
  30304. cert_no = psn_info.Certno
  30305. psn_info.VerifyNumber = psn_info.Certno
  30306. } else {
  30307. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30308. bas := strings.Split(psn_info.CardInfo, "|")
  30309. if his.IdCardType == 1 {
  30310. cert_no = bas[2]
  30311. } else {
  30312. cert_no = bas[1]
  30313. }
  30314. }
  30315. var api string
  30316. var med_type string
  30317. if his.Insutype == "390" {
  30318. if reg_type == 992102 {
  30319. med_type = "992102"
  30320. }
  30321. if reg_type == 140104 {
  30322. med_type = "140104"
  30323. }
  30324. if reg_type == 140201 {
  30325. med_type = "140201"
  30326. }
  30327. if reg_type == 14 {
  30328. med_type = "14"
  30329. }
  30330. } else if his.Insutype == "310" {
  30331. if reg_type == 992102 {
  30332. med_type = "992102"
  30333. }
  30334. if reg_type == 140104 {
  30335. med_type = "140104"
  30336. }
  30337. if reg_type == 140201 {
  30338. med_type = "140201"
  30339. }
  30340. if reg_type == 14 {
  30341. med_type = "14"
  30342. }
  30343. }
  30344. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30345. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30346. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30347. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30348. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30349. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30350. "&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
  30351. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30352. resp, requestErr := http.Get(api)
  30353. if requestErr != nil {
  30354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30355. return
  30356. }
  30357. body, ioErr := ioutil.ReadAll(resp.Body)
  30358. if ioErr != nil {
  30359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30361. return
  30362. }
  30363. var respJSON map[string]interface{}
  30364. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30367. return
  30368. }
  30369. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30370. if status == "0" {
  30371. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30372. c.ServeSuccessJSON(map[string]interface{}{
  30373. "failed_code": -10,
  30374. "msg": err_msg,
  30375. })
  30376. return
  30377. }
  30378. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30379. result, _ := json.Marshal(respJSON)
  30380. fmt.Println("log")
  30381. fmt.Println(string(result))
  30382. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30383. utils.ErrorLog("解析失败:%v", err)
  30384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30385. return
  30386. }
  30387. res.InfRefmsgid = ahres.InfRefmsgid
  30388. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30389. // 创建对应的Time类型
  30390. t := time.UnixMilli(timestamp)
  30391. // 格式化成指定的日期字符串
  30392. str := t.Format("2006-01-02 15:04:05")
  30393. res.Output.Setlinfo.SetlTime = str
  30394. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30395. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30396. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30397. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30398. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30399. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30400. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30401. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30402. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30403. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30404. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30405. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30406. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30407. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30408. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30409. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30410. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30411. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30412. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30413. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30414. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30415. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30416. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30417. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30418. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30419. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30420. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30421. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30422. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30423. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30424. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30425. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30426. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30427. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30428. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30429. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30430. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30431. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30432. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30433. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30434. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30435. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30436. //res.Output.Setldetail = ahres.Output.Setldetail
  30437. res.ErrMsg = ahres.ErrMsg
  30438. res.Cainfo = ahres.Cainfo
  30439. res.WarnMsg = ahres.WarnMsg
  30440. res.Infcode = ahres.Infcode
  30441. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30442. var result string
  30443. var request_log string
  30444. if his.IdCardType == 2 {
  30445. 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")
  30446. } else if his.IdCardType == 1 {
  30447. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30448. bas := strings.Split(psn_info.CardInfo, "|")
  30449. basNumber := bas[2]
  30450. card_sn := bas[3]
  30451. 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")
  30452. } else {
  30453. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30454. 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")
  30455. }
  30456. var dat map[string]interface{}
  30457. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30458. fmt.Println(dat)
  30459. } else {
  30460. fmt.Println(err)
  30461. }
  30462. saveLog(result, request_log, "2206", "预结算")
  30463. userJSONBytes, _ := json.Marshal(dat)
  30464. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30465. utils.ErrorLog("解析失败:%v", err)
  30466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30467. return
  30468. }
  30469. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30470. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30471. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30472. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30473. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30474. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30475. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30476. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30477. resp, requestErr := http.Get(api)
  30478. if requestErr != nil {
  30479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30480. return
  30481. }
  30482. body, ioErr := ioutil.ReadAll(resp.Body)
  30483. if ioErr != nil {
  30484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30486. return
  30487. }
  30488. var respJSON map[string]interface{}
  30489. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30492. return
  30493. }
  30494. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30495. result, _ := json.Marshal(respJSON)
  30496. fmt.Println("log")
  30497. fmt.Println(string(result))
  30498. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30499. utils.ErrorLog("解析失败:%v", err)
  30500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30501. return
  30502. }
  30503. } else {
  30504. if miConfig.MdtrtareaAdmvs == "441202" {
  30505. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30506. if result3101.Infcode == 0 {
  30507. if len(result3101.Output.Result) > 0 {
  30508. var errMsgs []string
  30509. for _, item := range result3101.Output.Result {
  30510. errMsgs = append(errMsgs, item.VolaCont)
  30511. }
  30512. c.ServeSuccessJSON(map[string]interface{}{
  30513. "failed_code": -10,
  30514. "msg": errMsgs,
  30515. })
  30516. return
  30517. } else {
  30518. var result string
  30519. var request_log string
  30520. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30521. allTotal = fmt.Sprintf("%.2f", total_two)
  30522. if his.IdCardType == 4 {
  30523. 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)
  30524. } else {
  30525. 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)
  30526. }
  30527. var dat map[string]interface{}
  30528. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30529. fmt.Println(dat)
  30530. } else {
  30531. fmt.Println(err)
  30532. }
  30533. saveLog(result, request_log, "2206", "预结算")
  30534. //userJSONBytes, _ := json.Marshal(dat)
  30535. //
  30536. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30537. // utils.ErrorLog("解析失败:%v", err)
  30538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30539. // return
  30540. //}
  30541. userJSONBytes, _ := json.Marshal(dat)
  30542. if miConfig.Code == "H15049901371" {
  30543. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30544. utils.ErrorLog("解析失败:%v", err)
  30545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30546. return
  30547. }
  30548. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30549. res.Output = resSeven10265.Output
  30550. res.ErrMsg = resSeven10265.ErrMsg
  30551. res.Cainfo = resSeven10265.Cainfo
  30552. res.WarnMsg = resSeven10265.WarnMsg
  30553. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30554. res.Infcode = infocode
  30555. } else {
  30556. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30557. utils.ErrorLog("解析失败:%v", err)
  30558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30559. return
  30560. }
  30561. }
  30562. }
  30563. } else {
  30564. c.ServeSuccessJSON(map[string]interface{}{
  30565. "failed_code": -10,
  30566. "msg": result3101.ErrMsg,
  30567. })
  30568. return
  30569. }
  30570. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30571. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30572. if result3101.Infcode == 0 {
  30573. if len(result3101.Output.Result) > 0 {
  30574. var errMsgs []string
  30575. for _, item := range result3101.Output.Result {
  30576. errMsgs = append(errMsgs, item.VolaCont)
  30577. }
  30578. c.ServeSuccessJSON(map[string]interface{}{
  30579. "failed_code": -10,
  30580. "msg": errMsgs,
  30581. })
  30582. return
  30583. } else {
  30584. var result string
  30585. var request_log string
  30586. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30587. allTotal = fmt.Sprintf("%.2f", total_two)
  30588. if his.IdCardType == 4 {
  30589. 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)
  30590. } else {
  30591. 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)
  30592. }
  30593. var dat map[string]interface{}
  30594. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30595. fmt.Println(dat)
  30596. } else {
  30597. fmt.Println(err)
  30598. }
  30599. saveLog(result, request_log, "2206", "预结算")
  30600. //userJSONBytes, _ := json.Marshal(dat)
  30601. //
  30602. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30603. // utils.ErrorLog("解析失败:%v", err)
  30604. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30605. // return
  30606. //}
  30607. userJSONBytes, _ := json.Marshal(dat)
  30608. if miConfig.Code == "H15049901371" {
  30609. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30610. utils.ErrorLog("解析失败:%v", err)
  30611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30612. return
  30613. }
  30614. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30615. res.Output = resSeven10265.Output
  30616. res.ErrMsg = resSeven10265.ErrMsg
  30617. res.Cainfo = resSeven10265.Cainfo
  30618. res.WarnMsg = resSeven10265.WarnMsg
  30619. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30620. res.Infcode = infocode
  30621. } else {
  30622. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30623. utils.ErrorLog("解析失败:%v", err)
  30624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30625. return
  30626. }
  30627. }
  30628. }
  30629. } else {
  30630. c.ServeSuccessJSON(map[string]interface{}{
  30631. "failed_code": -10,
  30632. "msg": result3101.ErrMsg,
  30633. })
  30634. return
  30635. }
  30636. } else {
  30637. var result string
  30638. var request_log string
  30639. var dat map[string]interface{}
  30640. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30641. allTotal = fmt.Sprintf("%.2f", total_two)
  30642. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  30643. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30644. if result3101.Infcode == 0 {
  30645. if len(result3101.Output.Result) > 0 {
  30646. var errMsgs []string
  30647. for _, item := range result3101.Output.Result {
  30648. errMsgs = append(errMsgs, item.VolaCont)
  30649. }
  30650. c.ServeSuccessJSON(map[string]interface{}{
  30651. "failed_code": -10,
  30652. "msg": errMsgs,
  30653. })
  30654. return
  30655. } else {
  30656. var result string
  30657. var request_log string
  30658. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30659. allTotal = fmt.Sprintf("%.2f", total_two)
  30660. if his.IdCardType == 4 {
  30661. 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)
  30662. } else {
  30663. if his.IdCardType == 2 {
  30664. cert_no = psn_info.Certno
  30665. psn_info.VerifyNumber = psn_info.Certno
  30666. } else {
  30667. bas := strings.Split(psn_info.CardInfo, "|")
  30668. cert_no = bas[2]
  30669. }
  30670. 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)
  30671. }
  30672. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30673. fmt.Println(dat)
  30674. } else {
  30675. fmt.Println(err)
  30676. }
  30677. saveLog(result, request_log, "2206", "预结算")
  30678. }
  30679. } else {
  30680. c.ServeSuccessJSON(map[string]interface{}{
  30681. "failed_code": -10,
  30682. "msg": result3101.ErrMsg,
  30683. })
  30684. return
  30685. }
  30686. } else {
  30687. if his.IdCardType == 4 {
  30688. 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)
  30689. } else {
  30690. if his.IdCardType == 2 {
  30691. cert_no = psn_info.Certno
  30692. psn_info.VerifyNumber = psn_info.Certno
  30693. } else {
  30694. bas := strings.Split(psn_info.CardInfo, "|")
  30695. cert_no = bas[2]
  30696. }
  30697. 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)
  30698. }
  30699. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30700. fmt.Println(dat)
  30701. } else {
  30702. fmt.Println(err)
  30703. }
  30704. saveLog(result, request_log, "2206", "预结算")
  30705. }
  30706. //userJSONBytes, _ := json.Marshal(dat)
  30707. //
  30708. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30709. // utils.ErrorLog("解析失败:%v", err)
  30710. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30711. // return
  30712. //}
  30713. userJSONBytes, _ := json.Marshal(dat)
  30714. if miConfig.Code == "H15049901371" {
  30715. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30716. utils.ErrorLog("解析失败:%v", err)
  30717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30718. return
  30719. }
  30720. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30721. res.Output = resSeven10265.Output
  30722. res.ErrMsg = resSeven10265.ErrMsg
  30723. res.Cainfo = resSeven10265.Cainfo
  30724. res.WarnMsg = resSeven10265.WarnMsg
  30725. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30726. res.Infcode = infocode
  30727. } else {
  30728. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30729. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  30730. utils.ErrorLog("解析失败:%v", err)
  30731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30732. return
  30733. }
  30734. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  30735. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  30736. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  30737. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30738. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  30739. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  30740. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  30741. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30742. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  30743. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30744. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30745. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30746. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30747. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30748. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30749. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  30750. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  30751. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  30752. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  30753. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  30754. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30755. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  30756. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  30757. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  30758. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  30759. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  30760. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  30761. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  30762. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  30763. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30764. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  30765. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  30766. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  30767. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30768. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30769. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30770. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30771. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  30772. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30773. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  30774. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  30775. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  30776. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  30777. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  30778. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  30779. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  30780. res.ErrMsg = gzresSeven10265Two.ErrMsg
  30781. res.Cainfo = gzresSeven10265Two.Cainfo
  30782. res.WarnMsg = gzresSeven10265Two.WarnMsg
  30783. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30784. //res.Infcode = infocode
  30785. } else {
  30786. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30787. utils.ErrorLog("解析失败:%v", err)
  30788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30789. return
  30790. }
  30791. }
  30792. }
  30793. }
  30794. }
  30795. utils.ErrorLog("解析失败:%v", res.Infcode)
  30796. if res.Infcode == -1 {
  30797. errlog := &models.HisOrderError{
  30798. UserOrgId: adminUser.CurrentOrgId,
  30799. Ctime: time.Now().Unix(),
  30800. Mtime: time.Now().Unix(),
  30801. Number: chrg_bchno,
  30802. ErrMsg: res.ErrMsg,
  30803. Status: 1,
  30804. PatientId: id,
  30805. RecordTime: recordDateTime,
  30806. Stage: 20,
  30807. }
  30808. service.CreateErrMsgLog(errlog)
  30809. c.ServeSuccessJSON(map[string]interface{}{
  30810. "failed_code": -10,
  30811. "msg": res.ErrMsg,
  30812. })
  30813. return
  30814. }
  30815. if res.Infcode != 0 {
  30816. errlog := &models.HisOrderError{
  30817. UserOrgId: adminUser.CurrentOrgId,
  30818. Ctime: time.Now().Unix(),
  30819. Mtime: time.Now().Unix(),
  30820. Number: chrg_bchno,
  30821. ErrMsg: res.ErrMsg,
  30822. Status: 1,
  30823. PatientId: id,
  30824. RecordTime: recordDateTime,
  30825. Stage: 20,
  30826. }
  30827. service.CreateErrMsgLog(errlog)
  30828. c.ServeSuccessJSON(map[string]interface{}{
  30829. "failed_code": -10,
  30830. "msg": res.ErrMsg,
  30831. })
  30832. return
  30833. } else {
  30834. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  30835. order.OrderStatus = 1
  30836. order.IsPre = 1
  30837. order.Status = 1
  30838. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  30839. order.SetlId = res.Output.Setlinfo.SetlID
  30840. order.PsnNo = res.Output.Setlinfo.PsnNo
  30841. order.PsnName = res.Output.Setlinfo.PsnName
  30842. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  30843. order.Certno = res.Output.Setlinfo.Certno
  30844. order.Gend = res.Output.Setlinfo.Gend
  30845. order.Naty = res.Output.Setlinfo.Naty
  30846. order.Age = res.Output.Setlinfo.Age
  30847. order.Insutype = res.Output.Setlinfo.Insutype
  30848. order.PsnType = res.Output.Setlinfo.PsnType
  30849. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  30850. order.SetlTime = res.Output.Setlinfo.SetlTime
  30851. order.AcctUsedFlag = acct_used_flag
  30852. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  30853. if res.Output.Setlinfo.MedType == "140101" {
  30854. order.MedType = "14"
  30855. } else {
  30856. if res.Output.Setlinfo.MedType == "110104" {
  30857. order.MedType = "11"
  30858. } else {
  30859. order.MedType = res.Output.Setlinfo.MedType
  30860. }
  30861. }
  30862. if res.Output.Setlinfo.MedType == "992102" {
  30863. order.MedType = "992102"
  30864. }
  30865. if res.Output.Setlinfo.MedType == "140104" {
  30866. order.MedType = "140104"
  30867. }
  30868. if res.Output.Setlinfo.MedType == "140201" {
  30869. order.MedType = "140201"
  30870. }
  30871. if res.Output.Setlinfo.MedType == "14" {
  30872. order.MedType = "14"
  30873. }
  30874. if reg_type == 1112 {
  30875. order.MedType = "1112"
  30876. }
  30877. if reg_type == 1111 {
  30878. order.MedType = "1111"
  30879. }
  30880. order.ClrType = res.Output.Setlinfo.ClrType
  30881. if adminUser.CurrentOrgId == 10480 {
  30882. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  30883. order.ClrType = "11"
  30884. } else {
  30885. order.ClrType = "9903"
  30886. }
  30887. }
  30888. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  30889. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  30890. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  30891. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  30892. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  30893. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  30894. order.HifpPay = res.Output.Setlinfo.HifpPay
  30895. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  30896. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  30897. order.HifesPay = res.Output.Setlinfo.HifesPay
  30898. order.HifobPay = res.Output.Setlinfo.HifobPay
  30899. order.MafPay = res.Output.Setlinfo.MafPay
  30900. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  30901. order.OthPay = res.Output.Setlinfo.OthPay
  30902. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  30903. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  30904. order.AcctPay = res.Output.Setlinfo.AcctPay
  30905. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  30906. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  30907. order.Balc = res.Output.Setlinfo.Balc
  30908. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  30909. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  30910. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  30911. order.ClrWay = res.Output.Setlinfo.ClrWay
  30912. order.Creator = order.Creator
  30913. order.Modify = roles.AdminUserId
  30914. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  30915. //detailStr := string(setlDetail)
  30916. //order.SetlDetail = detailStr
  30917. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  30918. err = service.UpDateOrder(order)
  30919. if err == nil {
  30920. c.ServeSuccessJSON(map[string]interface{}{
  30921. "msg": "预结算成功",
  30922. })
  30923. } else {
  30924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  30925. return
  30926. }
  30927. }
  30928. } else {
  30929. adminUser := c.GetAdminUserInfo()
  30930. errlog := &models.HisOrderError{
  30931. UserOrgId: adminUser.CurrentOrgId,
  30932. Ctime: time.Now().Unix(),
  30933. Mtime: time.Now().Unix(),
  30934. ErrMsg: res.ErrMsg,
  30935. Status: 1,
  30936. PatientId: id,
  30937. RecordTime: recordDateTime,
  30938. Stage: 4,
  30939. }
  30940. service.CreateErrMsgLog(errlog)
  30941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  30942. return
  30943. }
  30944. } else {
  30945. if miConfig.MdtrtareaAdmvs == "150499" {
  30946. order := &models.HisOrder{
  30947. UserOrgId: adminUser.CurrentOrgId,
  30948. HisPatientId: his.ID,
  30949. PatientId: his.PatientId,
  30950. SettleAccountsDate: recordDateTime,
  30951. Ctime: time.Now().Unix(),
  30952. Mtime: time.Now().Unix(),
  30953. MdtrtId: his.Number,
  30954. PsnNo: his.PsnNo,
  30955. MedType: strconv.FormatInt(reg_type, 10),
  30956. Status: 1,
  30957. Number: chrg_bchno,
  30958. Infcode: res.Infcode,
  30959. WarnMsg: res.WarnMsg,
  30960. Cainfo: res.Cainfo,
  30961. ErrMsg: res.ErrMsg,
  30962. RespondTime: res.RefmsgTime,
  30963. InfRefmsgid: res.InfRefmsgid,
  30964. OrderStatus: 1,
  30965. IsMedicineInsurance: 1,
  30966. SettleType: settle_accounts_type,
  30967. SettleStartTime: start_time,
  30968. SettleEndTime: end_time,
  30969. Creator: roles.AdminUserId,
  30970. Modify: roles.AdminUserId,
  30971. PType: 2,
  30972. Diagnosis: diagnosis_id,
  30973. }
  30974. err = service.CreateOrder(order)
  30975. if err != nil {
  30976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30977. return
  30978. }
  30979. }
  30980. adminUser := c.GetAdminUserInfo()
  30981. errlog := &models.HisOrderError{
  30982. UserOrgId: adminUser.CurrentOrgId,
  30983. Ctime: time.Now().Unix(),
  30984. Mtime: time.Now().Unix(),
  30985. ErrMsg: res.ErrMsg,
  30986. Status: 1,
  30987. PatientId: id,
  30988. RecordTime: recordDateTime,
  30989. Stage: 4,
  30990. }
  30991. service.CreateErrMsgLog(errlog)
  30992. c.ServeSuccessJSON(map[string]interface{}{
  30993. "failed_code": -10,
  30994. "msg": res.ErrMsg,
  30995. })
  30996. return
  30997. }
  30998. }
  30999. }
  31000. }
  31001. // 退款
  31002. func (c *HisApiController) Refund() {
  31003. order_id, _ := c.GetInt64("order_id")
  31004. admin_user_id, _ := c.GetInt64("admin_user_id")
  31005. adminUser := c.GetAdminUserInfo()
  31006. var order models.HisOrder
  31007. order, _ = service.GetHisOrderByID(order_id)
  31008. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  31009. if fapiao.ID > 0 {
  31010. c.ServeSuccessJSON(map[string]interface{}{
  31011. "failed_code": -10,
  31012. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  31013. })
  31014. return
  31015. }
  31016. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31017. if order.ID == 0 {
  31018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31019. return
  31020. }
  31021. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31022. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31023. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31024. if config.IsOpen == 1 { //对接了医保,走医保流程
  31025. var res ResultSixteen
  31026. var ahres ResultSevenAH
  31027. var resSixteen10265 ResultSixteen10265
  31028. var resSixteen10265Two ResultSixteen10265Two
  31029. var gz ResultgzSixteen10265Two
  31030. var src_resquest string
  31031. var result string
  31032. if miConfig.MdtrtareaAdmvs == "421300" {
  31033. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31034. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31035. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31036. resp3, requestErr3 := http.Get(api3)
  31037. if requestErr3 != nil {
  31038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31039. return
  31040. }
  31041. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31042. if ioErr3 != nil {
  31043. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31045. return
  31046. }
  31047. var respJSON3 map[string]interface{}
  31048. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31049. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31051. return
  31052. }
  31053. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31054. userJSONBytes3, _ := json.Marshal(respJSON3)
  31055. fmt.Println("log")
  31056. fmt.Println(string(userJSONBytes3))
  31057. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31058. utils.ErrorLog("解析失败:%v", err)
  31059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31060. return
  31061. }
  31062. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31063. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31064. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31065. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31066. resp3, requestErr3 := http.Get(api3)
  31067. if requestErr3 != nil {
  31068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31069. return
  31070. }
  31071. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31072. if ioErr3 != nil {
  31073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31075. return
  31076. }
  31077. var respJSON3 map[string]interface{}
  31078. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31081. return
  31082. }
  31083. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31084. userJSONBytes3, _ := json.Marshal(respJSON3)
  31085. fmt.Println("log")
  31086. fmt.Println(string(userJSONBytes3))
  31087. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31088. utils.ErrorLog("解析失败:%v", err)
  31089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31090. return
  31091. }
  31092. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31093. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31094. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31095. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31096. resp3, requestErr3 := http.Get(api3)
  31097. if requestErr3 != nil {
  31098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31099. return
  31100. }
  31101. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31102. if ioErr3 != nil {
  31103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31105. return
  31106. }
  31107. var respJSON3 map[string]interface{}
  31108. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31111. return
  31112. }
  31113. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31114. userJSONBytes3, _ := json.Marshal(respJSON3)
  31115. fmt.Println("log")
  31116. fmt.Println(string(userJSONBytes3))
  31117. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31118. utils.ErrorLog("解析失败:%v", err)
  31119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31120. return
  31121. }
  31122. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31123. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31124. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31125. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31126. resp3, requestErr3 := http.Get(api3)
  31127. if requestErr3 != nil {
  31128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31129. return
  31130. }
  31131. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31132. if ioErr3 != nil {
  31133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31135. return
  31136. }
  31137. var respJSON3 map[string]interface{}
  31138. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31141. return
  31142. }
  31143. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31144. userJSONBytes3, _ := json.Marshal(respJSON3)
  31145. fmt.Println("log")
  31146. fmt.Println(string(userJSONBytes3))
  31147. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31148. utils.ErrorLog("解析失败:%v", err)
  31149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31150. return
  31151. }
  31152. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31153. var api3 string
  31154. if miConfig.MdtrtareaAdmvs == "320921" {
  31155. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31156. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31157. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31158. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31159. } else {
  31160. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31161. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31162. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31163. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31164. }
  31165. resp3, requestErr3 := http.Get(api3)
  31166. if requestErr3 != nil {
  31167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31168. return
  31169. }
  31170. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31171. if ioErr3 != nil {
  31172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31174. return
  31175. }
  31176. var respJSON3 map[string]interface{}
  31177. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31180. return
  31181. }
  31182. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31183. userJSONBytes3, _ := json.Marshal(respJSON3)
  31184. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31185. utils.ErrorLog("解析失败:%v", err)
  31186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31187. return
  31188. }
  31189. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31190. res.Output = resSixteen10265.Output
  31191. res.ErrMsg = resSixteen10265.ErrMsg
  31192. res.Cainfo = resSixteen10265.Cainfo
  31193. res.WarnMsg = resSixteen10265.WarnMsg
  31194. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31195. res.Infcode = infocode
  31196. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31197. var api3 string
  31198. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  31199. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31200. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31201. resp3, requestErr3 := http.Get(api3)
  31202. if requestErr3 != nil {
  31203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31204. return
  31205. }
  31206. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31207. if ioErr3 != nil {
  31208. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31210. return
  31211. }
  31212. var respJSON3 map[string]interface{}
  31213. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31214. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31216. return
  31217. }
  31218. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31219. userJSONBytes3, _ := json.Marshal(respJSON3)
  31220. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31221. utils.ErrorLog("解析失败:%v", err)
  31222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31223. return
  31224. }
  31225. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31226. res.Output = resSixteen10265.Output
  31227. res.ErrMsg = resSixteen10265.ErrMsg
  31228. res.Cainfo = resSixteen10265.Cainfo
  31229. res.WarnMsg = resSixteen10265.WarnMsg
  31230. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31231. res.Infcode = infocode
  31232. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31233. 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)
  31234. var dat map[string]interface{}
  31235. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31236. fmt.Println(dat)
  31237. } else {
  31238. fmt.Println(err)
  31239. }
  31240. saveLog(result, src_resquest, "2208", "退费")
  31241. userJSONBytes, _ := json.Marshal(dat)
  31242. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31243. utils.ErrorLog("解析失败:%v", err)
  31244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31245. return
  31246. }
  31247. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31248. 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, "")
  31249. var dat map[string]interface{}
  31250. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31251. fmt.Println(dat)
  31252. } else {
  31253. fmt.Println(err)
  31254. }
  31255. saveLog(result, src_resquest, "2208", "退费")
  31256. userJSONBytes, _ := json.Marshal(dat)
  31257. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31258. utils.ErrorLog("解析失败:%v", err)
  31259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31260. return
  31261. }
  31262. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31263. 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, "")
  31264. var dat map[string]interface{}
  31265. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31266. fmt.Println(dat)
  31267. } else {
  31268. fmt.Println(err)
  31269. }
  31270. saveLog(result, src_resquest, "2208", "退费")
  31271. userJSONBytes, _ := json.Marshal(dat)
  31272. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31273. utils.ErrorLog("解析失败:%v", err)
  31274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31275. return
  31276. }
  31277. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31278. var api3 string
  31279. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31280. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31281. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31282. resp3, requestErr3 := http.Get(api3)
  31283. if requestErr3 != nil {
  31284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31285. return
  31286. }
  31287. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31288. if ioErr3 != nil {
  31289. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31291. return
  31292. }
  31293. var respJSON3 map[string]interface{}
  31294. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31297. return
  31298. }
  31299. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31300. if status == "0" {
  31301. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31302. c.ServeSuccessJSON(map[string]interface{}{
  31303. "failed_code": -10,
  31304. "msg": err_msg,
  31305. })
  31306. return
  31307. }
  31308. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31309. userJSONBytes3, _ := json.Marshal(respJSON3)
  31310. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31311. // utils.ErrorLog("解析失败:%v", err)
  31312. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31313. // return
  31314. //}
  31315. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31316. utils.ErrorLog("解析失败:%v", err)
  31317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31318. return
  31319. }
  31320. res.InfRefmsgid = ahres.InfRefmsgid
  31321. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31322. // 创建对应的Time类型
  31323. t := time.UnixMilli(timestamp)
  31324. // 格式化成指定的日期字符串
  31325. str := t.Format("2006-01-02 15:04:05")
  31326. res.Output.Setlinfo.SetlTime = str
  31327. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31328. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31329. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31330. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31331. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31332. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31333. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31334. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31335. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31336. //
  31337. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31338. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31339. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31340. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31341. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31342. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31343. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31344. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31345. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31346. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31347. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31348. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31349. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31350. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31351. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31352. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31353. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31354. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31355. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31356. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31357. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31358. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31359. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31360. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31361. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31362. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31363. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31364. //res.Output.Setldetail = ahres.Output.Setldetail
  31365. res.ErrMsg = ahres.ErrMsg
  31366. res.Cainfo = ahres.Cainfo
  31367. res.WarnMsg = ahres.WarnMsg
  31368. res.Infcode = ahres.Infcode
  31369. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31370. var api3 string
  31371. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31372. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31373. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31374. resp3, requestErr3 := http.Get(api3)
  31375. if requestErr3 != nil {
  31376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31377. return
  31378. }
  31379. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31380. if ioErr3 != nil {
  31381. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31383. return
  31384. }
  31385. var respJSON3 map[string]interface{}
  31386. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31389. return
  31390. }
  31391. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31392. if status == "0" {
  31393. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31394. c.ServeSuccessJSON(map[string]interface{}{
  31395. "failed_code": -10,
  31396. "msg": err_msg,
  31397. })
  31398. return
  31399. }
  31400. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31401. userJSONBytes3, _ := json.Marshal(respJSON3)
  31402. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31403. // utils.ErrorLog("解析失败:%v", err)
  31404. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31405. // return
  31406. //}
  31407. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31408. utils.ErrorLog("解析失败:%v", err)
  31409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31410. return
  31411. }
  31412. res.InfRefmsgid = ahres.InfRefmsgid
  31413. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31414. // 创建对应的Time类型
  31415. t := time.UnixMilli(timestamp)
  31416. // 格式化成指定的日期字符串
  31417. str := t.Format("2006-01-02 15:04:05")
  31418. res.Output.Setlinfo.SetlTime = str
  31419. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31420. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31421. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31422. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31423. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31424. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31425. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31426. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31427. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31428. //
  31429. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31430. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31431. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31432. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31433. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31434. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31435. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31436. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31437. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31438. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31439. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31440. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31441. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31442. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31443. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31444. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31445. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31446. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31447. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31448. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31449. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31450. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31451. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31452. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31453. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31454. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31455. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31456. //res.Output.Setldetail = ahres.Output.Setldetail
  31457. res.ErrMsg = ahres.ErrMsg
  31458. res.Cainfo = ahres.Cainfo
  31459. res.WarnMsg = ahres.WarnMsg
  31460. res.Infcode = ahres.Infcode
  31461. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31462. 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, "")
  31463. var dat map[string]interface{}
  31464. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31465. fmt.Println(dat)
  31466. } else {
  31467. fmt.Println(err)
  31468. }
  31469. saveLog(result, src_resquest, "2208", "退费")
  31470. userJSONBytes, _ := json.Marshal(dat)
  31471. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31472. utils.ErrorLog("解析失败:%v", err)
  31473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31474. return
  31475. }
  31476. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31477. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  31478. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31479. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31480. resp3, requestErr3 := http.Get(api3)
  31481. if requestErr3 != nil {
  31482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31483. return
  31484. }
  31485. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31486. if ioErr3 != nil {
  31487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31489. return
  31490. }
  31491. var respJSON3 map[string]interface{}
  31492. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31495. return
  31496. }
  31497. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31498. userJSONBytes3, _ := json.Marshal(respJSON3)
  31499. fmt.Println("log")
  31500. fmt.Println(string(userJSONBytes3))
  31501. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31502. utils.ErrorLog("解析失败:%v", err)
  31503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31504. return
  31505. }
  31506. } else {
  31507. if miConfig.Code == "H15049901371" {
  31508. 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)
  31509. var dat map[string]interface{}
  31510. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31511. fmt.Println(dat)
  31512. } else {
  31513. fmt.Println(err)
  31514. }
  31515. saveLog(result, src_resquest, "2208", "退费")
  31516. if strings.Contains(result, "Post") {
  31517. res.Infcode = -1
  31518. res.ErrMsg = result
  31519. }
  31520. userJSONBytes, _ := json.Marshal(dat)
  31521. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  31522. utils.ErrorLog("解析失败:%v", err)
  31523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31524. return
  31525. }
  31526. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31527. res.Output = resSixteen10265.Output
  31528. res.ErrMsg = resSixteen10265.ErrMsg
  31529. res.Cainfo = resSixteen10265.Cainfo
  31530. res.WarnMsg = resSixteen10265.WarnMsg
  31531. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31532. res.Infcode = infocode
  31533. } else {
  31534. 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)
  31535. var dat map[string]interface{}
  31536. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31537. fmt.Println(dat)
  31538. } else {
  31539. fmt.Println(err)
  31540. }
  31541. saveLog(result, src_resquest, "2208", "退费")
  31542. userJSONBytes, _ := json.Marshal(dat)
  31543. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31544. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  31545. utils.ErrorLog("解析失败:%v", err)
  31546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31547. return
  31548. }
  31549. res.Infcode = gz.Infcode
  31550. } else {
  31551. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31552. utils.ErrorLog("解析失败:%v", err)
  31553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31554. return
  31555. }
  31556. }
  31557. if strings.Contains(result, "Post") {
  31558. res.Infcode = -1
  31559. res.ErrMsg = result
  31560. }
  31561. }
  31562. }
  31563. if res.Infcode == -1 {
  31564. c.ServeSuccessJSON(map[string]interface{}{
  31565. "failed_code": -10,
  31566. "msg": res.ErrMsg,
  31567. })
  31568. return
  31569. }
  31570. if res.Infcode != -1 {
  31571. var res2 ResultSix
  31572. var resSix10265 ResultSix10265
  31573. if miConfig.MdtrtareaAdmvs == "421300" {
  31574. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31575. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31576. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31577. resp3, requestErr3 := http.Get(api3)
  31578. if requestErr3 != nil {
  31579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31580. return
  31581. }
  31582. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31583. if ioErr3 != nil {
  31584. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31586. return
  31587. }
  31588. var respJSON3 map[string]interface{}
  31589. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31592. return
  31593. }
  31594. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31595. userJSONBytes3, _ := json.Marshal(respJSON3)
  31596. fmt.Println("log")
  31597. fmt.Println(string(userJSONBytes3))
  31598. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31599. utils.ErrorLog("解析失败:%v", err)
  31600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31601. return
  31602. }
  31603. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31604. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31605. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31606. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31607. resp3, requestErr3 := http.Get(api3)
  31608. if requestErr3 != nil {
  31609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31610. return
  31611. }
  31612. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31613. if ioErr3 != nil {
  31614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31616. return
  31617. }
  31618. var respJSON3 map[string]interface{}
  31619. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31622. return
  31623. }
  31624. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31625. userJSONBytes3, _ := json.Marshal(respJSON3)
  31626. fmt.Println("log")
  31627. fmt.Println(string(userJSONBytes3))
  31628. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31629. utils.ErrorLog("解析失败:%v", err)
  31630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31631. return
  31632. }
  31633. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31634. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31635. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31636. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31637. resp3, requestErr3 := http.Get(api3)
  31638. if requestErr3 != nil {
  31639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31640. return
  31641. }
  31642. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31643. if ioErr3 != nil {
  31644. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31646. return
  31647. }
  31648. var respJSON3 map[string]interface{}
  31649. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31652. return
  31653. }
  31654. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31655. userJSONBytes3, _ := json.Marshal(respJSON3)
  31656. fmt.Println("log")
  31657. fmt.Println(string(userJSONBytes3))
  31658. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31659. utils.ErrorLog("解析失败:%v", err)
  31660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31661. return
  31662. }
  31663. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31664. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31665. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31666. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31667. resp3, requestErr3 := http.Get(api3)
  31668. if requestErr3 != nil {
  31669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31670. return
  31671. }
  31672. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31673. if ioErr3 != nil {
  31674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31676. return
  31677. }
  31678. var respJSON3 map[string]interface{}
  31679. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31682. return
  31683. }
  31684. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31685. userJSONBytes3, _ := json.Marshal(respJSON3)
  31686. fmt.Println("log")
  31687. fmt.Println(string(userJSONBytes3))
  31688. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31689. utils.ErrorLog("解析失败:%v", err)
  31690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31691. return
  31692. }
  31693. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31694. var api3 string
  31695. if miConfig.MdtrtareaAdmvs == "320921" {
  31696. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31697. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31698. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31699. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31700. } else {
  31701. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31702. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31703. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31704. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31705. }
  31706. resp3, requestErr3 := http.Get(api3)
  31707. if requestErr3 != nil {
  31708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31709. return
  31710. }
  31711. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31712. if ioErr3 != nil {
  31713. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31715. return
  31716. }
  31717. var respJSON3 map[string]interface{}
  31718. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31719. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31721. return
  31722. }
  31723. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31724. userJSONBytes3, _ := json.Marshal(respJSON3)
  31725. fmt.Println("log")
  31726. fmt.Println(string(userJSONBytes3))
  31727. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31728. utils.ErrorLog("解析失败:%v", err)
  31729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31730. return
  31731. }
  31732. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31733. res2.Output = resSix10265.Output
  31734. res2.ErrMsg = resSix10265.ErrMsg
  31735. res2.Cainfo = resSix10265.Cainfo
  31736. res2.WarnMsg = resSix10265.WarnMsg
  31737. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31738. res2.Infcode = infocode
  31739. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31740. var api3 string
  31741. new_chrg_bchno := order.Number
  31742. if adminUser.CurrentOrgId == 10265 {
  31743. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  31744. new_chrg_bchno = "0000"
  31745. }
  31746. }
  31747. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  31748. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31749. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31750. resp3, requestErr3 := http.Get(api3)
  31751. if requestErr3 != nil {
  31752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31753. return
  31754. }
  31755. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31756. if ioErr3 != nil {
  31757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31759. return
  31760. }
  31761. var respJSON3 map[string]interface{}
  31762. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31765. return
  31766. }
  31767. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31768. userJSONBytes3, _ := json.Marshal(respJSON3)
  31769. fmt.Println("log")
  31770. fmt.Println(string(userJSONBytes3))
  31771. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31772. utils.ErrorLog("解析失败:%v", err)
  31773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31774. return
  31775. }
  31776. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31777. res2.Output = resSix10265.Output
  31778. res2.ErrMsg = resSix10265.ErrMsg
  31779. res2.Cainfo = resSix10265.Cainfo
  31780. res2.WarnMsg = resSix10265.WarnMsg
  31781. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31782. res2.Infcode = infocode
  31783. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31784. 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)
  31785. var dat map[string]interface{}
  31786. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31787. fmt.Println(dat)
  31788. } else {
  31789. fmt.Println(err)
  31790. }
  31791. saveLog(result2, src_request, "2205", "撤销明细")
  31792. userJSONBytes, _ := json.Marshal(dat)
  31793. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31794. utils.ErrorLog("解析失败:%v", err)
  31795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31796. return
  31797. }
  31798. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31799. 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, "")
  31800. var dat map[string]interface{}
  31801. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31802. fmt.Println(dat)
  31803. } else {
  31804. fmt.Println(err)
  31805. }
  31806. saveLog(result2, src_request, "2205", "撤销明细")
  31807. userJSONBytes, _ := json.Marshal(dat)
  31808. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31809. utils.ErrorLog("解析失败:%v", err)
  31810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31811. return
  31812. }
  31813. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31814. 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, "")
  31815. var dat map[string]interface{}
  31816. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31817. fmt.Println(dat)
  31818. } else {
  31819. fmt.Println(err)
  31820. }
  31821. saveLog(result2, src_request, "2205", "撤销明细")
  31822. userJSONBytes, _ := json.Marshal(dat)
  31823. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31824. utils.ErrorLog("解析失败:%v", err)
  31825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31826. return
  31827. }
  31828. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31829. var api3 string
  31830. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31831. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31832. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31833. resp3, requestErr3 := http.Get(api3)
  31834. if requestErr3 != nil {
  31835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31836. return
  31837. }
  31838. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31839. if ioErr3 != nil {
  31840. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31842. return
  31843. }
  31844. var respJSON3 map[string]interface{}
  31845. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31848. return
  31849. }
  31850. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31851. if status == "0" {
  31852. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31853. c.ServeSuccessJSON(map[string]interface{}{
  31854. "failed_code": -10,
  31855. "msg": err_msg,
  31856. })
  31857. return
  31858. }
  31859. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31860. userJSONBytes3, _ := json.Marshal(respJSON3)
  31861. fmt.Println("log")
  31862. fmt.Println(string(userJSONBytes3))
  31863. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31864. utils.ErrorLog("解析失败:%v", err)
  31865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31866. return
  31867. }
  31868. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31869. 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, "")
  31870. var dat map[string]interface{}
  31871. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31872. fmt.Println(dat)
  31873. } else {
  31874. fmt.Println(err)
  31875. }
  31876. saveLog(result2, src_request, "2205", "撤销明细")
  31877. userJSONBytes, _ := json.Marshal(dat)
  31878. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31879. utils.ErrorLog("解析失败:%v", err)
  31880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31881. return
  31882. }
  31883. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31884. 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, "")
  31885. var dat map[string]interface{}
  31886. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31887. fmt.Println(dat)
  31888. } else {
  31889. fmt.Println(err)
  31890. }
  31891. saveLog(result2, src_request, "2205", "撤销明细")
  31892. userJSONBytes, _ := json.Marshal(dat)
  31893. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31894. utils.ErrorLog("解析失败:%v", err)
  31895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31896. return
  31897. }
  31898. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31899. var api3 string
  31900. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31901. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31902. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31903. resp3, requestErr3 := http.Get(api3)
  31904. if requestErr3 != nil {
  31905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31906. return
  31907. }
  31908. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31909. if ioErr3 != nil {
  31910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31912. return
  31913. }
  31914. var respJSON3 map[string]interface{}
  31915. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31918. return
  31919. }
  31920. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31921. if status == "0" {
  31922. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31923. c.ServeSuccessJSON(map[string]interface{}{
  31924. "failed_code": -10,
  31925. "msg": err_msg,
  31926. })
  31927. return
  31928. }
  31929. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31930. userJSONBytes3, _ := json.Marshal(respJSON3)
  31931. fmt.Println("log")
  31932. fmt.Println(string(userJSONBytes3))
  31933. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31934. utils.ErrorLog("解析失败:%v", err)
  31935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31936. return
  31937. }
  31938. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31939. 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, "")
  31940. var dat map[string]interface{}
  31941. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31942. fmt.Println(dat)
  31943. } else {
  31944. fmt.Println(err)
  31945. }
  31946. saveLog(result2, src_request, "2205", "撤销明细")
  31947. userJSONBytes, _ := json.Marshal(dat)
  31948. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31949. utils.ErrorLog("解析失败:%v", err)
  31950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31951. return
  31952. }
  31953. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31954. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  31955. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31956. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31957. resp3, requestErr3 := http.Get(api3)
  31958. if requestErr3 != nil {
  31959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31960. return
  31961. }
  31962. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31963. if ioErr3 != nil {
  31964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31966. return
  31967. }
  31968. var respJSON3 map[string]interface{}
  31969. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31972. return
  31973. }
  31974. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31975. userJSONBytes3, _ := json.Marshal(respJSON3)
  31976. fmt.Println("log")
  31977. fmt.Println(string(userJSONBytes3))
  31978. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31979. utils.ErrorLog("解析失败:%v", err)
  31980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31981. return
  31982. }
  31983. } else {
  31984. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31985. res2.Infcode = 0
  31986. } else {
  31987. 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)
  31988. var dat map[string]interface{}
  31989. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31990. fmt.Println(dat)
  31991. } else {
  31992. fmt.Println(err)
  31993. }
  31994. saveLog(result2, src_request, "2205", "撤销明细")
  31995. userJSONBytes, _ := json.Marshal(dat)
  31996. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31997. utils.ErrorLog("解析失败:%v", err)
  31998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31999. return
  32000. }
  32001. }
  32002. }
  32003. if res2.Infcode == -1 {
  32004. c.ServeSuccessJSON(map[string]interface{}{
  32005. "failed_code": -10,
  32006. "msg": res2.ErrMsg,
  32007. })
  32008. return
  32009. }
  32010. if res2.Infcode == 0 {
  32011. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  32012. if err == nil {
  32013. //当押金不为零时产生退费记录
  32014. if order.Decimal != 0 {
  32015. tmp := strconv.FormatInt(order.ID, 10)
  32016. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  32017. if err != nil {
  32018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32019. return
  32020. }
  32021. }
  32022. c.ServeSuccessJSON(map[string]interface{}{
  32023. "msg": "退费成功",
  32024. })
  32025. } else {
  32026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32027. return
  32028. }
  32029. } else {
  32030. c.ServeSuccessJSON(map[string]interface{}{
  32031. "failed_code": -10,
  32032. "msg": res2.ErrMsg,
  32033. })
  32034. }
  32035. } else {
  32036. c.ServeSuccessJSON(map[string]interface{}{
  32037. "failed_code": -10,
  32038. "msg": res.ErrMsg,
  32039. })
  32040. }
  32041. }
  32042. }
  32043. func (c *HisApiController) RefundNumber() {
  32044. record_time := c.GetString("record_time")
  32045. //patient_id, _ := c.GetInt64("patient_id")
  32046. admin_user_id, _ := c.GetInt64("admin_user_id")
  32047. his_patient_id, _ := c.GetInt64("id")
  32048. timeLayout := "2006-01-02"
  32049. loc, _ := time.LoadLocation("Local")
  32050. adminUser := c.GetAdminUserInfo()
  32051. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32052. fmt.Println(err)
  32053. if err != nil {
  32054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32055. return
  32056. }
  32057. recordDateTime := theTime.Unix()
  32058. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32059. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  32060. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32061. //order, _ := service.GetHisOrderByID(order_id)
  32062. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32063. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32064. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32065. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  32066. if count > 0 {
  32067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  32068. return
  32069. }
  32070. if config.IsOpen == 1 { //对接了医保,走医保流程
  32071. var res2 ResultSix
  32072. var res3 GZResultSix
  32073. var resSix10265 ResultSix10265
  32074. if miConfig.MdtrtareaAdmvs == "421300" {
  32075. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32076. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32077. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32078. resp3, requestErr3 := http.Get(api3)
  32079. if requestErr3 != nil {
  32080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32081. return
  32082. }
  32083. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32084. if ioErr3 != nil {
  32085. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32087. return
  32088. }
  32089. var respJSON3 map[string]interface{}
  32090. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32093. return
  32094. }
  32095. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32096. userJSONBytes3, _ := json.Marshal(respJSON3)
  32097. fmt.Println("log")
  32098. fmt.Println(string(userJSONBytes3))
  32099. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32100. utils.ErrorLog("解析失败:%v", err)
  32101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32102. return
  32103. }
  32104. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32105. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32106. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32107. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32108. resp3, requestErr3 := http.Get(api3)
  32109. if requestErr3 != nil {
  32110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32111. return
  32112. }
  32113. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32114. if ioErr3 != nil {
  32115. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32117. return
  32118. }
  32119. var respJSON3 map[string]interface{}
  32120. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32121. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32123. return
  32124. }
  32125. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32126. userJSONBytes3, _ := json.Marshal(respJSON3)
  32127. fmt.Println("log")
  32128. fmt.Println(string(userJSONBytes3))
  32129. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32130. utils.ErrorLog("解析失败:%v", err)
  32131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32132. return
  32133. }
  32134. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32135. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32136. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32137. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32138. resp3, requestErr3 := http.Get(api3)
  32139. if requestErr3 != nil {
  32140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32141. return
  32142. }
  32143. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32144. if ioErr3 != nil {
  32145. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32147. return
  32148. }
  32149. var respJSON3 map[string]interface{}
  32150. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32153. return
  32154. }
  32155. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32156. userJSONBytes3, _ := json.Marshal(respJSON3)
  32157. fmt.Println("log")
  32158. fmt.Println(string(userJSONBytes3))
  32159. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32160. utils.ErrorLog("解析失败:%v", err)
  32161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32162. return
  32163. }
  32164. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32165. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32166. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32167. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32168. resp3, requestErr3 := http.Get(api3)
  32169. if requestErr3 != nil {
  32170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32171. return
  32172. }
  32173. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32174. if ioErr3 != nil {
  32175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32177. return
  32178. }
  32179. var respJSON3 map[string]interface{}
  32180. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32183. return
  32184. }
  32185. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32186. userJSONBytes3, _ := json.Marshal(respJSON3)
  32187. fmt.Println("log")
  32188. fmt.Println(string(userJSONBytes3))
  32189. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32190. utils.ErrorLog("解析失败:%v", err)
  32191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32192. return
  32193. }
  32194. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32195. var api3 string
  32196. if miConfig.MdtrtareaAdmvs == "320921" {
  32197. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32198. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32199. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32200. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32201. } else {
  32202. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32203. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32204. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32205. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32206. }
  32207. resp3, requestErr3 := http.Get(api3)
  32208. if requestErr3 != nil {
  32209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32210. return
  32211. }
  32212. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32213. if ioErr3 != nil {
  32214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32216. return
  32217. }
  32218. var respJSON3 map[string]interface{}
  32219. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32222. return
  32223. }
  32224. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32225. userJSONBytes3, _ := json.Marshal(respJSON3)
  32226. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32227. utils.ErrorLog("解析失败:%v", err)
  32228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32229. return
  32230. }
  32231. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32232. res2.Output = resSix10265.Output
  32233. res2.ErrMsg = resSix10265.ErrMsg
  32234. res2.Cainfo = resSix10265.Cainfo
  32235. res2.WarnMsg = resSix10265.WarnMsg
  32236. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32237. res2.Infcode = infocode
  32238. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32239. var api3 string
  32240. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  32241. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32242. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32243. resp3, requestErr3 := http.Get(api3)
  32244. if requestErr3 != nil {
  32245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32246. return
  32247. }
  32248. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32249. if ioErr3 != nil {
  32250. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32252. return
  32253. }
  32254. var respJSON3 map[string]interface{}
  32255. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32258. return
  32259. }
  32260. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32261. userJSONBytes3, _ := json.Marshal(respJSON3)
  32262. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32263. utils.ErrorLog("解析失败:%v", err)
  32264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32265. return
  32266. }
  32267. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32268. res2.Output = resSix10265.Output
  32269. res2.ErrMsg = resSix10265.ErrMsg
  32270. res2.Cainfo = resSix10265.Cainfo
  32271. res2.WarnMsg = resSix10265.WarnMsg
  32272. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32273. res2.Infcode = infocode
  32274. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32275. 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)
  32276. var dat map[string]interface{}
  32277. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32278. fmt.Println(dat)
  32279. } else {
  32280. fmt.Println(err)
  32281. }
  32282. saveLog(result, request, "2202", "退号")
  32283. userJSONBytes, _ := json.Marshal(dat)
  32284. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32285. utils.ErrorLog("解析失败:%v", err)
  32286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32287. return
  32288. }
  32289. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32290. 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, "")
  32291. var dat map[string]interface{}
  32292. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32293. fmt.Println(dat)
  32294. } else {
  32295. fmt.Println(err)
  32296. }
  32297. saveLog(result, request, "2202", "退号")
  32298. userJSONBytes, _ := json.Marshal(dat)
  32299. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32300. utils.ErrorLog("解析失败:%v", err)
  32301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32302. return
  32303. }
  32304. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32305. 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, "")
  32306. var dat map[string]interface{}
  32307. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32308. fmt.Println(dat)
  32309. } else {
  32310. fmt.Println(err)
  32311. }
  32312. saveLog(result, request, "2202", "退号")
  32313. userJSONBytes, _ := json.Marshal(dat)
  32314. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32315. utils.ErrorLog("解析失败:%v", err)
  32316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32317. return
  32318. }
  32319. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32320. var api3 string
  32321. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32322. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32323. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32324. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32325. resp3, requestErr3 := http.Get(api3)
  32326. if requestErr3 != nil {
  32327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32328. return
  32329. }
  32330. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32331. if ioErr3 != nil {
  32332. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32334. return
  32335. }
  32336. var respJSON3 map[string]interface{}
  32337. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32340. return
  32341. }
  32342. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32343. if status == "0" {
  32344. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32345. c.ServeSuccessJSON(map[string]interface{}{
  32346. "failed_code": -10,
  32347. "msg": err_msg,
  32348. })
  32349. return
  32350. }
  32351. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32352. userJSONBytes3, _ := json.Marshal(respJSON3)
  32353. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32354. utils.ErrorLog("解析失败:%v", err)
  32355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32356. return
  32357. }
  32358. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32359. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32360. var api3 string
  32361. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32362. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32363. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32364. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32365. resp3, requestErr3 := http.Get(api3)
  32366. if requestErr3 != nil {
  32367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32368. return
  32369. }
  32370. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32371. if ioErr3 != nil {
  32372. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32374. return
  32375. }
  32376. var respJSON3 map[string]interface{}
  32377. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32378. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32380. return
  32381. }
  32382. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32383. if status == "0" {
  32384. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32385. c.ServeSuccessJSON(map[string]interface{}{
  32386. "failed_code": -10,
  32387. "msg": err_msg,
  32388. })
  32389. return
  32390. }
  32391. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32392. userJSONBytes3, _ := json.Marshal(respJSON3)
  32393. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32394. utils.ErrorLog("解析失败:%v", err)
  32395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32396. return
  32397. }
  32398. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32399. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32400. 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, "")
  32401. var dat map[string]interface{}
  32402. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32403. fmt.Println(dat)
  32404. } else {
  32405. fmt.Println(err)
  32406. }
  32407. saveLog(result, request, "2202", "退号")
  32408. userJSONBytes, _ := json.Marshal(dat)
  32409. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32410. utils.ErrorLog("解析失败:%v", err)
  32411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32412. return
  32413. }
  32414. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32415. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  32416. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32417. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32418. resp3, requestErr3 := http.Get(api3)
  32419. if requestErr3 != nil {
  32420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32421. return
  32422. }
  32423. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32424. if ioErr3 != nil {
  32425. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32427. return
  32428. }
  32429. var respJSON3 map[string]interface{}
  32430. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32433. return
  32434. }
  32435. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32436. userJSONBytes3, _ := json.Marshal(respJSON3)
  32437. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32438. utils.ErrorLog("解析失败:%v", err)
  32439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32440. return
  32441. }
  32442. } else {
  32443. var api3 string
  32444. if miConfig.Code == "H15049901371" {
  32445. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  32446. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32447. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32448. } else {
  32449. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  32450. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32451. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32452. }
  32453. resp3, requestErr3 := http.Get(api3)
  32454. if requestErr3 != nil {
  32455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32456. return
  32457. }
  32458. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32459. if ioErr3 != nil {
  32460. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32462. return
  32463. }
  32464. var respJSON3 map[string]interface{}
  32465. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32468. return
  32469. }
  32470. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32471. userJSONBytes3, _ := json.Marshal(respJSON3)
  32472. if miConfig.Code == "H15049901371" {
  32473. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32474. utils.ErrorLog("解析失败:%v", err)
  32475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32476. return
  32477. }
  32478. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32479. res2.Output = resSix10265.Output
  32480. res2.ErrMsg = resSix10265.ErrMsg
  32481. res2.Cainfo = resSix10265.Cainfo
  32482. res2.WarnMsg = resSix10265.WarnMsg
  32483. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32484. res2.Infcode = infocode
  32485. } else {
  32486. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32487. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  32488. utils.ErrorLog("解析失败:%v", err)
  32489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32490. return
  32491. }
  32492. res2.Infcode = res3.Infcode
  32493. } else {
  32494. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32495. utils.ErrorLog("解析失败:%v", err)
  32496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32497. return
  32498. }
  32499. }
  32500. }
  32501. }
  32502. if res2.Infcode == -1 {
  32503. c.ServeSuccessJSON(map[string]interface{}{
  32504. "failed_code": -10,
  32505. "msg": res2.ErrMsg,
  32506. })
  32507. return
  32508. }
  32509. if res2.Infcode == 0 {
  32510. if err == nil {
  32511. c.ServeSuccessJSON(map[string]interface{}{
  32512. "msg": "退号成功",
  32513. })
  32514. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  32515. } else {
  32516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32517. return
  32518. }
  32519. }
  32520. } else {
  32521. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  32522. //if err == nil {
  32523. // c.ServeSuccessJSON(map[string]interface{}{
  32524. // "msg": "退费成功",
  32525. // })
  32526. //} else {
  32527. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32528. // return
  32529. //}
  32530. }
  32531. }
  32532. func (c *HisApiController) RefundDetail() {
  32533. order_id, _ := c.GetInt64("order_id")
  32534. admin_user_id, _ := c.GetInt64("admin_user_id")
  32535. //his_patient_id, _ := c.GetInt64("his_patient_id")
  32536. number := c.GetString("number")
  32537. record_time := c.GetString("record_time")
  32538. patient_id, _ := c.GetInt64("patient_id")
  32539. //med_type, _ := c.GetInt64("med_type")
  32540. timeLayout := "2006-01-02"
  32541. loc, _ := time.LoadLocation("Local")
  32542. adminUser := c.GetAdminUserInfo()
  32543. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32544. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32545. fmt.Println(err)
  32546. if err != nil {
  32547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32548. return
  32549. }
  32550. recordDateTime := theTime.Unix()
  32551. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  32552. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32553. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32554. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32555. var order models.HisOrder
  32556. order, _ = service.GetHisOrderByID(order_id)
  32557. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32558. if config.IsOpen == 1 { //对接了医保,走医保流程
  32559. var res2 ResultSix
  32560. if miConfig.MdtrtareaAdmvs == "421300" {
  32561. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32562. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32563. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32564. resp3, requestErr3 := http.Get(api3)
  32565. if requestErr3 != nil {
  32566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32567. return
  32568. }
  32569. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32570. if ioErr3 != nil {
  32571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32573. return
  32574. }
  32575. var respJSON3 map[string]interface{}
  32576. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32579. return
  32580. }
  32581. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32582. userJSONBytes3, _ := json.Marshal(respJSON3)
  32583. fmt.Println("log")
  32584. fmt.Println(string(userJSONBytes3))
  32585. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32586. utils.ErrorLog("解析失败:%v", err)
  32587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32588. return
  32589. }
  32590. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32591. if err == nil {
  32592. c.ServeSuccessJSON(map[string]interface{}{
  32593. "msg": "撤销明细成功",
  32594. })
  32595. return
  32596. } else {
  32597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32598. return
  32599. }
  32600. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32601. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32602. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32603. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32604. resp3, requestErr3 := http.Get(api3)
  32605. if requestErr3 != nil {
  32606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32607. return
  32608. }
  32609. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32610. if ioErr3 != nil {
  32611. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32613. return
  32614. }
  32615. var respJSON3 map[string]interface{}
  32616. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32619. return
  32620. }
  32621. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32622. userJSONBytes3, _ := json.Marshal(respJSON3)
  32623. fmt.Println("log")
  32624. fmt.Println(string(userJSONBytes3))
  32625. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32626. utils.ErrorLog("解析失败:%v", err)
  32627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32628. return
  32629. }
  32630. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32631. if err == nil {
  32632. c.ServeSuccessJSON(map[string]interface{}{
  32633. "msg": "撤销明细成功",
  32634. })
  32635. return
  32636. } else {
  32637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32638. return
  32639. }
  32640. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32641. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32642. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32643. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32644. resp3, requestErr3 := http.Get(api3)
  32645. if requestErr3 != nil {
  32646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32647. return
  32648. }
  32649. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32650. if ioErr3 != nil {
  32651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32653. return
  32654. }
  32655. var respJSON3 map[string]interface{}
  32656. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32659. return
  32660. }
  32661. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32662. userJSONBytes3, _ := json.Marshal(respJSON3)
  32663. fmt.Println("log")
  32664. fmt.Println(string(userJSONBytes3))
  32665. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32666. utils.ErrorLog("解析失败:%v", err)
  32667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32668. return
  32669. }
  32670. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32671. if err == nil {
  32672. c.ServeSuccessJSON(map[string]interface{}{
  32673. "msg": "撤销明细成功",
  32674. })
  32675. return
  32676. } else {
  32677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32678. return
  32679. }
  32680. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32681. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32682. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32683. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32684. resp3, requestErr3 := http.Get(api3)
  32685. if requestErr3 != nil {
  32686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32687. return
  32688. }
  32689. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32690. if ioErr3 != nil {
  32691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32693. return
  32694. }
  32695. var respJSON3 map[string]interface{}
  32696. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32699. return
  32700. }
  32701. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32702. userJSONBytes3, _ := json.Marshal(respJSON3)
  32703. fmt.Println("log")
  32704. fmt.Println(string(userJSONBytes3))
  32705. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32706. utils.ErrorLog("解析失败:%v", err)
  32707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32708. return
  32709. }
  32710. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32711. if err == nil {
  32712. c.ServeSuccessJSON(map[string]interface{}{
  32713. "msg": "撤销明细成功",
  32714. })
  32715. return
  32716. } else {
  32717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32718. return
  32719. }
  32720. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32721. var resSix10265 ResultSix10265
  32722. var api3 string
  32723. if miConfig.MdtrtareaAdmvs == "320921" {
  32724. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32725. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32726. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32727. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32728. } else {
  32729. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32730. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32731. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32732. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32733. }
  32734. resp3, requestErr3 := http.Get(api3)
  32735. utils.ErrorLog("接口: %v", requestErr3)
  32736. if requestErr3 != nil {
  32737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32738. return
  32739. }
  32740. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32741. if ioErr3 != nil {
  32742. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32744. return
  32745. }
  32746. var respJSON3 map[string]interface{}
  32747. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32750. return
  32751. }
  32752. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32753. userJSONBytes3, _ := json.Marshal(respJSON3)
  32754. fmt.Println("log")
  32755. fmt.Println(string(userJSONBytes3))
  32756. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32757. utils.ErrorLog("解析失败:%v", err)
  32758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32759. return
  32760. }
  32761. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32762. res2.Output = resSix10265.Output
  32763. res2.ErrMsg = resSix10265.ErrMsg
  32764. res2.Cainfo = resSix10265.Cainfo
  32765. res2.WarnMsg = resSix10265.WarnMsg
  32766. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32767. res2.Infcode = infocode
  32768. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32769. if err == nil {
  32770. c.ServeSuccessJSON(map[string]interface{}{
  32771. "msg": "撤销明细成功",
  32772. })
  32773. return
  32774. } else {
  32775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32776. return
  32777. }
  32778. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32779. var api3 string
  32780. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32781. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32782. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32783. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32784. resp3, requestErr3 := http.Get(api3)
  32785. utils.ErrorLog("接口: %v", requestErr3)
  32786. if requestErr3 != nil {
  32787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32788. return
  32789. }
  32790. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32791. if ioErr3 != nil {
  32792. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32794. return
  32795. }
  32796. var respJSON3 map[string]interface{}
  32797. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32798. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32800. return
  32801. }
  32802. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32803. if status == "0" {
  32804. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32805. c.ServeSuccessJSON(map[string]interface{}{
  32806. "failed_code": -10,
  32807. "msg": err_msg,
  32808. })
  32809. return
  32810. }
  32811. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32812. userJSONBytes3, _ := json.Marshal(respJSON3)
  32813. fmt.Println("log")
  32814. fmt.Println(string(userJSONBytes3))
  32815. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32816. utils.ErrorLog("解析失败:%v", err)
  32817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32818. return
  32819. }
  32820. fmt.Println(res2.Infcode)
  32821. if res2.Infcode == -1 {
  32822. c.ServeSuccessJSON(map[string]interface{}{
  32823. "failed_code": -10,
  32824. "msg": res2.ErrMsg,
  32825. })
  32826. return
  32827. }
  32828. if res2.Infcode == 0 {
  32829. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32830. if err == nil {
  32831. c.ServeSuccessJSON(map[string]interface{}{
  32832. "msg": "撤销明细成功",
  32833. })
  32834. return
  32835. } else {
  32836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32837. return
  32838. }
  32839. } else {
  32840. c.ServeSuccessJSON(map[string]interface{}{
  32841. "failed_code": -10,
  32842. "msg": res2.ErrMsg,
  32843. })
  32844. }
  32845. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32846. if err == nil {
  32847. c.ServeSuccessJSON(map[string]interface{}{
  32848. "msg": "撤销明细成功",
  32849. })
  32850. return
  32851. } else {
  32852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32853. return
  32854. }
  32855. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32856. var api3 string
  32857. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32858. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32859. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32860. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32861. resp3, requestErr3 := http.Get(api3)
  32862. utils.ErrorLog("接口: %v", requestErr3)
  32863. if requestErr3 != nil {
  32864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32865. return
  32866. }
  32867. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32868. if ioErr3 != nil {
  32869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32871. return
  32872. }
  32873. var respJSON3 map[string]interface{}
  32874. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32877. return
  32878. }
  32879. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32880. if status == "0" {
  32881. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32882. c.ServeSuccessJSON(map[string]interface{}{
  32883. "failed_code": -10,
  32884. "msg": err_msg,
  32885. })
  32886. return
  32887. }
  32888. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32889. userJSONBytes3, _ := json.Marshal(respJSON3)
  32890. fmt.Println("log")
  32891. fmt.Println(string(userJSONBytes3))
  32892. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32893. utils.ErrorLog("解析失败:%v", err)
  32894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32895. return
  32896. }
  32897. fmt.Println(res2.Infcode)
  32898. if res2.Infcode == -1 {
  32899. c.ServeSuccessJSON(map[string]interface{}{
  32900. "failed_code": -10,
  32901. "msg": res2.ErrMsg,
  32902. })
  32903. return
  32904. }
  32905. if res2.Infcode == 0 {
  32906. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32907. if err == nil {
  32908. c.ServeSuccessJSON(map[string]interface{}{
  32909. "msg": "撤销明细成功",
  32910. })
  32911. return
  32912. } else {
  32913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32914. return
  32915. }
  32916. } else {
  32917. c.ServeSuccessJSON(map[string]interface{}{
  32918. "failed_code": -10,
  32919. "msg": res2.ErrMsg,
  32920. })
  32921. }
  32922. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32923. if err == nil {
  32924. c.ServeSuccessJSON(map[string]interface{}{
  32925. "msg": "撤销明细成功",
  32926. })
  32927. return
  32928. } else {
  32929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32930. return
  32931. }
  32932. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32933. var resSix10265 ResultSix10265
  32934. new_chrg_bchno := order.Number
  32935. if adminUser.CurrentOrgId == 10265 {
  32936. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  32937. new_chrg_bchno = "0000"
  32938. }
  32939. }
  32940. var api3 string
  32941. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  32942. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32943. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32944. resp3, requestErr3 := http.Get(api3)
  32945. if requestErr3 != nil {
  32946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32947. return
  32948. }
  32949. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32950. if ioErr3 != nil {
  32951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32953. return
  32954. }
  32955. var respJSON3 map[string]interface{}
  32956. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32959. return
  32960. }
  32961. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32962. userJSONBytes3, _ := json.Marshal(respJSON3)
  32963. fmt.Println("log")
  32964. fmt.Println(string(userJSONBytes3))
  32965. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32966. utils.ErrorLog("解析失败:%v", err)
  32967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32968. return
  32969. }
  32970. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32971. res2.Output = resSix10265.Output
  32972. res2.ErrMsg = resSix10265.ErrMsg
  32973. res2.Cainfo = resSix10265.Cainfo
  32974. res2.WarnMsg = resSix10265.WarnMsg
  32975. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32976. res2.Infcode = infocode
  32977. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32978. if err == nil {
  32979. c.ServeSuccessJSON(map[string]interface{}{
  32980. "msg": "撤销明细成功",
  32981. })
  32982. return
  32983. } else {
  32984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32985. return
  32986. }
  32987. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32988. 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)
  32989. var dat map[string]interface{}
  32990. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32991. fmt.Println(dat)
  32992. } else {
  32993. fmt.Println(err)
  32994. }
  32995. saveLog(result2, src_request, "2205", "撤销明细")
  32996. userJSONBytes, _ := json.Marshal(dat)
  32997. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32998. utils.ErrorLog("解析失败:%v", err)
  32999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33000. return
  33001. }
  33002. if res2.Infcode == 0 {
  33003. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33004. if err == nil {
  33005. c.ServeSuccessJSON(map[string]interface{}{
  33006. "msg": "撤销明细成功",
  33007. })
  33008. return
  33009. } else {
  33010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33011. return
  33012. }
  33013. } else {
  33014. c.ServeSuccessJSON(map[string]interface{}{
  33015. "failed_code": -10,
  33016. "msg": res2.ErrMsg,
  33017. })
  33018. }
  33019. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33020. 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, "")
  33021. var dat map[string]interface{}
  33022. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33023. fmt.Println(dat)
  33024. } else {
  33025. fmt.Println(err)
  33026. }
  33027. saveLog(result2, src_request, "2205", "撤销明细")
  33028. userJSONBytes, _ := json.Marshal(dat)
  33029. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33030. utils.ErrorLog("解析失败:%v", err)
  33031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33032. return
  33033. }
  33034. if res2.Infcode == 0 {
  33035. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33036. if err == nil {
  33037. c.ServeSuccessJSON(map[string]interface{}{
  33038. "msg": "撤销明细成功",
  33039. })
  33040. return
  33041. } else {
  33042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33043. return
  33044. }
  33045. } else {
  33046. c.ServeSuccessJSON(map[string]interface{}{
  33047. "failed_code": -10,
  33048. "msg": res2.ErrMsg,
  33049. })
  33050. }
  33051. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33052. 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, "")
  33053. var dat map[string]interface{}
  33054. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33055. fmt.Println(dat)
  33056. } else {
  33057. fmt.Println(err)
  33058. }
  33059. saveLog(result2, src_request, "2205", "撤销明细")
  33060. userJSONBytes, _ := json.Marshal(dat)
  33061. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33062. utils.ErrorLog("解析失败:%v", err)
  33063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33064. return
  33065. }
  33066. if res2.Infcode == 0 {
  33067. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33068. if err == nil {
  33069. c.ServeSuccessJSON(map[string]interface{}{
  33070. "msg": "撤销明细成功",
  33071. })
  33072. return
  33073. } else {
  33074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33075. return
  33076. }
  33077. } else {
  33078. c.ServeSuccessJSON(map[string]interface{}{
  33079. "failed_code": -10,
  33080. "msg": res2.ErrMsg,
  33081. })
  33082. }
  33083. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33084. 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, "")
  33085. var dat map[string]interface{}
  33086. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33087. fmt.Println(dat)
  33088. } else {
  33089. fmt.Println(err)
  33090. }
  33091. saveLog(result2, src_request, "2205", "撤销明细")
  33092. userJSONBytes, _ := json.Marshal(dat)
  33093. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33094. utils.ErrorLog("解析失败:%v", err)
  33095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33096. return
  33097. }
  33098. if res2.Infcode == 0 {
  33099. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33100. if err == nil {
  33101. c.ServeSuccessJSON(map[string]interface{}{
  33102. "msg": "撤销明细成功",
  33103. })
  33104. return
  33105. } else {
  33106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33107. return
  33108. }
  33109. } else {
  33110. c.ServeSuccessJSON(map[string]interface{}{
  33111. "failed_code": -10,
  33112. "msg": res2.ErrMsg,
  33113. })
  33114. }
  33115. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33116. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  33117. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33118. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33119. resp2, requestErr2 := http.Get(api2)
  33120. if requestErr2 != nil {
  33121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33122. return
  33123. }
  33124. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33125. if ioErr2 != nil {
  33126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33128. return
  33129. }
  33130. var respJSON2 map[string]interface{}
  33131. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33134. return
  33135. }
  33136. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33137. userJSONBytes3, _ := json.Marshal(respJSON2)
  33138. fmt.Println("log")
  33139. fmt.Println(string(userJSONBytes3))
  33140. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33141. utils.ErrorLog("解析失败:%v", err)
  33142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33143. return
  33144. }
  33145. if res2.Infcode == 0 {
  33146. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33147. if err == nil {
  33148. c.ServeSuccessJSON(map[string]interface{}{
  33149. "msg": "撤销明细成功",
  33150. })
  33151. return
  33152. } else {
  33153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33154. return
  33155. }
  33156. } else {
  33157. c.ServeSuccessJSON(map[string]interface{}{
  33158. "failed_code": -10,
  33159. "msg": res2.ErrMsg,
  33160. })
  33161. }
  33162. } else {
  33163. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  33164. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33165. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33166. resp2, requestErr2 := http.Get(api2)
  33167. if requestErr2 != nil {
  33168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33169. return
  33170. }
  33171. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33172. if ioErr2 != nil {
  33173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33175. return
  33176. }
  33177. var respJSON2 map[string]interface{}
  33178. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33181. return
  33182. }
  33183. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33184. userJSONBytes3, _ := json.Marshal(respJSON2)
  33185. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33186. utils.ErrorLog("解析失败:%v", err)
  33187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33188. return
  33189. }
  33190. if res2.Infcode == -1 {
  33191. c.ServeSuccessJSON(map[string]interface{}{
  33192. "failed_code": -10,
  33193. "msg": res2.ErrMsg,
  33194. })
  33195. return
  33196. } else {
  33197. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33198. if err == nil {
  33199. c.ServeSuccessJSON(map[string]interface{}{
  33200. "msg": "撤销明细成功",
  33201. })
  33202. return
  33203. } else {
  33204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33205. return
  33206. }
  33207. }
  33208. }
  33209. } else {
  33210. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33211. if err == nil {
  33212. c.ServeSuccessJSON(map[string]interface{}{
  33213. "msg": "退费成功",
  33214. })
  33215. } else {
  33216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33217. return
  33218. }
  33219. }
  33220. }
  33221. // 对账
  33222. func (c *HisApiController) GetCheckAccount() {
  33223. start_time := c.GetString("start_time")
  33224. end_time := c.GetString("end_time")
  33225. insutype := c.GetString("insutype")
  33226. clr_type := c.GetString("clr_type")
  33227. clr_org := c.GetString("clr_optins")
  33228. admin_user_id, _ := c.GetInt64("admin_user_id")
  33229. adminUser := c.GetAdminUserInfo()
  33230. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33231. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33232. if len(clr_org) == 0 {
  33233. clr_org = miConfig.InsuplcAdmdvs
  33234. }
  33235. timeLayout := "2006-01-02"
  33236. loc, _ := time.LoadLocation("Local")
  33237. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33238. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33239. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33240. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33241. fixmedins_setl_cnt := int64(len(orders))
  33242. var medfee_sumamt float64
  33243. var acct_pay float64
  33244. var fund_pay_sumamt float64
  33245. for _, item := range orders {
  33246. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33247. acct_pay = acct_pay + item.AcctPay
  33248. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33249. }
  33250. var user_name string
  33251. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33252. if role.ID == 0 {
  33253. user_name = "xxx"
  33254. } else {
  33255. user_name = role.UserName
  33256. }
  33257. var res ResultEight
  33258. var res10188 ResultEightFor10188
  33259. if config.IsOpen == 1 {
  33260. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33261. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  33262. "insutype=" + insutype +
  33263. "&clr_type=" + clr_type +
  33264. "&setl_optins=" + clr_org +
  33265. "&stmt_begndate=" + start_time +
  33266. "&stm_enddate=" + end_time +
  33267. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33268. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33269. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33270. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33271. "&fixmedins_code=" + miConfig.Code +
  33272. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33273. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33274. "&secret_key=" + miConfig.SecretKey +
  33275. "&org_name=" + miConfig.OrgName +
  33276. "&doctor=" + user_name +
  33277. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33278. fmt.Println(api)
  33279. resp, requestErr := http.Get(api)
  33280. if requestErr != nil {
  33281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33282. return
  33283. }
  33284. body, ioErr := ioutil.ReadAll(resp.Body)
  33285. fmt.Println(body)
  33286. if ioErr != nil {
  33287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33289. return
  33290. }
  33291. var respJSON map[string]interface{}
  33292. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33295. return
  33296. }
  33297. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33298. userJSONBytes, _ := json.Marshal(respJSON)
  33299. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33300. utils.ErrorLog("解析失败:%v", err)
  33301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33302. return
  33303. }
  33304. res.InfRefmsgid = res10188.InfRefmsgid
  33305. res.Output = res10188.Output
  33306. res.ErrMsg = res10188.ErrMsg
  33307. res.Cainfo = res10188.Cainfo
  33308. res.WarnMsg = res10188.WarnMsg
  33309. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33310. res.Infcode = infocode
  33311. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33312. if clr_type != "9903" {
  33313. clr_type = "99" // 就诊 ID(来自2201接口返回)
  33314. }
  33315. if clr_type == "9903" {
  33316. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  33317. }
  33318. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  33319. "insutype=" + insutype +
  33320. "&clr_type=" + clr_type +
  33321. "&setl_optins=" + clr_org +
  33322. "&stmt_begndate=" + start_time +
  33323. "&stm_enddate=" + end_time +
  33324. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33325. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33326. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33327. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33328. "&fixmedins_code=" + miConfig.Code +
  33329. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33330. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33331. "&secret_key=" + miConfig.SecretKey +
  33332. "&org_name=" + miConfig.OrgName +
  33333. "&doctor=" + user_name
  33334. resp, requestErr := http.Get(api)
  33335. if requestErr != nil {
  33336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33337. return
  33338. }
  33339. body, ioErr := ioutil.ReadAll(resp.Body)
  33340. if ioErr != nil {
  33341. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33343. return
  33344. }
  33345. var respJSON map[string]interface{}
  33346. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33347. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33349. return
  33350. }
  33351. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33352. result, _ := json.Marshal(respJSON)
  33353. fmt.Println("log")
  33354. fmt.Println(string(result))
  33355. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  33356. utils.ErrorLog("解析失败:%v", err)
  33357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33358. return
  33359. }
  33360. res.InfRefmsgid = res10188.InfRefmsgid
  33361. res.Output = res10188.Output
  33362. res.ErrMsg = res10188.ErrMsg
  33363. res.Cainfo = res10188.Cainfo
  33364. res.WarnMsg = res10188.WarnMsg
  33365. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33366. res.Infcode = infocode
  33367. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33368. var baseParams models.BaseParams
  33369. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33370. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33371. baseParams.SecretKey = miConfig.SecretKey
  33372. baseParams.OrgName = miConfig.OrgName
  33373. baseParams.FixmedinsCode = miConfig.Code
  33374. baseParams.EncKey = miConfig.EncKey
  33375. baseParams.AppSecret = miConfig.AppSecret
  33376. baseParams.SignKey = miConfig.SignKey
  33377. baseParams.AppID = miConfig.Code
  33378. baseParams.Doctor = role.UserName
  33379. baseParams.RequestUrl = miConfig.Url
  33380. businessParams := models.BusinessParams{
  33381. Insutype: insutype,
  33382. ClrType: clr_type,
  33383. SetlOptins: clr_org,
  33384. StmtBegndate: start_time,
  33385. StmtEnddate: end_time,
  33386. MedfeeSumamt: medfee_sumamt,
  33387. FundPaySumamt: fund_pay_sumamt,
  33388. AcctPay: acct_pay,
  33389. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33390. }
  33391. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33392. fmt.Println(requestLog)
  33393. fmt.Println(result)
  33394. fmt.Println(err_msg)
  33395. var dat map[string]interface{}
  33396. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33397. fmt.Println(dat)
  33398. } else {
  33399. fmt.Println(err)
  33400. }
  33401. userJSONBytes, _ := json.Marshal(dat)
  33402. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33403. utils.ErrorLog("解析失败:%v", err)
  33404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33405. return
  33406. }
  33407. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33408. var baseParams models.BaseParams
  33409. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33410. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33411. baseParams.SecretKey = miConfig.SecretKey
  33412. baseParams.OrgName = miConfig.OrgName
  33413. baseParams.FixmedinsCode = miConfig.Code
  33414. baseParams.EncKey = miConfig.EncKey
  33415. baseParams.AppSecret = miConfig.AppSecret
  33416. baseParams.SignKey = miConfig.SignKey
  33417. baseParams.AppID = miConfig.Code
  33418. baseParams.Doctor = role.UserName
  33419. baseParams.RequestUrl = miConfig.Url
  33420. baseParams.AccessKey = miConfig.AccessKey
  33421. businessParams := models.BusinessParams{
  33422. Insutype: insutype,
  33423. ClrType: clr_type,
  33424. SetlOptins: "430822",
  33425. StmtBegndate: start_time,
  33426. StmtEnddate: end_time,
  33427. MedfeeSumamt: medfee_sumamt,
  33428. FundPaySumamt: fund_pay_sumamt,
  33429. AcctPay: acct_pay,
  33430. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33431. }
  33432. 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)
  33433. fmt.Println(requestLog)
  33434. fmt.Println(result)
  33435. var dat map[string]interface{}
  33436. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33437. fmt.Println(dat)
  33438. } else {
  33439. fmt.Println(err)
  33440. }
  33441. userJSONBytes, _ := json.Marshal(dat)
  33442. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33443. utils.ErrorLog("解析失败:%v", err)
  33444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33445. return
  33446. }
  33447. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33448. var baseParams models.BaseParams
  33449. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33450. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33451. baseParams.SecretKey = miConfig.SecretKey
  33452. baseParams.OrgName = miConfig.OrgName
  33453. baseParams.FixmedinsCode = miConfig.Code
  33454. baseParams.EncKey = miConfig.EncKey
  33455. baseParams.AppSecret = miConfig.AppSecret
  33456. baseParams.SignKey = miConfig.SignKey
  33457. baseParams.AppID = miConfig.Code
  33458. baseParams.Doctor = role.UserName
  33459. baseParams.RequestUrl = miConfig.Url
  33460. businessParams := models.BusinessParams{
  33461. Insutype: insutype,
  33462. ClrType: clr_type,
  33463. SetlOptins: clr_org,
  33464. StmtBegndate: start_time,
  33465. StmtEnddate: end_time,
  33466. MedfeeSumamt: medfee_sumamt,
  33467. FundPaySumamt: fund_pay_sumamt,
  33468. AcctPay: acct_pay,
  33469. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33470. }
  33471. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33472. fmt.Println(requestLog)
  33473. fmt.Println(result)
  33474. fmt.Println(err_msg)
  33475. var dat map[string]interface{}
  33476. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33477. fmt.Println(dat)
  33478. } else {
  33479. fmt.Println(err)
  33480. }
  33481. userJSONBytes, _ := json.Marshal(dat)
  33482. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33483. utils.ErrorLog("解析失败:%v", err)
  33484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33485. return
  33486. }
  33487. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33488. if len(clr_type) == 0 {
  33489. clr_type = "11"
  33490. }
  33491. api := miConfig.Url + "gdyb/ten?" +
  33492. "insutype=" + insutype +
  33493. "&clr_type=" + clr_type +
  33494. "&setl_optins=" + clr_org +
  33495. "&stmt_begndate=" + start_time +
  33496. "&stm_enddate=" + end_time +
  33497. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33498. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33499. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33500. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33501. "&fixmedins_code=" + miConfig.Code +
  33502. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33503. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33504. "&secret_key=" + miConfig.SecretKey +
  33505. "&org_name=" + miConfig.OrgName +
  33506. "&doctor=" + user_name
  33507. fmt.Println(api)
  33508. resp, requestErr := http.Get(api)
  33509. if requestErr != nil {
  33510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33511. return
  33512. }
  33513. body, ioErr := ioutil.ReadAll(resp.Body)
  33514. fmt.Println(body)
  33515. if ioErr != nil {
  33516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33518. return
  33519. }
  33520. var respJSON map[string]interface{}
  33521. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33524. return
  33525. }
  33526. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33527. userJSONBytes, _ := json.Marshal(respJSON)
  33528. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33529. utils.ErrorLog("解析失败:%v", err)
  33530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33531. return
  33532. }
  33533. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33534. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33535. //fixmedins_setl_cnt := int64(len(orders_two))
  33536. //var medfee_sumamt float64
  33537. //var acct_pay float64
  33538. //var fund_pay_sumamt float64
  33539. //for _, item := range orders_two {
  33540. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33541. // acct_pay = acct_pay + item.AcctPay
  33542. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33543. //}
  33544. var baseParams models.BaseParams
  33545. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33546. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33547. baseParams.SecretKey = miConfig.SecretKey
  33548. baseParams.OrgName = miConfig.OrgName
  33549. baseParams.FixmedinsCode = miConfig.Code
  33550. baseParams.EncKey = miConfig.EncKey
  33551. baseParams.AppSecret = miConfig.AppSecret
  33552. baseParams.SignKey = miConfig.SignKey
  33553. baseParams.AppID = miConfig.Code
  33554. baseParams.Doctor = role.UserName
  33555. baseParams.RequestUrl = miConfig.Url
  33556. if clr_type == "9903" {
  33557. clr_type = "9994"
  33558. }
  33559. businessParams := models.BusinessParams{
  33560. Insutype: insutype,
  33561. ClrType: clr_type,
  33562. SetlOptins: "360302",
  33563. StmtBegndate: start_time,
  33564. StmtEnddate: end_time,
  33565. MedfeeSumamt: 0,
  33566. FundPaySumamt: 0,
  33567. AcctPay: 0,
  33568. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33569. }
  33570. 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))
  33571. fmt.Println(requestLog)
  33572. fmt.Println(result)
  33573. var dat map[string]interface{}
  33574. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33575. fmt.Println(dat)
  33576. } else {
  33577. fmt.Println(err)
  33578. }
  33579. userJSONBytes, _ := json.Marshal(dat)
  33580. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33581. utils.ErrorLog("解析失败:%v", err)
  33582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33583. return
  33584. }
  33585. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33586. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33587. fixmedins_setl_cnt := int64(len(orders_two))
  33588. var medfee_sumamt float64
  33589. var acct_pay float64
  33590. var fund_pay_sumamt float64
  33591. for _, item := range orders_two {
  33592. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33593. acct_pay = acct_pay + item.AcctPay
  33594. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33595. }
  33596. var baseParams models.BaseParams
  33597. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33598. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33599. baseParams.SecretKey = miConfig.SecretKey
  33600. baseParams.OrgName = miConfig.OrgName
  33601. baseParams.FixmedinsCode = miConfig.Code
  33602. baseParams.EncKey = miConfig.EncKey
  33603. baseParams.AppSecret = miConfig.AppSecret
  33604. baseParams.SignKey = miConfig.SignKey
  33605. baseParams.AppID = miConfig.Code
  33606. baseParams.Doctor = role.UserName
  33607. baseParams.RequestUrl = miConfig.Url
  33608. if clr_type == "9903" {
  33609. clr_type = "9994"
  33610. }
  33611. businessParams := models.BusinessParams{
  33612. Insutype: insutype,
  33613. ClrType: clr_type,
  33614. SetlOptins: "361025",
  33615. StmtBegndate: start_time,
  33616. StmtEnddate: end_time,
  33617. MedfeeSumamt: 0,
  33618. FundPaySumamt: 0,
  33619. AcctPay: 0,
  33620. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33621. }
  33622. 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))
  33623. fmt.Println(requestLog)
  33624. fmt.Println(result)
  33625. var dat map[string]interface{}
  33626. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33627. fmt.Println(dat)
  33628. } else {
  33629. fmt.Println(err)
  33630. }
  33631. userJSONBytes, _ := json.Marshal(dat)
  33632. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33633. utils.ErrorLog("解析失败:%v", err)
  33634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33635. return
  33636. }
  33637. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33638. var api string
  33639. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33640. "&clr_type=" + clr_type +
  33641. "&setl_optins=" + clr_org +
  33642. "&stmt_begndate=" + start_time +
  33643. "&stm_enddate=" + end_time +
  33644. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33645. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33646. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33647. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33648. "&fixmedins_code=" + miConfig.Code +
  33649. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33650. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33651. "&secret_key=" + miConfig.SecretKey +
  33652. "&org_name=" + miConfig.OrgName +
  33653. "&doctor=" + user_name + "&url=" + miConfig.Url
  33654. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33655. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33656. resp, requestErr := http.Get(api)
  33657. if requestErr != nil {
  33658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33659. return
  33660. }
  33661. body, ioErr := ioutil.ReadAll(resp.Body)
  33662. if ioErr != nil {
  33663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33665. return
  33666. }
  33667. var respJSON map[string]interface{}
  33668. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33671. return
  33672. }
  33673. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33674. if status == "0" {
  33675. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33676. c.ServeSuccessJSON(map[string]interface{}{
  33677. "failed_code": -10,
  33678. "msg": err_msg,
  33679. })
  33680. return
  33681. }
  33682. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33683. userJSONBytes, _ := json.Marshal(respJSON)
  33684. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33685. utils.ErrorLog("解析失败:%v", err)
  33686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33687. return
  33688. }
  33689. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33690. var api string
  33691. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33692. "&clr_type=" + clr_type +
  33693. "&setl_optins=" + clr_org +
  33694. "&stmt_begndate=" + start_time +
  33695. "&stm_enddate=" + end_time +
  33696. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33697. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33698. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33699. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33700. "&fixmedins_code=" + miConfig.Code +
  33701. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33702. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33703. "&secret_key=" + miConfig.SecretKey +
  33704. "&org_name=" + miConfig.OrgName +
  33705. "&doctor=" + user_name + "&url=" + miConfig.Url
  33706. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33707. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33708. resp, requestErr := http.Get(api)
  33709. if requestErr != nil {
  33710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33711. return
  33712. }
  33713. body, ioErr := ioutil.ReadAll(resp.Body)
  33714. if ioErr != nil {
  33715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33717. return
  33718. }
  33719. var respJSON map[string]interface{}
  33720. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33723. return
  33724. }
  33725. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33726. if status == "0" {
  33727. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33728. c.ServeSuccessJSON(map[string]interface{}{
  33729. "failed_code": -10,
  33730. "msg": err_msg,
  33731. })
  33732. return
  33733. }
  33734. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33735. userJSONBytes, _ := json.Marshal(respJSON)
  33736. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33737. utils.ErrorLog("解析失败:%v", err)
  33738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33739. return
  33740. }
  33741. } else {
  33742. if len(clr_type) == 0 {
  33743. clr_type = "11"
  33744. }
  33745. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33746. "insutype=" + insutype +
  33747. "&clr_type=" + clr_type +
  33748. "&setl_optins=" + clr_org +
  33749. "&stmt_begndate=" + start_time +
  33750. "&stm_enddate=" + end_time +
  33751. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33752. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33753. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33754. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33755. "&fixmedins_code=" + miConfig.Code +
  33756. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33757. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33758. "&secret_key=" + miConfig.SecretKey +
  33759. "&org_name=" + miConfig.OrgName +
  33760. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33761. fmt.Println(api)
  33762. resp, requestErr := http.Get(api)
  33763. if requestErr != nil {
  33764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33765. return
  33766. }
  33767. body, ioErr := ioutil.ReadAll(resp.Body)
  33768. fmt.Println(body)
  33769. if ioErr != nil {
  33770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33772. return
  33773. }
  33774. var respJSON map[string]interface{}
  33775. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33776. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33778. return
  33779. }
  33780. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33781. userJSONBytes, _ := json.Marshal(respJSON)
  33782. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33783. utils.ErrorLog("解析失败:%v", err)
  33784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33785. return
  33786. }
  33787. }
  33788. if res.Infcode == 0 {
  33789. if res.Output.Stmtinfo.StmtRslt == "0" {
  33790. micc := &models.MedicalInsuranceCostCompare{
  33791. StartTime: startime.Unix(),
  33792. EndTime: endtime.Unix(),
  33793. Insutype: insutype,
  33794. CheckType: 1,
  33795. Num: fixmedins_setl_cnt,
  33796. Mtime: time.Now().Unix(),
  33797. Status: 1,
  33798. UserOrgId: adminUser.CurrentOrgId,
  33799. CostTotal: medfee_sumamt,
  33800. FuncTotal: fund_pay_sumamt,
  33801. PsnPay: acct_pay,
  33802. Creator: admin_user_id,
  33803. Ctime: time.Now().Unix(),
  33804. ClrType: clr_type,
  33805. }
  33806. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  33807. if err == nil {
  33808. c.ServeSuccessJSON(map[string]interface{}{
  33809. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33810. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33811. })
  33812. } else {
  33813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33814. }
  33815. } else {
  33816. c.ServeSuccessJSON(map[string]interface{}{
  33817. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33818. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33819. })
  33820. }
  33821. } else {
  33822. c.ServeSuccessJSON(map[string]interface{}{
  33823. "failed_code": -10,
  33824. "msg": res.ErrMsg,
  33825. })
  33826. }
  33827. }
  33828. }
  33829. func (c *HisApiController) Check310() {
  33830. adminUser := c.GetAdminUserInfo()
  33831. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33832. var user_name string
  33833. user_name = "高慧裕"
  33834. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33835. "insutype=" + "310" +
  33836. "&clr_type=" + "" +
  33837. "&setl_optins=" + "441202" +
  33838. "&stmt_begndate=" + "2022-03-01" +
  33839. "&stm_enddate=" + "2022-03-31" +
  33840. "&medfee_sumamt=" + "194930.12" +
  33841. "&fund_pay_sumamt=" + "188741.46" +
  33842. "&acct_pay=" + "0" +
  33843. "&fixmedins_setl_cnt=" + "452" +
  33844. "&fixmedins_code=" + miConfig.Code +
  33845. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33846. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33847. "&secret_key=" + miConfig.SecretKey +
  33848. "&org_name=" + miConfig.OrgName +
  33849. "&doctor=" + user_name
  33850. fmt.Println(api)
  33851. resp, requestErr := http.Get(api)
  33852. if requestErr != nil {
  33853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33854. return
  33855. }
  33856. body, ioErr := ioutil.ReadAll(resp.Body)
  33857. fmt.Println(body)
  33858. if ioErr != nil {
  33859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33861. return
  33862. }
  33863. var respJSON map[string]interface{}
  33864. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33867. return
  33868. }
  33869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33870. userJSONBytes, _ := json.Marshal(respJSON)
  33871. var res ResultEight
  33872. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33873. utils.ErrorLog("解析失败:%v", err)
  33874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33875. return
  33876. }
  33877. }
  33878. func (c *HisApiController) Check390() {
  33879. adminUser := c.GetAdminUserInfo()
  33880. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33881. var user_name string
  33882. user_name = "高慧裕"
  33883. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33884. "insutype=" + "390" +
  33885. "&clr_type=" + "" +
  33886. "&setl_optins=" + "441202" +
  33887. "&stmt_begndate=" + "2022-03-01" +
  33888. "&stm_enddate=" + "2022-03-31" +
  33889. "&medfee_sumamt=" + "1068448.89" +
  33890. "&fund_pay_sumamt=" + "1014677.62" +
  33891. "&acct_pay=" + "0" +
  33892. "&fixmedins_setl_cnt=" + "1950" +
  33893. "&fixmedins_code=" + miConfig.Code +
  33894. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33895. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33896. "&secret_key=" + miConfig.SecretKey +
  33897. "&org_name=" + miConfig.OrgName +
  33898. "&doctor=" + user_name
  33899. fmt.Println(api)
  33900. resp, requestErr := http.Get(api)
  33901. if requestErr != nil {
  33902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33903. return
  33904. }
  33905. body, ioErr := ioutil.ReadAll(resp.Body)
  33906. fmt.Println(body)
  33907. if ioErr != nil {
  33908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33910. return
  33911. }
  33912. var respJSON map[string]interface{}
  33913. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33916. return
  33917. }
  33918. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33919. userJSONBytes, _ := json.Marshal(respJSON)
  33920. var res ResultEight
  33921. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33922. utils.ErrorLog("解析失败:%v", err)
  33923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33924. return
  33925. }
  33926. }
  33927. // 对账明细
  33928. func (c *HisApiController) GetCheckDetailAccount() {
  33929. start_time := c.GetString("start_time")
  33930. end_time := c.GetString("end_time")
  33931. admin_user_id, _ := c.GetInt64("admin_user_id")
  33932. adminUser := c.GetAdminUserInfo()
  33933. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33934. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33935. timeLayout := "2006-01-02"
  33936. loc, _ := time.LoadLocation("Local")
  33937. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33938. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33939. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  33940. rand.Seed(time.Now().UnixNano())
  33941. num := rand.Intn(30000)
  33942. Mkdir(miConfig.OrgName)
  33943. file := strconv.FormatInt(int64(num), 10)
  33944. file_name := file + ".txt"
  33945. zip_name := file + ".zip"
  33946. zip_path := miConfig.OrgName + "/" + zip_name
  33947. file_path := miConfig.OrgName + "/" + file_name
  33948. decimal.DivisionPrecision = 2
  33949. var medfee_sumamt float64
  33950. var psn_cash_pay float64
  33951. var fund_pay_sumamt float64
  33952. fixmedins_setl_cnt := int64(len(orders))
  33953. for _, item := range orders {
  33954. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33955. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  33956. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33957. }
  33958. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  33959. defer f.Close()
  33960. if err != nil {
  33961. fmt.Println(err.Error())
  33962. } else {
  33963. for _, item := range orders {
  33964. var refd_setl_flag string
  33965. if item.OrderStatus == 2 {
  33966. refd_setl_flag = "0"
  33967. var str string
  33968. str = item.SetlId + " " +
  33969. item.MdtrtId + " " +
  33970. item.PsnNo + " " +
  33971. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33972. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33973. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  33974. _, err = f.Write([]byte(str))
  33975. }
  33976. if item.OrderStatus == 3 {
  33977. var str string
  33978. str = item.SetlId + " " +
  33979. item.MdtrtId + " " +
  33980. item.PsnNo + " " +
  33981. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33982. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33983. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  33984. _, err = f.Write([]byte(str))
  33985. var str2 string
  33986. str2 = item.SetlId + " " +
  33987. item.MdtrtId + " " +
  33988. item.PsnNo + " " +
  33989. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  33990. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  33991. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  33992. _, err = f.Write([]byte(str2))
  33993. }
  33994. }
  33995. }
  33996. Zip(file_path, zip_path)
  33997. fmt.Println(ReadFile(zip_path))
  33998. fmt.Println(string(ReadFile(zip_path)))
  33999. if config.IsOpen == 1 {
  34000. var user_name string
  34001. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34002. if role.ID == 0 {
  34003. user_name = "管理员"
  34004. } else {
  34005. user_name = role.UserName
  34006. }
  34007. baseParams := models.BaseParams{
  34008. SecretKey: miConfig.SecretKey,
  34009. FixmedinsCode: miConfig.Code,
  34010. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34011. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34012. OrgName: miConfig.OrgName,
  34013. Doctor: user_name,
  34014. }
  34015. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  34016. var dat map[string]interface{}
  34017. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34018. fmt.Println(dat)
  34019. } else {
  34020. fmt.Println(err)
  34021. }
  34022. userJSONBytes, _ := json.Marshal(dat)
  34023. var res ResultNine
  34024. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34025. utils.ErrorLog("解析失败:%v", err)
  34026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34027. return
  34028. }
  34029. if res.Infcode == 0 {
  34030. fileNo := res.Output.FileQuryNo
  34031. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  34032. "file_qury_no=" + fileNo +
  34033. "&setl_optins=" + "定点医保中心" +
  34034. "&stmt_begndate=" + start_time +
  34035. "&stm_enddate=" + end_time +
  34036. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34037. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34038. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  34039. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34040. "&fixmedins_code=" + miConfig.Code +
  34041. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34042. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34043. "&secret_key=" + miConfig.SecretKey +
  34044. "&org_name=" + miConfig.OrgName +
  34045. "&doctor=" + user_name
  34046. resp, requestErr := http.Get(api)
  34047. if requestErr != nil {
  34048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34049. return
  34050. }
  34051. body, ioErr := ioutil.ReadAll(resp.Body)
  34052. if ioErr != nil {
  34053. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34055. return
  34056. }
  34057. var respJSON map[string]interface{}
  34058. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34059. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34061. return
  34062. }
  34063. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34064. userJSONBytes, _ := json.Marshal(respJSON)
  34065. var res ResultTen
  34066. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34067. utils.ErrorLog("解析失败:%v", err)
  34068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34069. return
  34070. }
  34071. if res.Infcode == 0 {
  34072. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  34073. micc := &models.MedicalInsuranceCostCompare{
  34074. StartTime: startime.Unix(),
  34075. EndTime: endtime.Unix(),
  34076. Insutype: "0",
  34077. CheckType: 2,
  34078. Num: fixmedins_setl_cnt,
  34079. Mtime: time.Now().Unix(),
  34080. Status: 1,
  34081. UserOrgId: adminUser.CurrentOrgId,
  34082. CostTotal: medfee_sumamt,
  34083. FuncTotal: fund_pay_sumamt,
  34084. PsnPay: psn_cash_pay,
  34085. Creator: admin_user_id,
  34086. Ctime: time.Now().Unix(),
  34087. }
  34088. service.CreateMedicalInsuranceCostCompareRecord(micc)
  34089. c.ServeSuccessJSON(map[string]interface{}{
  34090. "msg": "明细对账成功",
  34091. })
  34092. }
  34093. } else {
  34094. }
  34095. }
  34096. }
  34097. type CustomOrderInfo struct {
  34098. Name string
  34099. Spec string
  34100. Unit string
  34101. Count float64
  34102. Price float64
  34103. Total float64
  34104. }
  34105. func (c *HisApiController) GetBatchSettleAccounts() {
  34106. admin_user_id, _ := c.GetInt64("admin_user_id")
  34107. order_ids := c.GetString("order_ids")
  34108. order_ids_arr := strings.Split(order_ids, ",")
  34109. data3 := []map[string]interface{}{}
  34110. for _, item := range order_ids_arr {
  34111. id, _ := strconv.ParseInt(item, 10, 64)
  34112. order_id := id
  34113. adminUser := c.GetAdminUserInfo()
  34114. order, _ := service.GetHisOrderByID(order_id)
  34115. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34116. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34117. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34118. orderInfos = append(orderInfos, orderInfos_two...)
  34119. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34120. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34121. var diagnosis_ids []string
  34122. if his.ID > 0 {
  34123. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34124. } else {
  34125. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34126. }
  34127. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34128. var dia_config []*models.HisXtDiagnoseConfig
  34129. var name string
  34130. for _, item := range diagnosis_ids {
  34131. id, _ := strconv.ParseInt(item, 10, 64)
  34132. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34133. dia_config = append(dia_config, &diagnosisConfig)
  34134. if len(name) == 0 {
  34135. name = diagnosisConfig.ClassName
  34136. }
  34137. //} else {
  34138. // name = name + "," + diagnosisConfig.ClassName
  34139. //}
  34140. }
  34141. var bedCostTotal float64 = 0 //床位总费
  34142. var bedCostSelfTotal float64 = 0 //床位自费
  34143. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34144. var bedSelfTotal float64 = 0 //床位部分项目自费
  34145. var bedInscpTotal float64 = 0 //床位部分项目自费
  34146. var operationCostTotal float64 = 0 //手术费
  34147. var operationCostSelfTotal float64 = 0 //手术费
  34148. var operationCostPartSelfTotal float64 = 0 //手术费
  34149. var operationSelfTotal float64 = 0 //床位部分项目自费
  34150. var operationInscpTotal float64 = 0 //床位部分项目自费
  34151. var otherCostTotal float64 = 0 //其他费用
  34152. var otherCostSelfTotal float64 = 0 //其他费用
  34153. var otherCostPartSelfTotal float64 = 0 //其他费用
  34154. var otherSelfTotal float64 = 0 //床位部分项目自费
  34155. var otherInscpTotal float64 = 0 //床位部分项目自费
  34156. var materialCostTotal float64 = 0 //材料费
  34157. var materialCostSelfTotal float64 = 0 //材料费
  34158. var materialCostPartSelfTotal float64 = 0 //材料费
  34159. var materialSelfTotal float64 = 0 //床位部分项目自费
  34160. var materialInscpTotal float64 = 0 //床位部分项目自费
  34161. var westernMedicineCostTotal float64 = 0 //西药费
  34162. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34163. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34164. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34165. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34166. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34167. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34168. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34169. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34170. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34171. var checkCostTotal float64 = 0 //检查费
  34172. var checkCostSelfTotal float64 = 0 //检查费
  34173. var checkCostPartSelfTotal float64 = 0 //检查费
  34174. var checkSelfTotal float64 = 0 //床位部分项目自费
  34175. var checkInscpTotal float64 = 0 //床位部分项目自费
  34176. var laboratoryCostTotal float64 = 0 //化验费
  34177. var laboratoryCostSelfTotal float64 = 0 //化验费
  34178. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34179. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34180. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34181. var treatCostTotal float64 = 0 //治疗费用
  34182. var treatCostSelfTotal float64 = 0 //治疗费用
  34183. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34184. var treatSelfTotal float64 = 0 //床位部分项目自费
  34185. var treatInscpTotal float64 = 0 //床位部分项目自费
  34186. decimal.DivisionPrecision = 2
  34187. for _, item := range orderInfos {
  34188. if item.MedChrgitmType == "01" { //床位费
  34189. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34190. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34191. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34192. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34193. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34194. }
  34195. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34196. if item.MedChrgitmType == "03" { //检查费
  34197. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34198. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34199. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34200. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34201. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34202. }
  34203. } else {
  34204. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34205. fmt.Println("------------")
  34206. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34207. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34208. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34209. }
  34210. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34211. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34212. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34213. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34214. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34215. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34216. }
  34217. }
  34218. if item.MedChrgitmType == "04" { //化验费
  34219. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34220. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34221. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34222. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34223. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34224. }
  34225. if item.MedChrgitmType == "05" { //治疗费
  34226. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34227. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34228. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34229. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34230. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34231. }
  34232. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34233. fmt.Println("------------")
  34234. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34235. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34236. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34237. }
  34238. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34239. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34240. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34241. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34242. }
  34243. //if item.MedChrgitmType == "06" { //手术费
  34244. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34245. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34246. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34247. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34248. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34249. //
  34250. //}
  34251. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34252. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34253. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34254. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34255. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34256. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34257. }
  34258. if item.MedChrgitmType == "09" { //西药费
  34259. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34260. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34261. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34262. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34263. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34264. }
  34265. if item.MedChrgitmType == "11" { //中成费
  34266. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34267. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34268. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34269. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34270. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34271. }
  34272. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  34273. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34274. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34275. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34276. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34277. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34278. }
  34279. }
  34280. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34281. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34282. var user_name string
  34283. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34284. if role.ID == 0 {
  34285. user_name = "管理员"
  34286. } else {
  34287. user_name = role.UserName
  34288. }
  34289. baseParams := models.BaseParams{
  34290. SecretKey: miConfig.SecretKey,
  34291. FixmedinsCode: miConfig.Code,
  34292. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34293. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34294. OrgName: miConfig.OrgName,
  34295. Doctor: user_name,
  34296. RequestUrl: miConfig.Url,
  34297. AccessKey: miConfig.AccessKey,
  34298. }
  34299. businessParams := models.BusinessParams{
  34300. PsnNo: order.PsnNo,
  34301. MdtrtId: order.MdtrtId,
  34302. SetlId: order.SetlId,
  34303. }
  34304. var res ResultEleven
  34305. var resEleven10265 ResultEleven10265
  34306. if config.IsOpen == 1 {
  34307. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34308. result := service.Gdyb5203(baseParams, businessParams)
  34309. service.Gdyb5204(baseParams, businessParams)
  34310. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  34311. var dat map[string]interface{}
  34312. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34313. fmt.Println(dat)
  34314. } else {
  34315. fmt.Println(err)
  34316. }
  34317. userJSONBytes, _ := json.Marshal(dat)
  34318. if miConfig.Code == "H15049901371" {
  34319. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  34320. utils.ErrorLog("解析失败:%v", err)
  34321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34322. return
  34323. }
  34324. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34325. res.Output = resEleven10265.Output
  34326. res.ErrMsg = resEleven10265.ErrMsg
  34327. res.Cainfo = resEleven10265.Cainfo
  34328. res.WarnMsg = resEleven10265.WarnMsg
  34329. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34330. res.Infcode = infocode
  34331. } else {
  34332. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34333. utils.ErrorLog("解析失败:%v", err)
  34334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34335. return
  34336. }
  34337. }
  34338. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34339. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34340. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34341. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34342. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34343. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34344. var doctor_name string
  34345. if roles.ID == 0 {
  34346. doctor_name = "管理员"
  34347. } else {
  34348. doctor_name = roles.UserName
  34349. }
  34350. yiliao_leibie := ""
  34351. switch order.MedType {
  34352. case "11":
  34353. yiliao_leibie = "普通门诊"
  34354. break
  34355. case "12":
  34356. yiliao_leibie = "门诊挂号"
  34357. break
  34358. case "13":
  34359. yiliao_leibie = "急诊"
  34360. break
  34361. case "14":
  34362. yiliao_leibie = "门诊特殊病"
  34363. break
  34364. case "15":
  34365. yiliao_leibie = "门诊统筹"
  34366. break
  34367. case "16":
  34368. yiliao_leibie = "门诊慢性病"
  34369. break
  34370. case "21":
  34371. yiliao_leibie = "普通住院"
  34372. break
  34373. }
  34374. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34375. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  34376. if res.Infcode == 0 {
  34377. data2 := map[string]interface{}{
  34378. "diagnosis": name,
  34379. "order_infos": orderInfos,
  34380. "number": order.MdtrtId,
  34381. "date": order.SettleAccountsDate,
  34382. "charge_admin": charge_admin,
  34383. "printor_admin": printor_admin,
  34384. "info": res.Output.Setlinfo,
  34385. "order": order,
  34386. "bedCostTotal": bedCostTotal,
  34387. "bedCostSelfTotal": bedCostSelfTotal,
  34388. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34389. "bedSelfTotal": bedSelfTotal,
  34390. "bedInscpTotal": bedInscpTotal,
  34391. "operationCostTotal": operationCostTotal,
  34392. "operationCostSelfTotal": operationCostSelfTotal,
  34393. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34394. "operationSelfTotal": operationSelfTotal,
  34395. "operationInscpTotal": operationInscpTotal,
  34396. "otherCostTotal": otherCostTotal,
  34397. "otherCostSelfTotal": otherCostSelfTotal,
  34398. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34399. "otherSelfTotal": otherSelfTotal,
  34400. "otherInscpTotal": otherInscpTotal,
  34401. "materialCostTotal": materialCostTotal,
  34402. "materialCostSelfTotal": materialCostSelfTotal,
  34403. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34404. "materialSelfTotal": materialSelfTotal,
  34405. "materialInscpTotal": materialInscpTotal,
  34406. "westernMedicineCostTotal": westernMedicineCostTotal,
  34407. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34408. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34409. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34410. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34411. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34412. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34413. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34414. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34415. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34416. "checkCostTotal": checkCostTotal,
  34417. "checkCostSelfTotal": checkCostSelfTotal,
  34418. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34419. "checkSelfTotal": checkSelfTotal,
  34420. "checkInscpTotal": checkInscpTotal,
  34421. "laboratoryCostTotal": laboratoryCostTotal,
  34422. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34423. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34424. "laboratorySelfTotal": laboratorySelfTotal,
  34425. "laboratoryInscpTotal": laboratoryInscpTotal,
  34426. "treatCostTotal": treatCostTotal,
  34427. "treatCostSelfTotal": treatCostSelfTotal,
  34428. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34429. "treatSelfTotal": treatSelfTotal,
  34430. "treatInscpTotal": treatInscpTotal,
  34431. "doctor_info": doctor_info,
  34432. "doctor_code": adminRole_two.DoctorCode,
  34433. "doctor_name": doctor_name,
  34434. "health_card_no": order.PsnNo,
  34435. "department": departments.Name,
  34436. "yiliao_leibie": yiliao_leibie,
  34437. "after_money": order.AccountPrice,
  34438. "patient": patient,
  34439. "org_name": miConfig.OrgName,
  34440. "org_code": miConfig.Code,
  34441. "order_number": order.Number,
  34442. "his_hospital": his_hospital,
  34443. "his": his,
  34444. "dia_config": dia_config,
  34445. "psn_cash_pay": order.PsnCashPay,
  34446. //"check_order_info": cus_slice,
  34447. }
  34448. data3 = append(data3, data2)
  34449. }
  34450. }
  34451. }
  34452. c.ServeSuccessJSON(map[string]interface{}{
  34453. "infos": data3,
  34454. })
  34455. }
  34456. func (c *HisApiController) GetSettleAccounts() {
  34457. //id, _ := c.GetInt64("id")
  34458. //record_time := c.GetString("record_time")
  34459. order_id, _ := c.GetInt64("order_id")
  34460. admin_user_id, _ := c.GetInt64("admin_user_id")
  34461. //timeLayout := "2006-01-02"
  34462. //loc, _ := time.LoadLocation("Local")
  34463. //
  34464. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34465. //if err != nil {
  34466. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34467. // return
  34468. //}Hbyb5203
  34469. //recordDateTime := theTime.Unix()
  34470. adminUser := c.GetAdminUserInfo()
  34471. order, _ := service.GetHisOrderByID(order_id)
  34472. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34473. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34474. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34475. orderInfos = append(orderInfos, orderInfos_two...)
  34476. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34477. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34478. var diagnosis_ids []string
  34479. if his.ID > 0 {
  34480. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34481. } else {
  34482. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34483. }
  34484. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34485. var dia_config []*models.HisXtDiagnoseConfig
  34486. var name string
  34487. for _, item := range diagnosis_ids {
  34488. id, _ := strconv.ParseInt(item, 10, 64)
  34489. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34490. dia_config = append(dia_config, &diagnosisConfig)
  34491. if len(name) == 0 {
  34492. name = diagnosisConfig.ClassName
  34493. } else {
  34494. name = name + "," + diagnosisConfig.ClassName
  34495. }
  34496. }
  34497. if patient.UserOrgId == 10215 {
  34498. name = "慢性肾功能不全(血透治疗)"
  34499. }
  34500. var bedCostTotal float64 = 0 //床位总费
  34501. var bedCostSelfTotal float64 = 0 //床位自费
  34502. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34503. var bedSelfTotal float64 = 0 //床位部分项目自费
  34504. var bedInscpTotal float64 = 0 //床位部分项目自费
  34505. var operationCostTotal float64 = 0 //手术费
  34506. var operationCostSelfTotal float64 = 0 //手术费
  34507. var operationCostPartSelfTotal float64 = 0 //手术费
  34508. var operationSelfTotal float64 = 0 //床位部分项目自费
  34509. var operationInscpTotal float64 = 0 //床位部分项目自费
  34510. var otherCostTotal float64 = 0 //其他费用
  34511. var otherCostSelfTotal float64 = 0 //其他费用
  34512. var otherCostPartSelfTotal float64 = 0 //其他费用
  34513. var otherSelfTotal float64 = 0 //床位部分项目自费
  34514. var otherInscpTotal float64 = 0 //床位部分项目自费
  34515. var materialCostTotal float64 = 0 //材料费
  34516. var materialCostSelfTotal float64 = 0 //材料费
  34517. var materialCostPartSelfTotal float64 = 0 //材料费
  34518. var materialSelfTotal float64 = 0 //床位部分项目自费
  34519. var materialInscpTotal float64 = 0 //床位部分项目自费
  34520. var westernMedicineCostTotal float64 = 0 //西药费
  34521. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34522. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34523. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34524. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34525. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34526. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34527. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34528. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34529. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34530. var checkCostTotal float64 = 0 //检查费
  34531. var checkCostSelfTotal float64 = 0 //检查费
  34532. var checkCostPartSelfTotal float64 = 0 //检查费
  34533. var checkSelfTotal float64 = 0 //床位部分项目自费
  34534. var checkInscpTotal float64 = 0 //床位部分项目自费
  34535. var laboratoryCostTotal float64 = 0 //化验费
  34536. var laboratoryCostSelfTotal float64 = 0 //化验费
  34537. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34538. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34539. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34540. var treatCostTotal float64 = 0 //治疗费用
  34541. var treatCostSelfTotal float64 = 0 //治疗费用
  34542. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34543. var treatSelfTotal float64 = 0 //床位部分项目自费
  34544. var treatInscpTotal float64 = 0 //床位部分项目自费
  34545. var zcCostTotal float64 = 0 //治疗费用
  34546. var zcCostSelfTotal float64 = 0 //治疗费用
  34547. var zcCostPartSelfTotal float64 = 0 //治疗费用
  34548. var zcSelfTotal float64 = 0 //床位部分项目自费
  34549. var zcInscpTotal float64 = 0 //床位部分项目自费
  34550. var huliCostTotal float64 = 0 //治疗费用
  34551. var huliCostSelfTotal float64 = 0 //治疗费用
  34552. var huliCostPartSelfTotal float64 = 0 //治疗费用
  34553. var huliSelfTotal float64 = 0 //床位部分项目自费
  34554. var huliInscpTotal float64 = 0 //床位部分项目自费
  34555. decimal.DivisionPrecision = 2
  34556. for _, item := range orderInfos {
  34557. if item.MedChrgitmType == "01" { //床位费
  34558. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34559. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34560. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34561. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34562. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34563. }
  34564. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34565. if item.MedChrgitmType == "03" { //检查费
  34566. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34567. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34568. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34569. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34570. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34571. }
  34572. } else {
  34573. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34574. fmt.Println("------------")
  34575. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34576. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34577. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34578. }
  34579. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34580. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34581. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34582. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34583. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34584. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34585. }
  34586. }
  34587. if item.MedChrgitmType == "04" { //化验费
  34588. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34589. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34590. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34591. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34592. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34593. }
  34594. if item.MedChrgitmType == "05" { //治疗费
  34595. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34596. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34597. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34598. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34599. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34600. }
  34601. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34602. fmt.Println("------------")
  34603. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34604. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34605. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34606. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34607. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34608. }
  34609. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34610. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34611. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34612. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34613. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34614. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34615. }
  34616. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34617. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34618. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34619. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34620. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34621. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34622. }
  34623. if item.MedChrgitmType == "09" { //西药费
  34624. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34625. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34626. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34627. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34628. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34629. }
  34630. if item.MedChrgitmType == "11" { //中成费
  34631. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34632. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34633. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34634. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34635. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34636. }
  34637. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  34638. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34639. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34640. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34641. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34642. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34643. }
  34644. if item.MedChrgitmType == "02" { //其他费
  34645. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34646. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34647. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34648. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34649. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34650. }
  34651. if item.MedChrgitmType == "07" { //其他费
  34652. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34653. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34654. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34655. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34656. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34657. }
  34658. }
  34659. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34660. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34661. var user_name string
  34662. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34663. if role.ID == 0 {
  34664. user_name = "管理员"
  34665. } else {
  34666. user_name = role.UserName
  34667. }
  34668. baseParams := models.BaseParams{
  34669. SecretKey: miConfig.SecretKey,
  34670. FixmedinsCode: miConfig.Code,
  34671. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34672. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34673. OrgName: miConfig.OrgName,
  34674. Doctor: user_name,
  34675. RequestUrl: miConfig.Url,
  34676. AccessKey: miConfig.AccessKey,
  34677. }
  34678. businessParams := models.BusinessParams{
  34679. PsnNo: order.PsnNo,
  34680. MdtrtId: order.MdtrtId,
  34681. SetlId: order.SetlId,
  34682. }
  34683. var res ResultEleven
  34684. var resah ResultElevenah
  34685. var resEleven10265 ResultEleven10265
  34686. if config.IsOpen == 1 {
  34687. if miConfig.MdtrtareaAdmvs == "421300" {
  34688. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34689. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34690. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34691. resp, requestErr := http.Get(api)
  34692. if requestErr != nil {
  34693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34694. return
  34695. }
  34696. body, ioErr := ioutil.ReadAll(resp.Body)
  34697. if ioErr != nil {
  34698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34700. return
  34701. }
  34702. var respJSON map[string]interface{}
  34703. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34706. return
  34707. }
  34708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34709. result, _ := json.Marshal(respJSON)
  34710. fmt.Println("log")
  34711. fmt.Println(string(result))
  34712. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34713. utils.ErrorLog("解析失败:%v", err)
  34714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34715. return
  34716. }
  34717. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34718. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34719. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34720. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34721. resp, requestErr := http.Get(api)
  34722. if requestErr != nil {
  34723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34724. return
  34725. }
  34726. body, ioErr := ioutil.ReadAll(resp.Body)
  34727. if ioErr != nil {
  34728. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34730. return
  34731. }
  34732. var respJSON map[string]interface{}
  34733. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34736. return
  34737. }
  34738. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34739. result, _ := json.Marshal(respJSON)
  34740. fmt.Println("log")
  34741. fmt.Println(string(result))
  34742. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34743. utils.ErrorLog("解析失败:%v", err)
  34744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34745. return
  34746. }
  34747. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34748. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34749. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34750. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34751. resp, requestErr := http.Get(api)
  34752. if requestErr != nil {
  34753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34754. return
  34755. }
  34756. body, ioErr := ioutil.ReadAll(resp.Body)
  34757. if ioErr != nil {
  34758. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34760. return
  34761. }
  34762. var respJSON map[string]interface{}
  34763. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34766. return
  34767. }
  34768. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34769. result, _ := json.Marshal(respJSON)
  34770. fmt.Println("log")
  34771. fmt.Println(string(result))
  34772. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34773. utils.ErrorLog("解析失败:%v", err)
  34774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34775. return
  34776. }
  34777. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34778. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34779. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34780. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  34781. resp, requestErr := http.Get(api)
  34782. if requestErr != nil {
  34783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34784. return
  34785. }
  34786. body, ioErr := ioutil.ReadAll(resp.Body)
  34787. if ioErr != nil {
  34788. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34790. return
  34791. }
  34792. var respJSON map[string]interface{}
  34793. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34796. return
  34797. }
  34798. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34799. result, _ := json.Marshal(respJSON)
  34800. fmt.Println("log")
  34801. fmt.Println(string(result))
  34802. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34803. utils.ErrorLog("解析失败:%v", err)
  34804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34805. return
  34806. }
  34807. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34808. var api string
  34809. if miConfig.MdtrtareaAdmvs == "320921" {
  34810. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34811. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34812. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34813. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34814. } else {
  34815. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34816. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34817. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34818. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34819. }
  34820. resp, requestErr := http.Get(api)
  34821. if requestErr != nil {
  34822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34823. return
  34824. }
  34825. body, ioErr := ioutil.ReadAll(resp.Body)
  34826. if ioErr != nil {
  34827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34829. return
  34830. }
  34831. var respJSON map[string]interface{}
  34832. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34835. return
  34836. }
  34837. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34838. result, _ := json.Marshal(respJSON)
  34839. fmt.Println("log")
  34840. fmt.Println(string(result))
  34841. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34842. utils.ErrorLog("解析失败:%v", err)
  34843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34844. return
  34845. }
  34846. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34847. res.Output = resEleven10265.Output
  34848. res.ErrMsg = resEleven10265.ErrMsg
  34849. res.Cainfo = resEleven10265.Cainfo
  34850. res.WarnMsg = resEleven10265.WarnMsg
  34851. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34852. res.Infcode = infocode
  34853. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34854. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  34855. saveLog(result, requestLog, "5203", "结算单")
  34856. var dat map[string]interface{}
  34857. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34858. fmt.Println(dat)
  34859. } else {
  34860. fmt.Println(err)
  34861. }
  34862. userJSONBytes, _ := json.Marshal(dat)
  34863. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34864. utils.ErrorLog("解析失败:%v", err)
  34865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34866. return
  34867. }
  34868. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34869. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34870. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34871. saveLog(result, requestLog, "5203", "结算单")
  34872. var dat map[string]interface{}
  34873. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34874. fmt.Println(dat)
  34875. } else {
  34876. fmt.Println(err)
  34877. }
  34878. userJSONBytes, _ := json.Marshal(dat)
  34879. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34880. utils.ErrorLog("解析失败:%v", err)
  34881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34882. return
  34883. }
  34884. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34885. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34886. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34887. saveLog(result, requestLog, "5203", "结算单")
  34888. var dat map[string]interface{}
  34889. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34890. fmt.Println(dat)
  34891. } else {
  34892. fmt.Println(err)
  34893. }
  34894. userJSONBytes, _ := json.Marshal(dat)
  34895. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34896. utils.ErrorLog("解析失败:%v", err)
  34897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34898. return
  34899. }
  34900. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34901. var api string
  34902. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34903. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34904. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34905. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34906. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34907. resp, requestErr := http.Get(api)
  34908. if requestErr != nil {
  34909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34910. return
  34911. }
  34912. body, ioErr := ioutil.ReadAll(resp.Body)
  34913. if ioErr != nil {
  34914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34916. return
  34917. }
  34918. var respJSON map[string]interface{}
  34919. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34922. return
  34923. }
  34924. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34925. if status == "0" {
  34926. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34927. c.ServeSuccessJSON(map[string]interface{}{
  34928. "failed_code": -10,
  34929. "msg": err_msg,
  34930. })
  34931. return
  34932. }
  34933. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34934. result, _ := json.Marshal(respJSON)
  34935. fmt.Println("log")
  34936. fmt.Println(string(result))
  34937. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  34938. utils.ErrorLog("解析失败:%v", err)
  34939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34940. return
  34941. }
  34942. res.InfRefmsgid = resah.InfRefmsgid
  34943. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34944. // 创建对应的Time类型
  34945. t := time.UnixMilli(timestamp)
  34946. // 格式化成指定的日期字符串
  34947. str := t.Format("2006-01-02 15:04:05")
  34948. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34949. // 创建对应的Time类型
  34950. t3 := time.UnixMilli(timestamp2)
  34951. // 格式化成指定的日期字符串
  34952. str2 := t3.Format("2006-01-02 15:04:05")
  34953. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  34954. // 创建对应的Time类型
  34955. t4 := time.UnixMilli(timestamp3)
  34956. // 格式化成指定的日期字符串
  34957. str3 := t4.Format("2006-01-02 15:04:05")
  34958. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  34959. // 创建对应的Time类型
  34960. t5 := time.UnixMilli(timestamp4)
  34961. // 格式化成指定的日期字符串
  34962. str5 := t5.Format("2006-01-02 15:04:05")
  34963. res.Output.Setlinfo.Brdy = str2
  34964. res.Output.Setlinfo.SetlTime = str
  34965. res.Output.Setlinfo.Begndate = str3
  34966. res.Output.Setlinfo.Enddate = str5
  34967. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  34968. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  34969. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  34970. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  34971. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34972. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34973. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  34974. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  34975. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34976. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  34977. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  34978. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  34979. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  34980. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  34981. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  34982. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  34983. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  34984. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  34985. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34986. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  34987. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  34988. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34989. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  34990. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  34991. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  34992. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  34993. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  34994. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  34995. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  34996. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  34997. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  34998. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  34999. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35000. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35001. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35002. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35003. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35004. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35005. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35006. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35007. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35008. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35009. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35010. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35011. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35012. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35013. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35014. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35015. //res.Output.Setldetail = resah.Output.Setldetail
  35016. res.ErrMsg = resah.ErrMsg
  35017. res.Cainfo = resah.Cainfo
  35018. res.WarnMsg = resah.WarnMsg
  35019. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35020. var api string
  35021. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35022. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35023. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35024. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35025. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35026. resp, requestErr := http.Get(api)
  35027. if requestErr != nil {
  35028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35029. return
  35030. }
  35031. body, ioErr := ioutil.ReadAll(resp.Body)
  35032. if ioErr != nil {
  35033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35035. return
  35036. }
  35037. var respJSON map[string]interface{}
  35038. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35041. return
  35042. }
  35043. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35044. if status == "0" {
  35045. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35046. c.ServeSuccessJSON(map[string]interface{}{
  35047. "failed_code": -10,
  35048. "msg": err_msg,
  35049. })
  35050. return
  35051. }
  35052. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35053. result, _ := json.Marshal(respJSON)
  35054. fmt.Println("log")
  35055. fmt.Println(string(result))
  35056. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35057. utils.ErrorLog("解析失败:%v", err)
  35058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35059. return
  35060. }
  35061. res.InfRefmsgid = resah.InfRefmsgid
  35062. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35063. // 创建对应的Time类型
  35064. t := time.UnixMilli(timestamp)
  35065. // 格式化成指定的日期字符串
  35066. str := t.Format("2006-01-02 15:04:05")
  35067. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35068. // 创建对应的Time类型
  35069. t3 := time.UnixMilli(timestamp2)
  35070. // 格式化成指定的日期字符串
  35071. str2 := t3.Format("2006-01-02 15:04:05")
  35072. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35073. // 创建对应的Time类型
  35074. t4 := time.UnixMilli(timestamp3)
  35075. // 格式化成指定的日期字符串
  35076. str3 := t4.Format("2006-01-02 15:04:05")
  35077. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35078. // 创建对应的Time类型
  35079. t5 := time.UnixMilli(timestamp4)
  35080. // 格式化成指定的日期字符串
  35081. str5 := t5.Format("2006-01-02 15:04:05")
  35082. res.Output.Setlinfo.Brdy = str2
  35083. res.Output.Setlinfo.SetlTime = str
  35084. res.Output.Setlinfo.Begndate = str3
  35085. res.Output.Setlinfo.Enddate = str5
  35086. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35087. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35088. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35089. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35090. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35091. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35092. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35093. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35094. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35095. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35096. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35097. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35098. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35099. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35100. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35101. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35102. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35103. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35104. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35105. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35106. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35107. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35108. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35109. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35110. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35111. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35112. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35113. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35114. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35115. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35116. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35117. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35118. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35119. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35120. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35121. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35122. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35123. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35124. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35125. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35126. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35127. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35128. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35129. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35130. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35131. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35132. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35133. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35134. //res.Output.Setldetail = resah.Output.Setldetail
  35135. res.ErrMsg = resah.ErrMsg
  35136. res.Cainfo = resah.Cainfo
  35137. res.WarnMsg = resah.WarnMsg
  35138. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35139. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  35140. saveLog(result, requestLog, "5203", "结算单")
  35141. var dat map[string]interface{}
  35142. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35143. fmt.Println(dat)
  35144. } else {
  35145. fmt.Println(err)
  35146. }
  35147. userJSONBytes, _ := json.Marshal(dat)
  35148. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35149. utils.ErrorLog("解析失败:%v", err)
  35150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35151. return
  35152. }
  35153. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35154. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35155. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35156. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35157. resp, requestErr := http.Get(api)
  35158. if requestErr != nil {
  35159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35160. return
  35161. }
  35162. body, ioErr := ioutil.ReadAll(resp.Body)
  35163. if ioErr != nil {
  35164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35166. return
  35167. }
  35168. var respJSON map[string]interface{}
  35169. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35172. return
  35173. }
  35174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35175. result, _ := json.Marshal(respJSON)
  35176. fmt.Println("log")
  35177. fmt.Println(string(result))
  35178. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  35179. utils.ErrorLog("解析失败:%v", err)
  35180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35181. return
  35182. }
  35183. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35184. res.Output = resEleven10265.Output
  35185. res.ErrMsg = resEleven10265.ErrMsg
  35186. res.Cainfo = resEleven10265.Cainfo
  35187. res.WarnMsg = resEleven10265.WarnMsg
  35188. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35189. res.Infcode = infocode
  35190. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35191. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35192. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35193. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35194. resp, requestErr := http.Get(api)
  35195. if requestErr != nil {
  35196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35197. return
  35198. }
  35199. body, ioErr := ioutil.ReadAll(resp.Body)
  35200. if ioErr != nil {
  35201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35203. return
  35204. }
  35205. var respJSON map[string]interface{}
  35206. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35209. return
  35210. }
  35211. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35212. result, _ := json.Marshal(respJSON)
  35213. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35214. utils.ErrorLog("解析失败:%v", err)
  35215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35216. return
  35217. }
  35218. } else if miConfig.MdtrtareaAdmvs == "450721" {
  35219. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  35220. //return
  35221. } else {
  35222. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35223. if len(his.InsuplcAdmdvs) == 0 {
  35224. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35225. } else {
  35226. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35227. }
  35228. result := service.Gdyb5203(baseParams, businessParams)
  35229. //service.Gdyb5204(baseParams, businessParams)
  35230. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35231. var dat map[string]interface{}
  35232. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35233. fmt.Println(dat)
  35234. } else {
  35235. fmt.Println(err)
  35236. }
  35237. userJSONBytes, _ := json.Marshal(dat)
  35238. if miConfig.Code == "H15049901371" {
  35239. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  35240. utils.ErrorLog("解析失败:%v", err)
  35241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35242. return
  35243. }
  35244. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35245. res.Output = resEleven10265.Output
  35246. res.ErrMsg = resEleven10265.ErrMsg
  35247. res.Cainfo = resEleven10265.Cainfo
  35248. res.WarnMsg = resEleven10265.WarnMsg
  35249. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35250. res.Infcode = infocode
  35251. } else {
  35252. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35253. utils.ErrorLog("解析失败:%v", err)
  35254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35255. return
  35256. }
  35257. }
  35258. }
  35259. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35260. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  35261. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  35262. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  35263. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  35264. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35265. var doctor_name string
  35266. if roles.ID == 0 {
  35267. doctor_name = "管理员"
  35268. } else {
  35269. doctor_name = roles.UserName
  35270. }
  35271. yiliao_leibie := ""
  35272. switch order.MedType {
  35273. case "11":
  35274. yiliao_leibie = "普通门诊"
  35275. break
  35276. case "12":
  35277. yiliao_leibie = "门诊挂号"
  35278. break
  35279. case "13":
  35280. yiliao_leibie = "急诊"
  35281. break
  35282. case "14":
  35283. yiliao_leibie = "门诊特殊病"
  35284. break
  35285. case "15":
  35286. yiliao_leibie = "门诊统筹"
  35287. break
  35288. case "16":
  35289. yiliao_leibie = "门诊慢性病"
  35290. break
  35291. case "21":
  35292. yiliao_leibie = "普通住院"
  35293. break
  35294. }
  35295. //var rf []CustomFundPay
  35296. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  35297. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35298. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  35299. if res.Infcode == 0 {
  35300. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10454 || adminUser.CurrentOrgId == 10644 || adminUser.CurrentOrgId == 10653 || adminUser.CurrentOrgId == 10210 {
  35301. c.ServeSuccessJSON(map[string]interface{}{
  35302. "diagnosis": name,
  35303. "order_infos": orderInfos,
  35304. "number": order.MdtrtId,
  35305. "date": order.SettleAccountsDate,
  35306. "charge_admin": charge_admin,
  35307. "printor_admin": printor_admin,
  35308. "info": res.Output.Setlinfo,
  35309. "order": order,
  35310. "bedCostTotal": bedCostTotal,
  35311. "bedCostSelfTotal": bedCostSelfTotal,
  35312. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35313. "bedSelfTotal": bedSelfTotal,
  35314. "bedInscpTotal": bedInscpTotal,
  35315. "operationCostTotal": operationCostTotal,
  35316. "operationCostSelfTotal": operationCostSelfTotal,
  35317. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35318. "operationSelfTotal": operationSelfTotal,
  35319. "operationInscpTotal": operationInscpTotal,
  35320. "otherCostTotal": otherCostTotal,
  35321. "otherCostSelfTotal": otherCostSelfTotal,
  35322. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35323. "otherSelfTotal": otherSelfTotal,
  35324. "otherInscpTotal": otherInscpTotal,
  35325. "materialCostTotal": materialCostTotal,
  35326. "materialCostSelfTotal": materialCostSelfTotal,
  35327. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35328. "materialSelfTotal": materialSelfTotal,
  35329. "materialInscpTotal": materialInscpTotal,
  35330. "westernMedicineCostTotal": westernMedicineCostTotal,
  35331. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35332. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35333. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35334. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35335. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35336. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35337. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35338. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35339. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35340. "checkCostTotal": checkCostTotal,
  35341. "checkCostSelfTotal": checkCostSelfTotal,
  35342. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35343. "checkSelfTotal": checkSelfTotal,
  35344. "checkInscpTotal": checkInscpTotal,
  35345. "laboratoryCostTotal": laboratoryCostTotal,
  35346. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35347. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35348. "laboratorySelfTotal": laboratorySelfTotal,
  35349. "laboratoryInscpTotal": laboratoryInscpTotal,
  35350. "treatCostTotal": treatCostTotal,
  35351. "treatCostSelfTotal": treatCostSelfTotal,
  35352. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35353. "treatSelfTotal": treatSelfTotal,
  35354. "treatInscpTotal": treatInscpTotal,
  35355. "doctor_info": doctor_info,
  35356. "doctor_code": adminRole_two.DoctorCode,
  35357. "doctor_name": doctor_name,
  35358. "health_card_no": order.PsnNo,
  35359. "department": departments.Name,
  35360. "yiliao_leibie": yiliao_leibie,
  35361. "after_money": order.AccountPrice,
  35362. "patient": patient,
  35363. "org_name": miConfig.OrgName,
  35364. "org_code": miConfig.Code,
  35365. "order_number": order.Number,
  35366. "his_hospital": his_hospital,
  35367. "his": his,
  35368. "dia_config": dia_config,
  35369. "psn_cash_pay": order.PsnCashPay,
  35370. "zcCostTotal": zcCostTotal,
  35371. "zcCostSelfTotal": zcCostSelfTotal,
  35372. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35373. "zcSelfTotal": zcSelfTotal,
  35374. "zcInscpTotal": zcInscpTotal,
  35375. "huliCostTotal": huliCostTotal,
  35376. "huliCostSelfTotal": huliCostSelfTotal,
  35377. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35378. "huliSelfTotal": huliSelfTotal,
  35379. "huliInscpTotal": huliInscpTotal,
  35380. //"funds": rf,
  35381. //"check_order_info": cus_slice,
  35382. })
  35383. } else {
  35384. c.ServeSuccessJSON(map[string]interface{}{
  35385. "diagnosis": name,
  35386. "order_infos": orderInfos,
  35387. "number": order.MdtrtId,
  35388. "date": order.SettleAccountsDate,
  35389. "charge_admin": charge_admin,
  35390. "printor_admin": printor_admin,
  35391. "info": order,
  35392. "order": order,
  35393. "bedCostTotal": bedCostTotal,
  35394. "bedCostSelfTotal": bedCostSelfTotal,
  35395. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35396. "bedSelfTotal": bedSelfTotal,
  35397. "bedInscpTotal": bedInscpTotal,
  35398. "operationCostTotal": operationCostTotal,
  35399. "operationCostSelfTotal": operationCostSelfTotal,
  35400. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35401. "operationSelfTotal": operationSelfTotal,
  35402. "operationInscpTotal": operationInscpTotal,
  35403. "otherCostTotal": otherCostTotal,
  35404. "otherCostSelfTotal": otherCostSelfTotal,
  35405. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35406. "otherSelfTotal": otherSelfTotal,
  35407. "otherInscpTotal": otherInscpTotal,
  35408. "materialCostTotal": materialCostTotal,
  35409. "materialCostSelfTotal": materialCostSelfTotal,
  35410. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35411. "materialSelfTotal": materialSelfTotal,
  35412. "materialInscpTotal": materialInscpTotal,
  35413. "westernMedicineCostTotal": westernMedicineCostTotal,
  35414. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35415. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35416. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35417. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35418. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35419. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35420. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35421. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35422. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35423. "checkCostTotal": checkCostTotal,
  35424. "checkCostSelfTotal": checkCostSelfTotal,
  35425. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35426. "checkSelfTotal": checkSelfTotal,
  35427. "checkInscpTotal": checkInscpTotal,
  35428. "laboratoryCostTotal": laboratoryCostTotal,
  35429. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35430. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35431. "laboratorySelfTotal": laboratorySelfTotal,
  35432. "laboratoryInscpTotal": laboratoryInscpTotal,
  35433. "treatCostTotal": treatCostTotal,
  35434. "treatCostSelfTotal": treatCostSelfTotal,
  35435. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35436. "treatSelfTotal": treatSelfTotal,
  35437. "treatInscpTotal": treatInscpTotal,
  35438. "doctor_info": doctor_info,
  35439. "doctor_code": adminRole_two.DoctorCode,
  35440. "doctor_name": doctor_name,
  35441. "health_card_no": order.PsnNo,
  35442. "department": departments.Name,
  35443. "yiliao_leibie": yiliao_leibie,
  35444. "after_money": order.AccountPrice,
  35445. "patient": patient,
  35446. "org_name": miConfig.OrgName,
  35447. "org_code": miConfig.Code,
  35448. "order_number": order.Number,
  35449. "his_hospital": his_hospital,
  35450. "his": his,
  35451. "dia_config": dia_config,
  35452. "psn_cash_pay": order.PsnCashPay,
  35453. "zcCostTotal": zcCostTotal,
  35454. "zcCostSelfTotal": zcCostSelfTotal,
  35455. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35456. "zcSelfTotal": zcSelfTotal,
  35457. "zcInscpTotal": zcInscpTotal,
  35458. "huliCostTotal": huliCostTotal,
  35459. "huliCostSelfTotal": huliCostSelfTotal,
  35460. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35461. "huliSelfTotal": huliSelfTotal,
  35462. "huliInscpTotal": huliInscpTotal,
  35463. //"funds": rf,
  35464. //"check_order_info": cus_slice,
  35465. })
  35466. }
  35467. }
  35468. }
  35469. }
  35470. //func (c *HisApiController) CheckTreatment() {
  35471. // patient_id, _ := c.GetInt64("patient_id")
  35472. // id_card_no := c.GetString("id_card_no")
  35473. // insutype := c.GetString("insutype")
  35474. // med_type := c.GetString("med_type")
  35475. // admin_user_id, _ := c.GetInt64("admin_user_id")
  35476. //
  35477. // adminUser := c.GetAdminUserInfo()
  35478. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35479. //
  35480. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35481. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35482. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35483. //
  35484. // if miConfig.MdtrtareaAdmvs == "421300" {
  35485. // var res ResultTwo
  35486. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  35487. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35488. // "&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)
  35489. // resp, requestErr := http.Get(api)
  35490. // if requestErr != nil {
  35491. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35492. // return
  35493. // }
  35494. //
  35495. // body, ioErr := ioutil.ReadAll(resp.Body)
  35496. // if ioErr != nil {
  35497. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35498. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35499. // return
  35500. // }
  35501. // var respJSON map[string]interface{}
  35502. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35503. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35504. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35505. // return
  35506. // }
  35507. //
  35508. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35509. // result, _ := json.Marshal(respJSON)
  35510. //
  35511. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35512. // utils.ErrorLog("解析失败:%v", err)
  35513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35514. // return
  35515. // }
  35516. //
  35517. // if res.Infcode == 0 {
  35518. //
  35519. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  35520. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35521. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  35522. // resp, requestErr := http.Get(api)
  35523. // if requestErr != nil {
  35524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35525. // return
  35526. // }
  35527. //
  35528. // body, ioErr := ioutil.ReadAll(resp.Body)
  35529. // if ioErr != nil {
  35530. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35531. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35532. // return
  35533. // }
  35534. // var respJSON map[string]interface{}
  35535. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35536. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35537. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35538. // return
  35539. // }
  35540. // var res Result2001
  35541. //
  35542. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35543. // result2, _ := json.Marshal(respJSON)
  35544. //
  35545. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  35546. // utils.ErrorLog("解析失败:%v", err)
  35547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35548. // return
  35549. // }
  35550. //
  35551. // if res.Infcode == 0 {
  35552. // c.ServeSuccessJSON(map[string]interface{}{
  35553. // "msg": res.Output.Trtinfo,
  35554. // })
  35555. // }
  35556. //
  35557. // } else {
  35558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35559. // return
  35560. // }
  35561. //
  35562. // } else {
  35563. //
  35564. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35565. // var dat map[string]interface{}
  35566. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35567. // fmt.Println(dat)
  35568. // } else {
  35569. // fmt.Println(err)
  35570. // }
  35571. // userJSONBytes, _ := json.Marshal(dat)
  35572. // var res ResultTwo
  35573. // var res10265 ResultTwo10265
  35574. // if miConfig.Code == "H15049901371" {
  35575. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35576. // utils.ErrorLog("解析失败:%v", err)
  35577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35578. // return
  35579. // }
  35580. // res.ErrMsg = res10265.ErrMsg
  35581. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35582. // res.Infcode = infocode
  35583. // res.Output = res10265.Output
  35584. // res.InfRefmsgid = res10265.InfRefmsgid
  35585. // } else {
  35586. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35587. // utils.ErrorLog("解析失败:%v", err)
  35588. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35589. // return
  35590. // }
  35591. // }
  35592. //
  35593. // var user_name string
  35594. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  35595. // if role.ID == 0 {
  35596. // user_name = "xxx"
  35597. // } else {
  35598. // user_name = role.UserName
  35599. // }
  35600. //
  35601. // baseParams := models.BaseParams{
  35602. // SecretKey: miConfig.SecretKey,
  35603. // FixmedinsCode: miConfig.Code,
  35604. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35605. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35606. // OrgName: miConfig.OrgName,
  35607. // Doctor: user_name,
  35608. // }
  35609. //
  35610. // if config.IsOpen == 1 {
  35611. // if miConfig.Code == "H15049901371" {
  35612. // if med_type == "14" {
  35613. // if insutype == "390" {
  35614. // med_type = "9933"
  35615. // } else if insutype == "310" {
  35616. // med_type = "990502"
  35617. // }
  35618. // } else if med_type == "11" {
  35619. // med_type = "11"
  35620. // }
  35621. // }
  35622. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  35623. // var dat map[string]interface{}
  35624. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35625. // fmt.Println(dat)
  35626. // } else {
  35627. // fmt.Println(err)
  35628. // }
  35629. // var res Result2001
  35630. // var res10265 Result2001Org10265
  35631. // if miConfig.Code == "H15049901371" {
  35632. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35633. // utils.ErrorLog("解析失败:%v", err)
  35634. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35635. // return
  35636. // }
  35637. // res.ErrMsg = res10265.ErrMsg
  35638. // res.Output = res10265.Output
  35639. // res.InfRefmsgid = res10265.InfRefmsgid
  35640. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35641. // res.Infcode = infocode
  35642. // } else {
  35643. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35644. // utils.ErrorLog("解析失败:%v", err)
  35645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35646. // return
  35647. // }
  35648. // }
  35649. // if res.Infcode == 0 {
  35650. // c.ServeSuccessJSON(map[string]interface{}{
  35651. // "msg": res.Output.Trtinfo,
  35652. // })
  35653. // }
  35654. // }
  35655. // }
  35656. //}
  35657. //func (c *HisApiController) PutRecord() {
  35658. // id, _ := c.GetInt64("id")
  35659. // record_time := c.GetString("record_time")
  35660. // timeLayout := "2006-01-02"
  35661. // loc, _ := time.LoadLocation("Local")
  35662. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35663. // if err != nil {
  35664. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35665. // return
  35666. // }
  35667. // recordDateTime := theTime.Unix()
  35668. //
  35669. // adminInfo := c.GetAdminUserInfo()
  35670. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  35671. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35672. //
  35673. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35674. //
  35675. // fmt.Println(miConfig.SecretKey)
  35676. //
  35677. // if patient == nil {
  35678. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35679. // return
  35680. // }
  35681. // if len(patient.IdCardNo) == 0 {
  35682. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  35683. // return
  35684. // }
  35685. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  35686. // if config.IsOpen == 1 {
  35687. // 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
  35688. // resp, requestErr := http.Get(api)
  35689. // if requestErr != nil {
  35690. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35691. // return
  35692. // }
  35693. // defer resp.Body.Close()
  35694. // body, ioErr := ioutil.ReadAll(resp.Body)
  35695. // if ioErr != nil {
  35696. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35697. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35698. // return
  35699. // }
  35700. // var respJSON map[string]interface{}
  35701. //
  35702. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35703. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35704. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35705. // return
  35706. // }
  35707. //
  35708. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35709. // userJSONBytes, _ := json.Marshal(userJSON)
  35710. // var res ResultTwo
  35711. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35712. // utils.ErrorLog("解析失败:%v", err)
  35713. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35714. // return
  35715. // }
  35716. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35717. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35718. // infoStr := string(Iinfos)
  35719. // idetinfoStr := string(Idetinfos)
  35720. //
  35721. // if res.Infcode == 0 {
  35722. // his := models.VMHisPatient{
  35723. // Status: 1,
  35724. // Ctime: time.Now().Unix(),
  35725. // Mtime: time.Now().Unix(),
  35726. // PsnNo: res.Output.Baseinfo.PsnNo,
  35727. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  35728. // Certno: res.Output.Baseinfo.Certno,
  35729. // PsnName: res.Output.Baseinfo.PsnName,
  35730. // Gend: res.Output.Baseinfo.Gend,
  35731. // Naty: res.Output.Baseinfo.Naty,
  35732. // Brdy: res.Output.Baseinfo.Brdy,
  35733. // Age: res.Output.Baseinfo.Age,
  35734. // Iinfo: infoStr,
  35735. // Idetinfo: idetinfoStr,
  35736. // PatientId: patient.ID,
  35737. // RecordDate: theTime.Unix(),
  35738. // UserOrgId: adminInfo.CurrentOrgId,
  35739. // AdminUserId: adminInfo.AdminUser.Id,
  35740. // IsReturn: 1,
  35741. // }
  35742. //
  35743. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  35744. // //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")
  35745. // //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")
  35746. //
  35747. // //var dat map[string]interface{}
  35748. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35749. // // fmt.Println(dat)
  35750. // //} else {
  35751. // // fmt.Println(err)
  35752. // //}
  35753. //
  35754. // var dat2 map[string]interface{}
  35755. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35756. // fmt.Println(dat2)
  35757. // } else {
  35758. // fmt.Println(err)
  35759. // }
  35760. //
  35761. // } else {
  35762. // adminUser := c.GetAdminUserInfo()
  35763. // errlog := &models.HisOrderError{
  35764. // UserOrgId: adminUser.CurrentOrgId,
  35765. // Ctime: time.Now().Unix(),
  35766. // Mtime: time.Now().Unix(),
  35767. // ErrMsg: res.ErrMsg,
  35768. // Status: 1,
  35769. // PatientId: id,
  35770. // RecordTime: recordDateTime,
  35771. // Stage: 1,
  35772. // }
  35773. // service.CreateErrMsgLog(errlog)
  35774. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  35775. // return
  35776. // }
  35777. // }
  35778. //
  35779. //}
  35780. //func (c *HisApiController) GetUploadDiag() {
  35781. // id, _ := c.GetInt64("id")
  35782. // record_time := c.GetString("record_time")
  35783. //
  35784. // diagnosis_id, _ := c.GetInt64("diagnosis")
  35785. // sick_type, _ := c.GetInt64("sick_type")
  35786. // reg_type, _ := c.GetInt64("reg_type")
  35787. //
  35788. // timeLayout := "2006-01-02"
  35789. // loc, _ := time.LoadLocation("Local")
  35790. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35791. // if err != nil {
  35792. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35793. // return
  35794. // }
  35795. //
  35796. // var patientPrescription models.HisPrescriptionInfo
  35797. // recordDateTime := theTime.Unix()
  35798. // adminInfo := c.GetAdminUserInfo()
  35799. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35800. //
  35801. // if patientPrescription.ID == 0 {
  35802. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35803. // }
  35804. //
  35805. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35806. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  35807. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35808. // sickConfig, _ := service.FindSickById(sick_type)
  35809. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35810. //
  35811. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  35812. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  35813. // "&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 +
  35814. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  35815. // resp2, requestErr2 := http.Get(api2)
  35816. // if requestErr2 != nil {
  35817. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35818. // return
  35819. // }
  35820. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35821. // if ioErr2 != nil {
  35822. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35823. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35824. // return
  35825. // }
  35826. // var respJSON2 map[string]interface{}
  35827. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35828. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35829. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35830. // return
  35831. // }
  35832. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35833. // userJSONBytes2, _ := json.Marshal(respJSON2)
  35834. //
  35835. // var res2 ResultSix
  35836. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35837. // utils.ErrorLog("解析失败:%v", err)
  35838. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35839. // return
  35840. // }
  35841. // if res2.Infcode != 0 {
  35842. // adminUser := c.GetAdminUserInfo()
  35843. // errlog := &models.HisOrderError{
  35844. // UserOrgId: adminUser.CurrentOrgId,
  35845. // Ctime: time.Now().Unix(),
  35846. // Mtime: time.Now().Unix(),
  35847. // ErrMsg: res2.ErrMsg,
  35848. // Status: 1,
  35849. // PatientId: id,
  35850. // RecordTime: recordDateTime,
  35851. // Stage: 3,
  35852. // }
  35853. // service.CreateErrMsgLog(errlog)
  35854. //
  35855. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  35856. // return
  35857. // }
  35858. //
  35859. // c.ServeSuccessJSON(map[string]interface{}{
  35860. // "msg": "上传成功",
  35861. // })
  35862. //
  35863. //}
  35864. type QueryResult struct {
  35865. ID int64
  35866. Name string
  35867. Code string
  35868. List_type_code string
  35869. }
  35870. func (c *HisApiController) GetCheckCode() {
  35871. ids_str := c.GetString("ids")
  35872. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35873. ids_arr := strings.Split(ids_str, ",")
  35874. var queryResult []QueryResult
  35875. ids := make([]int64, 0)
  35876. for _, item := range ids_arr {
  35877. id, _ := strconv.ParseInt(item, 10, 64)
  35878. ids = append(ids, id)
  35879. }
  35880. if record_type == 1 {
  35881. drugs, _ := service.GetBatchDrugList(ids)
  35882. for _, item := range drugs {
  35883. result := QueryResult{
  35884. ID: item.ID,
  35885. Name: item.DrugName,
  35886. Code: item.MedicalInsuranceNumber,
  35887. List_type_code: "101",
  35888. }
  35889. queryResult = append(queryResult, result)
  35890. }
  35891. } else if record_type == 2 {
  35892. goods, _ := service.GetBatchGoodInformationList(ids)
  35893. fmt.Println(goods)
  35894. for _, item := range goods {
  35895. result := QueryResult{
  35896. ID: item.ID,
  35897. Name: item.GoodName,
  35898. Code: item.SocialSecurityDirectoryCode,
  35899. List_type_code: "301",
  35900. }
  35901. queryResult = append(queryResult, result)
  35902. }
  35903. } else if record_type == 3 {
  35904. projects, _ := service.GetBathchMyPorjecgList(ids)
  35905. for _, item := range projects {
  35906. result := QueryResult{
  35907. ID: item.ID,
  35908. Name: item.ProjectName,
  35909. Code: item.MedicalCode,
  35910. List_type_code: "201",
  35911. }
  35912. queryResult = append(queryResult, result)
  35913. }
  35914. }
  35915. admin_user_id, _ := c.GetInt64("admin_user_id")
  35916. adminUser := c.GetAdminUserInfo()
  35917. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35918. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35919. var user_name string
  35920. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35921. if role.ID == 0 {
  35922. user_name = "管理员"
  35923. } else {
  35924. user_name = role.UserName
  35925. }
  35926. baseParams := models.BaseParams{
  35927. SecretKey: miConfig.SecretKey,
  35928. FixmedinsCode: miConfig.Code,
  35929. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35930. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35931. OrgName: miConfig.OrgName,
  35932. Doctor: user_name,
  35933. }
  35934. var result string
  35935. if miConfig.MdtrtareaAdmvs == "430800" {
  35936. for _, item := range queryResult {
  35937. if record_type == 1 {
  35938. 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)
  35939. } else if record_type == 2 {
  35940. fmt.Println(item.Code)
  35941. 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)
  35942. } else if record_type == 3 {
  35943. 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)
  35944. }
  35945. var dat map[string]interface{}
  35946. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35947. fmt.Println(dat)
  35948. } else {
  35949. fmt.Println(err)
  35950. }
  35951. userJSONBytes, _ := json.Marshal(dat)
  35952. var res ResultSix
  35953. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35954. utils.ErrorLog("解析失败:%v", err)
  35955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35956. return
  35957. }
  35958. if res.Infcode == 0 {
  35959. if record_type == 1 {
  35960. service.UpdateBaseDrugById(item.ID)
  35961. } else if record_type == 2 {
  35962. service.UpdateGoodInformaitonByDetail(item.ID)
  35963. } else if record_type == 3 {
  35964. service.UpdateProjectById(item.ID)
  35965. }
  35966. c.ServeSuccessJSON(map[string]interface{}{
  35967. "failed_code": 0,
  35968. "msg": "目录对照成功",
  35969. })
  35970. } else {
  35971. c.ServeSuccessJSON(map[string]interface{}{
  35972. "failed_code": -10,
  35973. "msg": res.ErrMsg,
  35974. })
  35975. }
  35976. }
  35977. } else {
  35978. for _, item := range queryResult {
  35979. var result string
  35980. if record_type == 1 {
  35981. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35982. } else if record_type == 2 {
  35983. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35984. } else if record_type == 3 {
  35985. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35986. }
  35987. var dat map[string]interface{}
  35988. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35989. fmt.Println(dat)
  35990. } else {
  35991. fmt.Println(err)
  35992. }
  35993. userJSONBytes, _ := json.Marshal(dat)
  35994. var res ResultSix
  35995. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35996. utils.ErrorLog("解析失败:%v", err)
  35997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35998. return
  35999. }
  36000. if res.Infcode == 0 {
  36001. if record_type == 1 {
  36002. service.UpdateBaseDrugById(item.ID)
  36003. } else if record_type == 2 {
  36004. service.UpdateGoodInformaitonByDetail(item.ID)
  36005. } else if record_type == 3 {
  36006. service.UpdateProjectById(item.ID)
  36007. }
  36008. c.ServeSuccessJSON(map[string]interface{}{
  36009. "failed_code": 0,
  36010. "msg": "目录对照成功",
  36011. })
  36012. } else {
  36013. c.ServeSuccessJSON(map[string]interface{}{
  36014. "failed_code": -10,
  36015. "msg": res.ErrMsg,
  36016. })
  36017. }
  36018. }
  36019. }
  36020. }
  36021. func (c *HisApiController) UnCheckCode() {
  36022. ids_str := c.GetString("ids")
  36023. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  36024. admin_user_id, _ := c.GetInt64("admin_user_id")
  36025. ids_arr := strings.Split(ids_str, ",")
  36026. var queryResult []QueryResult
  36027. ids := make([]int64, 0)
  36028. for _, item := range ids_arr {
  36029. id, _ := strconv.ParseInt(item, 10, 64)
  36030. ids = append(ids, id)
  36031. }
  36032. if record_type == 1 {
  36033. drugs, _ := service.GetBatchDrugList(ids)
  36034. for _, item := range drugs {
  36035. result := QueryResult{
  36036. ID: item.ID,
  36037. Name: item.DrugName,
  36038. Code: item.MedicalInsuranceNumber,
  36039. List_type_code: "101",
  36040. }
  36041. queryResult = append(queryResult, result)
  36042. }
  36043. } else if record_type == 2 {
  36044. goods, _ := service.GetBatchGoodInformationList(ids)
  36045. for _, item := range goods {
  36046. result := QueryResult{
  36047. ID: item.ID,
  36048. Name: item.GoodName,
  36049. Code: item.SocialSecurityDirectoryCode,
  36050. List_type_code: "301",
  36051. }
  36052. queryResult = append(queryResult, result)
  36053. }
  36054. } else if record_type == 3 {
  36055. projects, _ := service.GetBathchMyPorjecgList(ids)
  36056. for _, item := range projects {
  36057. result := QueryResult{
  36058. ID: item.ID,
  36059. Name: item.ProjectName,
  36060. Code: item.MedicalCode,
  36061. List_type_code: "201",
  36062. }
  36063. queryResult = append(queryResult, result)
  36064. }
  36065. }
  36066. adminUser := c.GetAdminUserInfo()
  36067. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36068. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36069. var user_name string
  36070. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36071. if role.ID == 0 {
  36072. user_name = "xxx"
  36073. } else {
  36074. user_name = role.UserName
  36075. }
  36076. baseParams := &models.BaseParams{
  36077. SecretKey: miConfig.SecretKey,
  36078. FixmedinsCode: miConfig.Code,
  36079. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36080. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36081. OrgName: miConfig.OrgName,
  36082. Doctor: user_name,
  36083. }
  36084. if config.IsOpen == 1 {
  36085. if miConfig.MdtrtareaAdmvs == "430800" {
  36086. for _, item := range queryResult {
  36087. var result string
  36088. if record_type == 1 {
  36089. 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)
  36090. } else if record_type == 2 {
  36091. fmt.Println(item.Code)
  36092. 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)
  36093. } else if record_type == 3 {
  36094. 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)
  36095. }
  36096. var dat map[string]interface{}
  36097. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36098. fmt.Println(dat)
  36099. } else {
  36100. fmt.Println(err)
  36101. }
  36102. userJSONBytes, _ := json.Marshal(dat)
  36103. var res ResultSix
  36104. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36105. utils.ErrorLog("解析失败:%v", err)
  36106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36107. return
  36108. }
  36109. if res.Infcode == 0 {
  36110. if record_type == 1 {
  36111. service.UpdateBaseDrugById(item.ID)
  36112. } else if record_type == 2 {
  36113. service.UpdateGoodInformaitonByDetail(item.ID)
  36114. } else if record_type == 3 {
  36115. service.UpdateProjectById(item.ID)
  36116. }
  36117. c.ServeSuccessJSON(map[string]interface{}{
  36118. "failed_code": 0,
  36119. "msg": "目录对照成功",
  36120. })
  36121. } else {
  36122. c.ServeSuccessJSON(map[string]interface{}{
  36123. "failed_code": -10,
  36124. "msg": res.ErrMsg,
  36125. })
  36126. }
  36127. }
  36128. } else {
  36129. for _, item := range queryResult {
  36130. var result string
  36131. if record_type == 1 {
  36132. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36133. } else if record_type == 2 {
  36134. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36135. } else if record_type == 3 {
  36136. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36137. }
  36138. var dat2 map[string]interface{}
  36139. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36140. fmt.Println(dat2)
  36141. } else {
  36142. fmt.Println(err)
  36143. }
  36144. userJSONBytes, _ := json.Marshal(dat2)
  36145. var res ResultSix
  36146. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36147. utils.ErrorLog("解析失败:%v", err)
  36148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36149. return
  36150. }
  36151. if res.Infcode == 0 {
  36152. if record_type == 1 {
  36153. service.UpdateDrugByIdDetail(item.ID)
  36154. } else if record_type == 2 {
  36155. service.UpdateGoodInfoById(item.ID)
  36156. } else if record_type == 3 {
  36157. service.UpdateMyProjectById(item.ID)
  36158. }
  36159. c.ServeSuccessJSON(map[string]interface{}{
  36160. "failed_code": 0,
  36161. "msg": "撤销目录对照成功",
  36162. })
  36163. } else {
  36164. c.ServeSuccessJSON(map[string]interface{}{
  36165. "failed_code": -10,
  36166. "msg": res.ErrMsg,
  36167. })
  36168. }
  36169. }
  36170. }
  36171. }
  36172. }
  36173. func (c *HisApiController) GetPatientInfo() {
  36174. id_card_no := c.GetString("id_card_no")
  36175. admin_user_id, _ := c.GetInt64("admin_user_id")
  36176. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  36177. if patient.ID == 0 {
  36178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  36179. return
  36180. }
  36181. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  36182. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  36183. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  36184. var res ResultTwo
  36185. var res10265 ResultTwo10265
  36186. if config.IsOpen == 1 {
  36187. if miConfig.MdtrtareaAdmvs == "150499" {
  36188. //请求内网数据
  36189. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  36190. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36191. "&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
  36192. resp, requestErr := http.Get(api)
  36193. if requestErr != nil {
  36194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36195. return
  36196. }
  36197. body, ioErr := ioutil.ReadAll(resp.Body)
  36198. if ioErr != nil {
  36199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36201. return
  36202. }
  36203. var respJSON map[string]interface{}
  36204. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36207. return
  36208. }
  36209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36210. result_byte, _ := json.Marshal(respJSON)
  36211. result := string(result_byte)
  36212. var dat map[string]interface{}
  36213. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36214. fmt.Println(dat)
  36215. } else {
  36216. fmt.Println(err)
  36217. }
  36218. userJSONBytes, _ := json.Marshal(dat)
  36219. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36220. utils.ErrorLog("解析失败:%v", err)
  36221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36222. return
  36223. }
  36224. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36225. res.Infcode = Infcode
  36226. res.ErrMsg = res10265.ErrMsg
  36227. res.Output = res10265.Output
  36228. res.InfRefmsgid = res10265.InfRefmsgid
  36229. res.RespondTime = res10265.RespondTime
  36230. res.WarnInfo = res10265.WarnInfo
  36231. } else {
  36232. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  36233. var dat map[string]interface{}
  36234. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36235. fmt.Println(dat)
  36236. } else {
  36237. fmt.Println(err)
  36238. }
  36239. userJSONBytes, _ := json.Marshal(dat)
  36240. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36241. utils.ErrorLog("解析失败:%v", err)
  36242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36243. return
  36244. }
  36245. }
  36246. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36247. // utils.ErrorLog("解析失败:%v", err)
  36248. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36249. // return
  36250. //}
  36251. for index, item := range res.Output.Iinfo {
  36252. if item.PsnInsuStas == "2" {
  36253. fmt.Println("--------")
  36254. res.Output.Iinfo[index].Insutype = "300"
  36255. res.Output.Iinfo[index].PsnInsuStas = "1"
  36256. }
  36257. }
  36258. fmt.Println(res.Output.Iinfo)
  36259. if res.Infcode != 0 {
  36260. c.ServeSuccessJSON(map[string]interface{}{
  36261. "failed_code": -10,
  36262. "msg": res.ErrMsg,
  36263. })
  36264. } else {
  36265. c.ServeSuccessJSON(map[string]interface{}{
  36266. "failed_code": 0,
  36267. "info": res,
  36268. })
  36269. }
  36270. }
  36271. }
  36272. func (c *HisApiController) PsnPutOnRecord() {
  36273. record_type, _ := c.GetInt64("type")
  36274. patient_id, _ := c.GetInt64("patient_id")
  36275. admin_user_id, _ := c.GetInt64("admin_user_id")
  36276. start_time := c.GetString("start_time")
  36277. end_time := c.GetString("end_time")
  36278. adminUser := c.GetAdminUserInfo()
  36279. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36280. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36281. var patients []*models.Patients
  36282. if record_type == 1 { //全部备案
  36283. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  36284. patients = append(patients, patient...)
  36285. } else { //单个备案
  36286. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36287. patients = append(patients, patient)
  36288. }
  36289. var user_name string
  36290. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36291. if role.ID == 0 {
  36292. user_name = "xxx"
  36293. } else {
  36294. user_name = role.UserName
  36295. }
  36296. if config.IsOpen == 1 {
  36297. for _, item := range patients {
  36298. 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
  36299. resp, requestErr := http.Get(api)
  36300. if requestErr != nil {
  36301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36302. return
  36303. }
  36304. defer resp.Body.Close()
  36305. body, ioErr := ioutil.ReadAll(resp.Body)
  36306. if ioErr != nil {
  36307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36309. return
  36310. }
  36311. var respJSON map[string]interface{}
  36312. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36315. return
  36316. }
  36317. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36318. userJSONBytes, _ := json.Marshal(userJSON)
  36319. var res ResultTwo
  36320. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36321. utils.ErrorLog("解析失败:%v", err)
  36322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36323. return
  36324. }
  36325. if res.Infcode == 0 {
  36326. 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)
  36327. var dat map[string]interface{}
  36328. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36329. fmt.Println(dat)
  36330. } else {
  36331. fmt.Println(err)
  36332. }
  36333. userJSONBytes, _ := json.Marshal(dat)
  36334. var res2 ResultThirteen
  36335. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36336. utils.ErrorLog("解析失败:%v", err)
  36337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36338. return
  36339. }
  36340. if res2.Infcode == 0 {
  36341. psnResult := &models.GdybPsnRecord{
  36342. UserOrgId: adminUser.CurrentOrgId,
  36343. PatientId: item.ID,
  36344. PsnNo: res.Output.Baseinfo.PsnNo,
  36345. Ctime: time.Now().Unix(),
  36346. Mtime: time.Now().Unix(),
  36347. Status: 1,
  36348. IsCancel: 1,
  36349. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36350. }
  36351. service.CreatePsnRecord(psnResult)
  36352. } else {
  36353. c.ServeSuccessJSON(map[string]interface{}{
  36354. "failed_code": -10,
  36355. "msg": res2.ErrMsg,
  36356. })
  36357. return
  36358. }
  36359. }
  36360. }
  36361. }
  36362. }
  36363. func (c *HisApiController) PsnUnPutOnRecord() {
  36364. id, _ := c.GetInt64("id")
  36365. //record_type, _ := c.GetInt64("type")
  36366. admin_user_id, _ := c.GetInt64("admin_user_id")
  36367. adminUser := c.GetAdminUserInfo()
  36368. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36369. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36370. var user_name string
  36371. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36372. if role.ID == 0 {
  36373. user_name = "xxx"
  36374. } else {
  36375. user_name = role.UserName
  36376. }
  36377. psn_record, _ := service.GetPsnRecordById(id)
  36378. if psn_record.ID == 0 {
  36379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36380. return
  36381. }
  36382. if config.IsOpen == 1 {
  36383. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36384. var dat map[string]interface{}
  36385. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36386. fmt.Println(dat)
  36387. } else {
  36388. fmt.Println(err)
  36389. }
  36390. userJSONBytes, _ := json.Marshal(dat)
  36391. var res ResultFourteen
  36392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36393. utils.ErrorLog("解析失败:%v", err)
  36394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36395. return
  36396. }
  36397. if res.Infcode == 0 {
  36398. psn_record.IsCancel = 2
  36399. service.CreatePsnRecord(&psn_record)
  36400. } else {
  36401. c.ServeSuccessJSON(map[string]interface{}{
  36402. "failed_code": -10,
  36403. "msg": res.ErrMsg,
  36404. })
  36405. return
  36406. }
  36407. }
  36408. }
  36409. func (c *HisApiController) PsnPutNCDSOnRecord() {
  36410. patient_id, _ := c.GetInt64("patient_id")
  36411. insutype_two := c.GetString("insutype")
  36412. psn_no := c.GetString("psn_no")
  36413. doctor_id, _ := c.GetInt64("doctor_id")
  36414. sick_id, _ := c.GetInt64("sick_id")
  36415. department_id, _ := c.GetInt64("department_id")
  36416. start_time := c.GetString("start_time")
  36417. end_time := c.GetString("end_time")
  36418. check_time := c.GetString("check_time")
  36419. hospital_code := c.GetString("hospital_code")
  36420. hospital_name := c.GetString("hospital_name")
  36421. adminUser := c.GetAdminUserInfo()
  36422. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36423. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36424. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36425. sick, _ := service.FindSickById(sick_id)
  36426. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36427. if len(hospital_code) == 0 {
  36428. hospital_code = miConfig.Code
  36429. }
  36430. if len(hospital_name) == 0 {
  36431. hospital_name = miConfig.OrgName
  36432. }
  36433. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36434. var res ResultTwo
  36435. var res10265 ResultTwo10265
  36436. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36437. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  36438. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  36439. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36440. "&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
  36441. resp, requestErr := http.Get(api)
  36442. if requestErr != nil {
  36443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36444. return
  36445. }
  36446. body, ioErr := ioutil.ReadAll(resp.Body)
  36447. if ioErr != nil {
  36448. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36450. return
  36451. }
  36452. var respJSON map[string]interface{}
  36453. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36456. return
  36457. }
  36458. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36459. result, _ := json.Marshal(respJSON)
  36460. fmt.Println("log")
  36461. fmt.Println(string(result))
  36462. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36463. utils.ErrorLog("解析失败:%v", err)
  36464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36465. return
  36466. }
  36467. res.ErrMsg = res10265.ErrMsg
  36468. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36469. res.Infcode = infocode
  36470. res.Output = res10265.Output
  36471. res.InfRefmsgid = res10265.InfRefmsgid
  36472. } else {
  36473. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36474. if miConfig.Code == "H15049901371" {
  36475. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36476. utils.ErrorLog("解析失败:%v", err)
  36477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36478. return
  36479. }
  36480. res.ErrMsg = res10265.ErrMsg
  36481. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36482. res.Infcode = infocode
  36483. res.Output = res10265.Output
  36484. res.InfRefmsgid = res10265.InfRefmsgid
  36485. } else {
  36486. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36487. utils.ErrorLog("解析失败:%v", err)
  36488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36489. return
  36490. }
  36491. }
  36492. }
  36493. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36494. infoStr := string(Iinfos)
  36495. var rf []*ResultFive
  36496. json.Unmarshal([]byte(infoStr), &rf)
  36497. var insuplc_admdvs string
  36498. var insutype string
  36499. var is390 int = 0
  36500. var is310 int = 0
  36501. var insutypes []*ResultFive
  36502. for _, item := range rf {
  36503. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36504. insutypes = append(insutypes, item)
  36505. }
  36506. }
  36507. if len(insutypes) == 1 {
  36508. insutype = insutypes[0].Insutype
  36509. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36510. } else {
  36511. for _, i := range insutypes {
  36512. if i.Insutype == "390" {
  36513. is390 = 1
  36514. }
  36515. if i.Insutype == "310" {
  36516. is310 = 1
  36517. }
  36518. }
  36519. }
  36520. if is390 == 1 {
  36521. insutype = "390"
  36522. }
  36523. if is310 == 1 {
  36524. insutype = "310"
  36525. }
  36526. if len(insutypes) == 2 {
  36527. insutype = insutype_two
  36528. }
  36529. if len(insutypes) == 0 {
  36530. insutype = "310"
  36531. }
  36532. insutype = insutype_two
  36533. fmt.Println(insutype)
  36534. for _, item := range rf {
  36535. fmt.Println(item.Insutype)
  36536. fmt.Println(insutype)
  36537. if item.Insutype == insutype {
  36538. fmt.Println(item.Insutype)
  36539. fmt.Println(insutype)
  36540. insuplc_admdvs = item.InsuplcAdmdvs
  36541. }
  36542. }
  36543. fmt.Println(insuplc_admdvs)
  36544. var res2 ResultThirteen
  36545. var res10265_2 ResultThirteen10265
  36546. if config.IsOpen == 1 {
  36547. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36548. } else {
  36549. if miConfig.MdtrtareaAdmvs == "150499" {
  36550. //
  36551. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  36552. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36553. // "&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
  36554. //resp, requestErr := http.Get(api)
  36555. //if requestErr != nil {
  36556. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36557. // return
  36558. //}
  36559. //
  36560. //body, ioErr := ioutil.ReadAll(resp.Body)
  36561. //if ioErr != nil {
  36562. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36563. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36564. // return
  36565. //}
  36566. //var respJSON map[string]interface{}
  36567. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36568. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36569. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36570. // return
  36571. //}
  36572. //
  36573. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36574. //result, _ := json.Marshal(respJSON)
  36575. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  36576. // utils.ErrorLog("解析失败:%v", err)
  36577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36578. // return
  36579. //}
  36580. //infocode = resThree.Infcode
  36581. //result, _ := json.Marshal(respJSON)
  36582. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  36583. // utils.ErrorLog("解析失败:%v", err)
  36584. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36585. // return
  36586. //}
  36587. //
  36588. //resThree.ErrMsg = resThree10265.ErrMsg
  36589. //
  36590. //resThree.Output = resThree10265.Output
  36591. //
  36592. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  36593. //
  36594. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  36595. //
  36596. } else {
  36597. 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)
  36598. var dat map[string]interface{}
  36599. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36600. fmt.Println(dat)
  36601. } else {
  36602. fmt.Println(err)
  36603. }
  36604. userJSONBytes, _ := json.Marshal(dat)
  36605. if miConfig.Code == "H15049901371" {
  36606. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  36607. utils.ErrorLog("解析失败:%v", err)
  36608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36609. return
  36610. }
  36611. res2.ErrMsg = res10265_2.ErrMsg
  36612. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  36613. res2.Infcode = infocode
  36614. res2.Output = res10265_2.Output
  36615. res2.InfRefmsgid = res10265_2.InfRefmsgid
  36616. } else {
  36617. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36618. utils.ErrorLog("解析失败:%v", err)
  36619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36620. return
  36621. }
  36622. }
  36623. }
  36624. }
  36625. if res2.Infcode == 0 {
  36626. psnResult := &models.GdybPsnNcdsRecord{
  36627. UserOrgId: adminUser.CurrentOrgId,
  36628. PatientId: patient.ID,
  36629. PsnNo: psn_no,
  36630. DoctorId: doctor.AdminUserId,
  36631. DepartmentId: department_id,
  36632. SickType: sick_id,
  36633. Insutype: insutype,
  36634. Ctime: time.Now().Unix(),
  36635. Mtime: time.Now().Unix(),
  36636. Status: 1,
  36637. IsCancel: 1,
  36638. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36639. }
  36640. service.CreatePsnNCDSRecord(psnResult)
  36641. c.ServeSuccessJSON(map[string]interface{}{
  36642. "failed_code": 0,
  36643. "msg": "备案成功",
  36644. "result": psnResult,
  36645. })
  36646. } else {
  36647. c.ServeSuccessJSON(map[string]interface{}{
  36648. "failed_code": -10,
  36649. "msg": res2.ErrMsg,
  36650. })
  36651. return
  36652. }
  36653. }
  36654. }
  36655. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  36656. id, _ := c.GetInt64("id")
  36657. admin_user_id, _ := c.GetInt64("admin_user_id")
  36658. adminUser := c.GetAdminUserInfo()
  36659. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36660. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36661. //config, _ := service.Ge(adminUser.CurrentOrgId)
  36662. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  36663. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36664. //var user_name string
  36665. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36666. //if role.ID == 0 {
  36667. // user_name = "xxx"
  36668. //} else {
  36669. // user_name = role.UserName
  36670. //}
  36671. psn_record, _ := service.GetPsnNCDSRecordById(id)
  36672. if psn_record.ID == 0 {
  36673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36674. return
  36675. }
  36676. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36677. var res ResultTwo
  36678. var res10265 ResultTwo10265
  36679. if miConfig.Code == "H15049901371" {
  36680. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36681. utils.ErrorLog("解析失败:%v", err)
  36682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36683. return
  36684. }
  36685. res.ErrMsg = res10265.ErrMsg
  36686. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36687. res.Infcode = infocode
  36688. res.Output = res10265.Output
  36689. res.InfRefmsgid = res10265.InfRefmsgid
  36690. } else {
  36691. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36692. utils.ErrorLog("解析失败:%v", err)
  36693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36694. return
  36695. }
  36696. }
  36697. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36698. infoStr := string(Iinfos)
  36699. var rf []*ResultFive
  36700. json.Unmarshal([]byte(infoStr), &rf)
  36701. var insuplc_admdvs string
  36702. var insutype string
  36703. var is390 int = 0
  36704. var is310 int = 0
  36705. var insutypes []*ResultFive
  36706. for _, item := range rf {
  36707. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36708. insutypes = append(insutypes, item)
  36709. }
  36710. }
  36711. if len(insutypes) == 1 {
  36712. insutype = insutypes[0].Insutype
  36713. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36714. } else {
  36715. for _, i := range insutypes {
  36716. if i.Insutype == "390" {
  36717. is390 = 1
  36718. }
  36719. if i.Insutype == "310" {
  36720. is310 = 1
  36721. }
  36722. }
  36723. }
  36724. if is390 == 1 {
  36725. insutype = "390"
  36726. }
  36727. if is310 == 1 {
  36728. insutype = "310"
  36729. }
  36730. if len(insutypes) == 0 {
  36731. insutype = "310"
  36732. }
  36733. insutype = psn_record.Insutype
  36734. for _, item := range rf {
  36735. if item.Insutype == insutype {
  36736. insuplc_admdvs = item.InsuplcAdmdvs
  36737. }
  36738. }
  36739. if config.IsOpen == 1 {
  36740. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36741. var dat map[string]interface{}
  36742. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36743. fmt.Println(dat)
  36744. } else {
  36745. fmt.Println(err)
  36746. }
  36747. userJSONBytes, _ := json.Marshal(dat)
  36748. var res ResultFourteen
  36749. var res10265 ResultFourteen10265
  36750. if miConfig.Code == "H15049901371" {
  36751. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36752. utils.ErrorLog("解析失败:%v", err)
  36753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36754. return
  36755. }
  36756. res.ErrMsg = res10265.ErrMsg
  36757. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36758. res.Infcode = infocode
  36759. res.Output = res10265.Output
  36760. res.InfRefmsgid = res10265.InfRefmsgid
  36761. } else {
  36762. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36763. utils.ErrorLog("解析失败:%v", err)
  36764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36765. return
  36766. }
  36767. }
  36768. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36769. // utils.ErrorLog("解析失败:%v", err)
  36770. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36771. // return
  36772. //}
  36773. if res.Infcode == 0 {
  36774. psn_record.IsCancel = 2
  36775. service.CreatePsnNCDSRecord(&psn_record)
  36776. c.ServeSuccessJSON(map[string]interface{}{
  36777. "failed_code": 0,
  36778. "msg": "撤销备案成功",
  36779. })
  36780. } else {
  36781. c.ServeSuccessJSON(map[string]interface{}{
  36782. "failed_code": -10,
  36783. "msg": res.ErrMsg,
  36784. })
  36785. return
  36786. }
  36787. }
  36788. }
  36789. func (c *HisApiController) TestTest() {
  36790. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  36791. fmt.Println(patient.Iinfo)
  36792. }
  36793. type CustomData struct {
  36794. MsgId string
  36795. PsnNo string
  36796. Info string
  36797. }
  36798. func (c *HisApiController) ReversalData() {
  36799. var customData []*CustomData
  36800. custom := &CustomData{
  36801. MsgId: "H44022900158202103301714472004",
  36802. PsnNo: "44020000001101329945",
  36803. Info: "2207",
  36804. }
  36805. customData = append(customData, custom)
  36806. custom1 := &CustomData{
  36807. MsgId: "H4402290015820210330172057803",
  36808. PsnNo: "44020000001101161813",
  36809. Info: "2207",
  36810. }
  36811. customData = append(customData, custom1)
  36812. custom2 := &CustomData{
  36813. MsgId: "H44022900158202103301705198813",
  36814. PsnNo: "44190000133097375417",
  36815. Info: "2207",
  36816. }
  36817. customData = append(customData, custom2)
  36818. custom3 := &CustomData{
  36819. MsgId: "H44022900158202103301715524756",
  36820. PsnNo: "44020000001100187221",
  36821. Info: "2207",
  36822. }
  36823. customData = append(customData, custom3)
  36824. custom4 := &CustomData{
  36825. MsgId: "H44022900158202103301730376224",
  36826. PsnNo: "44020000001101959155",
  36827. Info: "2207",
  36828. }
  36829. customData = append(customData, custom4)
  36830. custom5 := &CustomData{
  36831. MsgId: "H44022900158202103301748008725",
  36832. PsnNo: "44020000001104246641",
  36833. Info: "2207",
  36834. }
  36835. customData = append(customData, custom5)
  36836. custom6 := &CustomData{
  36837. MsgId: "H44022900158202103301718096755",
  36838. PsnNo: "44020000001102211860",
  36839. Info: "2207",
  36840. }
  36841. customData = append(customData, custom6)
  36842. custom7 := &CustomData{
  36843. MsgId: "H44022900158202103301736551640",
  36844. PsnNo: "44020000001102687718",
  36845. Info: "2207",
  36846. }
  36847. customData = append(customData, custom7)
  36848. custom8 := &CustomData{
  36849. MsgId: "H44022900158202103301743097676",
  36850. PsnNo: "44020000001102127785",
  36851. Info: "2207",
  36852. }
  36853. customData = append(customData, custom8)
  36854. custom9 := &CustomData{
  36855. MsgId: "H44022900158202103301712304203",
  36856. PsnNo: "44020000001101518097",
  36857. Info: "2207",
  36858. }
  36859. customData = append(customData, custom9)
  36860. custom10 := &CustomData{
  36861. MsgId: "H44022900158202103301738448785",
  36862. PsnNo: "44020000001100500813",
  36863. Info: "2207",
  36864. }
  36865. customData = append(customData, custom10)
  36866. custom11 := &CustomData{
  36867. MsgId: "H44022900158202103301732455843",
  36868. PsnNo: "44020000001102690557",
  36869. Info: "2207",
  36870. }
  36871. customData = append(customData, custom11)
  36872. custom12 := &CustomData{
  36873. MsgId: "H44022900158202103301745421708",
  36874. PsnNo: "44020000001102211928",
  36875. Info: "2207",
  36876. }
  36877. customData = append(customData, custom12)
  36878. custom1212 := &CustomData{
  36879. MsgId: "H440229001582021033017351627",
  36880. PsnNo: "44020000001102481733",
  36881. Info: "2207",
  36882. }
  36883. customData = append(customData, custom1212)
  36884. custom13 := &CustomData{
  36885. MsgId: "H44022900158202103301740327951",
  36886. PsnNo: "44020000001103174866",
  36887. Info: "2207",
  36888. }
  36889. customData = append(customData, custom13)
  36890. custom14 := &CustomData{
  36891. MsgId: "H4402290015820210330174922668",
  36892. PsnNo: "44020000001102927272",
  36893. Info: "2207",
  36894. }
  36895. customData = append(customData, custom14)
  36896. custom15 := &CustomData{
  36897. MsgId: "H44022900158202103301752362273",
  36898. PsnNo: "44020000001102942890",
  36899. Info: "2207",
  36900. }
  36901. customData = append(customData, custom15)
  36902. custom16 := &CustomData{
  36903. MsgId: "H44022900158202103301751082917",
  36904. PsnNo: "44020000001101662162",
  36905. Info: "2207",
  36906. }
  36907. customData = append(customData, custom16)
  36908. custom17 := &CustomData{
  36909. MsgId: "H44022900158202103301754147728",
  36910. PsnNo: "44020000000229014511",
  36911. Info: "2207",
  36912. }
  36913. customData = append(customData, custom17)
  36914. adminUser := c.GetAdminUserInfo()
  36915. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36916. for _, item := range customData {
  36917. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  36918. fmt.Println(result)
  36919. }
  36920. }
  36921. func (c *HisApiController) GetAllopatry() {
  36922. year := c.GetString("year")
  36923. month := c.GetString("month")
  36924. admin_user_id, _ := c.GetInt64("admin_user_id")
  36925. adminUser := c.GetAdminUserInfo()
  36926. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36927. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36928. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36929. var dat map[string]interface{}
  36930. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36931. fmt.Println(dat)
  36932. } else {
  36933. fmt.Println(err)
  36934. }
  36935. userJSONBytes, _ := json.Marshal(dat)
  36936. var res models.Result9001
  36937. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36938. utils.ErrorLog("解析失败:%v", err)
  36939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36940. return
  36941. }
  36942. fmt.Println(res.Output.Signinoutb)
  36943. fmt.Println(res.Output.Signinoutb.SignNo)
  36944. fmt.Println(string(userJSONBytes))
  36945. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  36946. var dat3 map[string]interface{}
  36947. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  36948. fmt.Println(dat3)
  36949. } else {
  36950. fmt.Println(err)
  36951. }
  36952. userJSONBytes3, _ := json.Marshal(dat3)
  36953. var res3 models.Result3260
  36954. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  36955. utils.ErrorLog("解析失败:%v", err)
  36956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36957. return
  36958. }
  36959. var curpage int
  36960. var pagesize int = 100
  36961. var start int = 1
  36962. //var stop int
  36963. //pagecount := 10
  36964. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  36965. var res22 []models.Result3260
  36966. for curpage = 1; curpage <= pagecount; curpage++ {
  36967. if curpage == 1 {
  36968. start = 0
  36969. } else {
  36970. start = (curpage-1)*pagesize + 1
  36971. }
  36972. fmt.Println(start)
  36973. //stop = curpage * pagesize
  36974. //if stop > int(res3.Output.Totalrow) {
  36975. // stop =int(res3.Output.Totalrow)
  36976. //}
  36977. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  36978. var dat2 map[string]interface{}
  36979. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36980. fmt.Println(dat)
  36981. } else {
  36982. fmt.Println(err)
  36983. }
  36984. userJSONBytes2, _ := json.Marshal(dat2)
  36985. var res2 models.Result3260
  36986. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36987. utils.ErrorLog("解析失败:%v", err)
  36988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36989. return
  36990. }
  36991. if res2.Infcode == 0 {
  36992. res22 = append(res22, res2)
  36993. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36994. //var dat2 map[string]interface{}
  36995. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  36996. // fmt.Println(dat)
  36997. //} else {
  36998. // fmt.Println(err)
  36999. //}
  37000. //c.ServeSuccessJSON(map[string]interface{}{
  37001. // "list": res2.Output.Data,
  37002. //})
  37003. //continue
  37004. }
  37005. }
  37006. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37007. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37008. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  37009. //var dat2 map[string]interface{}
  37010. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37011. // fmt.Println(dat)
  37012. //} else {
  37013. // fmt.Println(err)
  37014. //}
  37015. //userJSONBytes2, _ := json.Marshal(dat2)
  37016. //var res2 models.Result3260
  37017. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37018. // utils.ErrorLog("解析失败:%v", err)
  37019. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37020. // return
  37021. //}
  37022. //if res2.Infcode == 0 {
  37023. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37024. // var dat2 map[string]interface{}
  37025. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37026. // fmt.Println(dat)
  37027. // } else {
  37028. // fmt.Println(err)
  37029. // }
  37030. // c.ServeSuccessJSON(map[string]interface{}{
  37031. // "list": res2.Output.Data,
  37032. // })
  37033. //}
  37034. }
  37035. func (c *HisApiController) ComfirmAllopatry() {
  37036. year := c.GetString("year")
  37037. month := c.GetString("month")
  37038. admin_user_id, _ := c.GetInt64("admin_user_id")
  37039. adminUser := c.GetAdminUserInfo()
  37040. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37041. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37042. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37043. var dat map[string]interface{}
  37044. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37045. fmt.Println(dat)
  37046. } else {
  37047. fmt.Println(err)
  37048. }
  37049. userJSONBytes, _ := json.Marshal(dat)
  37050. var res models.Result9001
  37051. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37052. utils.ErrorLog("解析失败:%v", err)
  37053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37054. return
  37055. }
  37056. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37057. var dat2 map[string]interface{}
  37058. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37059. fmt.Println(dat)
  37060. } else {
  37061. fmt.Println(err)
  37062. }
  37063. userJSONBytes2, _ := json.Marshal(dat2)
  37064. var res2 models.Result3260
  37065. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37066. utils.ErrorLog("解析失败:%v", err)
  37067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37068. return
  37069. }
  37070. //if res2.Infcode == 0 {
  37071. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37072. // var dat map[string]interface{}
  37073. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37074. // fmt.Println(dat)
  37075. // } else {
  37076. // fmt.Println(err)
  37077. // }
  37078. // userJSONBytes, _ := json.Marshal(dat)
  37079. // var res3 models.Result3261
  37080. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  37081. // utils.ErrorLog("解析失败:%v", err)
  37082. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37083. // return
  37084. // }
  37085. //
  37086. // if res3.Infcode == 0 {
  37087. // record := &models.HisYidiClearRecord{
  37088. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37089. // Ctime: time.Now().Unix(),
  37090. // Mtime: time.Now().Unix(),
  37091. // Status: 1,
  37092. // MsgId: msgId,
  37093. // }
  37094. // service.SaveClearRecord(record)
  37095. // c.ServeSuccessJSON(map[string]interface{}{
  37096. // "msg": "提取成功",
  37097. // })
  37098. // }
  37099. //}
  37100. }
  37101. func (c *HisApiController) RefundAllopatry() {
  37102. year := c.GetString("year")
  37103. month := c.GetString("month")
  37104. //id, _ := c.GetInt64("id")
  37105. admin_user_id, _ := c.GetInt64("admin_user_id")
  37106. adminUser := c.GetAdminUserInfo()
  37107. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37108. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37109. //record, _ := service.GetClearRecordById(id)
  37110. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37111. var dat map[string]interface{}
  37112. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  37113. fmt.Println(dat)
  37114. } else {
  37115. fmt.Println(err)
  37116. }
  37117. userJSONBytes, _ := json.Marshal(dat)
  37118. var res models.Result9001
  37119. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37120. utils.ErrorLog("解析失败:%v", err)
  37121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37122. return
  37123. }
  37124. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  37125. var dat2 map[string]interface{}
  37126. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37127. fmt.Println(dat)
  37128. } else {
  37129. fmt.Println(err)
  37130. }
  37131. userJSONBytes2, _ := json.Marshal(dat2)
  37132. var empty ResultFourteen
  37133. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  37134. utils.ErrorLog("解析失败:%v", err)
  37135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37136. return
  37137. }
  37138. if empty.Infcode == 0 {
  37139. c.ServeSuccessJSON(map[string]interface{}{
  37140. "msg": "撤销成功",
  37141. })
  37142. return
  37143. }
  37144. }
  37145. func (c *HisApiController) ReversalOtherData() {
  37146. var customData []*CustomData
  37147. custom := &CustomData{
  37148. MsgId: "H44022900158202103301714472004",
  37149. PsnNo: "44020000001101329945",
  37150. Info: "2208",
  37151. }
  37152. customData = append(customData, custom)
  37153. custom1 := &CustomData{
  37154. MsgId: "H4402290015820210330172057803",
  37155. PsnNo: "44020000001101161813",
  37156. Info: "2208",
  37157. }
  37158. customData = append(customData, custom1)
  37159. custom2 := &CustomData{
  37160. MsgId: "H44022900158202103301705198813",
  37161. PsnNo: "44190000133097375417",
  37162. Info: "2208",
  37163. }
  37164. customData = append(customData, custom2)
  37165. custom3 := &CustomData{
  37166. MsgId: "H44022900158202103301715524756",
  37167. PsnNo: "44020000001100187221",
  37168. Info: "2208",
  37169. }
  37170. customData = append(customData, custom3)
  37171. custom4 := &CustomData{
  37172. MsgId: "H44022900158202103301730376224",
  37173. PsnNo: "44020000001101959155",
  37174. Info: "2208",
  37175. }
  37176. customData = append(customData, custom4)
  37177. custom5 := &CustomData{
  37178. MsgId: "H44022900158202103301748008725",
  37179. PsnNo: "44020000001104246641",
  37180. Info: "2208",
  37181. }
  37182. customData = append(customData, custom5)
  37183. custom6 := &CustomData{
  37184. MsgId: "H44022900158202103301718096755",
  37185. PsnNo: "44020000001102211860",
  37186. Info: "2208",
  37187. }
  37188. customData = append(customData, custom6)
  37189. custom7 := &CustomData{
  37190. MsgId: "H44022900158202103301736551640",
  37191. PsnNo: "44020000001102687718",
  37192. Info: "2208",
  37193. }
  37194. customData = append(customData, custom7)
  37195. custom8 := &CustomData{
  37196. MsgId: "H44022900158202103301743097676",
  37197. PsnNo: "44020000001102127785",
  37198. Info: "2208",
  37199. }
  37200. customData = append(customData, custom8)
  37201. custom9 := &CustomData{
  37202. MsgId: "H44022900158202103301712304203",
  37203. PsnNo: "44020000001101518097",
  37204. Info: "2208",
  37205. }
  37206. customData = append(customData, custom9)
  37207. custom10 := &CustomData{
  37208. MsgId: "H44022900158202103301738448785",
  37209. PsnNo: "44020000001100500813",
  37210. Info: "2208",
  37211. }
  37212. customData = append(customData, custom10)
  37213. custom11 := &CustomData{
  37214. MsgId: "H44022900158202103301732455843",
  37215. PsnNo: "44020000001102690557",
  37216. Info: "2208",
  37217. }
  37218. customData = append(customData, custom11)
  37219. custom12 := &CustomData{
  37220. MsgId: "H44022900158202103301745421708",
  37221. PsnNo: "44020000001102211928",
  37222. Info: "2208",
  37223. }
  37224. customData = append(customData, custom12)
  37225. custom1212 := &CustomData{
  37226. MsgId: "H440229001582021033017351627",
  37227. PsnNo: "44020000001102481733",
  37228. Info: "2208",
  37229. }
  37230. customData = append(customData, custom1212)
  37231. custom13 := &CustomData{
  37232. MsgId: "H44022900158202103301740327951",
  37233. PsnNo: "44020000001103174866",
  37234. Info: "2208",
  37235. }
  37236. customData = append(customData, custom13)
  37237. custom14 := &CustomData{
  37238. MsgId: "H4402290015820210330174922668",
  37239. PsnNo: "44020000001102927272",
  37240. Info: "2208",
  37241. }
  37242. customData = append(customData, custom14)
  37243. custom15 := &CustomData{
  37244. MsgId: "H44022900158202103301752362273",
  37245. PsnNo: "44020000001102942890",
  37246. Info: "2208",
  37247. }
  37248. customData = append(customData, custom15)
  37249. custom16 := &CustomData{
  37250. MsgId: "H44022900158202103301751082917",
  37251. PsnNo: "44020000001101662162",
  37252. Info: "2208",
  37253. }
  37254. customData = append(customData, custom16)
  37255. custom17 := &CustomData{
  37256. MsgId: "H44022900158202103301754147728",
  37257. PsnNo: "44020000000229014511",
  37258. Info: "2208",
  37259. }
  37260. customData = append(customData, custom17)
  37261. adminUser := c.GetAdminUserInfo()
  37262. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37263. for _, item := range customData {
  37264. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37265. fmt.Println(result)
  37266. }
  37267. }
  37268. func PathExists(path string) (bool, error) {
  37269. _, err := os.Stat(path)
  37270. if err == nil {
  37271. return true, nil
  37272. }
  37273. if os.IsNotExist(err) {
  37274. return false, nil
  37275. }
  37276. return false, err
  37277. }
  37278. // 创建文件夹
  37279. func Mkdir(dir string) {
  37280. // 创建文件夹
  37281. exist, err := PathExists(dir)
  37282. if err != nil {
  37283. fmt.Println(err.Error())
  37284. } else {
  37285. if exist {
  37286. fmt.Println(dir + "文件夹已存在!")
  37287. } else {
  37288. // 文件夹名称,权限
  37289. err := os.Mkdir(dir, os.ModePerm)
  37290. if err != nil {
  37291. fmt.Println(dir+"文件夹创建失败:", err.Error())
  37292. } else {
  37293. fmt.Println(dir + "文件夹创建成功!")
  37294. }
  37295. }
  37296. }
  37297. }
  37298. // 压缩文件
  37299. func Zip(srcFile string, destZip string) error {
  37300. zipfile, err := os.Create(destZip)
  37301. if err != nil {
  37302. return err
  37303. }
  37304. defer zipfile.Close()
  37305. archive := zip.NewWriter(zipfile)
  37306. defer archive.Close()
  37307. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  37308. if err != nil {
  37309. return err
  37310. }
  37311. header, err := zip.FileInfoHeader(info)
  37312. if err != nil {
  37313. return err
  37314. }
  37315. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  37316. // header.Name = path
  37317. if info.IsDir() {
  37318. header.Name += "/"
  37319. } else {
  37320. header.Method = zip.Deflate
  37321. }
  37322. writer, err := archive.CreateHeader(header)
  37323. if err != nil {
  37324. return err
  37325. }
  37326. if !info.IsDir() {
  37327. file, err := os.Open(path)
  37328. if err != nil {
  37329. return err
  37330. }
  37331. defer file.Close()
  37332. _, err = io.Copy(writer, file)
  37333. }
  37334. return err
  37335. })
  37336. return err
  37337. }
  37338. func ReadFile(filePath string) []byte {
  37339. f, err := os.Open(filePath)
  37340. if err != nil {
  37341. fmt.Println("read file fail", err)
  37342. return nil
  37343. }
  37344. defer f.Close()
  37345. fd, err := ioutil.ReadAll(f)
  37346. if err != nil {
  37347. fmt.Println("read to fd fail", err)
  37348. return nil
  37349. }
  37350. return fd
  37351. }
  37352. func saveLogq(result string, request string, infno string, desc string) {
  37353. dir := "日志"
  37354. utils.Mkdir(dir)
  37355. month := time.Unix(1557042972, 0).Format("1")
  37356. year := time.Now().Format("2006")
  37357. month = time.Now().Format("01")
  37358. day := time.Now().Format("02")
  37359. hour := time.Now().Format("15")
  37360. min := time.Now().Format("04")
  37361. sec := time.Now().Format("05")
  37362. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37363. file := year + month + day + "_log"
  37364. file_name := file + ".txt"
  37365. file_path := "日志" + "/" + file_name
  37366. exist, _ := utils.PathExists(file_path)
  37367. if exist { //存在
  37368. fmt.Println("存在")
  37369. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37370. if err != nil {
  37371. fmt.Println("read fail")
  37372. }
  37373. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37374. n, _ := f.Seek(0, 2)
  37375. _, err = f.WriteAt([]byte(content), n)
  37376. } else { //不存在
  37377. fmt.Println("文件不存在,创建文件")
  37378. f, err := os.Create("日志" + "/" + file_name)
  37379. defer f.Close()
  37380. if err != nil {
  37381. } else {
  37382. _, err = f.Write([]byte("记录日志"))
  37383. }
  37384. }
  37385. }
  37386. func saveLog(result string, request string, infno string, desc string) {
  37387. org_id, _ := beego.AppConfig.Int64("org_id")
  37388. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37389. dir := miConfig.OrgName + "日志"
  37390. utils.Mkdir(dir)
  37391. month := time.Unix(1557042972, 0).Format("1")
  37392. year := time.Now().Format("2006")
  37393. month = time.Now().Format("01")
  37394. day := time.Now().Format("02")
  37395. hour := time.Now().Format("15")
  37396. min := time.Now().Format("04")
  37397. sec := time.Now().Format("05")
  37398. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37399. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  37400. file_name := file + ".txt"
  37401. file_path := miConfig.OrgName + "日志" + "/" + file_name
  37402. exist, _ := utils.PathExists(file_path)
  37403. if exist { //存在
  37404. fmt.Println("存在")
  37405. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37406. if err != nil {
  37407. fmt.Println("read fail")
  37408. }
  37409. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37410. n, _ := f.Seek(0, 2)
  37411. _, err = f.WriteAt([]byte(content), n)
  37412. } else { //不存在
  37413. fmt.Println("文件不存在,创建文件")
  37414. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  37415. defer f.Close()
  37416. if err != nil {
  37417. } else {
  37418. _, err = f.Write([]byte("记录日志"))
  37419. }
  37420. }
  37421. }
  37422. type Charset string
  37423. const (
  37424. UTF8 = Charset("UTF-8")
  37425. GB18030 = Charset("GB18030")
  37426. )
  37427. func ConvertToString(src string, srcCode string, tagCode string) string {
  37428. srcCoder := mahonia.NewDecoder(srcCode)
  37429. srcResult := srcCoder.ConvertString(src)
  37430. tagCoder := mahonia.NewDecoder(tagCode)
  37431. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  37432. result := string(cdata)
  37433. return result
  37434. }
  37435. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  37436. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37437. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37438. var token string
  37439. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37440. var api string
  37441. if miConfig.MdtrtareaAdmvs == "320921" {
  37442. 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 +
  37443. "&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
  37444. fmt.Println(api)
  37445. } else {
  37446. 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 +
  37447. "&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
  37448. }
  37449. resp, requestErr := http.Get(api)
  37450. if requestErr != nil {
  37451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37452. return ""
  37453. }
  37454. body, ioErr := ioutil.ReadAll(resp.Body)
  37455. if ioErr != nil {
  37456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37458. return ""
  37459. }
  37460. var respJSON map[string]interface{}
  37461. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37464. return ""
  37465. }
  37466. var status string
  37467. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37468. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37469. var res ResultTwo //1101结果
  37470. var res10265 ResultTwo10265 //1101结果
  37471. if status == "0" { //读卡成功
  37472. var card_info string //卡信息
  37473. var busi_card_info string
  37474. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37475. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37476. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37477. fmt.Println(card_info)
  37478. fmt.Println(busi_card_info)
  37479. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37480. result, _ := json.Marshal(respJSON)
  37481. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37482. utils.ErrorLog("解析失败:%v", err)
  37483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37484. return ""
  37485. }
  37486. res.ErrMsg = res10265.ErrMsg
  37487. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37488. res.Infcode = infocode
  37489. res.Output = res10265.Output
  37490. res.InfRefmsgid = res10265.InfRefmsgid
  37491. if res.Infcode == 0 {
  37492. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37493. if err == gorm.ErrRecordNotFound {
  37494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37495. return ""
  37496. } else if err != nil {
  37497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37498. return ""
  37499. } else {
  37500. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37501. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37502. infoStr := string(Iinfos)
  37503. idetinfoStr := string(Idetinfos)
  37504. psn := &models.HisPsn{
  37505. PsnNo: res.Output.Baseinfo.PsnNo,
  37506. PatientId: patient.ID,
  37507. Certno: res.Output.Baseinfo.Certno,
  37508. Gend: res.Output.Baseinfo.Gend,
  37509. Naty: res.Output.Baseinfo.Naty,
  37510. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37511. PsnName: res.Output.Baseinfo.PsnName,
  37512. Idetinfo: idetinfoStr,
  37513. Insuinfo: infoStr,
  37514. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37515. CardInfo: card_info,
  37516. VerifyNumber: token,
  37517. }
  37518. service.CreateHisPsn(psn)
  37519. return token
  37520. }
  37521. }
  37522. } else {
  37523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37524. return ""
  37525. }
  37526. } else { //读卡失败
  37527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37528. return ""
  37529. }
  37530. return token
  37531. }
  37532. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  37533. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37534. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37535. var token string
  37536. var api string
  37537. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  37538. "&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
  37539. fmt.Println(api)
  37540. resp, requestErr := http.Get(api)
  37541. if requestErr != nil {
  37542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37543. return ""
  37544. }
  37545. body, ioErr := ioutil.ReadAll(resp.Body)
  37546. if ioErr != nil {
  37547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37549. return ""
  37550. }
  37551. var respJSON map[string]interface{}
  37552. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37555. return ""
  37556. }
  37557. var status string
  37558. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37559. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37560. var res ResultTwo //1101结果
  37561. if status == "1" { //读卡成功
  37562. var card_info string //卡信息
  37563. var busi_card_info string
  37564. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37565. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37566. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37567. fmt.Println(card_info)
  37568. fmt.Println(busi_card_info)
  37569. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37570. result, _ := json.Marshal(respJSON)
  37571. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37572. utils.ErrorLog("解析失败:%v", err)
  37573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37574. return ""
  37575. }
  37576. if res.Infcode == 0 {
  37577. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37578. if err == gorm.ErrRecordNotFound {
  37579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37580. return ""
  37581. } else if err != nil {
  37582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37583. return ""
  37584. } else {
  37585. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37586. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37587. infoStr := string(Iinfos)
  37588. idetinfoStr := string(Idetinfos)
  37589. psn := &models.HisPsn{
  37590. PsnNo: res.Output.Baseinfo.PsnNo,
  37591. PatientId: patient.ID,
  37592. Certno: res.Output.Baseinfo.Certno,
  37593. Gend: res.Output.Baseinfo.Gend,
  37594. Naty: res.Output.Baseinfo.Naty,
  37595. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37596. PsnName: res.Output.Baseinfo.PsnName,
  37597. Idetinfo: idetinfoStr,
  37598. Insuinfo: infoStr,
  37599. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37600. CardInfo: card_info,
  37601. VerifyNumber: token,
  37602. }
  37603. service.CreateHisPsn(psn)
  37604. return token
  37605. }
  37606. }
  37607. } else {
  37608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37609. return ""
  37610. }
  37611. return token
  37612. }
  37613. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  37614. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37615. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37616. var token string
  37617. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37618. var api string
  37619. if miConfig.MdtrtareaAdmvs == "320921" {
  37620. 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 +
  37621. "&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
  37622. fmt.Println(api)
  37623. } else {
  37624. 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 +
  37625. "&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
  37626. }
  37627. resp, requestErr := http.Get(api)
  37628. if requestErr != nil {
  37629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37630. return ""
  37631. }
  37632. body, ioErr := ioutil.ReadAll(resp.Body)
  37633. if ioErr != nil {
  37634. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37636. return ""
  37637. }
  37638. var respJSON map[string]interface{}
  37639. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37642. return ""
  37643. }
  37644. var status string
  37645. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37646. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37647. var res ResultTwo //1101结果
  37648. var res10265 ResultTwo10265 //1101结果
  37649. if status == "0" { //读卡成功
  37650. var card_info string //卡信息
  37651. var busi_card_info string
  37652. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37653. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37654. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37655. fmt.Println(card_info)
  37656. fmt.Println(busi_card_info)
  37657. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37658. result, _ := json.Marshal(respJSON)
  37659. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37660. utils.ErrorLog("解析失败:%v", err)
  37661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37662. return ""
  37663. }
  37664. res.ErrMsg = res10265.ErrMsg
  37665. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37666. res.Infcode = infocode
  37667. res.Output = res10265.Output
  37668. res.InfRefmsgid = res10265.InfRefmsgid
  37669. if res.Infcode == 0 {
  37670. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37671. if err == gorm.ErrRecordNotFound {
  37672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37673. return ""
  37674. } else if err != nil {
  37675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37676. return ""
  37677. } else {
  37678. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37679. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37680. infoStr := string(Iinfos)
  37681. idetinfoStr := string(Idetinfos)
  37682. psn := &models.HisPsn{
  37683. PsnNo: res.Output.Baseinfo.PsnNo,
  37684. PatientId: patient.ID,
  37685. Certno: res.Output.Baseinfo.Certno,
  37686. Gend: res.Output.Baseinfo.Gend,
  37687. Naty: res.Output.Baseinfo.Naty,
  37688. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37689. PsnName: res.Output.Baseinfo.PsnName,
  37690. Idetinfo: idetinfoStr,
  37691. Insuinfo: infoStr,
  37692. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37693. CardInfo: card_info,
  37694. VerifyNumber: token,
  37695. }
  37696. service.CreateHisPsn(psn)
  37697. return token
  37698. }
  37699. }
  37700. } else {
  37701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37702. return ""
  37703. }
  37704. } else { //读卡失败
  37705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37706. return ""
  37707. }
  37708. return token
  37709. }
  37710. func DeleteExtraSpaceTwo(s string) string {
  37711. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37712. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37713. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37714. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37715. s2 := make([]byte, len(s1)) //定义字符数组切片
  37716. copy(s2, s1) //将字符串复制到切片
  37717. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37718. for len(spc_index) > 0 { //找到适配项
  37719. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37720. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37721. }
  37722. return string(s2)
  37723. }
  37724. func Remove0000(s string) string {
  37725. str := make([]rune, 0, len(s))
  37726. for _, v := range []rune(s) {
  37727. if v == 0 {
  37728. continue
  37729. }
  37730. str = append(str, v)
  37731. }
  37732. return string(str)
  37733. }
  37734. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  37735. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  37736. readCard := DllDef.MustFindProc("EcQuery")
  37737. pCardInfo := make([]byte, 8192)
  37738. pBusiCardInfo := make([]byte, 8192)
  37739. data := make(map[string]interface{})
  37740. //pData := make(map[string]interface{})
  37741. inputData := make(map[string]interface{})
  37742. inputData["orgId"] = code
  37743. inputData["businessType"] = "01101"
  37744. inputData["operatorId"] = operator_id
  37745. inputData["operatorName"] = operator_name
  37746. inputData["officeId"] = "001"
  37747. inputData["officeName"] = "血透室"
  37748. //
  37749. data["data"] = inputData
  37750. data["transType"] = "ec.query"
  37751. data["orgId"] = code
  37752. bytesData, _ := json.Marshal(data)
  37753. pCardInfo = bytesData
  37754. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  37755. fmt.Println(ret2)
  37756. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  37757. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  37758. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  37759. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  37760. if ret2 != 0 {
  37761. return "", ""
  37762. }
  37763. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  37764. }
  37765. func DeleteExtraSpace(s string) string {
  37766. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37767. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37768. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37769. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37770. s2 := make([]byte, len(s1)) //定义字符数组切片
  37771. copy(s2, s1) //将字符串复制到切片
  37772. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37773. for len(spc_index) > 0 { //找到适配项
  37774. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37775. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37776. }
  37777. return string(s2)
  37778. }
  37779. // 对账
  37780. func (c *HisApiController) Post3202() {
  37781. start_time := c.GetString("start_time")
  37782. end_time := c.GetString("end_time")
  37783. //insutype := c.GetString("insutype")
  37784. clr_type := c.GetString("clr_type")
  37785. clr_org := c.GetString("clr_optins")
  37786. admin_user_id, _ := c.GetInt64("admin_user_id")
  37787. adminUser := c.GetAdminUserInfo()
  37788. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37789. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37790. if len(clr_org) == 0 {
  37791. clr_org = miConfig.MdtrtareaAdmvs
  37792. }
  37793. timeLayout := "2006-01-02"
  37794. loc, _ := time.LoadLocation("Local")
  37795. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37796. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37797. var orders []*models.HisOrder
  37798. if clr_org == "421300" {
  37799. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37800. } else if clr_org == "420902" {
  37801. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37802. } else {
  37803. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37804. }
  37805. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37806. //fixmedins_setl_cnt := int64(len(orders))
  37807. var medfee_sumamt float64
  37808. var acct_pay float64
  37809. var fund_pay_sumamt float64
  37810. for _, item := range orders {
  37811. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37812. acct_pay = acct_pay + item.AcctPay
  37813. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37814. }
  37815. //var medfee_sumamt_two float64
  37816. //var acct_pay_two float64
  37817. //var fund_pay_sumamt_two float64
  37818. //for _, item := range orders_two {
  37819. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37820. // acct_pay_two = acct_pay_two + item.AcctPay
  37821. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37822. //}
  37823. //var user_name string
  37824. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37825. //if role.ID == 0 {
  37826. // user_name = "xxx"
  37827. //} else {
  37828. // user_name = role.UserName
  37829. //}
  37830. var res ResultSix
  37831. if config.IsOpen == 1 {
  37832. var bps []*models.BusinessParamsTwo
  37833. var bp models.BusinessParamsTwo
  37834. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37835. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37836. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37837. bp.MedfeeSumamt = medfee_sumamt_str
  37838. bp.AcctPay = acct_pay_str
  37839. bp.FundPaySumamt = fund_pay_sumamt_str
  37840. bp.Insutype = ""
  37841. bp.StmtBegndate = start_time
  37842. bp.ClrType = clr_type
  37843. bp.SetlOptins = clr_org
  37844. bp.StmtEnddate = end_time
  37845. bps = append(bps, &bp)
  37846. data := make(map[string]interface{})
  37847. data["bps"] = bps
  37848. data["org_name"] = miConfig.OrgName
  37849. data["doctor"] = role.UserName
  37850. data["fixmedins_code"] = miConfig.Code
  37851. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37852. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37853. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37854. if miConfig.MdtrtareaAdmvs == "421300" {
  37855. client := &http.Client{}
  37856. bytesData, _ := json.Marshal(data)
  37857. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37858. resp, _ := client.Do(req)
  37859. defer resp.Body.Close()
  37860. body, ioErr := ioutil.ReadAll(resp.Body)
  37861. if ioErr != nil {
  37862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37864. return
  37865. }
  37866. var respJSON map[string]interface{}
  37867. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37870. return
  37871. }
  37872. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37873. userJSONBytes, _ := json.Marshal(respJSON)
  37874. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37875. utils.ErrorLog("解析失败:%v", err)
  37876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37877. return
  37878. }
  37879. }
  37880. if miConfig.MdtrtareaAdmvs == "420200" {
  37881. client := &http.Client{}
  37882. bytesData, _ := json.Marshal(data)
  37883. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37884. resp, _ := client.Do(req)
  37885. defer resp.Body.Close()
  37886. body, ioErr := ioutil.ReadAll(resp.Body)
  37887. if ioErr != nil {
  37888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37890. return
  37891. }
  37892. var respJSON map[string]interface{}
  37893. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37896. return
  37897. }
  37898. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37899. userJSONBytes, _ := json.Marshal(respJSON)
  37900. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37901. utils.ErrorLog("解析失败:%v", err)
  37902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37903. return
  37904. }
  37905. }
  37906. if miConfig.MdtrtareaAdmvs == "421182" {
  37907. client := &http.Client{}
  37908. bytesData, _ := json.Marshal(data)
  37909. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37910. resp, _ := client.Do(req)
  37911. defer resp.Body.Close()
  37912. body, ioErr := ioutil.ReadAll(resp.Body)
  37913. if ioErr != nil {
  37914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37916. return
  37917. }
  37918. var respJSON map[string]interface{}
  37919. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37922. return
  37923. }
  37924. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37925. userJSONBytes, _ := json.Marshal(respJSON)
  37926. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37927. utils.ErrorLog("解析失败:%v", err)
  37928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37929. return
  37930. }
  37931. }
  37932. if miConfig.MdtrtareaAdmvs == "420902" {
  37933. client := &http.Client{}
  37934. bytesData, _ := json.Marshal(data)
  37935. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37936. resp, _ := client.Do(req)
  37937. defer resp.Body.Close()
  37938. body, ioErr := ioutil.ReadAll(resp.Body)
  37939. if ioErr != nil {
  37940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37942. return
  37943. }
  37944. var respJSON map[string]interface{}
  37945. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37948. return
  37949. }
  37950. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37951. userJSONBytes, _ := json.Marshal(respJSON)
  37952. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37953. utils.ErrorLog("解析失败:%v", err)
  37954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37955. return
  37956. }
  37957. }
  37958. if res.Infcode == 0 {
  37959. c.ServeSuccessJSON(map[string]interface{}{
  37960. "msg": "发起成功",
  37961. })
  37962. } else {
  37963. c.ServeSuccessJSON(map[string]interface{}{
  37964. "failed_code": -10,
  37965. "msg": res.ErrMsg,
  37966. })
  37967. }
  37968. }
  37969. }
  37970. func (c *HisApiController) Post3204a() {
  37971. start_time := c.GetString("start_time")
  37972. end_time := c.GetString("end_time")
  37973. //insutype := c.GetString("insutype")
  37974. clr_type := c.GetString("clr_type")
  37975. clr_org := c.GetString("clr_optins")
  37976. admin_user_id, _ := c.GetInt64("admin_user_id")
  37977. adminUser := c.GetAdminUserInfo()
  37978. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37979. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37980. if len(clr_org) == 0 {
  37981. clr_org = miConfig.MdtrtareaAdmvs
  37982. }
  37983. timeLayout := "2006-01-02"
  37984. loc, _ := time.LoadLocation("Local")
  37985. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37986. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37987. var orders []*models.HisOrder
  37988. if clr_org == "421300" {
  37989. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37990. } else if clr_org == "420902" {
  37991. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37992. } else {
  37993. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37994. }
  37995. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37996. //fixmedins_setl_cnt := int64(len(orders))
  37997. var medfee_sumamt float64
  37998. var acct_pay float64
  37999. var fund_pay_sumamt float64
  38000. for _, item := range orders {
  38001. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38002. acct_pay = acct_pay + item.AcctPay
  38003. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38004. }
  38005. //var medfee_sumamt_two float64
  38006. //var acct_pay_two float64
  38007. //var fund_pay_sumamt_two float64
  38008. //for _, item := range orders_two {
  38009. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38010. // acct_pay_two = acct_pay_two + item.AcctPay
  38011. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38012. //}
  38013. //var user_name string
  38014. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38015. //if role.ID == 0 {
  38016. // user_name = "xxx"
  38017. //} else {
  38018. // user_name = role.UserName
  38019. //}
  38020. var res ResultSix
  38021. if config.IsOpen == 1 {
  38022. var bps []*models.BusinessParamsTwo
  38023. var bp models.BusinessParamsTwo
  38024. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38025. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38026. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38027. bp.MedfeeSumamt = medfee_sumamt_str
  38028. bp.AcctPay = acct_pay_str
  38029. bp.FundPaySumamt = fund_pay_sumamt_str
  38030. bp.Insutype = ""
  38031. bp.StmtBegndate = start_time
  38032. bp.ClrType = clr_type
  38033. bp.SetlOptins = clr_org
  38034. bp.StmtEnddate = end_time
  38035. bps = append(bps, &bp)
  38036. data := make(map[string]interface{})
  38037. data["bps"] = bps
  38038. data["org_name"] = miConfig.OrgName
  38039. data["doctor"] = role.UserName
  38040. data["fixmedins_code"] = miConfig.Code
  38041. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38042. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38043. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38044. if miConfig.MdtrtareaAdmvs == "421300" {
  38045. client := &http.Client{}
  38046. bytesData, _ := json.Marshal(data)
  38047. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38048. resp, _ := client.Do(req)
  38049. defer resp.Body.Close()
  38050. body, ioErr := ioutil.ReadAll(resp.Body)
  38051. if ioErr != nil {
  38052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38054. return
  38055. }
  38056. var respJSON map[string]interface{}
  38057. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38060. return
  38061. }
  38062. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38063. userJSONBytes, _ := json.Marshal(respJSON)
  38064. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38065. utils.ErrorLog("解析失败:%v", err)
  38066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38067. return
  38068. }
  38069. }
  38070. if miConfig.MdtrtareaAdmvs == "420200" {
  38071. client := &http.Client{}
  38072. bytesData, _ := json.Marshal(data)
  38073. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38074. resp, _ := client.Do(req)
  38075. defer resp.Body.Close()
  38076. body, ioErr := ioutil.ReadAll(resp.Body)
  38077. if ioErr != nil {
  38078. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38080. return
  38081. }
  38082. var respJSON map[string]interface{}
  38083. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38086. return
  38087. }
  38088. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38089. userJSONBytes, _ := json.Marshal(respJSON)
  38090. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38091. utils.ErrorLog("解析失败:%v", err)
  38092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38093. return
  38094. }
  38095. }
  38096. if miConfig.MdtrtareaAdmvs == "421182" {
  38097. client := &http.Client{}
  38098. bytesData, _ := json.Marshal(data)
  38099. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38100. resp, _ := client.Do(req)
  38101. defer resp.Body.Close()
  38102. body, ioErr := ioutil.ReadAll(resp.Body)
  38103. if ioErr != nil {
  38104. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38106. return
  38107. }
  38108. var respJSON map[string]interface{}
  38109. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38112. return
  38113. }
  38114. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38115. userJSONBytes, _ := json.Marshal(respJSON)
  38116. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38117. utils.ErrorLog("解析失败:%v", err)
  38118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38119. return
  38120. }
  38121. }
  38122. if miConfig.MdtrtareaAdmvs == "420902" {
  38123. client := &http.Client{}
  38124. bytesData, _ := json.Marshal(data)
  38125. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38126. resp, _ := client.Do(req)
  38127. defer resp.Body.Close()
  38128. body, ioErr := ioutil.ReadAll(resp.Body)
  38129. if ioErr != nil {
  38130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38132. return
  38133. }
  38134. var respJSON map[string]interface{}
  38135. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38136. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38138. return
  38139. }
  38140. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38141. userJSONBytes, _ := json.Marshal(respJSON)
  38142. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38143. utils.ErrorLog("解析失败:%v", err)
  38144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38145. return
  38146. }
  38147. }
  38148. if res.Infcode == 0 {
  38149. c.ServeSuccessJSON(map[string]interface{}{
  38150. "msg": "撤销成功",
  38151. })
  38152. } else {
  38153. c.ServeSuccessJSON(map[string]interface{}{
  38154. "failed_code": -10,
  38155. "msg": res.ErrMsg,
  38156. })
  38157. }
  38158. }
  38159. }
  38160. func (c *HisApiController) Post3204() {
  38161. admin_user_id, _ := c.GetInt64("admin_user_id")
  38162. id := c.GetString("id")
  38163. adminUser := c.GetAdminUserInfo()
  38164. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38165. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38166. //clr_org := miConfig.MdtrtareaAdmvs
  38167. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38168. var res ResultSix
  38169. if config.IsOpen == 1 {
  38170. data := make(map[string]interface{})
  38171. data["id"] = id
  38172. data["org_name"] = miConfig.OrgName
  38173. data["doctor"] = role.UserName
  38174. data["fixmedins_code"] = miConfig.Code
  38175. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38176. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38177. client := &http.Client{}
  38178. bytesData, _ := json.Marshal(data)
  38179. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  38180. resp, _ := client.Do(req)
  38181. defer resp.Body.Close()
  38182. body, ioErr := ioutil.ReadAll(resp.Body)
  38183. if ioErr != nil {
  38184. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38186. return
  38187. }
  38188. var respJSON map[string]interface{}
  38189. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38192. return
  38193. }
  38194. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38195. userJSONBytes, _ := json.Marshal(respJSON)
  38196. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38197. utils.ErrorLog("解析失败:%v", err)
  38198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38199. return
  38200. }
  38201. if res.Infcode == 0 {
  38202. c.ServeSuccessJSON(map[string]interface{}{
  38203. "msg": "发起成功",
  38204. })
  38205. } else {
  38206. c.ServeSuccessJSON(map[string]interface{}{
  38207. "failed_code": -10,
  38208. "msg": res.ErrMsg,
  38209. })
  38210. }
  38211. }
  38212. }
  38213. func (c *HisApiController) Post8404() {
  38214. admin_user_id, _ := c.GetInt64("admin_user_id")
  38215. month := c.GetString("month")
  38216. adminUser := c.GetAdminUserInfo()
  38217. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38218. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38219. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38220. var res ResultSix
  38221. if config.IsOpen == 1 {
  38222. data := make(map[string]interface{})
  38223. data["month"] = month
  38224. data["org_name"] = miConfig.OrgName
  38225. data["doctor"] = role.UserName
  38226. data["fixmedins_code"] = miConfig.Code
  38227. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38228. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38229. client := &http.Client{}
  38230. bytesData, _ := json.Marshal(data)
  38231. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  38232. resp, _ := client.Do(req)
  38233. defer resp.Body.Close()
  38234. body, ioErr := ioutil.ReadAll(resp.Body)
  38235. if ioErr != nil {
  38236. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38238. return
  38239. }
  38240. var respJSON map[string]interface{}
  38241. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38244. return
  38245. }
  38246. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38247. userJSONBytes, _ := json.Marshal(respJSON)
  38248. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38249. utils.ErrorLog("解析失败:%v", err)
  38250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38251. return
  38252. }
  38253. if res.Infcode == 0 {
  38254. c.ServeSuccessJSON(map[string]interface{}{
  38255. "msg": "查询成功",
  38256. })
  38257. } else {
  38258. c.ServeSuccessJSON(map[string]interface{}{
  38259. "failed_code": -10,
  38260. "msg": res.ErrMsg,
  38261. })
  38262. }
  38263. }
  38264. }
  38265. func (c *HisApiController) Post3202b() {
  38266. start_time := c.GetString("start_time")
  38267. end_time := c.GetString("end_time")
  38268. //insutype := c.GetString("insutype")
  38269. clr_type := c.GetString("clr_type")
  38270. clr_org := c.GetString("clr_optins")
  38271. admin_user_id, _ := c.GetInt64("admin_user_id")
  38272. adminUser := c.GetAdminUserInfo()
  38273. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38274. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38275. if len(clr_org) == 0 {
  38276. clr_org = miConfig.MdtrtareaAdmvs
  38277. }
  38278. timeLayout := "2006-01-02"
  38279. loc, _ := time.LoadLocation("Local")
  38280. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38281. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38282. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38283. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38284. //fixmedins_setl_cnt := int64(len(orders))
  38285. var medfee_sumamt float64
  38286. var acct_pay float64
  38287. var fund_pay_sumamt float64
  38288. for _, item := range orders {
  38289. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38290. acct_pay = acct_pay + item.AcctPay
  38291. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38292. }
  38293. //var medfee_sumamt_two float64
  38294. //var acct_pay_two float64
  38295. //var fund_pay_sumamt_two float64
  38296. //for _, item := range orders_two {
  38297. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38298. // acct_pay_two = acct_pay_two + item.AcctPay
  38299. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38300. //}
  38301. //var user_name string
  38302. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38303. //if role.ID == 0 {
  38304. // user_name = "xxx"
  38305. //} else {
  38306. // user_name = role.UserName
  38307. //}
  38308. var res ResultSix
  38309. if config.IsOpen == 1 {
  38310. var bps []*models.BusinessParamsTwo
  38311. var bp models.BusinessParamsTwo
  38312. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38313. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38314. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38315. bp.MedfeeSumamt = medfee_sumamt_str
  38316. bp.AcctPay = acct_pay_str
  38317. bp.FundPaySumamt = fund_pay_sumamt_str
  38318. bp.Insutype = "390"
  38319. bp.StmtBegndate = start_time
  38320. bp.ClrType = clr_type
  38321. bp.SetlOptins = clr_org
  38322. bp.StmtEnddate = end_time
  38323. bps = append(bps, &bp)
  38324. data := make(map[string]interface{})
  38325. data["bps"] = bps
  38326. data["org_name"] = miConfig.OrgName
  38327. data["doctor"] = role.UserName
  38328. data["fixmedins_code"] = miConfig.Code
  38329. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38330. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38331. if miConfig.MdtrtareaAdmvs == "421300" {
  38332. client := &http.Client{}
  38333. bytesData, _ := json.Marshal(data)
  38334. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38335. resp, _ := client.Do(req)
  38336. defer resp.Body.Close()
  38337. body, ioErr := ioutil.ReadAll(resp.Body)
  38338. if ioErr != nil {
  38339. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38341. return
  38342. }
  38343. var respJSON map[string]interface{}
  38344. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38345. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38347. return
  38348. }
  38349. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38350. userJSONBytes, _ := json.Marshal(respJSON)
  38351. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38352. utils.ErrorLog("解析失败:%v", err)
  38353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38354. return
  38355. }
  38356. }
  38357. if miConfig.MdtrtareaAdmvs == "420200" {
  38358. client := &http.Client{}
  38359. bytesData, _ := json.Marshal(data)
  38360. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38361. resp, _ := client.Do(req)
  38362. defer resp.Body.Close()
  38363. body, ioErr := ioutil.ReadAll(resp.Body)
  38364. if ioErr != nil {
  38365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38367. return
  38368. }
  38369. var respJSON map[string]interface{}
  38370. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38373. return
  38374. }
  38375. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38376. userJSONBytes, _ := json.Marshal(respJSON)
  38377. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38378. utils.ErrorLog("解析失败:%v", err)
  38379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38380. return
  38381. }
  38382. }
  38383. if miConfig.MdtrtareaAdmvs == "421182" {
  38384. client := &http.Client{}
  38385. bytesData, _ := json.Marshal(data)
  38386. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  38387. resp, _ := client.Do(req)
  38388. defer resp.Body.Close()
  38389. body, ioErr := ioutil.ReadAll(resp.Body)
  38390. if ioErr != nil {
  38391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38393. return
  38394. }
  38395. var respJSON map[string]interface{}
  38396. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38399. return
  38400. }
  38401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38402. userJSONBytes, _ := json.Marshal(respJSON)
  38403. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38404. utils.ErrorLog("解析失败:%v", err)
  38405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38406. return
  38407. }
  38408. }
  38409. if res.Infcode == 0 {
  38410. c.ServeSuccessJSON(map[string]interface{}{
  38411. "msg": "发起成功",
  38412. })
  38413. } else {
  38414. c.ServeSuccessJSON(map[string]interface{}{
  38415. "failed_code": -10,
  38416. "msg": res.ErrMsg,
  38417. })
  38418. }
  38419. }
  38420. }
  38421. func (c *HisApiController) Post1608() {
  38422. start_time := c.GetString("start_time")
  38423. end_time := c.GetString("end_time")
  38424. admin_user_id, _ := c.GetInt64("admin_user_id")
  38425. adminUser := c.GetAdminUserInfo()
  38426. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38427. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38428. timeLayout := "2006-01-02"
  38429. loc, _ := time.LoadLocation("Local")
  38430. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38431. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38432. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38433. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38434. fixmedins_setl_cnt := int64(len(orders))
  38435. var medfee_sumamt float64
  38436. var func_smamt float64
  38437. for _, item := range orders {
  38438. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38439. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  38440. }
  38441. times := strings.Split(start_time, "-")
  38442. time_tows := strings.Split(end_time, "-")
  38443. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38444. var res ResultSix
  38445. if config.IsOpen == 1 {
  38446. //var bps []*models.BusinessParamsTwo
  38447. //var bp models.BusinessParamsTwo
  38448. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38449. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  38450. data := make(map[string]interface{})
  38451. data["org_name"] = miConfig.OrgName
  38452. data["doctor"] = role.UserName
  38453. data["func_smamt"] = func_smamt_str
  38454. data["fixmedins_code"] = miConfig.Code
  38455. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38456. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38457. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  38458. data["medfee_sumamt"] = medfee_sumamt_str
  38459. data["start_time"] = times[0] + times[1] + times[2]
  38460. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  38461. if miConfig.MdtrtareaAdmvs == "421300" {
  38462. client := &http.Client{}
  38463. bytesData, _ := json.Marshal(data)
  38464. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38465. resp, _ := client.Do(req)
  38466. defer resp.Body.Close()
  38467. body, ioErr := ioutil.ReadAll(resp.Body)
  38468. if ioErr != nil {
  38469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38471. return
  38472. }
  38473. var respJSON map[string]interface{}
  38474. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38477. return
  38478. }
  38479. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38480. userJSONBytes, _ := json.Marshal(respJSON)
  38481. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38482. utils.ErrorLog("解析失败:%v", err)
  38483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38484. return
  38485. }
  38486. }
  38487. if miConfig.MdtrtareaAdmvs == "420200" {
  38488. client := &http.Client{}
  38489. bytesData, _ := json.Marshal(data)
  38490. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38491. resp, _ := client.Do(req)
  38492. defer resp.Body.Close()
  38493. body, ioErr := ioutil.ReadAll(resp.Body)
  38494. if ioErr != nil {
  38495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38497. return
  38498. }
  38499. var respJSON map[string]interface{}
  38500. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38503. return
  38504. }
  38505. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38506. userJSONBytes, _ := json.Marshal(respJSON)
  38507. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38508. utils.ErrorLog("解析失败:%v", err)
  38509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38510. return
  38511. }
  38512. }
  38513. if miConfig.MdtrtareaAdmvs == "421182" {
  38514. client := &http.Client{}
  38515. bytesData, _ := json.Marshal(data)
  38516. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  38517. resp, _ := client.Do(req)
  38518. defer resp.Body.Close()
  38519. body, ioErr := ioutil.ReadAll(resp.Body)
  38520. if ioErr != nil {
  38521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38523. return
  38524. }
  38525. var respJSON map[string]interface{}
  38526. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38529. return
  38530. }
  38531. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38532. userJSONBytes, _ := json.Marshal(respJSON)
  38533. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38534. utils.ErrorLog("解析失败:%v", err)
  38535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38536. return
  38537. }
  38538. }
  38539. if res.Infcode == 0 {
  38540. c.ServeSuccessJSON(map[string]interface{}{
  38541. "msg": "发起成功",
  38542. })
  38543. } else {
  38544. c.ServeSuccessJSON(map[string]interface{}{
  38545. "failed_code": -10,
  38546. "msg": res.ErrMsg,
  38547. })
  38548. }
  38549. }
  38550. }
  38551. // 5.11.1.1【5262】结算信息按时间段查询
  38552. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38553. admin_user_id, _ := c.GetInt64("admin_user_id")
  38554. adminUser := c.GetAdminUserInfo()
  38555. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38556. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38557. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38558. var res Result5262
  38559. if config.IsOpen == 1 {
  38560. if miConfig.MdtrtareaAdmvs == "421300" {
  38561. data := make(map[string]interface{})
  38562. data["bps"] = bp
  38563. data["org_name"] = miConfig.OrgName
  38564. data["doctor"] = role.UserName
  38565. data["fixmedins_code"] = miConfig.Code
  38566. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38567. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38568. data["page"] = strconv.FormatInt(page, 10)
  38569. data["limit"] = strconv.FormatInt(limit, 10)
  38570. fmt.Println(data)
  38571. client := &http.Client{}
  38572. bytesData, _ := json.Marshal(data)
  38573. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38574. resp, _ := client.Do(req)
  38575. defer resp.Body.Close()
  38576. body, ioErr := ioutil.ReadAll(resp.Body)
  38577. if ioErr != nil {
  38578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38580. return
  38581. }
  38582. var respJSON map[string]interface{}
  38583. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38586. return
  38587. }
  38588. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38589. userJSONBytes, _ := json.Marshal(respJSON)
  38590. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38591. utils.ErrorLog("解析失败:%v", err)
  38592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38593. return
  38594. }
  38595. }
  38596. if miConfig.MdtrtareaAdmvs == "420200" {
  38597. data := make(map[string]interface{})
  38598. data["bps"] = bp
  38599. data["org_name"] = miConfig.OrgName
  38600. data["doctor"] = role.UserName
  38601. data["fixmedins_code"] = miConfig.Code
  38602. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38603. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38604. data["page"] = strconv.FormatInt(page, 10)
  38605. data["limit"] = strconv.FormatInt(limit, 10)
  38606. fmt.Println(data)
  38607. client := &http.Client{}
  38608. bytesData, _ := json.Marshal(data)
  38609. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38610. resp, _ := client.Do(req)
  38611. defer resp.Body.Close()
  38612. body, ioErr := ioutil.ReadAll(resp.Body)
  38613. if ioErr != nil {
  38614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38616. return
  38617. }
  38618. var respJSON map[string]interface{}
  38619. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38622. return
  38623. }
  38624. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38625. userJSONBytes, _ := json.Marshal(respJSON)
  38626. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38627. utils.ErrorLog("解析失败:%v", err)
  38628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38629. return
  38630. }
  38631. }
  38632. if miConfig.MdtrtareaAdmvs == "421182" {
  38633. data := make(map[string]interface{})
  38634. data["bps"] = bp
  38635. data["org_name"] = miConfig.OrgName
  38636. data["doctor"] = role.UserName
  38637. data["fixmedins_code"] = miConfig.Code
  38638. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38639. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38640. data["page"] = strconv.FormatInt(page, 10)
  38641. data["limit"] = strconv.FormatInt(limit, 10)
  38642. fmt.Println(data)
  38643. client := &http.Client{}
  38644. bytesData, _ := json.Marshal(data)
  38645. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38646. resp, _ := client.Do(req)
  38647. defer resp.Body.Close()
  38648. body, ioErr := ioutil.ReadAll(resp.Body)
  38649. if ioErr != nil {
  38650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38652. return
  38653. }
  38654. var respJSON map[string]interface{}
  38655. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38658. return
  38659. }
  38660. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38661. userJSONBytes, _ := json.Marshal(respJSON)
  38662. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38663. utils.ErrorLog("解析失败:%v", err)
  38664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38665. return
  38666. }
  38667. }
  38668. if miConfig.MdtrtareaAdmvs == "420902" {
  38669. data := make(map[string]interface{})
  38670. data["bps"] = bp
  38671. data["org_name"] = miConfig.OrgName
  38672. data["doctor"] = role.UserName
  38673. data["fixmedins_code"] = miConfig.Code
  38674. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38675. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38676. data["page"] = strconv.FormatInt(page, 10)
  38677. data["limit"] = strconv.FormatInt(limit, 10)
  38678. fmt.Println(data)
  38679. client := &http.Client{}
  38680. bytesData, _ := json.Marshal(data)
  38681. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38682. resp, _ := client.Do(req)
  38683. defer resp.Body.Close()
  38684. body, ioErr := ioutil.ReadAll(resp.Body)
  38685. if ioErr != nil {
  38686. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38688. return
  38689. }
  38690. var respJSON map[string]interface{}
  38691. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38692. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38694. return
  38695. }
  38696. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38697. userJSONBytes, _ := json.Marshal(respJSON)
  38698. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38699. utils.ErrorLog("解析失败:%v", err)
  38700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38701. return
  38702. }
  38703. }
  38704. if res.Infcode == 0 {
  38705. c.ServeSuccessJSON(map[string]interface{}{
  38706. "order": res.Output.Result,
  38707. "total": res.Output.PageInfo.RecordCounts,
  38708. })
  38709. } else {
  38710. c.ServeSuccessJSON(map[string]interface{}{
  38711. "failed_code": -10,
  38712. "msg": res.ErrMsg,
  38713. })
  38714. }
  38715. }
  38716. }
  38717. // 5.11.1.2【5267】异地结算信息时间段查询
  38718. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38719. admin_user_id, _ := c.GetInt64("admin_user_id")
  38720. adminUser := c.GetAdminUserInfo()
  38721. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38722. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38723. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38724. var res Result5267
  38725. if config.IsOpen == 1 {
  38726. if miConfig.MdtrtareaAdmvs == "421300" {
  38727. data := make(map[string]interface{})
  38728. data["bps"] = bp
  38729. data["org_name"] = miConfig.OrgName
  38730. data["doctor"] = role.UserName
  38731. data["fixmedins_code"] = miConfig.Code
  38732. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38733. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38734. data["page"] = page
  38735. data["limit"] = limit
  38736. fmt.Println(data)
  38737. client := &http.Client{}
  38738. bytesData, _ := json.Marshal(data)
  38739. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38740. resp, _ := client.Do(req)
  38741. defer resp.Body.Close()
  38742. body, ioErr := ioutil.ReadAll(resp.Body)
  38743. if ioErr != nil {
  38744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38746. return
  38747. }
  38748. var respJSON map[string]interface{}
  38749. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38752. return
  38753. }
  38754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38755. userJSONBytes, _ := json.Marshal(respJSON)
  38756. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38757. utils.ErrorLog("解析失败:%v", err)
  38758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38759. return
  38760. }
  38761. }
  38762. if miConfig.MdtrtareaAdmvs == "420200" {
  38763. data := make(map[string]interface{})
  38764. data["bps"] = bp
  38765. data["org_name"] = miConfig.OrgName
  38766. data["doctor"] = role.UserName
  38767. data["fixmedins_code"] = miConfig.Code
  38768. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38769. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38770. data["page"] = page
  38771. data["limit"] = limit
  38772. fmt.Println(data)
  38773. client := &http.Client{}
  38774. bytesData, _ := json.Marshal(data)
  38775. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38776. resp, _ := client.Do(req)
  38777. defer resp.Body.Close()
  38778. body, ioErr := ioutil.ReadAll(resp.Body)
  38779. if ioErr != nil {
  38780. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38782. return
  38783. }
  38784. var respJSON map[string]interface{}
  38785. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38786. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38788. return
  38789. }
  38790. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38791. userJSONBytes, _ := json.Marshal(respJSON)
  38792. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38793. utils.ErrorLog("解析失败:%v", err)
  38794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38795. return
  38796. }
  38797. }
  38798. if miConfig.MdtrtareaAdmvs == "421182" {
  38799. data := make(map[string]interface{})
  38800. data["bps"] = bp
  38801. data["org_name"] = miConfig.OrgName
  38802. data["doctor"] = role.UserName
  38803. data["fixmedins_code"] = miConfig.Code
  38804. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38805. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38806. data["page"] = page
  38807. data["limit"] = limit
  38808. fmt.Println(data)
  38809. client := &http.Client{}
  38810. bytesData, _ := json.Marshal(data)
  38811. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  38812. resp, _ := client.Do(req)
  38813. defer resp.Body.Close()
  38814. body, ioErr := ioutil.ReadAll(resp.Body)
  38815. if ioErr != nil {
  38816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38818. return
  38819. }
  38820. var respJSON map[string]interface{}
  38821. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38824. return
  38825. }
  38826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38827. userJSONBytes, _ := json.Marshal(respJSON)
  38828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38829. utils.ErrorLog("解析失败:%v", err)
  38830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38831. return
  38832. }
  38833. }
  38834. if res.Infcode == 0 {
  38835. c.ServeSuccessJSON(map[string]interface{}{
  38836. "order": res.Output.Result,
  38837. "total": res.Output.PageInfo.RecordCounts,
  38838. })
  38839. } else {
  38840. c.ServeSuccessJSON(map[string]interface{}{
  38841. "failed_code": -10,
  38842. "msg": res.ErrMsg,
  38843. })
  38844. }
  38845. }
  38846. }
  38847. func (c *HisApiController) Post3501() {
  38848. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38849. data := make(map[string]interface{})
  38850. var struct3501s []models.Struct3501
  38851. var struct3501 models.Struct3501
  38852. struct3501.OrgName = miConfig.OrgName
  38853. struct3501.AccessKey = miConfig.AccessKey
  38854. struct3501.RequestUrl = miConfig.Url
  38855. struct3501.SecretKey = miConfig.SecretKey
  38856. struct3501.ManuDate = "2022-08-17"
  38857. struct3501.FixmedinsBchno = ""
  38858. struct3501.ManuLotnum = ""
  38859. struct3501.RxFlag = "0"
  38860. struct3501.ExpyEnd = "2022-08-17"
  38861. struct3501.Invdate = "2022-08-17"
  38862. struct3501.InvCnt = "20.25"
  38863. struct3501.Memo = ""
  38864. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38865. struct3501.FixmedinsHilistId = miConfig.Code
  38866. struct3501.FixmedinsHilistName = miConfig.OrgName
  38867. struct3501s = append(struct3501s, struct3501)
  38868. data["struct_3501s"] = struct3501s
  38869. client := &http.Client{}
  38870. bytesData, _ := json.Marshal(data)
  38871. var req *http.Request
  38872. if miConfig.MdtrtareaAdmvs == "320921" {
  38873. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38874. } else {
  38875. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38876. }
  38877. resp, _ := client.Do(req)
  38878. defer resp.Body.Close()
  38879. body, ioErr := ioutil.ReadAll(resp.Body)
  38880. if ioErr != nil {
  38881. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38883. return
  38884. }
  38885. var respJSON map[string]interface{}
  38886. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38887. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38889. return
  38890. }
  38891. var res ResultSix
  38892. var resSix10265 ResultSix10265 //1101结果
  38893. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38894. result, _ := json.Marshal(respJSON)
  38895. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38896. utils.ErrorLog("解析失败:%v", err)
  38897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38898. return
  38899. }
  38900. res.InfRefmsgid = resSix10265.InfRefmsgid
  38901. res.Output = resSix10265.Output
  38902. res.ErrMsg = resSix10265.ErrMsg
  38903. res.Cainfo = resSix10265.Cainfo
  38904. res.WarnMsg = resSix10265.WarnMsg
  38905. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38906. res.Infcode = infocode
  38907. if infocode == 0 {
  38908. c.ServeSuccessJSON(map[string]interface{}{
  38909. "msg": "上传成功",
  38910. })
  38911. return
  38912. } else {
  38913. c.ServeSuccessJSON(map[string]interface{}{
  38914. "failed_code": -10,
  38915. "msg": res.ErrMsg,
  38916. })
  38917. return
  38918. }
  38919. }
  38920. func (c *HisApiController) Post3502() {
  38921. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38922. data := make(map[string]interface{})
  38923. var struct3502s []models.Struct3502
  38924. var struct3502 models.Struct3502
  38925. struct3502.OrgName = miConfig.OrgName
  38926. struct3502.AccessKey = miConfig.AccessKey
  38927. struct3502.RequestUrl = miConfig.Url
  38928. struct3502.SecretKey = miConfig.SecretKey
  38929. struct3502.ManuDate = "2022-08-15"
  38930. struct3502.FixmedinsBchno = ""
  38931. struct3502.ManuLotnum = ""
  38932. struct3502.RxFlag = "0"
  38933. struct3502.ExpyEnd = "2022-08-15"
  38934. struct3502.Invdate = "2022-08-15"
  38935. struct3502.InvCnt = "20.25"
  38936. struct3502.Memo = ""
  38937. struct3502.MedListCodg = "XB01ABD056B002020200517"
  38938. struct3502.FixmedinsHilistId = miConfig.Code
  38939. struct3502.FixmedinsHilistName = miConfig.OrgName
  38940. struct3502s = append(struct3502s, struct3502)
  38941. data["struct_3502s"] = struct3502s
  38942. client := &http.Client{}
  38943. bytesData, _ := json.Marshal(data)
  38944. var req *http.Request
  38945. if miConfig.MdtrtareaAdmvs == "320921" {
  38946. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38947. } else {
  38948. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38949. }
  38950. resp, _ := client.Do(req)
  38951. defer resp.Body.Close()
  38952. body, ioErr := ioutil.ReadAll(resp.Body)
  38953. if ioErr != nil {
  38954. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38956. return
  38957. }
  38958. var respJSON map[string]interface{}
  38959. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38960. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38962. return
  38963. }
  38964. var res ResultSix
  38965. var resSix10265 ResultSix10265 //1101结果
  38966. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38967. result, _ := json.Marshal(respJSON)
  38968. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38969. utils.ErrorLog("解析失败:%v", err)
  38970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38971. return
  38972. }
  38973. res.InfRefmsgid = resSix10265.InfRefmsgid
  38974. res.Output = resSix10265.Output
  38975. res.ErrMsg = resSix10265.ErrMsg
  38976. res.Cainfo = resSix10265.Cainfo
  38977. res.WarnMsg = resSix10265.WarnMsg
  38978. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38979. res.Infcode = infocode
  38980. if infocode == 0 {
  38981. c.ServeSuccessJSON(map[string]interface{}{
  38982. "msg": "上传成功",
  38983. })
  38984. return
  38985. } else {
  38986. c.ServeSuccessJSON(map[string]interface{}{
  38987. "failed_code": -10,
  38988. "msg": res.ErrMsg,
  38989. })
  38990. return
  38991. }
  38992. }
  38993. func (c *HisApiController) Post3503() {
  38994. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38995. data := make(map[string]interface{})
  38996. var struct3501s []models.Struct3501
  38997. var struct3501 models.Struct3501
  38998. struct3501.OrgName = miConfig.OrgName
  38999. struct3501.AccessKey = miConfig.AccessKey
  39000. struct3501.RequestUrl = miConfig.Url
  39001. struct3501.SecretKey = miConfig.SecretKey
  39002. struct3501.ManuDate = "2022-08-15"
  39003. struct3501.FixmedinsBchno = ""
  39004. struct3501.ManuLotnum = ""
  39005. struct3501.RxFlag = "0"
  39006. struct3501.ExpyEnd = "2022-08-15"
  39007. struct3501.Invdate = "2022-08-15"
  39008. struct3501.InvCnt = "20.25"
  39009. struct3501.Memo = ""
  39010. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39011. struct3501.FixmedinsHilistId = miConfig.Code
  39012. struct3501.FixmedinsHilistName = miConfig.OrgName
  39013. struct3501s = append(struct3501s, struct3501)
  39014. data["struct_3501s"] = struct3501s
  39015. client := &http.Client{}
  39016. bytesData, _ := json.Marshal(data)
  39017. var req *http.Request
  39018. if miConfig.MdtrtareaAdmvs == "320921" {
  39019. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39020. } else {
  39021. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39022. }
  39023. resp, _ := client.Do(req)
  39024. defer resp.Body.Close()
  39025. body, ioErr := ioutil.ReadAll(resp.Body)
  39026. if ioErr != nil {
  39027. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39029. return
  39030. }
  39031. var respJSON map[string]interface{}
  39032. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39033. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39035. return
  39036. }
  39037. var res ResultSix
  39038. var resSix10265 ResultSix10265 //1101结果
  39039. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39040. result, _ := json.Marshal(respJSON)
  39041. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39042. utils.ErrorLog("解析失败:%v", err)
  39043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39044. return
  39045. }
  39046. res.InfRefmsgid = resSix10265.InfRefmsgid
  39047. res.Output = resSix10265.Output
  39048. res.ErrMsg = resSix10265.ErrMsg
  39049. res.Cainfo = resSix10265.Cainfo
  39050. res.WarnMsg = resSix10265.WarnMsg
  39051. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39052. res.Infcode = infocode
  39053. if infocode == 0 {
  39054. c.ServeSuccessJSON(map[string]interface{}{
  39055. "msg": "上传成功",
  39056. })
  39057. return
  39058. } else {
  39059. c.ServeSuccessJSON(map[string]interface{}{
  39060. "failed_code": -10,
  39061. "msg": res.ErrMsg,
  39062. })
  39063. return
  39064. }
  39065. }
  39066. func (c *HisApiController) Post3504() {
  39067. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39068. data := make(map[string]interface{})
  39069. var struct3501s []models.Struct3501
  39070. var struct3501 models.Struct3501
  39071. struct3501.OrgName = miConfig.OrgName
  39072. struct3501.AccessKey = miConfig.AccessKey
  39073. struct3501.RequestUrl = miConfig.Url
  39074. struct3501.SecretKey = miConfig.SecretKey
  39075. struct3501.ManuDate = "2022-08-15"
  39076. struct3501.FixmedinsBchno = ""
  39077. struct3501.ManuLotnum = ""
  39078. struct3501.RxFlag = "0"
  39079. struct3501.ExpyEnd = "2022-08-15"
  39080. struct3501.Invdate = "2022-08-15"
  39081. struct3501.InvCnt = "20.25"
  39082. struct3501.Memo = ""
  39083. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39084. struct3501.FixmedinsHilistId = miConfig.Code
  39085. struct3501.FixmedinsHilistName = miConfig.OrgName
  39086. struct3501s = append(struct3501s, struct3501)
  39087. data["struct_3501s"] = struct3501s
  39088. client := &http.Client{}
  39089. bytesData, _ := json.Marshal(data)
  39090. var req *http.Request
  39091. if miConfig.MdtrtareaAdmvs == "320921" {
  39092. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39093. } else {
  39094. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39095. }
  39096. resp, _ := client.Do(req)
  39097. defer resp.Body.Close()
  39098. body, ioErr := ioutil.ReadAll(resp.Body)
  39099. if ioErr != nil {
  39100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39102. return
  39103. }
  39104. var respJSON map[string]interface{}
  39105. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39108. return
  39109. }
  39110. var res ResultSix
  39111. var resSix10265 ResultSix10265 //1101结果
  39112. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39113. result, _ := json.Marshal(respJSON)
  39114. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39115. utils.ErrorLog("解析失败:%v", err)
  39116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39117. return
  39118. }
  39119. res.InfRefmsgid = resSix10265.InfRefmsgid
  39120. res.Output = resSix10265.Output
  39121. res.ErrMsg = resSix10265.ErrMsg
  39122. res.Cainfo = resSix10265.Cainfo
  39123. res.WarnMsg = resSix10265.WarnMsg
  39124. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39125. res.Infcode = infocode
  39126. if infocode == 0 {
  39127. c.ServeSuccessJSON(map[string]interface{}{
  39128. "msg": "上传成功",
  39129. })
  39130. return
  39131. } else {
  39132. c.ServeSuccessJSON(map[string]interface{}{
  39133. "failed_code": -10,
  39134. "msg": res.ErrMsg,
  39135. })
  39136. return
  39137. }
  39138. }
  39139. func (c *HisApiController) Post3505() {
  39140. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39141. data := make(map[string]interface{})
  39142. var struct3501s []models.Struct3501
  39143. var struct3501 models.Struct3501
  39144. struct3501.OrgName = miConfig.OrgName
  39145. struct3501.AccessKey = miConfig.AccessKey
  39146. struct3501.RequestUrl = miConfig.Url
  39147. struct3501.SecretKey = miConfig.SecretKey
  39148. struct3501.ManuDate = "2022-08-15"
  39149. struct3501.FixmedinsBchno = ""
  39150. struct3501.ManuLotnum = ""
  39151. struct3501.RxFlag = "0"
  39152. struct3501.ExpyEnd = "2022-08-15"
  39153. struct3501.Invdate = "2022-08-15"
  39154. struct3501.InvCnt = "20.25"
  39155. struct3501.Memo = ""
  39156. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39157. struct3501.FixmedinsHilistId = miConfig.Code
  39158. struct3501.FixmedinsHilistName = miConfig.OrgName
  39159. struct3501s = append(struct3501s, struct3501)
  39160. data["struct_3501s"] = struct3501s
  39161. client := &http.Client{}
  39162. bytesData, _ := json.Marshal(data)
  39163. var req *http.Request
  39164. if miConfig.MdtrtareaAdmvs == "320921" {
  39165. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39166. } else {
  39167. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39168. }
  39169. resp, _ := client.Do(req)
  39170. defer resp.Body.Close()
  39171. body, ioErr := ioutil.ReadAll(resp.Body)
  39172. if ioErr != nil {
  39173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39175. return
  39176. }
  39177. var respJSON map[string]interface{}
  39178. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39181. return
  39182. }
  39183. var res ResultSix
  39184. var resSix10265 ResultSix10265 //1101结果
  39185. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39186. result, _ := json.Marshal(respJSON)
  39187. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39188. utils.ErrorLog("解析失败:%v", err)
  39189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39190. return
  39191. }
  39192. res.InfRefmsgid = resSix10265.InfRefmsgid
  39193. res.Output = resSix10265.Output
  39194. res.ErrMsg = resSix10265.ErrMsg
  39195. res.Cainfo = resSix10265.Cainfo
  39196. res.WarnMsg = resSix10265.WarnMsg
  39197. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39198. res.Infcode = infocode
  39199. if infocode == 0 {
  39200. c.ServeSuccessJSON(map[string]interface{}{
  39201. "msg": "上传成功",
  39202. })
  39203. return
  39204. } else {
  39205. c.ServeSuccessJSON(map[string]interface{}{
  39206. "failed_code": -10,
  39207. "msg": res.ErrMsg,
  39208. })
  39209. return
  39210. }
  39211. }
  39212. func (c *HisApiController) Post3506() {
  39213. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39214. data := make(map[string]interface{})
  39215. var struct3501s []models.Struct3501
  39216. var struct3501 models.Struct3501
  39217. struct3501.OrgName = miConfig.OrgName
  39218. struct3501.AccessKey = miConfig.AccessKey
  39219. struct3501.RequestUrl = miConfig.Url
  39220. struct3501.SecretKey = miConfig.SecretKey
  39221. struct3501.ManuDate = "2022-08-15"
  39222. struct3501.FixmedinsBchno = ""
  39223. struct3501.ManuLotnum = ""
  39224. struct3501.RxFlag = "0"
  39225. struct3501.ExpyEnd = "2022-08-15"
  39226. struct3501.Invdate = "2022-08-15"
  39227. struct3501.InvCnt = "20.25"
  39228. struct3501.Memo = ""
  39229. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39230. struct3501.FixmedinsHilistId = miConfig.Code
  39231. struct3501.FixmedinsHilistName = miConfig.OrgName
  39232. struct3501s = append(struct3501s, struct3501)
  39233. data["struct_3501s"] = struct3501s
  39234. client := &http.Client{}
  39235. bytesData, _ := json.Marshal(data)
  39236. var req *http.Request
  39237. if miConfig.MdtrtareaAdmvs == "320921" {
  39238. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39239. } else {
  39240. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39241. }
  39242. resp, _ := client.Do(req)
  39243. defer resp.Body.Close()
  39244. body, ioErr := ioutil.ReadAll(resp.Body)
  39245. if ioErr != nil {
  39246. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39248. return
  39249. }
  39250. var respJSON map[string]interface{}
  39251. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39254. return
  39255. }
  39256. var res ResultSix
  39257. var resSix10265 ResultSix10265 //1101结果
  39258. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39259. result, _ := json.Marshal(respJSON)
  39260. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39261. utils.ErrorLog("解析失败:%v", err)
  39262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39263. return
  39264. }
  39265. res.InfRefmsgid = resSix10265.InfRefmsgid
  39266. res.Output = resSix10265.Output
  39267. res.ErrMsg = resSix10265.ErrMsg
  39268. res.Cainfo = resSix10265.Cainfo
  39269. res.WarnMsg = resSix10265.WarnMsg
  39270. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39271. res.Infcode = infocode
  39272. if infocode == 0 {
  39273. c.ServeSuccessJSON(map[string]interface{}{
  39274. "msg": "上传成功",
  39275. })
  39276. return
  39277. } else {
  39278. c.ServeSuccessJSON(map[string]interface{}{
  39279. "failed_code": -10,
  39280. "msg": res.ErrMsg,
  39281. })
  39282. return
  39283. }
  39284. }
  39285. func (c *HisApiController) Post3507() {
  39286. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39287. data := make(map[string]interface{})
  39288. var struct3501s []models.Struct3501
  39289. var struct3501 models.Struct3501
  39290. struct3501.OrgName = miConfig.OrgName
  39291. struct3501.AccessKey = miConfig.AccessKey
  39292. struct3501.RequestUrl = miConfig.Url
  39293. struct3501.SecretKey = miConfig.SecretKey
  39294. struct3501.ManuDate = "2022-08-15"
  39295. struct3501.FixmedinsBchno = ""
  39296. struct3501.ManuLotnum = ""
  39297. struct3501.RxFlag = "0"
  39298. struct3501.ExpyEnd = "2022-08-15"
  39299. struct3501.Invdate = "2022-08-15"
  39300. struct3501.InvCnt = "20.25"
  39301. struct3501.Memo = ""
  39302. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39303. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  39304. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  39305. struct3501s = append(struct3501s, struct3501)
  39306. data["struct_3501s"] = struct3501s
  39307. client := &http.Client{}
  39308. bytesData, _ := json.Marshal(data)
  39309. var req *http.Request
  39310. if miConfig.MdtrtareaAdmvs == "320921" {
  39311. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39312. } else {
  39313. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39314. }
  39315. resp, _ := client.Do(req)
  39316. defer resp.Body.Close()
  39317. body, ioErr := ioutil.ReadAll(resp.Body)
  39318. if ioErr != nil {
  39319. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39321. return
  39322. }
  39323. var respJSON map[string]interface{}
  39324. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39327. return
  39328. }
  39329. var res ResultSix
  39330. var resSix10265 ResultSix10265 //1101结果
  39331. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39332. result, _ := json.Marshal(respJSON)
  39333. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39334. utils.ErrorLog("解析失败:%v", err)
  39335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39336. return
  39337. }
  39338. res.InfRefmsgid = resSix10265.InfRefmsgid
  39339. res.Output = resSix10265.Output
  39340. res.ErrMsg = resSix10265.ErrMsg
  39341. res.Cainfo = resSix10265.Cainfo
  39342. res.WarnMsg = resSix10265.WarnMsg
  39343. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39344. res.Infcode = infocode
  39345. if infocode == 0 {
  39346. c.ServeSuccessJSON(map[string]interface{}{
  39347. "msg": "上传成功",
  39348. })
  39349. return
  39350. } else {
  39351. c.ServeSuccessJSON(map[string]interface{}{
  39352. "failed_code": -10,
  39353. "msg": res.ErrMsg,
  39354. })
  39355. return
  39356. }
  39357. }
  39358. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39359. // WebSocket服务器地址
  39360. serverURL := "ws://127.0.0.1:8899"
  39361. // 解析WebSocket服务器地址
  39362. u, err := url.Parse(serverURL)
  39363. if err != nil {
  39364. }
  39365. // 建立WebSocket连接
  39366. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39367. if err != nil {
  39368. }
  39369. defer conn.Close()
  39370. input2 := make(map[string]interface{})
  39371. input := make(map[string]interface{})
  39372. inputData := make(map[string]interface{})
  39373. inputData["orgId"] = code
  39374. inputData["businessType"] = "01101"
  39375. inputData["operatorId"] = operator_id
  39376. inputData["operatorName"] = operator_name
  39377. inputData["officeId"] = "001"
  39378. inputData["officeName"] = "血透室"
  39379. inputData["deviceType"] = ""
  39380. input["data"] = inputData
  39381. input["orgId"] = code
  39382. input["transType"] = "ec.query"
  39383. //if md == ""
  39384. if md[:4] == "4403" {
  39385. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39386. } else if md[:4] == "4401" {
  39387. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39388. } else {
  39389. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39390. }
  39391. input2["indata"] = input
  39392. fmt.Println(input2)
  39393. bytesData, _ := json.Marshal(input2)
  39394. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39395. if err != nil {
  39396. fmt.Println(err)
  39397. }
  39398. // 接收消息
  39399. _, receivedMessage, err := conn.ReadMessage()
  39400. if err != nil {
  39401. fmt.Println(err)
  39402. }
  39403. return "", string(receivedMessage)
  39404. }
  39405. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  39406. // WebSocket服务器地址
  39407. serverURL := "ws://127.0.0.1:8899"
  39408. // 解析WebSocket服务器地址
  39409. u, err := url.Parse(serverURL)
  39410. if err != nil {
  39411. }
  39412. // 建立WebSocket连接
  39413. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39414. if err != nil {
  39415. }
  39416. defer conn.Close()
  39417. input2 := make(map[string]interface{})
  39418. input := make(map[string]interface{})
  39419. inputData := make(map[string]interface{})
  39420. inputData["orgId"] = code
  39421. inputData["businessType"] = "01101"
  39422. inputData["operatorId"] = operator_id
  39423. inputData["operatorName"] = operator_name
  39424. inputData["officeId"] = "001"
  39425. inputData["officeName"] = "血透室"
  39426. inputData["deviceType"] = ""
  39427. input["data"] = inputData
  39428. input["orgId"] = code
  39429. input["transType"] = "ec.query"
  39430. //if md == ""
  39431. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39432. input2["indata"] = input
  39433. fmt.Println(input2)
  39434. bytesData, _ := json.Marshal(input2)
  39435. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39436. if err != nil {
  39437. fmt.Println(err)
  39438. }
  39439. // 接收消息
  39440. _, receivedMessage, err := conn.ReadMessage()
  39441. if err != nil {
  39442. fmt.Println(err)
  39443. }
  39444. return "", string(receivedMessage)
  39445. }
  39446. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  39447. // WebSocket服务器地址
  39448. serverURL := "ws://127.0.0.1:8899"
  39449. // 解析WebSocket服务器地址
  39450. u, err := url.Parse(serverURL)
  39451. if err != nil {
  39452. }
  39453. // 建立WebSocket连接
  39454. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39455. if err != nil {
  39456. }
  39457. defer conn.Close()
  39458. input2 := make(map[string]interface{})
  39459. input := make(map[string]interface{})
  39460. inputData := make(map[string]interface{})
  39461. inputData["orgId"] = code
  39462. inputData["businessType"] = "01301"
  39463. inputData["operatorId"] = operator_id
  39464. inputData["operatorName"] = operator_name
  39465. inputData["officeId"] = "001"
  39466. inputData["officeName"] = "血透室"
  39467. inputData["deviceType"] = ""
  39468. input["data"] = inputData
  39469. input["orgId"] = code
  39470. input["transType"] = "ec.query"
  39471. //if md == ""
  39472. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39473. input2["indata"] = input
  39474. fmt.Println(input2)
  39475. bytesData, _ := json.Marshal(input2)
  39476. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39477. if err != nil {
  39478. fmt.Println(err)
  39479. }
  39480. // 接收消息
  39481. _, receivedMessage, err := conn.ReadMessage()
  39482. if err != nil {
  39483. fmt.Println(err)
  39484. }
  39485. return "", string(receivedMessage)
  39486. }
  39487. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  39488. // WebSocket服务器地址
  39489. serverURL := "ws://127.0.0.1:8899"
  39490. // 解析WebSocket服务器地址
  39491. u, err := url.Parse(serverURL)
  39492. if err != nil {
  39493. }
  39494. // 建立WebSocket连接
  39495. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39496. if err != nil {
  39497. }
  39498. defer conn.Close()
  39499. input2 := make(map[string]interface{})
  39500. input := make(map[string]interface{})
  39501. inputData := make(map[string]interface{})
  39502. inputData["orgId"] = code
  39503. inputData["businessType"] = "01103"
  39504. inputData["operatorId"] = operator_id
  39505. inputData["operatorName"] = operator_name
  39506. inputData["officeId"] = "001"
  39507. inputData["officeName"] = "血透室"
  39508. inputData["deviceType"] = ""
  39509. input["data"] = inputData
  39510. input["orgId"] = code
  39511. input["transType"] = "ec.query"
  39512. //if md ==
  39513. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  39514. input2["indata"] = input
  39515. fmt.Println(input2)
  39516. bytesData, _ := json.Marshal(input2)
  39517. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39518. if err != nil {
  39519. fmt.Println(err)
  39520. }
  39521. // 接收消息
  39522. _, receivedMessage, err := conn.ReadMessage()
  39523. if err != nil {
  39524. fmt.Println(err)
  39525. }
  39526. return "", string(receivedMessage)
  39527. }
  39528. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39529. // WebSocket服务器地址
  39530. serverURL := "ws://127.0.0.1:8899"
  39531. // 解析WebSocket服务器地址
  39532. u, err := url.Parse(serverURL)
  39533. if err != nil {
  39534. }
  39535. // 建立WebSocket连接
  39536. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39537. if err != nil {
  39538. }
  39539. defer conn.Close()
  39540. input2 := make(map[string]interface{})
  39541. input := make(map[string]interface{})
  39542. inputData := make(map[string]interface{})
  39543. inputData["orgId"] = code
  39544. inputData["businessType"] = "01101"
  39545. inputData["operatorId"] = operator_id
  39546. inputData["operatorName"] = operator_name
  39547. inputData["officeId"] = "001"
  39548. inputData["officeName"] = "血透室"
  39549. inputData["deviceType"] = ""
  39550. input["data"] = inputData
  39551. input["orgId"] = code
  39552. input["transType"] = "ec.query"
  39553. //if md == ""
  39554. if md[:4] == "4403" {
  39555. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39556. } else if md[:4] == "4401" {
  39557. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39558. } else {
  39559. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39560. }
  39561. input2["indata"] = input
  39562. fmt.Println(input2)
  39563. bytesData, _ := json.Marshal(input2)
  39564. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39565. if err != nil {
  39566. fmt.Println(err)
  39567. }
  39568. // 接收消息
  39569. _, receivedMessage, err := conn.ReadMessage()
  39570. if err != nil {
  39571. fmt.Println(err)
  39572. }
  39573. return "", string(receivedMessage)
  39574. }
  39575. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  39576. // WebSocket服务器地址
  39577. serverURL := "ws://127.0.0.1:8899"
  39578. // 解析WebSocket服务器地址
  39579. u, err := url.Parse(serverURL)
  39580. if err != nil {
  39581. }
  39582. // 建立WebSocket连接
  39583. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39584. if err != nil {
  39585. }
  39586. defer conn.Close()
  39587. input2 := make(map[string]interface{})
  39588. input := make(map[string]interface{})
  39589. inputData := make(map[string]interface{})
  39590. inputData["orgId"] = code
  39591. inputData["businessType"] = "01301"
  39592. inputData["operatorId"] = operator_id
  39593. inputData["operatorName"] = operator_name
  39594. inputData["officeId"] = "001"
  39595. inputData["officeName"] = "血透室"
  39596. inputData["deviceType"] = ""
  39597. input["data"] = inputData
  39598. input["orgId"] = code
  39599. input["transType"] = "ec.query"
  39600. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39601. input2["indata"] = input
  39602. bytesData, _ := json.Marshal(input2)
  39603. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39604. if err != nil {
  39605. fmt.Println(err)
  39606. }
  39607. // 接收消息
  39608. _, receivedMessage, err := conn.ReadMessage()
  39609. if err != nil {
  39610. fmt.Println(err)
  39611. }
  39612. return "", string(receivedMessage)
  39613. }
  39614. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  39615. newArr = make([]string, 0)
  39616. for i := 0; i < len(arr); i++ {
  39617. repeat := false
  39618. for j := i + 1; j < len(arr); j++ {
  39619. if arr[i] == arr[j] {
  39620. repeat = true
  39621. break
  39622. }
  39623. }
  39624. if !repeat {
  39625. newArr = append(newArr, arr[i])
  39626. }
  39627. }
  39628. return
  39629. }
  39630. func getBirthdateAndAge(idNumber string) (string, int, error) {
  39631. if len(idNumber) != 18 {
  39632. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  39633. }
  39634. // 提取出生日期
  39635. year, err := strconv.Atoi(idNumber[6:10])
  39636. if err != nil {
  39637. return "", 0, err
  39638. }
  39639. month, err := strconv.Atoi(idNumber[10:12])
  39640. if err != nil {
  39641. return "", 0, err
  39642. }
  39643. day, err := strconv.Atoi(idNumber[12:14])
  39644. if err != nil {
  39645. return "", 0, err
  39646. }
  39647. // 格式化生日字符串
  39648. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  39649. birthdateFormatted := birthdate.Format("2006-01-02")
  39650. // 计算年龄
  39651. today := time.Now()
  39652. age := today.Year() - birthdate.Year()
  39653. if today.YearDay() < birthdate.YearDay() {
  39654. age--
  39655. }
  39656. return birthdateFormatted, age, nil
  39657. }
  39658. // 从身份证号码中提取出生年月日
  39659. func getBirthDateFromIDCard(idCard string) (string, error) {
  39660. // 身份证号码长度应为18位
  39661. if len(idCard) != 18 {
  39662. return "", fmt.Errorf("身份证号码长度应为18位")
  39663. }
  39664. // 提取出生日期部分 (YYYYMMDD)
  39665. birthDateStr := idCard[6:14]
  39666. // 解析出生日期
  39667. birthDate, err := time.Parse("20060102", birthDateStr)
  39668. if err != nil {
  39669. return "", fmt.Errorf("解析出生日期失败: %v", err)
  39670. }
  39671. // 格式化出生日期为 YYYY-MM-DD
  39672. formattedDate := birthDate.Format("2006-01-02")
  39673. return formattedDate, nil
  39674. }